[{"Question":"I wrote a python app that manage gcm messaging for an android chat app, where could I host this app to be able to work 24\/7, it's not a web app, Is it safe and reliable to use PythonAnywhere consoles?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":239,"Q_Id":38166331,"Users Score":1,"Answer":"PythonAnywhere dev here: I wouldn't recommend our consoles as a place to run an XMPP server -- they're meant more for exploratory programming. AWS (like Adam Barnes suggests) or a VPS somewhere like Digital Ocean would probably be a better option.","Q_Score":0,"Tags":"python,server,xmpp,host","A_Id":38188784,"CreationDate":"2016-07-03T02:55:00.000","Title":"Where to host a python chat server?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python script (wap.py) from which I am calling wapiti asynchronously using Popen. Command for it in wap.py:\np = Popen(\"python wapiti domainName\", shell = True)\nWhen I am running wap.py, it is executing completely fine.\nBut when I am running it using php exec, it doesn't work.\nCommand from php file : exec(\"python wap.py\")","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":72,"Q_Id":38191403,"Users Score":0,"Answer":"Look at the php.ini to see if there's anything set for disable_functions. If you're using PHP CLI for the script, you can execute the following command in the shell:\nphp -i | grep disable_functions\nAlso make sure wap.py has execute permissions.","Q_Score":0,"Tags":"php,python-2.7,exec,wapiti","A_Id":38191469,"CreationDate":"2016-07-04T19:49:00.000","Title":"php exec not working along with wapiti","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a Python project that I'm working on for research. I've been working on two different machines, and I recently discovered that half of my files used tabs and the other half used spaces.\nPython objected to this when I attempted to edit and run a file from one machine on the other, so I'd like to switch everything to spaces instead of tabs. However, this seems like a waste of a Git commit - running 'git diff' on the uncommitted-but-correct files makes it look like I'm wiping out and replacing the entire file.\nIs there a way around this? That is, is there some way that I can \"hide\" these (IMO) frivolous changes?","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":89,"Q_Id":38236636,"Users Score":5,"Answer":"There is, it's called a rebase - however, you'd probably want to add spaces to every file retroactively in each commit where you edited that file, which would be extremely tedious.\nHowever, there is absolutely nothing wrong with having a commit like this. A commit represents a change a distinct functioning state of your project, and replacing tabs with spaces is definitely a distinct state.\nOne place where you would want to use rebase is if you accidentally make a non-functional commit. For example, you might have committed only half the files you need to.\nOne last thing: never edit history (i.e. with rebase) once you've pushed your changes to another machine. The machines will get out of sync, and your repo will start slowly exploding.","Q_Score":3,"Tags":"python,git","A_Id":38236672,"CreationDate":"2016-07-07T02:12:00.000","Title":"Is a format-only update a frivolous Git commit?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Python project that I'm working on for research. I've been working on two different machines, and I recently discovered that half of my files used tabs and the other half used spaces.\nPython objected to this when I attempted to edit and run a file from one machine on the other, so I'd like to switch everything to spaces instead of tabs. However, this seems like a waste of a Git commit - running 'git diff' on the uncommitted-but-correct files makes it look like I'm wiping out and replacing the entire file.\nIs there a way around this? That is, is there some way that I can \"hide\" these (IMO) frivolous changes?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":89,"Q_Id":38236636,"Users Score":0,"Answer":"It is perfectly valid. Coupling a white space reformat with other changes in the same file could obfuscate the non white space changes. The commit has a single responsibility to reformat white space.","Q_Score":3,"Tags":"python,git","A_Id":38284795,"CreationDate":"2016-07-07T02:12:00.000","Title":"Is a format-only update a frivolous Git commit?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Python project that I'm working on for research. I've been working on two different machines, and I recently discovered that half of my files used tabs and the other half used spaces.\nPython objected to this when I attempted to edit and run a file from one machine on the other, so I'd like to switch everything to spaces instead of tabs. However, this seems like a waste of a Git commit - running 'git diff' on the uncommitted-but-correct files makes it look like I'm wiping out and replacing the entire file.\nIs there a way around this? That is, is there some way that I can \"hide\" these (IMO) frivolous changes?","AnswerCount":3,"Available Count":3,"Score":0.1973753202,"is_accepted":false,"ViewCount":89,"Q_Id":38236636,"Users Score":3,"Answer":"Unfortunately there is no way around the fact that at the textual level, this is a big change. The best you can do is not mix whitespace changes with any other changes. The topic of a such a commit should be nothing but the whitespace change.\nIf this screwup is unpublished (only in your private repos), you can go back in time and fix the mess in that point in the history when it was introduced, and then go through the pain of fixing up the subsequent changes (which have to be re-worked in the correct indentation style). For the effort, you end up with a clean history.","Q_Score":3,"Tags":"python,git","A_Id":38236665,"CreationDate":"2016-07-07T02:12:00.000","Title":"Is a format-only update a frivolous Git commit?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to push Python script to Git repo. Script contains variables with personal data like USER_NAME = \"some_name\" and USER_PASS = \"some_password\". This data could be accessible for other users. I want to hide this data.\nI found following approach: \n\ncreate separate data.py module with USER_NAME = \"some_name\" and USER_PASS = \"some_password\"\nimport it once to generate compiled version- data.pyc\nchange main script source: variables should be accessible like \nimport data\nusername = data.USER_NAME\npassword = data.USER_PASS \nremove data.pyand push data.pyc to repo\n\nThis was promising, but actually data in data.pyc appears like ???some_namet???some_passwords??? and still could be recognized as username and password. \nSo what is the best practices to hide data in Python script?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":940,"Q_Id":38248928,"Users Score":2,"Answer":"Include in git repo code to read those things from environment variables. On the target machine, set those environment variables. This could be done by hand, or with a script that you don't include in your repo. Include instructions in your readme file","Q_Score":4,"Tags":"python,git","A_Id":38249044,"CreationDate":"2016-07-07T15:03:00.000","Title":"How to hide personal data in Python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to push Python script to Git repo. Script contains variables with personal data like USER_NAME = \"some_name\" and USER_PASS = \"some_password\". This data could be accessible for other users. I want to hide this data.\nI found following approach: \n\ncreate separate data.py module with USER_NAME = \"some_name\" and USER_PASS = \"some_password\"\nimport it once to generate compiled version- data.pyc\nchange main script source: variables should be accessible like \nimport data\nusername = data.USER_NAME\npassword = data.USER_PASS \nremove data.pyand push data.pyc to repo\n\nThis was promising, but actually data in data.pyc appears like ???some_namet???some_passwords??? and still could be recognized as username and password. \nSo what is the best practices to hide data in Python script?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":940,"Q_Id":38248928,"Users Score":1,"Answer":"You should never put sensitive pieces of information inside your code neither store them into a public repository.\nIt's better to follow Joel Goldstick's suggestion and modify your code to get passwords from private sources, e.g. local environment variables or local modules.\nTry googling for \"python store sensitive information\" to look at some ideas (and involved issues).","Q_Score":4,"Tags":"python,git","A_Id":38296218,"CreationDate":"2016-07-07T15:03:00.000","Title":"How to hide personal data in Python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I originally posted on his on Network Engineering but it was suggested that o post it on here. \nI've been learning Python and since I work in networking I'd like to start writing a few scripts that I can use in my day to day work tasks with switches. So my question is this, what network projects have you used python in? What sort of tasks have you written scripts for? I'm not asking for source code, I'm interested in what projects people have done to inspire my own coding adventures!\nThanks all!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":411,"Q_Id":38257055,"Users Score":1,"Answer":"Backing up and copying configs to server. Automate certain config changes to adhere to standards. Scripts to copy run start on all devices at will. Finding various config entries on all devices that may need to be altered.\nThere are so many possibilities.\nSearch github and pastebin and the overflow sites for anything using:\nImport netmiko\nImport paramiko\nImport ciscoconfparse \nScripts using any of those libraries will be network related typically and offer up ideas.","Q_Score":1,"Tags":"python,network-programming","A_Id":38258777,"CreationDate":"2016-07-07T23:57:00.000","Title":"Python Network Projects","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'd like to create an Python class that superficially appears to be a subclass of another class, but doesn't actually inherit its attributes.\nFor instance, if my class is named B, I'd like isinstance(B(), A) to return True, as well as issubclass(B, A), but I don't want B to have the attributes defined for A. Is this possible?\nNote: I don't control the implementation of A.\nWhy I care: The module I'm working with checks that a passed object is a subclass of A. I want to define the necessary attributes in B without inheriting the superfluous attributes defined in A (whose implementation I do not control) because I'm using __getattr__ to pass some attribute calls onto a wrapped class, and if these attributes are defined by inheritance from A, __getattr__ won't be called.","AnswerCount":5,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2382,"Q_Id":38275148,"Users Score":3,"Answer":"In Python3, override the special method __getattribute__. This gives you almost complete control over attribute lookups. There are a few corner cases so check the docs carefully (it's section 3.3.2 of the Language Reference Manual).","Q_Score":3,"Tags":"python,class,oop,inheritance","A_Id":38275281,"CreationDate":"2016-07-08T20:46:00.000","Title":"Python subclass that doesn't inherit attributes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'd like to create an Python class that superficially appears to be a subclass of another class, but doesn't actually inherit its attributes.\nFor instance, if my class is named B, I'd like isinstance(B(), A) to return True, as well as issubclass(B, A), but I don't want B to have the attributes defined for A. Is this possible?\nNote: I don't control the implementation of A.\nWhy I care: The module I'm working with checks that a passed object is a subclass of A. I want to define the necessary attributes in B without inheriting the superfluous attributes defined in A (whose implementation I do not control) because I'm using __getattr__ to pass some attribute calls onto a wrapped class, and if these attributes are defined by inheritance from A, __getattr__ won't be called.","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":2382,"Q_Id":38275148,"Users Score":1,"Answer":"As long as you're defining attributes in the __init__ method and you override that method, B will not run the code from A's __init__ and will thus not define attributes et al. Removing methods would be harder, but seem beyond the scope of the question.","Q_Score":3,"Tags":"python,class,oop,inheritance","A_Id":38275187,"CreationDate":"2016-07-08T20:46:00.000","Title":"Python subclass that doesn't inherit attributes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wrote a SSH server with Twisted Conch. When I execute \"ssh username@xx.xx.xx.xx\" command on the client side. My twisted SSH server will return a prompt requesting password that like \"username@xx.xx.xx.xx's password: \".\n But now I want to change this password prompt that like \"your codes is:\". Dose anyone know how to do it?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":122,"Q_Id":38321820,"Users Score":0,"Answer":"The password prompt is part of keyboard-authentication which is part of the ssh protocol and thus cannot be changed. Technically, the prompt is actually client side. However, you can bypass security (very bad idea) and then output \"your codes is\"[sic] via the channel","Q_Score":0,"Tags":"python,ssh,twisted.conch,password-prompt","A_Id":38324034,"CreationDate":"2016-07-12T06:49:00.000","Title":"Python SSH Server(twisted.conch) change the password prompt","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm using SNS to trigger lambda functions in AWS. This works fine and as expected, but I'm wondering if there is a way to get feedback about the execution times and if an exception was raised within the function.\nObviously there is exception handling code in my lambda functions for most of the business logic, but I'm thinking about cases like an external program (like Ghostscript) that might end up in an endless loop and eventually get terminated by the 10 minute Lambda limit.\nAs far as I know you can do this easily if you invoke the method in an synchronous fashion, but I can't seem to find a way to get information about how long the execution lasted and if something bad happened.\nIs there a way to subscribe to execution errors or similar, or have a callback from AWS (not my code) when an exception or timeout occurs?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":85,"Q_Id":38327327,"Users Score":0,"Answer":"Exceptions of Lambda functions will be in your logs, which are streamed to AWS CloudWatch Logs. Execution time is stored as the Lambda Duration metric in CloudWatch. You would need to setup CloudWatch alerts on those items to be notified.","Q_Score":0,"Tags":"python,amazon-web-services,aws-lambda,amazon-sns","A_Id":38329761,"CreationDate":"2016-07-12T11:15:00.000","Title":"Getting information about function execution time\/billing and if the function call was successful","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running multiple scenarios and would like to incorporate some sort of dynamic scenario dispatcher which would allow me to have specific steps to execute after a test is done based on the scenario executed. When I was using PHPUnit, I used to be able to subclass the TestCase class and add my own setup and teardown methods. For behave, what I have been doing is adding an extra \"Then\" step at the end of the scenario which would be executed once the scenario finishes to clean up everything - clean up the configuration changes made by scenario, etc. But since every scenario is different, the configuration changes I need to make are specific to a scenario so I can't use the after_scenario hook that I have in my environment.py file. Any ideas on how to implement something similar?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":697,"Q_Id":38364568,"Users Score":0,"Answer":"What I've been doing might give you an idea:\nIn the before_all specify a list in the context (eg context.teardown_items =[]).\nThen in the various steps of various scenarios add to that list (accounts, orders or whatever)\nThen in the after_all I login as a superuser and clean everything up I specified in that list.\nCould something like that work for you ?","Q_Score":0,"Tags":"python,bdd,scenarios,python-behave","A_Id":38643609,"CreationDate":"2016-07-14T02:30:00.000","Title":"Dynamic scenario dispatcher for Python Behave","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm creating a python script that plays mp3\/cdg karaoke files. I can open these files and they play with no problems when using the standalone VLC gui, however when I use the python libvlc library to open them, they play for a few frames then stop while the audio continues.\nI'm almost certain that this is is because the gui has some configuration set that the python implementation is defaulting to something else, but I'm not sure what it is. My question is:\nA) is there some way to just \"export\" the settings from the gui to command line arguments so I can pass them to the python implementation?\nB) If not, is there some way to compare the settings each one is using?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":251,"Q_Id":38378578,"Users Score":0,"Answer":"First, make sure you only have one copy of libvlc and that it's current.\nYou can see what options VLC is using to play the file by clicking the \"show more options\" in the \"Open Media\" dialog.","Q_Score":1,"Tags":"python,linux,vlc,libvlc","A_Id":38379334,"CreationDate":"2016-07-14T15:40:00.000","Title":"Video plays in VLC gui but not when using python libvlc","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My background in programming is mostly Java. It was the first language I learned, and the language I spent the most amount of time with (I then moved on to C# for a little, and eventually C in school). A while back I tried dabbling with Python, and it seemed so different to me (based on my experience with Java). Anyways, now I'm doing much more Python stuff, and I've learned that Python is considered an OOP language with classes and such. I was just curious as to whether these attributes of Python function similarly to their Java counterparts.\nPlease understand, that I'm asking this at a very rudimentary level. I'm still a \"new\" programmer in the sense that I just know how to write code, but don't know much about the various intricacies and subtleties with various languages and types of programming.\nThanks\nEDIT\nSorry, I realize that this was incredibly broad, but I really wasn't looking for specifics. I guess the root of my question stems from my curiosity about the purpose\/role of classes in Python to begin with. From my experience, and what I've seen (and this is by no means extensive or considered to be an accurate representation of the actual uses of Python), most of the time, Python is used without classes or any sort of OOP. As to how that relates to Java, I merely wanted to know if there was a special use or scenario for classes in Python. Essentially, since classes are required in Java, and I was brought up on Java, classes seemed like a norm to me. However, when I got to Python, I noticed that a lack of classes was the norm. This led me to wonder whether classes in Python had some sort of special significance.\nI apologize if this is no more clear than my original post, or if any of this sounds confusing\/inaccurate.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":57,"Q_Id":38400918,"Users Score":2,"Answer":"The short answer is yes and no.\nOne of the key differences I see in Python compared to Java and C# is that in Python, functions don't have to be in a class. In fact, operations don't even have to be in a function.\nJava and C# both have two main rules:\n\nAll code must be in a class.\nOperations are generally required to be in functions.\n\nThis isn't true in Python. In fact, you can write a very basic Python script that's not even in a function. Java does not offer that flexibility - sometimes, that can be very positive because those strict rules help keep the code organized.\nClasses in Python operate in a manner that's very similar to Java and C#, but they aren't necessarily applied in the same way because of the rules above.","Q_Score":0,"Tags":"java,python,oop","A_Id":38400988,"CreationDate":"2016-07-15T16:23:00.000","Title":"Do classes in Python work the same way as classes in Java?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to AWS Lambda, I have phantomjs application to run there.\nThere is a python script of 5 kb and phantomjs binary which makes the whole uploadable zip to 32MB.\nAnd I have to upload this bunch all the time. Is there any way of pushing phantomjs binary to AWS lambda \/bin folder separately ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":345,"Q_Id":38401090,"Users Score":0,"Answer":"No, there is no way to accomplish this. Your Lambda function is always provisioned as a whole from the latest zipped package you provide (or S3 bucket\/key if you choose that method).","Q_Score":0,"Tags":"python,amazon-web-services,aws-lambda,continuous-deployment","A_Id":38442640,"CreationDate":"2016-07-15T16:33:00.000","Title":"Does AWS Lambda allows to upload binaries separately to avoid re-upload","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"This may seem like a simple question, but I haven't found an answer that explains the behavior I'm seeing. Hard to provide a simple repro case but I basically have a package structure like this:\na.b.c\na.b.utils\nI have one project that has files in a.b.c. (let's call this aux_project) and another that has files in a.b.d, a.b.utils, etc (call it main_project). I'm trying to import a.b.utils inside pytest tests in the first project, using tests_require. This does not work because a.b is for some reason sourced from inside aux_project\/a\/b\/__init__.pyc instead of the virtualenv and it shadows the other package (i.e. this a.b only has a c in it, not d or utils). This happens ONLY in the test context. In ipython I can load all packages fine, and they are correctly loaded from virtualenv.\nWhat's weirder is that if I simply delete the actual directory, the tests do load the pycs from virtualenv and everything works (I need that directory, though)\npython==2.7.9\nWhat is going on?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":17,"Q_Id":38405109,"Users Score":0,"Answer":"Ok, the problem was simply that the cwd is prepended to the PYTHONPATH. sys.path.pop(1) (0 is the tests dir, prepended by pytest) resolved the behavior.","Q_Score":0,"Tags":"python,pytest,python-module","A_Id":38405572,"CreationDate":"2016-07-15T21:13:00.000","Title":"How are python module paths translated to filesystem paths?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"For a college project I'm tasked with getting a Raspberry Pi to control an RC car over WiFi, the best way to do this would be through a web interface for the sake of accessibility (one of the key reqs for the module). However I keep hitting walls, I can make a python script control the car, however doing this through a web interface has proven to be dificult to say the least. \nI'm using an Adafruit PWM Pi Hat to control the servo and ESC within the RC car and it only has python libraries as far as I'm aware so it has to be witihn python. If there is some method of passing variables from javascript to python that may work, but in a live environment I don't know how reliable it would be.\nAny help on the matter would prove most valuable, thanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":229,"Q_Id":38418140,"Users Score":0,"Answer":"I can suggest a way to handle that situation but I'm not sure how much will it suit for your scenario.\nSince you are trying to use a wifi network, I think it would be better if you can use a sql server to store commands you need to give to the vehicle to follow from the web interface sequentially. Make the vehicle to read the database to check whether there are new commands to be executed, if there are, execute sequentially.\nFrom that way you can divide the work into two parts and handle the project easily. Handling user inputs via web interface to control vehicle. Then make the vehicle read the requests and execute them.\nHope this will help you in someway. Cheers!","Q_Score":0,"Tags":"javascript,python,html,raspberry-pi2","A_Id":38418381,"CreationDate":"2016-07-17T05:18:00.000","Title":"How do I control a python script through a web interface?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Im trying to get all Ami images using below code using python 2.7 in AWS lambda\nresult = client.describe_images(\n Owners=[\n 'self'\n ]\n )\nIm able to get the ami images but not able to get in which region its created...i would like to filter images based on region.Please suggest","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":330,"Q_Id":38491463,"Users Score":2,"Answer":"When you are working with the AWS EC2 SDK, you are only working in a single region.\nSo by calling client.describe_images(), you are already filtered to a single region. All AMI images returned in the result are in that same region.\nTo get all AMI images in all regions, then you need to iterate across all regions, calling client.describe_images() within each region.","Q_Score":0,"Tags":"python-2.7,amazon-web-services,aws-lambda,boto3","A_Id":38494011,"CreationDate":"2016-07-20T21:51:00.000","Title":"get AWS region for describeImages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"What I wanna do is just like 'Shazam' or 'SoundHound' with Python, only sound version, not music.\nFor example, when I make sound(e.g door slam), find the most similar sound data in the sound list.\nI don't know you can understand that because my English is bad, but just imagine the sound version of 'Shazam'.\nI know that 'Shazam' doesn't have open API.\nIs there any api like 'Shazam'?\nOr,\nHow can I implement it?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2228,"Q_Id":38494736,"Users Score":0,"Answer":"The problem here is that music has structure, while the sounds you want to find may have different signatures. Using the door as an example, the weight, size and material of the door alone will influence the types of acoustic signatures it will produce. If you want to search by similarity, a bag-of-features approach may be the easy(ish) way to go. However, there are different approaches, such as taking samples by a sliding window along the spectrogram of a sound, and trying to match (by similarity) with a previous sound you recorded, decomposition of the sound, etc...","Q_Score":0,"Tags":"python,audio","A_Id":47418314,"CreationDate":"2016-07-21T04:10:00.000","Title":"Get sound input & Find similar sound with Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been on it for several days + researching the internet on how to get specific information from a pdf file.\nEventually I was able to fetch all information using Python from a text file(which I created by going to the PDF file -----> File ------> Save as Text).\nThe question is how do I get Python to accomplish those tasks(Going to the PDF file(opening it - is quite easy open(\"file path\"), clicking on File in the menu, and then saving the file as a text file in the same directory).\nJust to be clear, I do not require the pdfminer or pypdf libraries as I have already extracted the information with the same file(after converting it manually to txt)","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3865,"Q_Id":38496026,"Users Score":0,"Answer":"You can use \"tabula\" python library. which basically uses Java though so you have to install Java SDK and JDK.\n\"pip install tabula\"\nand import it to the python script then you can convert pdf to txt file as:\ntabula.convert_into(\"path_or_name_of_pdf.pdf\", \"output.txt\", output_format=\"csv\", pages='all')\nYou can see other functions on google. It worked for me.\nCheers!!!","Q_Score":3,"Tags":"python,python-2.7,pdf,text,converter","A_Id":70157888,"CreationDate":"2016-07-21T06:01:00.000","Title":"Converting a PDF file to a Text file in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"We have implemented a simple DynamoDB database that is updated by a remote IoT device that does not have a user (i.e. root) constantly logged in to the device. We have experience issues in logging data as the database is not updated if a user (i.e. root) is not logged into the device (we log in via a ssh session). We are confident that the process is running in the background as we are using a Linux service that runs on bootup to execute a script. We have verified that the script runs on bootup and successfully pushes data to Dynamo upon user log in (via ssh). We have also tried to disassociate a screen session to allow for the device to publish data to Dynamo but this did not seem to fix the issue. Has anyone else experienced this issue? Does amazon AWS require a user (i.e. root) to be logged in to the device at all times in order to allow for data to be published to AWS?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":66,"Q_Id":38527573,"Users Score":0,"Answer":"No, it does not. I have done similar setup and it is working fine. Are you sure that your IoT device does not go into some kind of sleep mode after a while ?","Q_Score":1,"Tags":"python,amazon-web-services,amazon-dynamodb,iot","A_Id":38537832,"CreationDate":"2016-07-22T13:21:00.000","Title":"AWS IOT with DynamoDB logging service issue","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I'm attempting to execute foo.py from mysite.com\/foo.py, however the script requires access to directories that would normally require sudo -i root access first. chmod u+s foo.py still doesn't give the script enough permission. What can I do so the script has root access? Thank you!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":690,"Q_Id":38529591,"Users Score":0,"Answer":"Have you tried chmod 777 foo.py or chmod +x foo.py? Those are generally the commands used to give file permission to run.","Q_Score":0,"Tags":"python,apache,cgi","A_Id":38529657,"CreationDate":"2016-07-22T14:57:00.000","Title":"CGI: Execute python script as root","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to install some python packages on a remote server where I can actually log in and work on some existing python packages. Sometimes I need new python packages like easydict, then I have to install it. However, since I don't have access to the root (I mean I cannot sudo). How to solve this problem? Is it impossible to debug on someone else's computer where you cannot even \"sudo\"?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":176,"Q_Id":38562310,"Users Score":1,"Answer":"There is no need for sudo if you want to install packages locally. Generally, you should always use a virtualenv; once that is activated, all packages install within that virtualenv only, with no need for admin privileges.","Q_Score":0,"Tags":"python","A_Id":38562772,"CreationDate":"2016-07-25T07:50:00.000","Title":"Install python packages on a remote server without access to root","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want festival tts to read a bit slower, can anyone help me with that?\nI use python 2.7 and I run the code in gnome-terminal.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3733,"Q_Id":38572860,"Users Score":0,"Answer":"Consider using the Festival utility text2wave to write the audio as a file, then play the file using sox with the speed and pitch effects. To slow the audio down you will need a speed value less than one, and compensate for the effect on pitch with a positive value in pitch.","Q_Score":3,"Tags":"python-2.7,gnome-terminal,festival","A_Id":41790004,"CreationDate":"2016-07-25T16:19:00.000","Title":"Can festival tts's speed of speech be changed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am unsure whether to name a method send_auto_reply() or send_autoreply().\nWhat guidelines can be applied here?\nIt's Python, but AFAIK this should not matter.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":29,"Q_Id":38587600,"Users Score":2,"Answer":"There is no such word as autoreply so you should name it as send_auto_reply","Q_Score":0,"Tags":"python,naming-conventions,naming","A_Id":38587644,"CreationDate":"2016-07-26T10:38:00.000","Title":"Naming method: send_auto_reply() vs send_autoreply()","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm a student, I am a beginner with beaglebones. I have a project and in the project we have a BeagleBone Black connected to a battery and solar panels.\nIt will work autonomously, and the beagle will send datas by the 3G network through an 3G usb. \nWhat I want to do is to save as more energy as it's possible. What I thought first was to switch on hibernation or sleep mode the beaglebone. To switch on hibernate\/sleep mode and then wake up the Beagle every x seconds or minutes or anything else. \nSo I want to know if it's possible and if there is an OS more adapted for that use. \nI succeeded to disable the usb chipset and then to reactivate it several minutes later.\nThank you if you can help me !","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2087,"Q_Id":38601376,"Users Score":0,"Answer":"For the beaglebone black, I was able to do this using the rtcwake function. There are several different modes. \nFor instance, if you want to put the BBB in sleep mode for 10 seconds and then wake back up, you would enter the following command:\nsudo rtcwake -u 10 -m standby\nsudo rtcwake --help to see all options.","Q_Score":1,"Tags":"python,sleep,beagleboneblack","A_Id":59011900,"CreationDate":"2016-07-26T23:19:00.000","Title":"Hibernate a BeagleBone Black","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"so I made that python program using several module including os, zipfile, time, datetime, shutil, shelve and ftplib. I froze it with cx_freeze, it won't run on the target machine (but it run on mine). I'm super new to cx_freeze, but I've poked around a bit and I suspect it's a module ot found error. Trouble is, when I execute the exe on the target machine the window doesn't stay open long enough for me to catch the error message so I can't even narrow down the issue to try and solve it. Any idea on how I could deal with it?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":205,"Q_Id":38616200,"Users Score":0,"Answer":"Executing the exe from the console works out fine. Thanks.","Q_Score":0,"Tags":"python,cx-freeze","A_Id":38618295,"CreationDate":"2016-07-27T14:42:00.000","Title":"cx_freeze freezed python program doesn't run - no time to see the error message on executing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to write a little code that detects how long a button connected to my Raspberry Pi is pushed down, not just if it's pushed. Is there an easy way to do this with Python? Thanks!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":36,"Q_Id":38616773,"Users Score":1,"Answer":"You just have to detect whenever the state of the button is toggled. When toggled if it's pushed down you will need to store the current time with pressedTime = time.time(). When released, to get how long the button have been pushed down, you just do : howLong = time.time() - pressedTime","Q_Score":0,"Tags":"python-3.x,raspberry-pi3","A_Id":38617501,"CreationDate":"2016-07-27T15:04:00.000","Title":"Detect time button is pushed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"at the first place, I could not help myself with the correct search terms on this.\nsecondly, I couldnt pretty much make it working with standard smtplib or email package in python.\n\nThe question is, I have a normal html page(basically it contains a that is generated from bokeh package in python, and all it does is generating an html page the javascript within renders a nice zoomable plot when viewed in a browser.\nMy aim is to send that report (the html basically) over to recipients in a mail.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":516,"Q_Id":38650665,"Users Score":2,"Answer":"Sorry, but you'll not be able to send an email with JavaScript embedded. That is a security risk. If you're lucky, an email provider will strip it before rendering, if you're unlucky, you'll be sent directly to spam and the provider will distrust your domain.\nYou're better off sending an email with a link to the chart.","Q_Score":0,"Tags":"javascript,python,email,bokeh,smtplib","A_Id":38650801,"CreationDate":"2016-07-29T04:43:00.000","Title":"sending dynamic html email containing javascript via a python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to import everything from nodebox.graphics into my python 3.5 code but I get errors:\n\n\nImportError: No module named 'bezier'\n\n\nTo mention, this module exists in nodebox\/graphics. As I searched in python documentations, I have to add the nodebox and pyglet folders into the directory of my code but that did not work.\nI also didn't succeed in adding them to system directories.\nHow can I solve the problem and run my code properly?\nP.S. I'm currently using ubuntu 16.04 if it matters.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":730,"Q_Id":38671739,"Users Score":1,"Answer":"I had the same error. Placing all the .py files except (and this is important) the __init__.py file in the main libraries folder fixed it for me. The final path should look like ~\/lib\/python3.5\/site-packages\/bezier.py","Q_Score":0,"Tags":"linux,python-3.x,pyglet,nodebox","A_Id":42557054,"CreationDate":"2016-07-30T08:00:00.000","Title":"use nodebox as a module for python 3.5","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to scan all project files in a python project, identify all instantiations of objects that are subclass of a certain type and then:\n1. Add the \"yield\" keyword to the object instantiation\n2. identify all call stack for that object creation, and add a decorator to all functions in that call stack.\nis that doable using Rascal?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":149,"Q_Id":38696394,"Users Score":2,"Answer":"When you have a representation of your Python source code as tree (parse tree or abstract syntax tree) you\ncan convert this to a Rascal data type and use Rascal for \nfurther processing. This can be achieved by using and connecting an existing Python parser to generate the Rascal\nrepresentation of your Python program. This could be done by simply\ndumping the parse tree in a format that can be read by Rascal.\nWhy this complex solution: because the built-in parser\ngenerator of Rascal is not (yet) well equipped to parse\nindentation-sensitive languages like Python.","Q_Score":1,"Tags":"python,callstack,rascal","A_Id":38777882,"CreationDate":"2016-08-01T10:21:00.000","Title":"python source file analysis and transformation using Rascal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was faced with the following problem: on a computer (number 2) script execution time is significantly greater than on another computer (computer 1).\n\nComputer 1 - i3 - 4170 CPU @ 3.7 GHz (4 core), 4GB RAM (Execution time 9.5 minutes)\nComputer 2 - i7 - 3.07GHz (8 core), 8GB RAM (Execution time 15-17 minutes)\n\nI use Python to process Excel files. \nI import for these three libraries:\n\nxlrd, xlsxwriter, win32com\n\nWhy is the execution time different? How can I fix it?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":61,"Q_Id":38737144,"Users Score":1,"Answer":"It runs on single core, the computer1 has higher clock rate = faster single threaded processing.","Q_Score":0,"Tags":"python,excel,python-3.5,execution-time,miniconda","A_Id":38737237,"CreationDate":"2016-08-03T07:31:00.000","Title":"Script execution time on different computers (python 3.5, miniconda)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to open files from a Raspberry pi in windows for editing (using for example notepad++)?\nI am currently using the built in python IDE in Raspbian but i feel that it would speed up the development process if i could use a windows IDE for development. I have also tried using a git repo to share files between the PI and Windows but it is a bit cumbersome to.\nOr does anyone have any other ideas about workflow between Windows and Raspberry?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":606,"Q_Id":38755220,"Users Score":2,"Answer":"You can run a SAMBA server on your Raspberry Pi, set your python project folder as a network disk. Then you can use any windows IDE you like, just open the file which is on the network disk.\nCurrently I am using VS2015 + Python Tools for Visual Studio for remote debugging purpose.","Q_Score":1,"Tags":"python,windows,git,raspberry-pi","A_Id":38760276,"CreationDate":"2016-08-03T23:29:00.000","Title":"Develop Raspberry apps from windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am having a hard time trying to figure out the big picture of the handling of multiple requests by the uwsgi server with django or pyramid application. \nMy understanding at the moment is this: \nWhen multiple http requests are sent to uwsgi server concurrently, the server creates a separate processes or threads (copies of itself) for every request (or assigns to them the request) and every process\/thread loads the webapplication's code (say django or pyramid) into computers memory and executes it and returns the response. In between every copy of the code can access the session, cache or database. There is a separate database server usually and it can also handle concurrent requests to the database. \nSo here some questions I am fighting with. \n\nIs my above understanding correct or not? \nAre the copies of code interact with each other somehow or are they wholly separated from each other?\nWhat about the session or cache? Are they shared between them or are they local to each copy? \nHow are they created: by the webserver or by copies of python code? \nHow are responses returned to the requesters: by each process concurrently or are they put to some kind of queue and sent synchroniously?\n\nI have googled these questions and have found very interesting answers on StackOverflow but anyway can't get the whole picture and the whole process remains a mystery for me. It would be fantastic if someone can explain the whole picture in terms of django or pyramid with uwsgi or whatever webserver.\nSorry for asking kind of dumb questions, but they really torment me every night and I am looking forward to your help:)","AnswerCount":2,"Available Count":2,"Score":0.3799489623,"is_accepted":false,"ViewCount":1964,"Q_Id":38767616,"Users Score":4,"Answer":"There's no magic in pyramid or django that gets you past process boundaries. The answers depend entirely on the particular server you've selected and the settings you've selected. For example, uwsgi has the ability to run multiple threads and multiple processes. If uwsig spins up multiple processes then they will each have their own copies of data which are not shared unless you took the time to create some IPC (this is why you should keep state in a third party like a database instead of in-memory objects which are not shared across processes). Each process initializes a WSGI object (let's call it app) which the server calls via body_iter = app(environ, start_response). This app object is shared across all of the threads in the process and is invoked concurrently, thus it needs to be threadsafe (usually the structures the app uses are either threadlocal or readonly to deal with this, for example a connection pool to the database).\nIn general the answers to your questions are that things happen concurrently, and objects may or may not be shared based on your server model but in general you should take anything that you want to be shared and store it somewhere that can handle concurrency properly (a database).","Q_Score":7,"Tags":"python,django,multithreading,webserver,pyramid","A_Id":38782897,"CreationDate":"2016-08-04T12:40:00.000","Title":"What exactly happens on the computer when multiple requests came to the webserver serving django or pyramid application?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am having a hard time trying to figure out the big picture of the handling of multiple requests by the uwsgi server with django or pyramid application. \nMy understanding at the moment is this: \nWhen multiple http requests are sent to uwsgi server concurrently, the server creates a separate processes or threads (copies of itself) for every request (or assigns to them the request) and every process\/thread loads the webapplication's code (say django or pyramid) into computers memory and executes it and returns the response. In between every copy of the code can access the session, cache or database. There is a separate database server usually and it can also handle concurrent requests to the database. \nSo here some questions I am fighting with. \n\nIs my above understanding correct or not? \nAre the copies of code interact with each other somehow or are they wholly separated from each other?\nWhat about the session or cache? Are they shared between them or are they local to each copy? \nHow are they created: by the webserver or by copies of python code? \nHow are responses returned to the requesters: by each process concurrently or are they put to some kind of queue and sent synchroniously?\n\nI have googled these questions and have found very interesting answers on StackOverflow but anyway can't get the whole picture and the whole process remains a mystery for me. It would be fantastic if someone can explain the whole picture in terms of django or pyramid with uwsgi or whatever webserver.\nSorry for asking kind of dumb questions, but they really torment me every night and I am looking forward to your help:)","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":1964,"Q_Id":38767616,"Users Score":3,"Answer":"The power and weakness of webservers is that they are in principle stateless. This enables them to be massively parallel. So indeed for each page request a different thread may be spawned. Wether or not this indeed happens depends on the configuration settings of you webserver. There's also a cost to spawning many threads, so if possible threads are reused from a thread pool.\nAlmost all serious webservers have page cache. So if the same page is requested multiple times, it can be retrieved from cache. In addition, browsers do their own caching. A webserver has to be clever about what to cache and what not. Static pages aren't a big problem, although they may be replaced, in which case it is quite confusing to still get the old page served because of the cache.\nOne way to defeat the cache is by adding (dummy) parameters to the page request.\nThe statelessness of the web was initialy welcomed as a necessity to achieve scalability, where webpages of busy sites even could be served concurrently from different servers at nearby or remote locations.\nHowever the trend is to have stateful apps. State can be maintained on the browser, easing the burden on the server. If it's maintained on the server it requires the server to know 'who's talking'. One way to do this is saving and recognizing cookies (small identifiable bits of data) on the client.\nFor databases the story is a bit different. As soon as anything gets stored that relates to a particular user, the application is in principle stateful. While there's no conceptual difference between retaining state on disk and in RAM memory, traditionally statefulness was left to the database, which in turned used thread pools and load balancing to do its job efficiently.\nWith the advent of very large internet shops like amazon and google, mandatory disk access to achieve statefulness created a performance problem. The answer were in-memory databases. While they may be accessed traditionally using e.g. SQL, they offer much more flexibility in the way data is stored conceptually.\nA type of database that enjoys growing popularity is persistent object store. With this database, while the distinction still can be made formally, the boundary between webserver and database is blurred. Both have their data in RAM (but can swap to disk if needed), both work with objects rather than flat records as in SQL tables. These objects can be interconnected in complex ways.\nIn short there's an explosion of innovative storage \/ thread pooling \/ caching\/ persistence \/ redundance \/ synchronisation technology, driving what has become popularly know as 'the cloud'.","Q_Score":7,"Tags":"python,django,multithreading,webserver,pyramid","A_Id":38767725,"CreationDate":"2016-08-04T12:40:00.000","Title":"What exactly happens on the computer when multiple requests came to the webserver serving django or pyramid application?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is it possibe to copy all of the python modules from one Windows computer to another computer? They are both running the same version of Python 2.7.12. \nThe reason for doing so is that I have internet access on one of them, and manual installing modules on the other requires to much time because of dependencies.","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":25254,"Q_Id":38807772,"Users Score":2,"Answer":"I suppose you mean \"copy the python installation from one system to another\" (else the answer is: put your modules on a USB key and copy them to the other system).\nthe best way\nThe best way of course would be to install Python properly on the other system using setup. But as you said, all dependencies\/external libraries that you could easily get using pip for instance would have to be re-done. Nothing impossible with a small batch script, even if you don't have internet, but you would have to get hold of all the .whl files.\nthe full treatment, portable-style\nBut if you cannot you can create a \"portable\" version of python like this:\n\nzip the contents of C:\\python27 to an USB key\ncopy all python DLLS: copy C:\\windows\\system32\\py*DLL K: (if K is your usb drive)\nunzip the contents of the archive somewhere on the second machine\nadd the DLLs directly in the python27 directory.\n\n(those DLLs were installed in the windows system in previous Python versions, now it's even simpler since they are natively installed in the python directory)\nThe advantage of this method is that it can be automated to be performed on several machines.\nThere are some disadvantages too:\n\npython is not seen as \"installed\" in the registry, so no \"uninstall\" is proposed. It's a portable install\nassociations with .py and .pyw are not done. But you can do it manually by altering some registry keys.\n\nanother method, better\nYou can have best of both worlds like this:\n\nperform a basic install of python on the second machine\noverwrite the install with the zip file\n\n=> you get the registered install + the associations + the PATH... I would recommend that last method.\nLast partial method, maybe best matching your question\nTry copying the Lib directory only. It's where the libraries are installed. I'm not 100% sure but it worked for me when I wanted to put wx on a python install lacking wx.\nOf course you will copy over already existing files, but they are the same so no problem. I let other people comment if this is acceptable or not. I'm not sure of all the installation mechanism, maybe that will fail in some particular case.","Q_Score":13,"Tags":"windows,python-2.7,python-module","A_Id":38808033,"CreationDate":"2016-08-06T18:59:00.000","Title":"Copy python modules from one system to another","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possibe to copy all of the python modules from one Windows computer to another computer? They are both running the same version of Python 2.7.12. \nThe reason for doing so is that I have internet access on one of them, and manual installing modules on the other requires to much time because of dependencies.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":25254,"Q_Id":38807772,"Users Score":0,"Answer":"In my case, copy-pasting python installation didn't do the job.\nYou need to check the \"C:\\Users\\\\AppData\\Roaming\\Python*\" folder. You may find installed python modules there. Copy and paste these into your source folder will add these modules to your python.","Q_Score":13,"Tags":"windows,python-2.7,python-module","A_Id":59914406,"CreationDate":"2016-08-06T18:59:00.000","Title":"Copy python modules from one system to another","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm facing problem like this. I used tweepy to collect +10000 tweets, i use nltk naive-bayes classification and filtered the tweets into +5000. \nI want to generate a graph of user friendship from that classified 5000 tweet. The problem is that I am able to check it with tweepy.api.show_frienship(), but it takes so much and much time and sometime ended up with endless ratelimit error. \nis there any way i can check the friendship more eficiently?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":592,"Q_Id":38818981,"Users Score":0,"Answer":"I don't know much about the limits with Tweepy, but you can always write a basic web scraper with urllib and BeautifulSoup to do so.\nYou could take a website such as www.doesfollow.com which accomplishes what you are trying to do. (not sure about request limits with this page, but there are dozens of other websites that do the same thing) This website is interesting because the url is super simple.\nFor example, in order to check if Google and Twitter are \"friends\" on Twitter, the link is simply www.doesfollow.com\/google\/twitter.\nThis would make it very easy for you to run through the users as you can just append the users to the url such as 'www.doesfollow.com\/'+ user1 + '\/' + user2\nThe results page of doesfollow has this tag if the users are friends on Twitter:\n
yup<\/div>, \nand this tag if the users are not friends on Twitter:\n
nope<\/div>\nSo you could parse the page source code and search to find which of those tags exist to determine if the users are friends on Twitter.\nThis might not be the way that you wanted to approach the problem, but it's a possibility. I'm not entirely sure how to approach the graphing part of your question though. I'd have to look into that.","Q_Score":3,"Tags":"python,twitter,tweepy","A_Id":38819049,"CreationDate":"2016-08-07T22:03:00.000","Title":"Most efficient way to check twitter friendship? (over 5000 check)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to stay connected to multiple queues in RabbitMQ. Each time I pop a new message from one of these queue, I'd like to spawn an external process.\nThis process will take some time to process the message, and I don't want to start processing another message from that specific queue until the one I popped earlier is completed. If possible, I wouldn't want to keep a process\/thread around just to wait on the external process to complete and ack the server. Ideally, I would like to ack in this external process, maybe passing some identifier so that it can connect to RabbitMQ and ack the message.\nIs it possible to design this system with RabbitMQ? I'm using Python and Pika, if this is relevant to the answer.\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1536,"Q_Id":38833309,"Users Score":0,"Answer":"RabbitMQ can do this.\nYou only want to read from the queue when you're ready - so spin up a thread that can spawn the external process and watch it, then fetch the next message from the queue when the process is done. You can then have mulitiple threads running in parallel to manage multiple queues.\nI'm not sure what you want an ack for? Are you trying to stop RabbitMQ from adding new elements to that queue if it gets too full (because its elements are being processed too slowly\/not at all)? There might be a way to do this when you add messages to the queues - before adding an item, check to make sure that the number of messages already in that queue is not \"much greater than\" the average across all queues?","Q_Score":1,"Tags":"python,rabbitmq,amqp,pika","A_Id":38833846,"CreationDate":"2016-08-08T15:36:00.000","Title":"RabbitMQ: Consuming only one message at a time from multiple queues","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am learning robot and creating a testframework. I want to give people an easy way to add more tests.\nIs it possible to dynamically create tests based on arguments passed in argument file? \nI have all my tests in a .rst file and right now users have to populate the test table , but I want to make it simpler so other people actually use the framework.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":71,"Q_Id":38836411,"Users Score":1,"Answer":"No, it is not possible to dynamically create tests via an argument file.\nIt is, however, possible to write a script that reads a data file and generates a suite of tests before running pybot.","Q_Score":0,"Tags":"python,robotframework","A_Id":38837243,"CreationDate":"2016-08-08T18:46:00.000","Title":"RobotFramework adding tests through argument file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am beginner to python and programming in general. As I am learning python, I am tying to develop a good habit or follow a good practice. So let me first explain what I am currently doing.\nI use Emacs (prelude) to execute python scripts. The keybinding C-c C-c evaluates the buffer which contains the python script. Then I get a new buffer with a python interpreter with >>> prompt. In this environment all the variables used in the scripts are accessible. For example, if x and y were defined in the script, I can do >>> x + y to evaluate it. \nI see many people (if not most) around me using command line to execute the python script (i.e., $ python scriptname.py). If I do this, then I return to the shell prompt, and I am not able to access the variables x and y to perform x + y. So I wasn't sure what the advantage of running python scripts using the command line. \nShould I just use Emacs as a editor and use Terminal (I am using Mac) to execute the script? What is a better practice?\nThank you!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1721,"Q_Id":38839215,"Users Score":0,"Answer":"People use different tools for different purposes. \nAn important question about the interface into any program is who is the user? You, as a programmer, will use the interpreter to test a program and check for errors. Often times, the user doesn't really need to access the variables inside because they are not interacting with the application\/script with an interpreter. For example, with Python web applications, there is usually a main.py script to redirect client HTTP requests to appropriate handlers. These handlers execute a python script automatically when a client requests it. That output is then displayed to the user. In Python web applications, unless you are the developer trying to eliminate a bug in the program, you usually don't care about accessing variables within a file like main.py (in fact, giving the client access to those variables would pose a security issue in some cases). Since you only need the output of a script, you'd execute that script function in command line and display the result to the client.\nAbout best practices: again, depends on what you are doing.\nUsing the python interpreter for computation is okay for smaller testing of isolated functions but it doesn't work for larger projects where there are more moving parts in a python script. If you have a python script reaching a few hundred lines, you won't really remember or need to remember variable names. In that case, it's better to execute the script in command-line, since you don't need access to the internal components. \nYou want to create a new script file if you are fashioning that script for a single set of tasks. For example with the handlers example above, the functions in main.py are all geared towards handling HTTP requests. For something like defining x, defining y, and then adding it, you don't really need your own file since you aren't creating a function that you might need in the future and adding two numbers is a built-in method. However, say you have a bunch of functions you've created that aren't available in a built-in method (complicated example: softmax function to reduce K dimension vector to another K dimension vector where every element is a value between 0 and 1 and all the elements sum to 1), you want to capture in a script file and cite that script's procedure later. In that case, you'd create your own script file and cite it in a different python script to execute.","Q_Score":0,"Tags":"python,command-line,emacs","A_Id":38909330,"CreationDate":"2016-08-08T22:04:00.000","Title":"What is the advantage of running python script using command line?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a Raspberry PI collecting data from a break beam sensor I wish to use as part of an already developed Laravel application. I was just wondering what would the best way to transfer the data be.\nI was thinking of creating an JSON file uploading it to a directory then running a cron job hourly to pick up on new files before running them through the Laravel controller to update the database and send emails.\nI would like to pass the data through the Laravel application rather than sending from Python for management purposes. Could anyone see any issues with my way\/ know a better way?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":93,"Q_Id":38839269,"Users Score":1,"Answer":"Use python to extract data from the serial ports of rasberry pi and json encode it and store it in the web directory of your laravel project files. Later json decode and present the data on the web end via laravel php. This is all good . Beind said that another way is to get data from python and then make a curl Post request to your php project and collect data","Q_Score":1,"Tags":"php,python,json,laravel","A_Id":38839396,"CreationDate":"2016-08-08T22:10:00.000","Title":"What is the best way to send Python generated data to PHP?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Raspberry PI collecting data from a break beam sensor I wish to use as part of an already developed Laravel application. I was just wondering what would the best way to transfer the data be.\nI was thinking of creating an JSON file uploading it to a directory then running a cron job hourly to pick up on new files before running them through the Laravel controller to update the database and send emails.\nI would like to pass the data through the Laravel application rather than sending from Python for management purposes. Could anyone see any issues with my way\/ know a better way?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":93,"Q_Id":38839269,"Users Score":2,"Answer":"Your approach sounds fine - the only caveat would be that you will not have \"real time\" data. You rely on the schedule of your cron jobs to sync the data around - of course you could do this every minute if you wanted to, which would minimize most of the effect of that delay.\nThe other option is to expose an API in your Laravel application which can accept the JSON payload from your python script and process it immediately. This approach offers the benefits of real-time processing and less processing overall because it's on demand, but also requires you to properly secure your API endpoint which you wouldn't need to do with a cron based approach.\nFor the record, I highly recommend using JSON as the data transfer format. Unless you need to implement schema validation (in which case possibly look as XML), using JSON is easy on both PHP and python's side.","Q_Score":1,"Tags":"php,python,json,laravel","A_Id":38839403,"CreationDate":"2016-08-08T22:10:00.000","Title":"What is the best way to send Python generated data to PHP?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am building a mobile app and would like to follow best practice for datetime. Initially, we launched it in India and made our server, database and app time to IST.\nNow we are launching the app to other countries(timezones), how should I store the datetime? Should the server time be set to UTC and app should display time-based on user's timezone?\nWhat's the best practice to follow in terms of storing date time and exchanging date time format between client and server? Should the client send date time in UTC to the server or in it's own timezone along with locale?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":224,"Q_Id":38842666,"Users Score":1,"Answer":"Keep as much in UTC as possible. Do your timezone conversion at your edges (client display and input processing), but keep anything stored server side in UTC.","Q_Score":1,"Tags":"python,postgresql,internationalization,datetime-format,datetimeoffset","A_Id":38843085,"CreationDate":"2016-08-09T05:23:00.000","Title":"Internationalization for datetime","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"So I have this Python pyramid-based application, and my development workflow has basically just been to upload changed files directly to the production area.\nComing close to launch, and obviously that's not going to work anymore.\nI managed to edit the connection strings and development.ini and point the development instance to a secondary database.\nNow I just have to figure out how to create another copy of the project somewhere where I can work on things and then make the changes live.\nAt first, I thought that I could just make a copy of the project directory somewhere else and run it with different arguments pointing to the new location. That didn't work.\nThen, I basically set up an entirely new project called myproject-dev. I went through the setup instructions:\nI used pcreate, and then setup.py develop, and then I copied over my development.ini from my project and carefully edited the various references to myproject-dev instead of myproject.\nThen,\ninitialize_myproject-dev_db \/var\/www\/projects\/myproject\/development.ini\nFinally, I get a nice pyramid welcome page that everything is working correctly.\nI thought at that point I could just blow out everything in the project directory and copy over the main project files, but then I got that feeling in the pit of my stomach when I noticed that a lot of things weren't working, like static URLs.\nApparently, I'm referencing myproject in includes and also static URLs, and who knows where else.\nI don't think this idea is going to work, so I've given up for now.\nCan anyone give me an idea of how people go about setting up a development instance for a Python pyramid project?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":166,"Q_Id":38843404,"Users Score":1,"Answer":"Here's how I managed my last Pyramid app:\nI had both a development.ini and a production.ini. I actually had a development.local.ini in addition to the other two - one for local development, one for our \"test\" system, and one for production. I used git for version control, and had a main branch for production deployments. On my prod server I created the virtual environment, etc., then would pull my main branch and run using the production.ini config file. Updates basically involved jumping back into the virtualenv and pulling latest updates from the repo, then restarting the pyramid server.","Q_Score":2,"Tags":"python,pyramid,pylons","A_Id":38886655,"CreationDate":"2016-08-09T06:17:00.000","Title":"Trying to make a development instance for a Python pyramid project","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I wish to add more python modules to my yocto\/openembedded project but I am unsure how to? I wish to add flask and its dependencies.","AnswerCount":4,"Available Count":1,"Score":0.1488850336,"is_accepted":false,"ViewCount":20667,"Q_Id":38862088,"Users Score":3,"Answer":"The OE layer index at layers.openembedded.org lists all known layers and the recipes they contain, so searching that should bring up the meta-python layer that you can add to your build and use recipes from.","Q_Score":13,"Tags":"python,linux,yocto,bitbake,openembedded","A_Id":38865576,"CreationDate":"2016-08-09T23:38:00.000","Title":"How do I add more python modules to my yocto\/openembedded project?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to pytest and I have python2.6 installed on my setup.\nI installed pytest and the testcases get executed properly. I installed couple of plugins like pytest-timeout, putest-xdist etc but these plugins does not load when I run the cases. For timeout, I get following error: py.test: error: unrecognized arguments: --timeout\nSame steps followed with python2.7 works. \nAny idea how this can be solved or alteast steps to debug to know what exactly is causing the issue.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":128,"Q_Id":38866244,"Users Score":0,"Answer":"Unfortunately pytest < 3.0 \"hides\" the ImportError happening when failing to import a plugin. If you remove all plugin arguments but add -rw, you should be able to see what exactly is going wrong in the warning summary.","Q_Score":1,"Tags":"python,pytest,python-2.6","A_Id":38869743,"CreationDate":"2016-08-10T06:54:00.000","Title":"Does pytest plugins work with python2.6","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am making an android application in which I am first uploading the image to the server and on the server side, I want to execute a Python script from PHP. But I am not getting any output. When I access the Python script from the command prompt and run python TestCode.py it runs successfully and gives the desired output. I'm running Python script from PHP using the following command:\n$result = exec('\/usr\/bin\/python \/var\/www\/html\/Source\/TestCode.py');\necho $result\nHowever, if I run a simple Python program from PHP it works.\nPHP has the permissions to access and execute the file.\nIs there something which I am missing here?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":173,"Q_Id":38869507,"Users Score":1,"Answer":"First Check your python PATH using \"which python\" command and check result is \/usr\/bin\/python. \nCheck your \"TestCode.py\" if you have written #!\/usr\/bin\/sh than replace it with #!\/usr\/bin\/bash.\nThan run these commands \nexec('\/usr\/bin\/python \/var\/www\/html\/Source\/TestCode.py', $result);\necho $result","Q_Score":1,"Tags":"php,android,python,linux,exec","A_Id":38870240,"CreationDate":"2016-08-10T09:34:00.000","Title":"Execution of a Python Script from PHP","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm new to using programming vlc, I'm using python specifically python-vlc to play a internet radio station.\nI have it playing the station but can't get the current track that is playing.\nWhen I get the audio track info it returns Track 1 all the time.\nAnyways, I am looking for a way to get the song change event. It seems that it could be possible. Because vlc title bar shows the current playing song and windows pops up a notification of the new playing song.\nI would prefer to get the change event with the song so that I don't have to poll to check to see if the name change.\nAny help would be appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":398,"Q_Id":38877514,"Users Score":2,"Answer":"In an MPEG stream, there is no such thing as \"songs\". It's just an audio stream. Some radio stations do change metadata in between, so you might be able to check whether the stream title changes or something. But that's purely heuristic.\nI guess the notification you see is also triggered by the metadata change.","Q_Score":0,"Tags":"python,vlc,libvlc","A_Id":38877998,"CreationDate":"2016-08-10T15:19:00.000","Title":"VideoLan song change event for radio stream","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to be able to schedule an e-mail or more of them to be sent on a specific date, preferably using GAE Mail API if possible (so far I haven't found the solution). \nWould using Cron be an acceptable workaround and if so, would I even be able to create a Cron task with Python? The dates are various with no specific pattern so I can't use the same task over and over again.\nAny suggestions how to solve this problem? All help appreciated","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":197,"Q_Id":38880555,"Users Score":2,"Answer":"You can easily accomplish what you need with Task API. When you create a task, you can set an ETA parameter (when to execute). ETA time can be up to 30 days into the future.\nIf 30 days is not enough, you can store a \"send_email\" entity in the Datastore, and set one of the properties to the date\/time when this email should be sent. Then you create a cron job that runs once a month (week). This cron job will retrieve all \"send_email\" entities that need to be send the next month (week), and create tasks for them, setting ETA to the exact date\/time when they should be executed.","Q_Score":0,"Tags":"python,email,google-app-engine,cron","A_Id":38884139,"CreationDate":"2016-08-10T18:04:00.000","Title":"Is there a way to schedule sending an e-mail through Google App Engine Mail API (Python)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I'm starting with ASK development. I'm a little confused by some behavior and I would like to know how to debug errors from the \"service simulator\" console. How can I get more information on the The remote endpoint could not be called, or the response it returned was invalid. errors?\nHere's my situation:\nI have a skill and three Lambda functions (ARN:A, ARN:B, ARN:C). If I set the skill's endpoint to ARN:A and try to test it from the skill's service simulator, I get an error response: The remote endpoint could not be called, or the response it returned was invalid.\nI copy the lambda request, I head to the lambda console for ARN:A, I set the test even, paste the request from the service simulator, I test it and I get a perfectly fine ASK response. Then I head to the lambda console for ARN:B and I make a dummy handler that returns exactly the same response that ARN:A gave me from the console (literally copy and paste). I set my skill's endpoint to ARN:B, test it using the service simulator and I get the anticipated response (therefore, the response is well formatted) albeit static. I head to the lambda console again and copy and paste the code from ARN:A into a new ARN:C. Set the skill's endpoint to ARN:C and it works perfectly fine. Problem with ARN:C is that it doesn't have the proper permissions to persist data into DynamoDB (I'm still getting familiar with the system, not sure wether I can share an IAM role between different lambdas, I believe not).\nHow can I figure out what's going on with ARN:A? Is that logged somewhere? I can't find any entry in cloudwatch\/logs related to this particular lambda or for the skill.\nNot sure if relevant, I'm using python for my lambda runtime, the code is (for now) inline on the web editor and I'm using boto3 for persisting to DynamoDB.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":3387,"Q_Id":38887061,"Users Score":0,"Answer":"My guess would be that you missed a step on setup. There's one where you have to set the \"event source\". IF you don't do that, I think you get that message.\nBut the debug options are limited. I wrote EchoSim (the original one on GitHub) before the service simulator was written and, although it is a bit out of date, it does a better job of giving diagnostics.\nLacking debug options, the best is to do what you've done. Partition and re-test. Do static replies until you can work out where the problem is.","Q_Score":2,"Tags":"python,amazon-web-services,amazon-dynamodb,aws-lambda,alexa-skills-kit","A_Id":38895935,"CreationDate":"2016-08-11T04:02:00.000","Title":"Troubleshooting Amazon's Alexa Skill Kit (ASK) Lambda interaction","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm starting with ASK development. I'm a little confused by some behavior and I would like to know how to debug errors from the \"service simulator\" console. How can I get more information on the The remote endpoint could not be called, or the response it returned was invalid. errors?\nHere's my situation:\nI have a skill and three Lambda functions (ARN:A, ARN:B, ARN:C). If I set the skill's endpoint to ARN:A and try to test it from the skill's service simulator, I get an error response: The remote endpoint could not be called, or the response it returned was invalid.\nI copy the lambda request, I head to the lambda console for ARN:A, I set the test even, paste the request from the service simulator, I test it and I get a perfectly fine ASK response. Then I head to the lambda console for ARN:B and I make a dummy handler that returns exactly the same response that ARN:A gave me from the console (literally copy and paste). I set my skill's endpoint to ARN:B, test it using the service simulator and I get the anticipated response (therefore, the response is well formatted) albeit static. I head to the lambda console again and copy and paste the code from ARN:A into a new ARN:C. Set the skill's endpoint to ARN:C and it works perfectly fine. Problem with ARN:C is that it doesn't have the proper permissions to persist data into DynamoDB (I'm still getting familiar with the system, not sure wether I can share an IAM role between different lambdas, I believe not).\nHow can I figure out what's going on with ARN:A? Is that logged somewhere? I can't find any entry in cloudwatch\/logs related to this particular lambda or for the skill.\nNot sure if relevant, I'm using python for my lambda runtime, the code is (for now) inline on the web editor and I'm using boto3 for persisting to DynamoDB.","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":3387,"Q_Id":38887061,"Users Score":3,"Answer":"tl;dr: The remote endpoint could not be called, or the response it returned was invalid. also means there may have been a timeout waiting for the endpoint. \nI was able to narrow it down to a timeout. \nSeems like the Alexa service simulator (and the Alexa itself) is less tolerant to long responses than the lambda testing console. During development I had increased the timeout of ARN:1 to 30 seconds (whereas I believe the default is 3 seconds). The DynamoDB table used by ARN:1 has more data and it takes slightly longer to process than ARN:3 which has an almost empty table. As soon as I commented out some of the data loading stuff it was running slightly faster and the Alexa service simulator was working again. I can't find the time budget documented anywhere, I'm guessing 3 seconds? I most likely need to move to another backend, DynamoDB+Python on lambda is too slow for very trivial requests.","Q_Score":2,"Tags":"python,amazon-web-services,amazon-dynamodb,aws-lambda,alexa-skills-kit","A_Id":38902127,"CreationDate":"2016-08-11T04:02:00.000","Title":"Troubleshooting Amazon's Alexa Skill Kit (ASK) Lambda interaction","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm starting with ASK development. I'm a little confused by some behavior and I would like to know how to debug errors from the \"service simulator\" console. How can I get more information on the The remote endpoint could not be called, or the response it returned was invalid. errors?\nHere's my situation:\nI have a skill and three Lambda functions (ARN:A, ARN:B, ARN:C). If I set the skill's endpoint to ARN:A and try to test it from the skill's service simulator, I get an error response: The remote endpoint could not be called, or the response it returned was invalid.\nI copy the lambda request, I head to the lambda console for ARN:A, I set the test even, paste the request from the service simulator, I test it and I get a perfectly fine ASK response. Then I head to the lambda console for ARN:B and I make a dummy handler that returns exactly the same response that ARN:A gave me from the console (literally copy and paste). I set my skill's endpoint to ARN:B, test it using the service simulator and I get the anticipated response (therefore, the response is well formatted) albeit static. I head to the lambda console again and copy and paste the code from ARN:A into a new ARN:C. Set the skill's endpoint to ARN:C and it works perfectly fine. Problem with ARN:C is that it doesn't have the proper permissions to persist data into DynamoDB (I'm still getting familiar with the system, not sure wether I can share an IAM role between different lambdas, I believe not).\nHow can I figure out what's going on with ARN:A? Is that logged somewhere? I can't find any entry in cloudwatch\/logs related to this particular lambda or for the skill.\nNot sure if relevant, I'm using python for my lambda runtime, the code is (for now) inline on the web editor and I'm using boto3 for persisting to DynamoDB.","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":3387,"Q_Id":38887061,"Users Score":1,"Answer":"I think the problem you having for ARN:1 is you probably didn't set a trigger to alexa skill in your lambda function.\nOr it can be the alexa session timeout which is by default set to 8 seconds.","Q_Score":2,"Tags":"python,amazon-web-services,amazon-dynamodb,aws-lambda,alexa-skills-kit","A_Id":39245816,"CreationDate":"2016-08-11T04:02:00.000","Title":"Troubleshooting Amazon's Alexa Skill Kit (ASK) Lambda interaction","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to run a python script from bamboo. I created a script task and wrote inline \"python myFile.py\". Should I be listing the full path for python? \nI changed the working directory to the location of myFile.py so that is not a problem. Is there anything else I need to do within the configuration plan to properly run this script? It isn't running but I know it should be running because the script works fine from terminal on my local machine. Thanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5082,"Q_Id":38906844,"Users Score":0,"Answer":"I run a lot of python tasks from bamboo, so it is possible. Using the Script task is generally painless...\nYou should be able to use your script task to run the commands directly and have stdout written to the logs. Since this is true, you can run: \n'which python' -- Output the path of which python that is being ran.\n'pip list' -- Output a list of which modules are installed with pip.\nYou should verify that the output from the above commands matches the output when ran from the server. I'm guessing they won't match up and once that is addressed, everything will work fine.\nIf not, comment back and we can look at a few other things.\nFor the future, there are a handful of different ways you can package things with python which could assist with this problem (e.g. automatically installing missing modules, etc).","Q_Score":2,"Tags":"python,python-2.7,bamboo","A_Id":40619044,"CreationDate":"2016-08-11T22:06:00.000","Title":"Run a python script from bamboo","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a sensor value which can be read using the C++ only because it was implemented using it , I want to pass location value (two float variable) of one sensor to Python. I have been reading a lot and I found shared memory , piping and more any idea what is the best way to do it ?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3054,"Q_Id":38944172,"Users Score":0,"Answer":"I'm not familiar with python however, a simple approach is to use some communication protocols such as serial ports or udp which is a network protocol. For real-time applications, UDP protocol is a preferable choice.","Q_Score":3,"Tags":"python,c++,subprocess,piping","A_Id":38959725,"CreationDate":"2016-08-14T16:23:00.000","Title":"How to pass variable value from C++ to Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to monitor jboss if its running or not through Icinga.\nI don't want to check \/etc\/inid.d\/jboss status as sometimes service is up but some of the jboss is killed or hang & jboss doesn't work properly.\nI would like to create a script to monitor all of its process from ps output. But few servers are running in standalone mode, domain(master,slave) and processes are different for each case.\nI'm not sure from where do I start. Anyone here who did same earlier? Just looking for the idea to do this.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1024,"Q_Id":38945299,"Users Score":0,"Answer":"I did this by monitored jboss process using ps aux | grep \"\\-D\\[Standalone\\]\" for standalone mode and ps aux | grep \"\\-D\\[Server\" for domain mode.","Q_Score":0,"Tags":"python,shell,jboss,nagios,icinga","A_Id":39367798,"CreationDate":"2016-08-14T18:26:00.000","Title":"monitoring jboss process with icinga\/nagios","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am creating a Windows program that so far has a .bat file calling a .pyw file, and I need functions from Java and C++. How can I do this?(I don't mind creating a new batch or python file, and I already have the header file for the C++ section and a .jar file for my java components. (For Java I use Eclipse Java Mars, and it's Java 8u101)) Thanks!!!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":455,"Q_Id":38968007,"Users Score":1,"Answer":"You can load C++ function and execute it from Python like BasicWolf explained in his answer. For Java, Jython might be a good approach. But then there's a problem - you will need to be dependent on Jython which is not up to date with the latest versions of Python. You will face compatibility issues with different libraries too. \nI would recommend compiling your C++ and Java functions to create individual binaries out of them. Then execute these binaries from within Python, passing the arguments as command line parameters. This way you can keep using CPython. You can interoperate with programs written in any language.","Q_Score":2,"Tags":"java,python,c++,python-2.7,batch-file","A_Id":38968156,"CreationDate":"2016-08-16T06:30:00.000","Title":"How do you call C++ and\\or Java functions from Python 2.7?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a problem that I am trying to conceptualize whether possible or not. Nothing too fancy (i.e. remote login or anything etc.)\nI have Website A and Website B. \nOn website A a user selects on a few links from website B, i would like to then remotely click on behalf of the user on the link (as Website B creates a cookie with the clicked information) so when the user gets redirected to Website B, the cookie (and the links) are pre-selected and the user does not need to click on them one by one.\nCan this be done?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":38,"Q_Id":38979170,"Users Score":0,"Answer":"IF you want to interact to anorher webservice the resolution is send post\/get request and parse response\nQuestion is what is your goal?","Q_Score":0,"Tags":"javascript,jquery,python,cookies","A_Id":38979448,"CreationDate":"2016-08-16T15:42:00.000","Title":"How to remote click on links from a 3rd party website","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"(centos6.6) before updating python2.7.3 ,it is python 2.6.6. When running pybot --version, errors came out as follows.\nI want to install the test environment of python 2.7.3 and robot framework 2.7.6 and paramiko-1.7.4 and pycrypto-2.6\n\n[root@localhost robotframework-2.7.6]# pybot --version\n Traceback (most recent call last):\n File \"\/usr\/bin\/pybot\", line 4, in \n from robot import run_cli\n File \"\/usr\/lib\/python2.7\/site-packages\/robot\/__init__.py\", line 22, in \n from robot.rebot import rebot, rebot_cli\n File \"\/usr\/lib\/python2.7\/site-packages\/robot\/rebot.py\", line 268, in \n from robot.conf import RebotSettings\n File \"\/usr\/lib\/python2.7\/site-packages\/robot\/conf\/__init__.py\", line 17, in \n from .settings import RobotSettings, RebotSettings\n File \"\/usr\/lib\/python2.7\/site-packages\/robot\/conf\/settings.py\", line 17, in \n from robot import utils\n File \"\/usr\/lib\/python2.7\/site-packages\/robot\/utils\/__init__.py\", line 23, in \n from .compress import compress_text\n File \"\/usr\/lib\/python2.7\/site-packages\/robot\/utils\/compress.py\", line 25, in \n import zlib\n ImportError: No module named zlib","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":127,"Q_Id":39014670,"Users Score":0,"Answer":"I installed the zlib-devel and python-level with the help of yum, and recompiled the python, finally completed the test of installation. Thank you for your answer.","Q_Score":0,"Tags":"python,linux,robotframework","A_Id":39104313,"CreationDate":"2016-08-18T09:33:00.000","Title":"(centos6.6) before updating python2.7.3 ,it is python 2.6.6. When running pybot --version,errors came out","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"(centos6.6) before updating python2.7.3 ,it is python 2.6.6. When running pybot --version, errors came out as follows.\nI want to install the test environment of python 2.7.3 and robot framework 2.7.6 and paramiko-1.7.4 and pycrypto-2.6\n\n[root@localhost robotframework-2.7.6]# pybot --version\n Traceback (most recent call last):\n File \"\/usr\/bin\/pybot\", line 4, in \n from robot import run_cli\n File \"\/usr\/lib\/python2.7\/site-packages\/robot\/__init__.py\", line 22, in \n from robot.rebot import rebot, rebot_cli\n File \"\/usr\/lib\/python2.7\/site-packages\/robot\/rebot.py\", line 268, in \n from robot.conf import RebotSettings\n File \"\/usr\/lib\/python2.7\/site-packages\/robot\/conf\/__init__.py\", line 17, in \n from .settings import RobotSettings, RebotSettings\n File \"\/usr\/lib\/python2.7\/site-packages\/robot\/conf\/settings.py\", line 17, in \n from robot import utils\n File \"\/usr\/lib\/python2.7\/site-packages\/robot\/utils\/__init__.py\", line 23, in \n from .compress import compress_text\n File \"\/usr\/lib\/python2.7\/site-packages\/robot\/utils\/compress.py\", line 25, in \n import zlib\n ImportError: No module named zlib","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":127,"Q_Id":39014670,"Users Score":0,"Answer":"Reasons could be any of the following:\n\nEither the python files (at least one) have lost the formatting. Python is prone to formatting errors\nAt least one installation (python, Robo) doesn't have administrative privileges.\nEnvironment variables (PATH, CLASSPATH, PYTHON PATH) are not set fine.\nWhat does python --version print? If this throws errors, installation has issues.","Q_Score":0,"Tags":"python,linux,robotframework","A_Id":39037542,"CreationDate":"2016-08-18T09:33:00.000","Title":"(centos6.6) before updating python2.7.3 ,it is python 2.6.6. When running pybot --version,errors came out","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'd like to understand the sequence of events when sending a method to the telegram server.\nFor example, if I send the get_future_salts method I am expecting from the server a response of type FutureSalts, but what I receive is a type of MessageContainer (which I'm having trouble parsing, but that is a separate issue).\nIf I ignore the MessageContainer object and simply request the next response from the server I receive the expected FutureSalts object.\nWill there always be a MessageContainer object returned for each method called? If so, do I need to parse and process these MessageContainer objects?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":87,"Q_Id":39021814,"Users Score":1,"Answer":"No, not always. \nThe server however usually packs multiple messages into containers. \nI would advise that you decode all the data returned from the server. \nYou then have a full view \/log of all that is being returned, then you can decide on what needs to be replied to.","Q_Score":1,"Tags":"python,api,telegram","A_Id":39022320,"CreationDate":"2016-08-18T15:14:00.000","Title":"Client\/Server interactions using the Telegram.org API","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way to have nosetests restrict the coverage information to only the tests that were run?\nI know about the cover-package flag, but it would be nicer if you didn't have to specify the package.\nThis would be especially useful when running a a single unit test class that lives in a file with multiple unit test classes.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":155,"Q_Id":39022185,"Users Score":0,"Answer":"Unfortunately I do not know of a way in nosetests to perform this action. I actually ended up uninstalling nosetests and using just coverage.py because it seems like nosetests and coverage don't play nicely together. I know for a fact you can specify down to individual test methods what you want to run. I'm not sure if that's exactly what you are looking for but I beat my head against a brick wall for days trying to get nosetests to cooperate with no luck. Maybe it would save some effort to switch and run coverage.py directly instead?","Q_Score":1,"Tags":"python,testing,code-coverage,nose","A_Id":39025314,"CreationDate":"2016-08-18T15:32:00.000","Title":"Restrict nosetests coverage to only the tests that were run","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm thinking of something like\npython3 my_script.py --pythonpath \/path\/to\/some\/necessary\/modules\nIs there something like this? I know (I think) that Pycharm temporarily modifies PYTHONPATH when you use it to execute scripts; how does Pycharm do it?\nReasons I want to do this (you don't really need to read the following)\nThe reason I want to do this is that I have some code that usually needs to run on my own machine (which is fine because I use Pycharm to run it) but sometimes needs to run on a remote server (on the commandline), and it doesn't work because the remote server doesn't have the PYTHONPATHs that Pycharm automatically temporarily adds. I don't want to export PYTHONPATH=[...] because it's a big hassle to change it often (and suppose it really does need to change often).","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3666,"Q_Id":39022629,"Users Score":0,"Answer":"Not sure how much effort you want to put into this temporary python path thing but you could always use a python virtual environment for running scripts or whatever you need.","Q_Score":8,"Tags":"python,pycharm,pythonpath","A_Id":39022921,"CreationDate":"2016-08-18T15:53:00.000","Title":"Provide temporary PYTHONPATH on the commandline?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Hadoop Cluster running on Centos 7. I am running a program (sitting on HDFS) to extract tweets and I need to import tweepy for that. I did pip install tweepy as root on all the nodes of the cluster but i still get an import error when I run the program. \nError says: ImportError: No module named tweepy\n\nI am sure Tweepy is installed because, pip freeze | grep \"tweepy\" returns tweepy==3.5.0. \nI created another file x.py with just one line import tweepy in the \/tmp folder and that runs without an error. Error occurs only on HDFS.\nAlso, my default python is Python 2.7.12 which I installed using Anaconda. Can someone help me with this issue? The same code is running without any such errors on another cluster running on Centos 6.6. Is it an OS issue? Or do I have to look into the Cluster?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":192,"Q_Id":39045825,"Users Score":0,"Answer":"It looks like you're using Anaconda's Python to run your script, but you installed tweepy into CentOS's system installation of Python using pip. Either use conda to install tweepy, or use Anaconda's pip executable to install tweepy onto your Hadoop cluster.","Q_Score":0,"Tags":"python-2.7,hadoop,hdfs,tweepy,centos7","A_Id":39046078,"CreationDate":"2016-08-19T18:42:00.000","Title":"Tweepy import Error on HDFS running on Centos 7","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using the Python AWS API. I would like to invoke a lambda function from client code, but I have not been able to find documentation on whether the payload sent during invocation is encrypted. \nCan someone watching the network potentially snoop on the AWS invocation payload? Or is the payload transmitted over a secure channel?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":943,"Q_Id":39057569,"Users Score":0,"Answer":"If you turn on the debug logging you should see how exactly is data transmitted. Or try netstat or Wireshark to see if it makes connection to port 443 rather than 80.\nFrom my experience with boto3 and S3 (not Lambda) it uses HTTPS, which I would consider somewhat secure. I hope the certificates are verified...","Q_Score":1,"Tags":"python,amazon-web-services,encryption,aws-lambda,boto3","A_Id":39058104,"CreationDate":"2016-08-20T18:43:00.000","Title":"Does Boto3 encrypt the payload during transmission when invoking a lambda function?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a scrip 'xyz.py' that I'm importing as a module for another script (Main.py). Everything in xyz.py is inside of a class that I call in Main.py. Both, xyz.py and Main.py share the same import statements: \"xml.etree.ElementTree\"; \"Tkinter\"; \"cv2\"; \"tkFileDialog\"; \"tkfd\"; \"from PIL import Image\"; \"ImageTk\"; \"os\"\nI noticed that when I run in Main.py the class having all the methods and statements of xyz.py, they run faster as a module than as the main script.\nIs there a general fact behind this observation that I could use to speed up other stuff? Thank you.\nPS: I didn't provide the code because it sums up to >400 lines, and I don't know exactly what I'm supposed to be looking at, so I'm not able to take a small and relevant sample.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":50,"Q_Id":39060596,"Users Score":0,"Answer":"When a python program runs, the main script is always passed through the interpreter. When a module is imported, however, python checks its cache ( subdirectory named __pycache__) where it stores modules that have previously been compiled to bytecode. If the date of the cached copy matches the date of the source code date, it uses the cached version. That probably accounts for what you are seeing.","Q_Score":0,"Tags":"python,performance,import,module","A_Id":39060635,"CreationDate":"2016-08-21T03:26:00.000","Title":"why does a script run faster as a module?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have two related graphs created in iGraph, A and G. I find community in structure in G using either infomap or label_propagation methods (because they are two that allow for weighted, directional links). From this, I can see the modularity of this community for the G graph. However, I need to see what modularity this will provide for the A graph. How can I do this?","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":366,"Q_Id":39085646,"Users Score":-1,"Answer":"So I figured it out. What you need to do is find a community structure, either pre-defined or using one of the methods provided for community detection, such as infomap or label_propagation. This gives you a vertex clustering, which you can use to place on another graph and from that use .q to find the modularity.","Q_Score":0,"Tags":"python,graph,igraph","A_Id":39735109,"CreationDate":"2016-08-22T17:43:00.000","Title":"Find overlapping modularity in two graphs - iGraph in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Maybe this is a silly question, I just set up free Amazon Linux instance according to the tutorial, what I want to do is simply running python scripts.\nThen I googled AWS and Python, Amazon mentioned Boto.\nI don't know why using Boto. Because if I type python, it already installed.\nWhat I want to do is run a script on day time. \nIs there a need for me to reading about Boto or just run xx.py on AWS ?\nAny help is appreciated.","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":561,"Q_Id":39086388,"Users Score":2,"Answer":"Boto is a Python wrapper for AWS APIs. If you want to interact with AWS using its published APIs, you need boto\/boto3 library installed. Boto will not be supported for long. So if you are starting to use Boto, use Boto3 which is much simpler than Boto.\nBoto3 supports (almost) all AWS services.","Q_Score":1,"Tags":"python,amazon-web-services,boto3,boto","A_Id":39086478,"CreationDate":"2016-08-22T18:30:00.000","Title":"Running Python scripts on Amazon Web Services? Do I need to use Boto?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Maybe this is a silly question, I just set up free Amazon Linux instance according to the tutorial, what I want to do is simply running python scripts.\nThen I googled AWS and Python, Amazon mentioned Boto.\nI don't know why using Boto. Because if I type python, it already installed.\nWhat I want to do is run a script on day time. \nIs there a need for me to reading about Boto or just run xx.py on AWS ?\nAny help is appreciated.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":561,"Q_Id":39086388,"Users Score":3,"Answer":"Boto is a python interface to Amazon Services (like copying to S3, etc).\nYou don't need it to just run regular python as you would on any linux instance with python installed, except to access AWS services from your EC2 instance.","Q_Score":1,"Tags":"python,amazon-web-services,boto3,boto","A_Id":39086443,"CreationDate":"2016-08-22T18:30:00.000","Title":"Running Python scripts on Amazon Web Services? Do I need to use Boto?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to test a view in my Django application. So I open the python shell by typing python and then I type from django.test.utils import setup_test_environment. It seems to work fine. Then I type setup_test_environment() and it says \n\ndjango.core.exceptions.ImproperlyConfigured: Requested setting\n EMAIL_BACKEND, but settings are not configured. You must either define\n the environment variable DJANGO_SETTINGS_MODULE or call\n settings.configure() before accessing settings.\n\nI don't need to send mails in my test, so why does Django wants me to configure an email back-end ?\nAre we forced to configure an email back-end for any test even if it doesn't need it ?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":969,"Q_Id":39086434,"Users Score":1,"Answer":"You don't need to define the EMAIL_BACKEND setting (it has a default), but you do need to define a setting module. You can set the DJANGO_SETTINGS_MODULE in your shell environment, or set os.environ['DJANGO_SETTINGS_MODULE'] to point to your settings module.\nNote that calling python manage.py shell will set up the Django environment for you, which includes setting DJANGO_SETTINGS_MODULE and calling django.setup(). You still need to call setup_test_environment() to manually run tests in your python shell.","Q_Score":0,"Tags":"python,django,email,testing","A_Id":39087027,"CreationDate":"2016-08-22T18:33:00.000","Title":"django testing without email backend","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I need to install an existing pydev project into Eclipse on a new machine. (Actually it is the same machine, but re-imaged.) The new machine has Eclipse Neon. I was using an older version previously.\nMy data has all been copied over. I have the folder where the project lived on my old machine, which includes the .project and .pydevproject files. I used the Import wizard to import it, but I don't see my run configurations, pythonpath, etc.\nWhere might those be stored on my old machine, and can I recover them easily without setting them up again by hand?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":35,"Q_Id":39087037,"Users Score":0,"Answer":"I figured out that I was opening Eclipse in the wrong workspace. When I found the correct workspace for that project (by looking for the .metadata file on my C drive) everything was all set (and I didn't have to import the project at all).\nI was going to delete the question, but figured instead I'd answer in case this helps someone else.","Q_Score":0,"Tags":"eclipse,python-3.x,pydev","A_Id":39088428,"CreationDate":"2016-08-22T19:09:00.000","Title":"Import Pydev Project into Eclipse on a new machine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm current developing an event-driven backtesting engine in Python. I would like to have an idea about how fast a high speed backtesting engine should be, especially in Python. Right now, I can replay one year of 1 min bar data about 10 hours.Is it fair to say the speed now is acceptable? \nI know there are some open source backtesting engine on Github, like Pipline. I don't really know whether it is event-driven , because I did not play around with it before. \nAnyone has a good idea of how fast a good quality event driven backtesting engine should be ? Thank you so much for your help.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":818,"Q_Id":39127477,"Users Score":1,"Answer":"That's terribly slow. I run backtest on 350k+ min bars, including multiple signal generations, portfolio optimization, rebalancing, and execution priority algorithm, in around 40 mins. Pure python, no pandas, jit, or cython.\nIMO, it will depend a lot on the level of sophistication and complexity on the many of your moving parts.","Q_Score":3,"Tags":"python,finance,back-testing","A_Id":49956148,"CreationDate":"2016-08-24T15:31:00.000","Title":"Event Driven Backtesting Engine Speed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm looking for a way to block message delivery for a moment and reactivate it without loosing the messages.\nThe case is when we need to migrate consumers, I don't want messsages to be delivered for like 10 minutes. I want to block queue delivery and then reactivate it.\nIs there a way to do this? In Python or in PHP?\nEDIT:\nWith this process I don't want to get consumers disconnected. I want it like putting the queue on hold, no message delivered to current consumers and then \"reactivate it\".","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":167,"Q_Id":39140566,"Users Score":0,"Answer":"Though you already might have solved the problem:\nYou could use 2 Queues instead of one.\nproduce -> Q1 -> Direct Exchange -> Q2 -> consume\nThen you can dynamically delete the binding (API call \"unbind\") between the Exchange and the Q2. Then Q2 drains empty and Msg queue in Q1 until you bind it again after your maintenance.\nI wish there was something like \"Pause Queue for x-Minutes\" to implement a simple retry mechanism.","Q_Score":1,"Tags":"php,python,rabbitmq","A_Id":64604740,"CreationDate":"2016-08-25T08:43:00.000","Title":"Block Queue delivery on RabbitMQ","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have this huge Excel (xls) file that I have to read data from. I tried using the xlrd library, but is pretty slow. I then found out that by converting the Excel file to CSV file manually and reading the CSV file is orders of magnitude faster.\nBut I cannot ask my client to save the xls as csv manually every time before importing the file. So I thought of converting the file on the fly, before reading it.\nHas anyone done any benchmarking as to which procedure is faster:\n\nOpen the Excel file with with the xlrd library and save it as CSV file, or\nOpen the Excel file with win32com library and save it as CSV file?\n\nI am asking because the slowest part is the opening of the file, so if I can get a performance boots from using win32com I would gladly try it.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":582,"Q_Id":39179880,"Users Score":1,"Answer":"if you need to read the file frequently, I think it is better to save it as CSV. Otherwise, just read it on the fly. \nfor performance issue, I think win32com outperforms. however, considering cross-platform compatibility, I think xlrd is better.\nwin32com is more powerful. With it, one can handle Excel in all ways (e.g. reading\/writing cells or ranges). \nHowever, if you are seeking a quick file conversion, I think pandas.read_excel also works.\nI am using another package xlwings. so I am also interested with a comparison among these packages. \nto my opinion,\nI would use pandas.read_excel to for quick file conversion.\nIf demanding more processing on Excel, I would choose win32com.","Q_Score":1,"Tags":"python,excel,csv,win32com","A_Id":39360812,"CreationDate":"2016-08-27T10:07:00.000","Title":"XLRD vs Win32 COM performance comparison","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The following code produces an error message in the Processing IDE:\nfrom pyfirmata import Arduino,util\n\"No module named pyfirmata\"\nI have no problem running the code directly in the python 2.7 interpreter.\nBut, I can't access the Processing API from the interpreter.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":177,"Q_Id":39215404,"Users Score":1,"Answer":"You'll have to place the library in question inside your sketch folder. Python Mode doesn't use your system python, and cannot see any of the modules installed there.","Q_Score":0,"Tags":"python,arduino,processing,firmata,pyprocessing","A_Id":40960308,"CreationDate":"2016-08-29T21:20:00.000","Title":"Can't access pyFirmata from Processing.py","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to retrieve internal attributes from openldap server. More specifically I need to retrieve entryUUID attribute of an object. In LDAP, objectGUID is being fetched from server but couldn't retrieve similar field from openldap.\nSCOPE_SUBTREE is being used to retrieve attributes.\nAnyone knows way out? Thanks in advance.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2194,"Q_Id":39221697,"Users Score":0,"Answer":"It's an operational attribute, so you have to request it explicitly, or include \"+\" in the attributes to be returned.\nHowever you should not be using this for your own purposes. It's none of your business. It can change across backup\/restore, for example.","Q_Score":0,"Tags":"python-2.7,ldap,openldap","A_Id":39302136,"CreationDate":"2016-08-30T07:47:00.000","Title":"Retrieve Internal attributes(entryUUID) from openldap server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am not expecting a code here, but rather to pick up on knowledge of the folks out there. \nI have a python code - which uses pyserial for serial communication with an Micro Controller Unit(MCU). My MCU is 128byte RAM and has internal memory. I use ser.write command to write to the MCU and MCU responds with data - I read it using ser.read command. \nThe question here is - It is working excellently until last week. Since yesterday - I am able to do the serial communication only in the morning of the day. After a while, when I read the data the MCU responds with\"NONE\" message. I read the data next day, it works fine. Strange thing is - I have Hyperterminal installed and it properly communicates with the MCU and reads the data. So I was hoping if anyone have faced this problem before. \nI am using threads in my python program - Just to check if running the program mulitple times with threads is causing the problem. To my knowledge, threads should only effect the Memory of my PC and not the MCU. \nI rebooted my Computer and also the MCU and I still have this problem. \nNote: Pycharm is giving me the answers I mentioned in the question. If I do the same thing in IDLE - it is giving me completely different answers","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":252,"Q_Id":39235868,"Users Score":3,"Answer":"So, ultimately you're looking for advice on how to debug this sort of time dependent problem.\nSomehow, state is getting created somewhere in your computer, your python process, or the microcontroller that affects things. (It's also theoretically possible that an external environmental factor is affecting things. As an example, if your microcontroller has a realtime clock, you could actually have a time-of-day dependent bug. That seems less likely than other possibilities).\nFirst, try restarting your python program. If that fixes things, then you know some state is created inside python or your program that causes the problem.\nUpdate your question with this information.\nIf that doesn't fix it, try rebooting your computer. If that fixes things, then you strongly suspect some state in your computer is affecting things.\nIf none of that works, try rebooting the micro controller. If rebooting both the PC and the micro controller doesn't fix things, include that in your question as it is very interesting data.\nExamples of state that can get created:\n\nflow control. The micro controller could be sending xoff, clearing clear-to-send or otherwise indicating it does not want data\nFlow control in the other direction: your PC could be sending xoff, clearing request-to-send or otherwise indicating that it doesn't want data\nYour program gets pyserial into a confused state--either because of a bug in your code or pyserial.\nSerial port configuration--the serial port settings could be getting messed up.\n\nHyper terminal could do various things to clear flow control state or reconfigure the serial port.\nIf restarting python doesn't fix the problem, threading is very unlikely to be your issue. If restarting python fixes the problem threading may be an issue.","Q_Score":2,"Tags":"python,multithreading,embedded,pyserial","A_Id":39236047,"CreationDate":"2016-08-30T19:42:00.000","Title":"Pyserial - Embedded Systems","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to use h5py which needs libhdf5-dev to be installed. I installed hdf5 from the source, and thought that any options with compiling that one would offer me the developer headers, but doesn't look like it.\nAnyone know how I can do this? Is there some other source i need to download? (I cant find any though)\nI am on amazon linux, yum search libhdf5-dev doesn't give me any result and I cant use rpm nor apt-get there, hence I wanted to compile it myself.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":20706,"Q_Id":39236025,"Users Score":0,"Answer":"For Centos 8, I got the below warning message :\n\nWarning: Couldn't find any HDF5 C++ libraries. Disabling HDF5 support.\n\nand I solved it using the command :\n\nsudo yum -y install hdf5-devel","Q_Score":6,"Tags":"python,linux,installation,hdf5","A_Id":67224754,"CreationDate":"2016-08-30T19:53:00.000","Title":"how to install libhdf5-dev? (without yum, rpm nor apt-get)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"How to read the status of the Power-LED (or the rainbow square - if you like that better) on Raspberry Pi 3 to detect an low-voltage-condition in a python script? Since the wiring of the Power-LED has changed since Raspberry Pi 2, it seems that GPIO 35 cannot longer be used for that purpose.\n\nUpdate:\nSince it seems to be non-trivial to detect a low-power-condition in code on Raspberry Pi 3, i solved it with a quick hardware hack. I soldered a wire between the Output of the APX803 (the power-monitoring device used on Pi 3) and GPIO26 and that way I can simply read GPIO26 to get the power status. Works like a charm.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":3791,"Q_Id":39251079,"Users Score":1,"Answer":"Because of Pi3's BT\/wifi support Power LED is controlled directly from the GPU through a GPIO expander. \nI believe that there's no way to do what you want","Q_Score":2,"Tags":"python,raspberry-pi3","A_Id":39251247,"CreationDate":"2016-08-31T13:31:00.000","Title":"How to read the status of the Power-LED on Raspberry Pi 3 with Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently learning building a SOAP web services with django and spyne. I have successfully tested my model using unit test. However, when I tried to test all those @rpc functions, I have no luck there at all.\nWhat I have tried in testing those @rpc functions:\n1. Get dummy data in model database\n2. Start a server at localhost:8000\n3. Create a suds.Client object that can communicate with localhost:8000\n4. Try to invoke @rpc functions from the suds.Client object, and test if the output matches what I expected.\nHowever, when I run the test, I believe the test got blocked by the running server at localhost:8000 thus no test code can be run while the server is running.\nI tried to make the server run on a different thread, but that messed up my test even more.\nI have searched as much as I could online and found no materials that can answer this question.\nTL;DR: how do you test @rpc functions using unit test?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":458,"Q_Id":39274850,"Users Score":1,"Answer":"I believe if you are using a service inside a test, that test should not be a unit test.\nyou might want to consider use factory_boy or mock, both of them are python modules to mock or fake a object, for instance, to fake a object to give a response to your rpc call.","Q_Score":1,"Tags":"python,django,testing,rpc,spyne","A_Id":39275854,"CreationDate":"2016-09-01T14:54:00.000","Title":"How to test RPC of SOAP web services?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"My team and I are designing a project which requires the detection of rising edge of a square wave and then storing the time using time.time() in a variable.If a same square wave is given to 3 different pins of RPi,and event detection is applied on each pin,theoretically,they should occur at the same time,but they have a delay which causes a difference in phase too (we are calculating phase from time).\nWe concluded that time.time() is a slow function.\nCan anyone please help me as to which function to use to get SOC more precise than time.time()?\nOr please provide me with the programming behind the function time.time().\nI'll be really thankful.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":116,"Q_Id":39298445,"Users Score":0,"Answer":"time.time uses gettimeofday on platforms that support it. That means its resolution is in microseconds.\nYou might try using time.clock_gettime(time.CLOCK_REALTIME) which provides nanosecond resolution (assuming the underlying hardware\/OS provides that). The result still gets converted to floating point as with time.time.\nIt's also possible to load up the libc shared object and invoke the native clock_gettime using the ctypes module. In that way, you could obtain access to the actual nanosecond count provided by the OS. (Using ctypes has a fairly steep learning curve though.)","Q_Score":1,"Tags":"python,time,soc","A_Id":39298941,"CreationDate":"2016-09-02T18:08:00.000","Title":"something better than time.time()?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I got the following error while executing a python script on appium \nImportError: No module named appium\nI am running appium in one terminal and tried executing the test on another terminal. Does anyone know what is the reason for this error? and how to resolve it?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":571,"Q_Id":39303681,"Users Score":1,"Answer":"Try to use nosetest.\nInstall:\npip install nose\nRun:\nnosetests (name of the file containing test)","Q_Score":0,"Tags":"ubuntu,python-appium","A_Id":41982234,"CreationDate":"2016-09-03T05:48:00.000","Title":"Python and Appium","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I've been trying to install the pybfd module but nothing works so far.\nTried the following:\npip install pybfd returns error: option --single-version-externally-managed not recognized. After a quick search I found the --egg option for pip which seems to work, says successfully installed but when I try to run my code ImportError: No module named pybfd.bfd\neasy_install pybfd returns an error as well: \nWriting \/tmp\/easy_install-oZUgBf\/pybfd-0.1.1\/setup.cfg\nRunning pybfd-0.1.1\/setup.py -q bdist_egg --dist-dir \/tmp\/easy_install-oZUgBf\/pybfd-0.1.1\/egg-dist-tmp-gWwhoT\n[-] Error : unable to determine correct include path for bfd.h \/ dis-asm.h\nNo eggs found in \/tmp\/easy_install-oZUgBf\/pybfd-0.1.1\/egg-dist-tmp-gWwhoT (setup script problem?)\nFor the last attempt I downloaded the pybfd repo from GitHub and ran the setup script: [-] Error : unable to determine correct include path for bfd.h \/ dis-asm.h\n\nDoes anyone have any idea what could be causing all this and how to actually install the module ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":259,"Q_Id":39318053,"Users Score":1,"Answer":"After some trial and error I discovered that binutils-dev and python-dev packages were missing and causing the header path errors. After installing those the setup script worked.","Q_Score":1,"Tags":"python,pip,easy-install","A_Id":39318468,"CreationDate":"2016-09-04T14:36:00.000","Title":"Problems installing python module pybfd","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I've multiple consumers which are polling on the same queue, and checking the queue every X seconds, basically after X seconds it could be that at least two consumers can launch basic.get at the very same time. \nQuestion are:\n1.If at least two consumers at the same time can get the same message?\n2.According to what I understood only basic_ack will delete a mesage from the queue, so suppose we have the following scenario: \nConsumer1 takes msg with basic.get and before it reaches basic_ack line , Consumer2 is getting this message also (basic.get), now Consumer1 reaches the basic.ack, and only now Consumer2 reaches its own basic.ack.\n What will happen When Consumer2 will reach its basic.ack?\nWill the message be processes by Consumer2 as well, because actions are not atomic?\nMy code logic of consumer using python pika is as follows:\nwhile true:\n m_frame =None\n while(m_frame is None):\n self.connection.sleep(10)\n m_frame,h_frame,body = self.channel.basic_get('test_queue')\n self.channel.basic_ack(m_frame.delivery_tag)\n [Doing some long logic - couple of minutes]\n \nPlease note that I don't use basic.consume \nSo I don't know if round robin fetching is included for such usage","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1439,"Q_Id":39337821,"Users Score":2,"Answer":"1.If at least two consumers at the same time can get the same message?\n\nno - a single message will only be delivered to a single consumer.\nBecause of that, your scenario #2 doesn't come into play at all. \nYou'll never have 2 consumers working on the same message, unless you nack the message back to the queue but continue processing it anyways.","Q_Score":1,"Tags":"python,python-2.7,rabbitmq,pika","A_Id":39340382,"CreationDate":"2016-09-05T21:20:00.000","Title":"Rabbitmq one queue multiple consumers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I came to the requirement to send SMS from my django app. Its a dashboard from multiple clients, and each client will have the ability to send programable SMS. \nIs this achievable with django smsish? I have found some packages that aren't updated, and I sending email sms is not possible.\nAll answers found are old and I have tried all approaches suggested.\nDo I have to use services like twilio mandatorily? Thanks","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":765,"Q_Id":39378728,"Users Score":1,"Answer":"Using Twilio is not mandatory, but I do recommend it. Twilio does the heavy lifting, your Django App just needs to make the proper API Requests to Twilio, which has great documentation on it. \nTwilio has Webhooks as well which you can 'hook' to specific Django Views and process certain events. As for the 'programmable' aspect of your app you can use django-celery, django-cron, RabbitMQ or other task-queueing software.","Q_Score":1,"Tags":"python,django,sms","A_Id":39379920,"CreationDate":"2016-09-07T20:46:00.000","Title":"Sending SMS from django app","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I need to compare two files of differing formats quickly and I'm not sure how to do it. I would very much appreciate it if someone could point me in the right direction.\nI am working on CentOS 6 and I am most comfortable with Python (both Python 2 and Python 3 are available).\n\nThe problem\nI am looking to compare the contents two large files (quickly). The files, unfortunately, differ in content; I will need to modify the contents of one before I can compare them. They are not particularly well-organized, so I can't move linearly down each and compare line-by-line.\nHere's an example of the files:\n\nFile 1 File 2\nJob,Time Job,Start,End\n0123,3-00:00:00 0123,2016-01-01T00:00:00,2016-01-04T00:00:00\n1111,05:30:00 1111,2016-01-01T00:00:00,2016-01-01T05:30:00\n0000,00:00:05 9090.abc,2016-01-01T12:00:00,2016-01-01T22:00:00\n9090.abc,10:00:00 0000,2015-06-01T00:00:00,2015-06-01T00:00:05\n... ...\n\nI would like to compare the contents of lines with the same \"Job\" field, like so:\n\nJob File 1 Content File 2 Content\n0123 3-00:00:00 2016-01-01T00:00:00,2016-01-04T00:00:00\n1111 05:30:00 2016-01-01T00:00:00,2016-01-01T05:30:00\n0000 00:00:05 2015-06-01T00:00:00,2015-06-01T00:00:05\n9090.abc 10:00:00 2016-01-01T12:00:00,2016-01-01T22:00:00\n... ... ...\n\nI will be performing calculations on the File 1 Content and File 2 Content and comparing the two (for each line).\nWhat is the most efficient way of doing this (matching lines)?\n\nThe system currently in place loops through one file in its entirety for each line in the other (until a match is found). This process may take hours to complete, and the files are always growing. I am looking to make the process of comparing them as efficient as possible, but even marginal improvements in performance can have a drastic effect.\nI appreciate any and all help.\nThank you!","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":1140,"Q_Id":39394328,"Users Score":1,"Answer":"If you can find a way to take advantage of hash tables your task will change from O(N^2) to O(N). The implementation will depend on exactly how large your files are and whether or not you have duplicate job IDs in file 2. I'll assume you don't have any duplicates. If you can fit file 2 in memory, just load the thing into pandas with job as the index. If you can't fit file 2 in memory, you can at least build a dictionary of {Job #: row # in file 2}. Either way, finding a match should be substantially faster.","Q_Score":0,"Tags":"python,performance,file,io","A_Id":39395013,"CreationDate":"2016-09-08T15:02:00.000","Title":"Comparing the contents of very large files efficiently","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I need to compare two files of differing formats quickly and I'm not sure how to do it. I would very much appreciate it if someone could point me in the right direction.\nI am working on CentOS 6 and I am most comfortable with Python (both Python 2 and Python 3 are available).\n\nThe problem\nI am looking to compare the contents two large files (quickly). The files, unfortunately, differ in content; I will need to modify the contents of one before I can compare them. They are not particularly well-organized, so I can't move linearly down each and compare line-by-line.\nHere's an example of the files:\n\nFile 1 File 2\nJob,Time Job,Start,End\n0123,3-00:00:00 0123,2016-01-01T00:00:00,2016-01-04T00:00:00\n1111,05:30:00 1111,2016-01-01T00:00:00,2016-01-01T05:30:00\n0000,00:00:05 9090.abc,2016-01-01T12:00:00,2016-01-01T22:00:00\n9090.abc,10:00:00 0000,2015-06-01T00:00:00,2015-06-01T00:00:05\n... ...\n\nI would like to compare the contents of lines with the same \"Job\" field, like so:\n\nJob File 1 Content File 2 Content\n0123 3-00:00:00 2016-01-01T00:00:00,2016-01-04T00:00:00\n1111 05:30:00 2016-01-01T00:00:00,2016-01-01T05:30:00\n0000 00:00:05 2015-06-01T00:00:00,2015-06-01T00:00:05\n9090.abc 10:00:00 2016-01-01T12:00:00,2016-01-01T22:00:00\n... ... ...\n\nI will be performing calculations on the File 1 Content and File 2 Content and comparing the two (for each line).\nWhat is the most efficient way of doing this (matching lines)?\n\nThe system currently in place loops through one file in its entirety for each line in the other (until a match is found). This process may take hours to complete, and the files are always growing. I am looking to make the process of comparing them as efficient as possible, but even marginal improvements in performance can have a drastic effect.\nI appreciate any and all help.\nThank you!","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":1140,"Q_Id":39394328,"Users Score":1,"Answer":"I was trying to develop something where you'd split one of the files into smaller files (say 100,000 records each) and keep a pickled dictionary of each file that contains all Job_id as a key and its line as a value. In a sense, an index for each database and you could use a hash lookup on each subfile to determine whether you wanted to read its contents.\nHowever, you say that the file grows continually and each Job_id is unique. So, I would bite the bullet and run your current analysis once. Have a line counter that records how many lines you analysed for each file and write to a file somewhere. Then in future, you can use linecache to know what line you want to start at for your next analysis in both file1 and file2; all previous lines have been processed so there's absolutely no point in scanning the whole content of that file again, just start where you ended in the previous analysis. \nIf you run the analysis at sufficiently frequent intervals, who cares if it's O(n^2) since you're processing, say, 10 records at a time and appending it to your combined database. In other words, the first analysis takes a long time but each subsequent analysis gets quicker and eventually n should converge on 1 so it becomes irrelevant.","Q_Score":0,"Tags":"python,performance,file,io","A_Id":39396201,"CreationDate":"2016-09-08T15:02:00.000","Title":"Comparing the contents of very large files efficiently","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to scrape the font-size of each section of text in an HTML page. I have spent the past few days trying to do it, but I feel like I am trying to re-invent the wheel. I have looked at python libraries like cssutils, beautiful-soup, but haven't had much luck sadly. I have made my own html parser that finds the font size inside the html only, but it doesn't look at stylesheets which is really important. Any tips to get me headed in the right direction?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":556,"Q_Id":39420152,"Users Score":0,"Answer":"You can use selenium with firefox or phantomjs if you're on a headless machine, the browser will render the page, then you can locate the element and get it's attributes.\nOn python the method to get attributes is self explanatory, Element_obj.get_attribute('attribute_name')","Q_Score":0,"Tags":"python,html,css,web-scraping","A_Id":39420644,"CreationDate":"2016-09-09T21:46:00.000","Title":"Scraping font-size from HTML and CSS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to write try except block for smartsheet aPI using python sdk, specially in cases where the API response to call returns error object rather than a usual index result object. Could someone explain what kind of exception would I be catching. I am not sure if I would have to create custom exceptions of my own or whether there are some way to capture exceptions. The API document talks about the error messages, not handling the. Would be great if someone could share some simple examples around the same.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":153,"Q_Id":39433457,"Users Score":0,"Answer":"Knowing what a successful response will look like you could try checking for the error response. For example, running a get_row with an invalid rowId will result in this error:\n\n{\"requestResponse\": null, \"result\": {\"code\": 1006, \"name\": \"NotFoundError\", \"recommendation\": \"Do not retry without fixing the problem. Hint: Verify that specified URI is correct. If the URI contains an object ID, verify that the object ID is correct and that the requester has access to the corresponding object in Smartsheet.\", \"shouldRetry\": false, \"message\": \"Not Found\", \"statusCode\": 404}}\n\nSeeing requestResponse being null you can check the result object to know what the code is to look up in the Smartsheet API docs. Also, there is a recommendation parameter that gives next steps.","Q_Score":0,"Tags":"python,python-2.7,exception-handling,smartsheet-api,smartsheet-api-1.1","A_Id":39480478,"CreationDate":"2016-09-11T06:29:00.000","Title":"Smartsheet SDK exception handling","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a python\/django project which calls a C++ shared library. I am using boost_python C++ library.\nIt works fine: I can call C++ methods from python interpreter. I can also call this methods from my django project. But i am wondering something: Where is the best folder for my C++ shared library ?\nI actually put this binary shared library in django app folder (same folder as view.py). It works but i think this is ugly... Is there a specific folder for shared library in django directory structure ?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":628,"Q_Id":39447513,"Users Score":0,"Answer":"put them to $PROJECT_HOME\/lib just like a normal package","Q_Score":0,"Tags":"django,boost-python","A_Id":39454692,"CreationDate":"2016-09-12T09:44:00.000","Title":"Where is the Folder for shared library in a django project","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am running my application in a virtualenv using Python3.4.\nWiringPi requires sudo privilege to access the hardware pins. Flask, on the other hand, resides in my virtualEnv folder, so I can't access it using sudo flask.\nI've tried making it run on startup by placing some commands in \/etc\/rc.local so that it can have root access automatically. It only tells me that it can't find basic Python library modules (like re).\nMy RPI2 is running Raspbian. For the time being I am running it using flask run --localhost=0.0.0.0, which I know I am not supposed to do, but I'll change that later.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":105,"Q_Id":39480992,"Users Score":0,"Answer":"Turns out I just had to make sure that \"root\" had the proper libraries installed too. Root and User have different directories for their Python binaries.","Q_Score":0,"Tags":"python,flask,raspberry-pi,virtualenv,wiringpi","A_Id":39521293,"CreationDate":"2016-09-14T00:54:00.000","Title":"WiringPi and Flask Sudo Conflict","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using pytest for writing some tests at integration level. I would like to be able to also report the number of assertions done on each test case. By default, pytest will only report the number of test cases which have passed and failed.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1091,"Q_Id":39500416,"Users Score":-1,"Answer":"On assertion further execution of test is aborted. So there will always be 1 assertion per test.\nTo achieve what you want you will have to write your own wrapper over assertion to keep track. At the end of the test check if count is >0 then raise assertion.\nThe count can be reset to zero either the setup or at teardown of test.","Q_Score":4,"Tags":"python,integration-testing,pytest","A_Id":39559306,"CreationDate":"2016-09-14T22:10:00.000","Title":"Report number of assertions in pyTest","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using pytest for writing some tests at integration level. I would like to be able to also report the number of assertions done on each test case. By default, pytest will only report the number of test cases which have passed and failed.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1091,"Q_Id":39500416,"Users Score":1,"Answer":"As far as I can see there is no such possibility to get the number of passed assertions out of pytest. \nReason: it employs Python's standard assert statement, so the determination whether the assertion is a pass or a fail is done within the engine used, and in case the engine does not count how often it got into the \"pass\" branch of the necessary if in assert's implementation, and offer a way to read out that counter, there is just no way to elicit that information from the engine. So pyTest can't tell you that either.\nMany (unit) test frameworks report assertion count by default, and IMHO i deem it desirable, because it is - amongst others - a measure for test quality: sloppy tests might apply too few checks to values.","Q_Score":4,"Tags":"python,integration-testing,pytest","A_Id":53409809,"CreationDate":"2016-09-14T22:10:00.000","Title":"Report number of assertions in pyTest","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working with RapidMiner at the moment and am trying to copy my RapidMiner results which are in xlsx files to txt files in order to do some further processing with python. I do have plain text in column A (A1-A1500) as well as the according filename in column C (C1-C1500). \nNow my question: \nIs there any possibility (I am thinking of the xlrd module) to read the content of every cell in column A and print this to a new created txt file with the filename being given in corresponding column C? \nAs I have never worked with the xlrd module before I am a bit lost at the moment...","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5449,"Q_Id":39512166,"Users Score":0,"Answer":"Good day! So, I'm not sure I understand your question correctly, but have you tried a combination of Read Excel operator with the Loop Examples operator? Your loop subprocess could then use Write CSV operator or similar.","Q_Score":1,"Tags":"python-3.x,xlrd,rapidminer","A_Id":39519713,"CreationDate":"2016-09-15T13:22:00.000","Title":"Read Excel Cells and Copy content to txt file","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to make a kivy app for the raspberry pi that can use a touch screen. I was able to get the demos to work with the touchscreen with just \"python ~\/kivy\/examples\/demo\/showcase\/main.py\". The issue comes when I need to start the app with \"sudo python main.py\", the touchscreen then ceases to work. \nThe app I am trying to write uses the rpi_ws281x library for controlling addressable leds which HAS to be run as root. Is there a way to run the kivy app as root while still enabling the touchscreen functionality? \nIf there isn't, is there a way to send data from the kivy app to say a script which is running sudo that controls the leds? \nI've looked a lot of places but no one seems to have had this problem before (or they could work around it by changing the privileges of other directories where they were accessing the sudo protected content). Any help is greatly appreciated!","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":989,"Q_Id":39542539,"Users Score":4,"Answer":"Well apparently I didn't look hard enough. The solution is to copy \"~\/.kivy\/config.ini\" to \"\/root\/.kivy\/config.ini\"\nSo the commands are \n\"sudo cp ~\/.kivy\/config.ini \/root\/.kivy\/config.ini\"\nAnd then everything works happily together!","Q_Score":1,"Tags":"python,raspberry-pi,kivy,led","A_Id":39542558,"CreationDate":"2016-09-17T03:22:00.000","Title":"Run Kivy app as root user with touch screen on raspberry pi","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have project that uses same initial variables on same server by different programming languages. they are PHP, python and bash. i need all languages to access those variable and I cannot exclude any language.\nfor now I keep 3 places to store variables: \nfor php I have Mysql storage, for python and bash 2 separate files\nif initial value of any variable changes, i need to change it at 3 locations\ni want to simplify that now. lest assume all systems can access Mysql. is there the way define initial variables in Mysql instead of files? or what is the best practice to share variables in my case?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":46,"Q_Id":39573614,"Users Score":0,"Answer":"OK, I think the best approach for me here would be to limit variable storages from 3 to at least 2 and make python script deal with bash tasks over os.system. To use 2 storages is somehow manageable","Q_Score":1,"Tags":"php,python,bash,variables,share","A_Id":39580897,"CreationDate":"2016-09-19T12:48:00.000","Title":"share variables by PHP, python, bash","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am a complete newbie to python transiting from C++. \nWhile learning C++, I was explained that header files tells about the working of the function or define them to the compiler so that it understands what means what i.e., iostream contains the definition of cin (nd much more) so that the compiler knows that it is a keyword and understands its function.\nHowever, python and java do not need header files.\n So basically how does the compiler understands the actual meaning\/function of 'print' or 'input' in python?????","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":2209,"Q_Id":39576478,"Users Score":4,"Answer":"Header files in C\/C++ are a \"copy paste\" mechanism. The included header file is literally written into the file while preprocessing (copy pasting the source code together).\nAfter that is done, the compiler transaltes the source code. The linker then connects the function calls.\nThat is somewhat outdated and error prone -> can be really frustrating as well when sth doesnt work as expected.\nNewer languages have module systems, which are nicer (import simply does it).","Q_Score":2,"Tags":"python","A_Id":39576570,"CreationDate":"2016-09-19T15:08:00.000","Title":"Why Python and java does not need any header file whereas C and C++ needs them","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am a complete newbie to python transiting from C++. \nWhile learning C++, I was explained that header files tells about the working of the function or define them to the compiler so that it understands what means what i.e., iostream contains the definition of cin (nd much more) so that the compiler knows that it is a keyword and understands its function.\nHowever, python and java do not need header files.\n So basically how does the compiler understands the actual meaning\/function of 'print' or 'input' in python?????","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":2209,"Q_Id":39576478,"Users Score":1,"Answer":"In Java and Python we use a similar keyword called import to add a package and use the methods in it. But in advanced languages like Java and Python few packages are imported by default.\ne.g. in Java java.lang.* is imported by default.","Q_Score":2,"Tags":"python","A_Id":39576943,"CreationDate":"2016-09-19T15:08:00.000","Title":"Why Python and java does not need any header file whereas C and C++ needs them","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am a complete newbie to python transiting from C++. \nWhile learning C++, I was explained that header files tells about the working of the function or define them to the compiler so that it understands what means what i.e., iostream contains the definition of cin (nd much more) so that the compiler knows that it is a keyword and understands its function.\nHowever, python and java do not need header files.\n So basically how does the compiler understands the actual meaning\/function of 'print' or 'input' in python?????","AnswerCount":3,"Available Count":3,"Score":-0.0665680765,"is_accepted":false,"ViewCount":2209,"Q_Id":39576478,"Users Score":-1,"Answer":"Java and Python have import which is similar to include.\nSome inbuilt functions are built in and hence does not require any imports.","Q_Score":2,"Tags":"python","A_Id":39576524,"CreationDate":"2016-09-19T15:08:00.000","Title":"Why Python and java does not need any header file whereas C and C++ needs them","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've recently discovered the inspect and thought if it's possible to manually remove \"outer\" frames of the current frame and thus implementing tail-recursion optimization. \nIs it possible? How?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":36,"Q_Id":39600764,"Users Score":1,"Answer":"It's not possible. inspect doesn't let you rewrite the stack that way, and in any case, it only gives Python stack frames. Even if you could change how the Python stack frames hook up to each other, the C call stack would be unaffected.","Q_Score":0,"Tags":"python,optimization,tail-recursion","A_Id":39600829,"CreationDate":"2016-09-20T17:57:00.000","Title":"Hacking tail-optimization","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've try before sending message from single producer to 2 different consumer with DIFFERENT consumer group id. The result is both consumer able to read the complete message (both consumers getting the same message). But I would like to ask is it possible for these 2 consumers read different messages while setting them under a SAME consumer group name?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":112,"Q_Id":39611124,"Users Score":0,"Answer":"I found the answer already, just make sure the partition number is not equal to one while creating new topic.","Q_Score":0,"Tags":"python,producer-consumer,kafka-python","A_Id":39652029,"CreationDate":"2016-09-21T08:21:00.000","Title":"Single producer to multi consumers (Same consumer group)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm making a simple home automation system with my Beagle Bone, raspberry pi and a hand full of components. I have a simple interface on a webpage and i'm currently trying to remotely toggle a relay. Right now I have a button on the webpage that uses php to call a python script that either turns the relay on or off depending on a boolean. \nI'm having trouble figuring out the best way to share this boolean. Is there any way to pass a php varible into the python script? or is there anyway to have the python interpreter \"keep\/save\" the state of the variable in-betweeen instances of the script. Or is the best way just to have it write\/read from a common file? any help would be awesome","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":55,"Q_Id":39648803,"Users Score":0,"Answer":"I am unfamiliar with php, but could you have php write to a temporary text file, and then when that python script gets called, it simply reads in that text file to store the boolean value?","Q_Score":1,"Tags":"php,python,linux,apache,beagleboneblack","A_Id":39649062,"CreationDate":"2016-09-22T21:01:00.000","Title":"Best way to share a variable with multiple instances of the same python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is the time complexity of Zlib's deflate algorithm?\nI understand that in Python this algorithm is made available via the zlib.compress function.\nPresumably the corresponding decompression algorithm has the same or better complexity.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":858,"Q_Id":39654986,"Users Score":3,"Answer":"Time complexity is how the processing time scales with the size of the input. For zlib, and any other compression scheme I know of, it is O(n) for both compression and decompression. The time scales linearly with the size of the input.\nIf you are thinking that the time complexity of decompression is less somehow, then perhaps you are thinking about the constant in front of the n, as opposed to the n. Yes, decompression is usually faster than compression, because that constant is smaller. Not because the time complexity is different, because it isn't.","Q_Score":3,"Tags":"python,compression,complexity-theory,zlib","A_Id":39662445,"CreationDate":"2016-09-23T07:23:00.000","Title":"Time complexity of zlib's deflate algorithm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I changed the interpreter for my python projects from 2.x to 3.5 recently. The code interpretes correctly with the 3.5 version.\nI noticed that the autocompletion function of Eclipse still autocompletes as if I am using 2.x Python version. For example: print gets autocompleted without parenthesis as a statement and not as a function. Any idea how to notify the Eclipse that it need to use 3.5 autocompletion?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":82,"Q_Id":39659748,"Users Score":1,"Answer":"If you are using PyDev, make sure that interpreter grammar is set to 3.0 (right click project -> Properties -> PyDev - Interpreter\/Grammar)","Q_Score":0,"Tags":"python,eclipse,python-3.x,autocomplete","A_Id":39773761,"CreationDate":"2016-09-23T11:32:00.000","Title":"force eclipse to use Python 3.5 autocompletion","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am very new to Python. I am curious to how I would be able to copy some files from my directory to another Users directory on my computer using python script? And would I be correct in saying I need to check the permissions of the users and files? So my question is how do I send files and also check the permissions at the same time","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":639,"Q_Id":39665029,"Users Score":1,"Answer":"shutil is a very usefull thing to use when copying files.\nI once needed to have a python script that moved all .mp3 files from a directory to a backup, deleted the original directory, created a new once, and moved the .mp3 files back in. shutil was perfect for thise.\nThe formatting for the command is how @Kieran has stated earlier.\nIf you're looking to keep file metadata, then use shutil.copy2(src, dest), as that is the equivalent of running copy() and copystat() one after another.","Q_Score":1,"Tags":"python","A_Id":39665400,"CreationDate":"2016-09-23T15:59:00.000","Title":"Python sending files from a user directory to another user directory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We are testing networking devices to which test interaction is done using serial ports. Python 2.7 with Windows is used to achieve this using the PySerial module of Python. \nThe scripts are run using Robot framework.\nWe observe that the Robot logs do not contain the serial device interaction dialogues. \nWe tried checking on Robot framework forums and it is unlikely that such support exists at Robot framework level.\nWe need to implement this in Python.\nHow can the following be achieved:\nI) Basic requirement: All script interaction with the (multiple) test devices on serial port needs to be captured into a log file\nII) Advanced requirement: while the script is not actively interacting with the test device there has to be continuous background monitoring of the device under test over serial ports for any errors\/crashes\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":466,"Q_Id":39736740,"Users Score":0,"Answer":"I may be incorrect but perhaps you want to capture data sent\/received between computer and device through serial port. If this is true then serial port sniffer will be required. Linux and mac os x does not support sniffing however you may use sniffing for windows.","Q_Score":0,"Tags":"python,python-2.7,testing,automated-tests,robotframework","A_Id":39766125,"CreationDate":"2016-09-28T01:43:00.000","Title":"Python2.7(on Windows) Need to capture serial port output into log files during Python\/Robot script run","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Im using a scientific linux on a remote machine. I tried to install python 2.7 on it. After that the yum and some other python packages are not working (it says \"no module named yum\"). I searched it online and it seems I should not have touched the system python as it breaks some of the system tools. Is there a way to reinstall the previous python (which was 2.6). I already tried to install python 2.6 by downloading the package but still yum is not working.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":165,"Q_Id":39736788,"Users Score":0,"Answer":"Once you get your system back to normal, add Python 2.7 as a Software Collection - it installs \"along side\" the original Python 2.6 rather than replace it so both are available without collision. Get 2.7 and others from softwarecollections.org.","Q_Score":0,"Tags":"python,linux,redhat,yum","A_Id":39917999,"CreationDate":"2016-09-28T01:49:00.000","Title":"Yum is not working anymore in scientific linux after python update","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created a bot for my website and I currently host in on heroku.com. \nI run it by executing the command \nheroku run --app cghelper python bot.py\nThis executes the command perfectly through CMD and runs that specific .py file in my github repo. \nThe issue is when I close the cmd window this stops the bot.py. How can I get the to run automatically. \nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":43,"Q_Id":39753285,"Users Score":0,"Answer":"Not sure but try: \nheroku run --app cghelper python bot.py &","Q_Score":0,"Tags":"python,django,git,heroku","A_Id":39754555,"CreationDate":"2016-09-28T16:45:00.000","Title":"Automatically running app .py in in Heroku","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am new to Cognex's in-sight explorer. I am using it for test automation and I want to know is it possible to capture image using a script [preference is python, but other scripting methods are welcome].\n I have my Test Cases [TC] running using python scripts, in case a TC fail I want to capture the camera image at run time and store it on my host PC.\nI don't want to use any web came or any thing else. I want to use my existing system of Cognex's Camera and in-sight Explorer.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1101,"Q_Id":39772952,"Users Score":1,"Answer":"Look into the In-Sight Native Mode commands. ASCII native mode commands are sent to the camera over Ethernet on port 23 (telnet). These commands are documented in the In-Sight Explorer help file which can be accessed from the In-Sight Explorer Help menu. Look under the 'Communications Reference -> Native Mode Commands' section.\nThe command RB (Read BMP) will send the current image from the camera in ASCII hexadecimal format.\nUsing In-Sight Explorer, you can set the cameras trigger mode to 'Continuous' to continuously acquire images, or you can set it to 'Manual' and trigger the camera via a native mode command. The command to trigger the camera is SE8 (Set event 8). The camera must be online for either trigger method to work (Sensor menu -> Online).","Q_Score":0,"Tags":"python,automation,camera-calibration","A_Id":41273193,"CreationDate":"2016-09-29T14:22:00.000","Title":"Automate Image capturing using Cognex's In-sight Explorer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"We (our company) have a webserver which is fully hosted, I can only access it through FTP and put files on it that way. It has a couple of Python scripts installed in a \/cgi-bin\/ folder, and I've been asked to upgrade the functionality of one of them (it uses Apache and regular old CGI, if that helps). Unfortunately, to do this I need to use a package from pip, one with several dependencies. \nIs there any way to install packages from pip to a server I only have FTP access to? Can I maybe just copy all the folders containing the pip package and its dependencies to some location on the server? I imagine putting it in \/cgi-bin\/ would be unsafe, but I do have access to non-public_html folders. How would I have to configure my python scripts to be able to import these, if it is even possible to do it this way?\nAny advice would be greatly appreciated.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1529,"Q_Id":39786630,"Users Score":2,"Answer":"As far as I know, it is not possible to install packages through an FTP server. Pip works fine using an HTTP server or by downloading it locally. To use it with an HTTP server, just do pip install -i .","Q_Score":3,"Tags":"python,ftp,pip","A_Id":40282271,"CreationDate":"2016-09-30T08:07:00.000","Title":"Installing pip packages on a server where I have only ftp access?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have problem on import nltk.\nI configured apache and run some sample python code, it worked well on the browser.\nThe URL is : \/localhost\/cgi-bin\/test.py.\nWhen I import the nltk in test.py its not running. The execution not continue after the \"import nltk\" line.And it gives me that error ValueError: Could not find a default download directory \nBut when I run in the command prompt its working perfect.\nhow to remove this error?","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1011,"Q_Id":39805675,"Users Score":-1,"Answer":"The Problem is raised probably because you don't have a default directory created for your ntlk downloads. If you are on a Windows Platform, All you need to do is to create a directory named \"nltk_data\" in any of your root directory and grant write permissions to that directory. The Natural Language Tool Kit initially searches for the destination named \"nltk_data\" in all of the root directories.\nFor Instance: Create a folder in your C:\\ drive named \"nltk_data\"\nAfter Making sure everything is done fine, execute your script to get rid of this error.\nHope this helps. \nRegards.","Q_Score":1,"Tags":"python,nltk","A_Id":39810288,"CreationDate":"2016-10-01T10:46:00.000","Title":"ValueError: Could not find a default download directory of nltk","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to invoke python script from C application using system() call\nThe python script has #!\/usr\/bin\/python3 on the first line.\nIf I do system(python_script), the script does not seem to run.\nIt seems I need to do system(\/usr\/bin\/python3 python_script).\nI thought I do not need to specify the interpreter externally if I have #!\/usr\/bin\/python3 in the first line of the script.\nAm I doing something wrong?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":46,"Q_Id":39861960,"Users Score":1,"Answer":"Make sure you have executable permission for python_script.\nYou can make python_script executable by \nchmod +x python_script\nAlso check if you are giving correct path for python_script","Q_Score":2,"Tags":"python,c,system,interpreter","A_Id":39862114,"CreationDate":"2016-10-04T21:20:00.000","Title":"Do we need to specify python interpreter externally if python script contains #!\/usr\/bin\/python3?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to download a couple of packages in python 3.5 but pip keeps throwing an exception(via pip install pyzmail), please see below:\nHow do I overcome this issue?\n\nException:\n Traceback (most recent call last):\n File \"c:\\users\\chiruld\\appdata\\local\\programs\\python\\python35\\lib\\pip\\basecommand.py\", line 122, in main\n status = self.run(options, args)\n File \"c:\\users\\chiruld\\appdata\\local\\programs\\python\\python35\\lib\\pip\\commands\\install.py\", line 278, in run\n requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)\n File \"c:\\users\\chiruld\\appdata\\local\\programs\\python\\python35\\lib\\pip\\req.py\", line 1229, in prepare_files\n req_to_install.run_egg_info()\n File \"c:\\users\\chiruld\\appdata\\local\\programs\\python\\python35\\lib\\pip\\req.py\", line 292, in run_egg_info\n logger.notify('Running setup.py (path:%s) egg_info for package %s' % (self.setup_py, self.name))\n File \"c:\\users\\chiruld\\appdata\\local\\programs\\python\\python35\\lib\\pip\\req.py\", line 265, in setup_py\n import setuptools\n File \"c:\\users\\chiruld\\appdata\\local\\programs\\python\\python35\\lib\\setuptools__init__.py\", line 2, in \n from setuptools.extension import Extension, Library\n File \"c:\\users\\chiruld\\appdata\\local\\programs\\python\\python35\\lib\\setuptools\\extension.py\", line 5, in \n from setuptools.dist import _get_unpatched\n File \"c:\\users\\chiruld\\appdata\\local\\programs\\python\\python35\\lib\\setuptools\\dist.py\", line 103\n except ValueError, e:\n ^\n SyntaxError: invalid syntax","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":328,"Q_Id":39862803,"Users Score":0,"Answer":"If you are using Windows.., try right clicking 'cmd.exe' and select 'Run as Administrator' and click 'Yes' to allow the following program to make changes to this computer.","Q_Score":0,"Tags":"python-3.x,exception,pip,imapclient","A_Id":49603292,"CreationDate":"2016-10-04T22:35:00.000","Title":"Issues installing pyzmail or imapclient on python 3.5, pip throws a value and syntax error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to get the sonar result in the class wise classification or modularized format. I am using python and the sonar web API. Apart from the basic APIs are there any other APIs which give me the results per class","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":143,"Q_Id":39871632,"Users Score":2,"Answer":"SonarQube doesn't know the concept of \"class\". This is a logical element, whereas SonarQube manages only \"physical\" components like files or folders. The consequence is that the Web API allows you to query only components that are \"physical\".","Q_Score":1,"Tags":"python,sonarqube","A_Id":39873031,"CreationDate":"2016-10-05T10:34:00.000","Title":"Is there a way to get the sonar result per class or per module","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"My Desktop is Debian 8.5 running firefox and running Mozilla Firefox 45.3 and SmartSheet latest version. Lately I have been trying to obtain attributes from a sheet, among them createdAt or modifiedAt, but when I run the code below:\n!\/usr\/bin\/python\nimport smartsheet\nToken\nplanilha = smartsheet.Smartsheet(MyToken)\naction = planilha.Sheets.list_sheets(include_all=True)\nsheets = action.data\ncounter\nxCount=0\nfor row in sheets:\n xCount+=1\n print row.id, row.createdAt\nprint xCount\nI get\n.......\nprint row.id, row.createdAt\n File \"\/usr\/local\/lib\/python2.7\/dist-packages\/smartsheet\/models\/sheet.py\", line 175, in getattr\n raise AttributeError(key)\nAttributeError: createdAt\n......\nI just wonder why or I certainly miss something in Smartsheet API 2.0 docs..\nthanks in advance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":186,"Q_Id":39877804,"Users Score":0,"Answer":"Any attributes described in the Smartsheet API documentation (which do not specifically appear in a Python code example) represent how the attributes appear in the raw API (JSON) requests\/responses. The Python SDK itself actually uses Python variable naming conventions: \"lowercase with words separated by underscores as necessary to improve readability\" (as described here: python.org\/dev\/peps\/pep-0008). So, for example, the raw API response may contain the attribute \"modifiedAt\" -- but when using this attribute via the Python SDK, you'll refer to it as \"modified_at\".\nSo, try using created_at and modified_at (instead of createdAt and modifiedAt).","Q_Score":0,"Tags":"python-2.7,smartsheet-api","A_Id":39885588,"CreationDate":"2016-10-05T15:14:00.000","Title":"SmartSheetAPI using python: createdAt or modifiedAt attributes from a sheet","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am testing malware detection on guest VM using Cuckoo sandbox platform. To speed up the analysis, I want to remove pending analysis but keep completed analysis. \nCuckoo have --clean option but it will clean all tasks and samples. Can you think of a way to only remove pending analysis? \nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2686,"Q_Id":39881589,"Users Score":0,"Answer":"You can do it by deleting entries from the mysql database for pending analysis.","Q_Score":1,"Tags":"python,virtual-machine,antivirus,malware-detection,cuckoo","A_Id":39904650,"CreationDate":"2016-10-05T18:50:00.000","Title":"How to clear pending analysis in Cuckoo sandbox platform","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have deployed my zipped project without psycopg2 package. I want to install this package on my lambda without re-uploading my fixed project (i haven't access to my project right now). How can i install this package on my lambda? Is it possible to do it with pip?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":958,"Q_Id":39900449,"Users Score":0,"Answer":"It's not possible to do with pip. You have to add the dependency to your zipped Lambda deployment file. You can't modify your Lambda deployment without uploading a new zipped deployment file.","Q_Score":0,"Tags":"python,amazon-web-services,pip,aws-lambda,psycopg2","A_Id":39900507,"CreationDate":"2016-10-06T15:48:00.000","Title":"Installing python package on AWS lambda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to do object recognition in an embedded environment, and for this I'm using Raspberry Pi (Specifically version 2).\nI'm using OpenCV Library and as of now I'm using feature detection algorithms contained in OpenCV.\nSo far I've tried different approaches:\n\nI tried different keypoint extraction and description algorithms: SIFT, SURF, ORB. SIFT and SURF are too heavy and ORB is not so good.\nThen I tried using different algorithms for keypoint extraction and then description. The first approach was to use FAST algorithm to extract key points and then ORB or SURF for description, the results were not good and not rotation invariant, then i tried mixing the others.\n\nI now am to the point where I get the best results time permitting using ORB for keypoint extraction and SURF for description. But it is still really slow.\nSo do you have any suggestions or new ideas to obtain better results? Am I missing something?\nAs additional information, I'm using Python 3.5 with OpenCV 3.1","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":406,"Q_Id":39936967,"Users Score":0,"Answer":"I have done similar project in my Masters Degree. \nI had used Raspberry Pi 3 because it is faster than Pi 2 and has more resources for image processing. \nI had used KNN algorithm in OpenCV for Number Detection. It was fast and had good efficiency. \nThe main advantage of KNN algorithm is it is very light weight.","Q_Score":1,"Tags":"python,algorithm,opencv,raspberry-pi,computer-vision","A_Id":41820410,"CreationDate":"2016-10-08T20:19:00.000","Title":"Feature detection for embedded platform OpenCV","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm having an error for what seems to be a permissions problem when trying to create a zip file in a specified folder testfolder -folder has the following permissions:\ndrwxr-xr-x 193 nobody nobody\nWhen trying to launch the following command in python I get the following:\np= subprocess.Popen(['7z','a','-pinfected','-y','\/home\/John\/testfolder\/yada.zip'] + ['test.txt'],stdout=PIPE.subprocess,stderr=PIPE.subprocess)\nTraceback (most recent call last):\n File \"\", line 1, in \n File \"\/usr\/local\/lib\/python2.7\/subprocess.py\", line 710, in __init__\n errread, errwrite)\n File \"\/usr\/local\/lib\/python2.7\/subprocess.py\", line 1327, in _execute_child\n raise child_exception\nOSError: [Errno 13] Permission denied\nAny idea what wrong with permissions?\nI pretty new to it, my python runs from \/usr\/local\/bin path","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":589,"Q_Id":39982491,"Users Score":1,"Answer":"drwxr-xr-x means that:\n1] only the directory's owner can list its contents, create new files in it (elevated access) etc.,\n2] members of the directory's group and other users can also list its contents, and have simple access to it.\nSo in fact you don't have to change the directory's permissions unless you know what you are doing, you could just run your script with sudo like sudo python my_script.py.","Q_Score":0,"Tags":"python,linux,python-2.7,permissions,permission-denied","A_Id":39982764,"CreationDate":"2016-10-11T16:47:00.000","Title":"Using 7zip with python to create a password protected file in a given path","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am using Ubuntu server 12.04 to run Apache2 web server.\nI am hosting several webpages, and most are working fine.\nOne page is running a cgi script which mostly works (I have the python code working outside Apache building the html code nicely.)\nHowever, I am calling a home automation program (heyu) and it is returning different answers then when I run it in my user account.\nIs there a way I can...\n1 call the heyu program from my python script as a specific user, (me) and leave the rest of the python code and cgi code alone?\n2, configure apache2 to run the cgi code, as a whole, as me? I would like to leave all the other pages unchanged. Maybe using the sites_available part.\n3, at least determine which user is running the cgi code so maybe I can get heyu to be OK with that user.\nThanks, Mark.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":206,"Q_Id":40010657,"Users Score":0,"Answer":"It looks like I could use suEXEC.\nIt is an Apache module that is not installed at default because they really don't want you to use it. It can be installed using the apt-get scheme.\nThat said, I found the real answer to my issue, heyu uses the serial ports to do it's work. I needed to add www-data to the dialout group then reboot.\nThis circumvented the need to run my code as me (as I had already add me to the dialout group a long time ago) in favor of properly changing the permissions.\nThanks.","Q_Score":0,"Tags":"php,python,apache","A_Id":40065573,"CreationDate":"2016-10-13T01:00:00.000","Title":"Apache2 server run script as specific user","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am running a website where user can send in-site message (no instantaneity required) to other user, and the receiver will get a notification about the message.\nNow I am using a simple system to implement that, detail below.\nTable Message:\n\nid\ncontent\nreceiver\nsender\n\nTable User:\n\nsome info\nnotification\nsome info\n\nWhen a User A send message to User B, a record will be add to Message and the B.notification will increase by 1. When B open the message box the notification will decrease to 0.\nIt's simple but does well.\nI wonder how you\/company implement message system like that.\nNo need to care about UE(like confirm which message is read by user), just the struct implement.\nThank a lot :D","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":123,"Q_Id":40013849,"Users Score":0,"Answer":"I think you will need to read about pub\/sub for messaging services. For php, you can use libraries such as redis.\nSo for e.g, user1 subscribe to topic1, any user which publish to topic1, user1 will be notified, and you can implement what will happen to the user1.","Q_Score":0,"Tags":"php,python,web,messagebox","A_Id":40015293,"CreationDate":"2016-10-13T06:34:00.000","Title":"How to implement a message system?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am connecting to a server through PHP SSH and then using exec to run a python program on that server. \nIf I connect to that server through putty and execute the same command through command line, I get result like:\n\nEvaluating....\nConnecting....\nRetrieving data....\n1) Statement 1\n2) Statement 2\n.\n.\n.\nN) Statement N\n\nPython program is written by somebody else...\nWhen I connect through SSH php, I can execute $ssh->exec(\"ls\") and get the full results as proper as on server command line. But when I try $ssh->exec(\"python myscript.py -s statement 0 0 0\"); I couldn't get the full results but I get a random line as an ouput.\nIn general, if somebody had experienced the same issue and solved, please let me know.\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":142,"Q_Id":40019042,"Users Score":2,"Answer":"Perhaps it's caused by buffering of the output. Try adding the -u option to your Python command - this forces stdout, stdin and stderr to be unbuffered.","Q_Score":0,"Tags":"php,python,ssh,centos,exec","A_Id":40019200,"CreationDate":"2016-10-13T10:55:00.000","Title":"PHP exec command is not returning full data from Python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to write an algorithm that can work out the 'unexpectedness' or 'information complexity' of a sentence. More specifically I'm trying to sort a set of sentences so the least complex come first. \nMy thought was that I could use a compression library, like zlib?, 'pre train' it on a large corpus of text in the same language (call this the 'Corpus') and then append to that corpus of text the different sentences.\nThat is I could define the complexity measure for a sentence to be how many more bytes it requires to compress the whole corpus with that sentence appended, versus the whole corpus with a different sentence appended. (The fewer extra bytes, the more predictable or 'expected' that sentence is, and therefore the lower the complexity). Does that make sense?\nThe problem is with trying to find the right library that will let me do this, preferably from python.\nI could do this by literally appending sentences to a large corpus and asking a compression library to compress the whole shebang, but if possible, I'd much rather halt the processing of the compression library at the end of the corpus, take a snapshot of the relevant compression 'state', and then, with all that 'state' available try to compress the final sentence. (I would then roll back to the snapshot of the state at the end of the corpus and try a different sentence).\nCan anyone help me with a compression library that might be suitable for this need? (Something that lets me 'freeze' its state after 'pre training'.)\nI'd prefer to use a library I can call from Python, or Scala. Even better if it is pure python (or pure scala)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":101,"Q_Id":40034334,"Users Score":2,"Answer":"All this is going to do is tell you whether the words in the sentence, and maybe phrases in the sentence, are in the dictionary you supplied. I don't see how that's complexity. More like grade level. And there are better tools for that. Anyway, I'll answer your question.\nYes, you can preset the zlib compressor a dictionary. All it is is up to 32K bytes of text. You don't need to run zlib on the dictionary or \"freeze a state\" -- you simply start compressing the new data, but permit it to look back at the dictionary for matching strings. However 32K isn't very much. That's as far back as zlib's deflate format will look, and you can't load much of the English language in 32K bytes.\nLZMA2 also allows for a preset dictionary, but it can be much larger, up to 4 GB. There is a Python binding for the LZMA2 library, but you may need to extend it to provide the dictionary preset function.","Q_Score":1,"Tags":"python,scala,compression,information-theory","A_Id":40046686,"CreationDate":"2016-10-14T03:12:00.000","Title":"Using compression library to estimate information complexity of an english sentence?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"streamer.filter(locations=[-180, -90, 180, 90], languages=['en'], async=True)\nI am trying to extract the tweets which have been geotagged from the twitter streaming API using the above call. However, I guess tweepy is not able to handle the requests and quickly falls behind the twitter rate. Is there a suggested workaround the problem ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":74,"Q_Id":40071459,"Users Score":0,"Answer":"There is no workaround to rate limits other than polling for the rate limit status and waiting for the rate limit to be over. you can also use the flag 'wait_on_rate_limit=True'. This way tweepy will poll for rate limit by itself and sleep until the rate limit period is over.\nYou can also use the flag 'monitor_rate_limit=True' if you want to handle the rate limit \"Exception\" by yourself.\nThat being said, you should really devise some smaller geo range, since your rate limit will be reached every 0.000000001 seconds (or less... it's still twitter).","Q_Score":0,"Tags":"python,twitter,tweepy","A_Id":40072173,"CreationDate":"2016-10-16T14:34:00.000","Title":"Prevent Tweepy from falling behind","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am Publishing data from Raspberry Pi to AWS IoT and I can see the updates there. \nNow, I need to get that data into AWS Lambda and connect it to AWS SNS to send a message above a threshold. I know about working with SNS and IoT.\nI just want to know that how I can get the data from AWS IoT to AWS Lambda ?? \nPlease Help !!\nThanks :)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":471,"Q_Id":40141313,"Users Score":0,"Answer":"In IoT Code, Create a rule for invoking a Lambda to accept JSON data. Then you can do anything with that data.","Q_Score":0,"Tags":"python,amazon-web-services,aws-lambda","A_Id":56790848,"CreationDate":"2016-10-19T20:51:00.000","Title":"Stream data from AWS IoT to AWS Lambda using Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My project is composed by a main.py main script and a module aaa.py . I've succesfully setup a log procedure by using the logging package in main.py, also specifying a log filename. \nWhich is the cleanest\/\"correct\" way to let the functions contained in aaa.py to write in the same log file?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":411,"Q_Id":40154798,"Users Score":0,"Answer":"If you call only a single python script at once (main.py)\nthen you simply can define your logging config once; for exemple:\nlogging.basicConfig(filename=logfilepath, format='%(levelname)s:%(message)s')\nand call it wherever you want in the modules, for exemple\nlogging.(\"log_string\")","Q_Score":3,"Tags":"python,python-3.x,logging,module","A_Id":40155626,"CreationDate":"2016-10-20T12:41:00.000","Title":"logging package - share log file between main and modules - python 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Currently I'm developing a system to analyse and visualise textual data based on NLP. \nThe backend (Python+Flask+AWS EC2) handles the analysis, and uses an API to feed the result back to a frontend (FLASK+D3+Heroku) app that solely handles interactive visualisations.\nRight now the analysis in the prototype is a basic python function which means on large files the analysis take longer and thus resulting a request timeout during the API data bridging to frontend. As well as the analysis of many files is done in a linear blocking queue. \nSo to scale this prototype, I need to modify the Analysis(text) function to be a background task so it does not block further execution and can do a callback once the function is done. The input text is fetched from AWS S3 and the output is a relatively large JSON format aiming to be stored in AWS S3 as well, so the API bridge will simply fetch this JSON that contains data for all the graphs in the frontend app. (I find S3 slightly easier to handle than creating a large relational database structure to store persistent data..)\nI'm doing simple examples with Celery and find it fitting as a solution, however i just did some reading in AWS Lambda which on paper seems like a better solution in terms of scaling...\nThe Analysis(text) function uses a pre-built model and functions from relatively common NLP python packages. As my lack of experience in scaling a prototype I'd like to ask for your experiences and judgement of which solution would be most fitting for this scenario.\nThank you :)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":7335,"Q_Id":40173481,"Users Score":24,"Answer":"I would like to share a personal experience. I moved my heavy-lifting tasks to AWS Lambda and I must admit that the ROI has been pretty good. For instance, one of my tasks was to generate monthly statements for the customers and then mail them to the customers as well. The data for each statement was fed into a Jinja template which gave me an HTML of the statement. Using Weasyprint, I converted the HTML to a Pdf file. And then mailing those pdf statements was the last step. I researched through various options for creating pdf files directly, but they didn't looked feasible for me.\nThat said, when the scale was low, i.e. for when the number of customers was small, celery was wonderful. However to mention, during this task, I observed CPU usages went high. I would add to the celery queue this task for each of the customers, from which the celery workers would pick up the tasks and execute it.\nBut when the scale went high, celery didn't turn out to be a robust option. CPU usages were pretty high(I don't blame celery for it, but that is what I observed). Celery is still good though. But do understand this, that with celery, you can face scaling issues. Vertical scaling may not help you. So you need horizontally scale as your backend grows to get get a good performance from celery. When there are a lot of tasks waiting in the queue, and the number of workers is limited, naturally a lot of tasks would have to wait.\nSo in my case, I moved this CPU-intensive task to AWS Lambda. So, I deployed a function that would generate the statement Pdf from the customer's statement data, and mail it afterward. Immediately, AWS Lambda solved our scaling issues. Secondly, since this was more of a period task, not a daily task - so we didn't need to run celery everyday. The Lambda would launch whenever needed - but won't run when not in use. Besides, this function was in NodeJS, since the npm package I found turned out to be more efficient the solution I had in Python. So Lambda is also advantageous because you can take advantages of various programming languages, yet your core may be unchanged. Also, I personally think that Lambda is quite cheap - since the free tier offers a lot of compute time per month(GB-seconds). Also, underlying servers on which your Lambdas are taken care to be updated to the latest security patches as and when available. As you can see, my maintenance cost has drastically dropped.\nAWS Lambdas scale as per need. Plus, they can serve a good use case for tasks like real-time stream processing, or for heavy data-processing tasks, or for running tasks which could be very CPU intensive.","Q_Score":12,"Tags":"python-2.7,amazon-web-services,nlp,celery,aws-lambda","A_Id":48643501,"CreationDate":"2016-10-21T09:50:00.000","Title":"Celery message queue vs AWS Lambda task processing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am new pyomo user. I want to learn that is there any document or way to see all attributes, methods and functions of pyomo? Same issue for CBC.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":315,"Q_Id":40194860,"Users Score":2,"Answer":"Source-level documentation is not currently supported for Pyomo. The Pyomo developers have discussed whether\/how to make this a priority, but this is not yet the focus of the team.","Q_Score":1,"Tags":"python,optimization,pyomo","A_Id":40197955,"CreationDate":"2016-10-22T17:12:00.000","Title":"Pyomo attributes, methods, functions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Just discovered the amazing Raspberry Pi 3 and I am trying to learn how to use it in one of my projects.\nSetup:\n\nASP.NET app on Azure.\nRPi: \n\n\nsoftware: Raspbian, PHP, Apache 2, and MariaDB.\nhas internet access and a web server a configured.\n\n3G dongle for SMS sending, connected to the RPi.\n\nDesired scenario:\n\nwhen a specific button within the ASP app is clicked:\n\n\nthrough jQuery $.ajax() the RPi's ip is called with the parameters phoneNumber and smsType.\n\nthen the RPi:\n\n\nfetches the SMS text from a MariaDB database based on the smsType parameter.\ninvokes a Python script using the PHP exec(\"python sendSms.py -p phoneNumber -m fetchedText\", $output) (i.e. with the phone number and the fetched text):\n\n\nscript will send the AT command(s) to the dongle.\nscript will return true or false based on the action of the dongle. \n\n\necho the $output to tell the ASP what is the status.\nfinally, the ASP will launch a JavaScript alert() saying if it worked or not.\n\nThis is what I need to accomplish. For most of the parts I found resources and explanations. However, before starting on this path I want to understand few things:\n\nGeneral questions (if you think they are not appropriate, please ignore this category):\n\nWhat are the (logical) pitfalls of this scenario?\nWhat would be a simpler way to approach this?\n\nSpecific questions:\n\nIs there a size limit to consider when passing parameters through the url?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":98,"Q_Id":40195188,"Users Score":0,"Answer":"What are the (logical) pitfalls of this scenario?\nMy opion would be to pass the data and the two fields (phoneNumber and SmsType) through a POST request rather then an GET request because you can send more data in an post request and encapsulate it with JSON making it easier to handle the data.\nWhat would be a simpler approch ?\nMaybe not simple but more elegant, extend the python script with something like flask and build the webserver right into the python script, saves you running a webserver with php!","Q_Score":0,"Tags":"php,python,asp.net,raspberry-pi,sms","A_Id":40195564,"CreationDate":"2016-10-22T17:45:00.000","Title":"Calling Raspberry Pi from ASP.NET to send a SMS remotely","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have multiple python version installed in Ubuntu OS. I've set up sublime text 3 (ST3) to run python2 code successfully. But I would like to have the option to run python code using command console during debugging as well. But I found that when I open the cmd console, the python version that it used is not the same of the python that I'm building my python code. To be exact, cmd console called python3, while I would like it to use python2. Any way to set which default python that the cmd console call? Thanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":230,"Q_Id":40207785,"Users Score":0,"Answer":"Tools > Build System > New Build System\nYou can set it up there and choose your python binary","Q_Score":0,"Tags":"python,cmd,console,sublimetext3","A_Id":40207826,"CreationDate":"2016-10-23T21:04:00.000","Title":"sublime text 3: How to open command console with correct python version","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I've created tool, that runs as a server, and allow clients to connect to it through TCP, and run some commands. It's written on python 3\nNow I'm going to build package and upload it to Pypi, and have conceptual problem.\nThis tool have python client library inside, so, after installation of the package, it'll be possible to just import library into python script, and use for connection to the daemon without dealing with raw TCP\/IP.\nAlso, I have PHP library, for connection to me server, and the problem is - I don't know how to include it into my python package the right way.\nVariants, that I found and can't choose the right one:\n\nJust include library.php file into package, and after running \"pip install my_package\", I would write \"require('\/usr\/lib\/python3\/dist-packages\/my_package\/library.php')\" into my php file. This way allows to distribute library with the server, and update it synchronously, but add long ugly paths to php require instruction.\nAs library.php in placed on github repository, I could just publish it's url in the docs, and it'll be possible to just clone repository. It makes possible to clone repo, and update library by git pull. \nCreate separate package with my library.php, upload it into packagist, and use composer to download it when it's needed. Good for all composer users, and allow manual update, but doens't update with server's package.\n\nMaybe I've missed some other variants.\nI want to know what would be true python'ic and php'ic way to do this. Thanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":605,"Q_Id":40236281,"Users Score":0,"Answer":"I've decided to create separate PHP package for my PHP library, and upload it to a packagist.org, so, user could get it using php composer, but not forced to, as it would be in case of including library.php into python package.","Q_Score":0,"Tags":"php,python,python-3.x,pip,composer-php","A_Id":40252615,"CreationDate":"2016-10-25T09:29:00.000","Title":"How to include PHP library in Python package (on not do it)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing Python extension modules for my C++ application. Also, I embedded Python interpreter in the same application and use these modules. So, I am not building separately these extension modules, because modules are created and used in the same application (just add PyImport_AppendInittab(\"modulename\", &PyInit_modulename) before the Py_Initialize()). \nIf I do it like this is it possible to create Python package structure?\nCurrently, I have import module, but I need to have the possibility to use import package.module in my embedded Python interpreter.\nIs there anything for creating packages like there is a function for modules PyModule_Create()?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":159,"Q_Id":40284713,"Users Score":0,"Answer":"My further research shows that it is not possible to have packages structure in extension modules. Actually, you can create the structure using a simple trick, add a module to existing module as an object. For example, you can create the structure like this: mod1.mod2.mod3. But, it's not same like packages. You cannot use import mod1.mod2 or import mod1.mod2.mod3. You have to use import mod1, and that will import all modules. No way to import just one module.","Q_Score":0,"Tags":"python,c++","A_Id":40971453,"CreationDate":"2016-10-27T12:34:00.000","Title":"Python extension modules package structure (namespaces)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way to upload questions to \"Retrieve and Rank\" (R&R) using cURL and have them be visible in the web tool? \nI started testing R&R using web tool (which I find very intuitive). Now, I have started testing the command line interface (CLI) for more efficient uploading of question-and-answer pairs using train.py. However, I would still like to have the questions visible in web tool so that other people can enter the collection and perform training there as well. Is it possible in the present status of R&R?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":85,"Q_Id":40293466,"Users Score":1,"Answer":"Sorry, no - there isn't a public supported API for submitting questions for use in the tool. \n(That wouldn't stop you looking to see how the web tool does it and copying that, but I wouldn't encourage that as the auth step alone would make that fairly messy).","Q_Score":0,"Tags":"python,curl,ibm-watson,retrieve-and-rank","A_Id":40302783,"CreationDate":"2016-10-27T20:14:00.000","Title":"Upload questions to Retrieve and Rank using cURL, visible in webtool","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"When I run pytest --collect-only to get the list of my tests, I get them in a format like . However, when I use pytest -k ... to run a specific test, I need to input the \"address\" of the test in the format foo::test_whatever. Is it possible to get a list of all the addresses of all the tests in the same format that -k takes?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1577,"Q_Id":40314098,"Users Score":0,"Answer":"If you are using -k switch, you don't need to specify the full path separated by colons. If the path is unique, you can use just part of the path. You need full path of tests only when you are not using -k switch.\ne.g. \npytest -k \"unique_part_of_path_name\"\nfor pytest tests\/a\/b\/c.py::test_x, you can use pytest -k \"a and b and c and x\". \nYou can use boolean logic for -k switch.\nBTW, pytest --collect-only does give the file name of the test in i_ca_cert -> s_cert. Thus ca_cert signed i_ca_cert and i_ca_cert signed s_cert. Does verify_certificate() check whether the signer's (RSA) key was used to sign the certificate and whether the signature is correct, for every certificate along the chain?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":559,"Q_Id":40578207,"Users Score":0,"Answer":"But I was wondering if the function also checks the signatures along the certificate chain\n\nOf course it does. Otherwise what is the purpose of chain verification? From the OpenSSL documentation (man 1ssl verify on linux):\n\nThe final operation is to check the validity of the certificate chain. The validity period is checked against the current system time and the notBefore and notAfter dates in the certificate. The certificate signatures are also checked at this point.","Q_Score":0,"Tags":"python,x509,verification,pyopenssl","A_Id":40578492,"CreationDate":"2016-11-13T20:00:00.000","Title":"Does PyOpenSSL verify_certificate() do signature verification","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wrote 4 lambda functions in Python, one stops my dev instances at 19p.m from monday to friday, second function starts them at 7a.m from monday to friday, the third function stops the test instances at 17p.m all days of the week and the forth function starts them at 8a.m all days of the week.\nI put cloudWatch as a trigger and I created a rule with the cron expression for each one of them.\nI wonder, if there is any way to put them all together in only one function, and specify the cron expression in python inside the function ? If that's possible what would be the trigger here? Thank you.\nEdited by: Cloudgls on Nov 16, 2016 12:29 PM","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":353,"Q_Id":40613427,"Users Score":1,"Answer":"You could just have a single CloudWatch alarm trigger hourly and the Lambda function could check to see if any scheduled tasks need to run. If any evaluate to true then execute them.","Q_Score":1,"Tags":"python,cron,aws-lambda,amazon-cloudwatch,cloudwatch","A_Id":40633940,"CreationDate":"2016-11-15T15:17:00.000","Title":"AWS Lambda function with multipal cron expressions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an s3 bucket which is used for users to upload zipped directories, often 1GB in size. The zipped directory holdes images in subfolders and more. \nI need to create a lambda function, that will get triggered upon new uploads, unzip the file, and upload the unzipped content back to an s3 bucket, so I can access the individual files via http - but I'm pretty clueless as to how I can write such a function?\nMy concerns are:\n\nPyphon or Java is probably better performance over nodejs?\nAvoid running out of memory, when unzipping files of a GB or more (can I stream the content back to s3?)","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1257,"Q_Id":40627395,"Users Score":0,"Answer":"Lambda would not be a good fit for the actual processing of the files for the reasons mentioned by other posters. However, since it integrates with S3 events it could be used as a trigger for something else. It could send a message to SQS where another process that runs on EC2 (ECS, ElasticBeanstalk, ECS) could handle the messages in the queue and then process the files from S3.","Q_Score":0,"Tags":"java,python,amazon-web-services,amazon-s3,aws-lambda","A_Id":40632303,"CreationDate":"2016-11-16T08:38:00.000","Title":"AWS lambda function to retrieve any uploaded files from s3 and upload the unzipped folder back to s3 again","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"On a remote server I can execute a certain command only via \"sudo\". The authentication is done via a certificate. So when I login via SSH by a bash script, python, ruby or something else, how can I execute a certain command with sudo?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":210,"Q_Id":40630602,"Users Score":1,"Answer":"The proper way of doing this is using a configuration management solution, like ansible, You can use become directive to run script\/command with sudo privileges from a remote client.\nIf there is only one box or you need to schedule, you can use \/etc\/crontab and run it with root user at desired interval.","Q_Score":1,"Tags":"python,linux,bash,ssh","A_Id":40630667,"CreationDate":"2016-11-16T11:08:00.000","Title":"How can I execute a command with \"sudo\" in a python\/bash\/ruby script via SSH?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have some Appium testing scripts that needed to be put through a repository for version control, mainly Git.\nI looked through Google to figure out what is the best way to go about this if you have an Android App project in Andriod Studio that you're writing the tests for (which happens to be in it's own Git repository), and so far I haven't found anything in my search.\nMy question is: Would it be better if I include the test scripts inside the Android studio project in it's Git repository, or would it be better if I put the test scripts in their own repository? If putting the scripts in the Android project is better, where in the project's file structure should I include the test scripts?\nAny input is greatly appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":181,"Q_Id":40644986,"Users Score":0,"Answer":"I put my autotests in separate repository just to have them safe from deleting from my work computer or something else.\nWhen I'm sure that my tests are stable I clone dev branch of the main project and making a pull request including my tests. When my request is merged we have a project repository with autotests.\nDon't know any better ways, but for me it works great and very comfortable.","Q_Score":2,"Tags":"android,python,git,android-studio,appium","A_Id":57672871,"CreationDate":"2016-11-17T00:51:00.000","Title":"Best Practice for putting Appium Python UI test scripts in repository","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am attempting to run a package after installing it, but am getting this error:\nImportError: \/home\/brownc\/anaconda3\/lib\/python3.5\/site-packages\/dawg.cpython-35m-x86_64-linux-gnu.so: undefined symbol: _ZTVNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEE\nThe dawg....gnu.so file is binary and so it doesn't give much information when opened in sublime. I don't know enough about binary files in order to go in and remove the line or fix it. Is there a simple fix for this that I am not aware of?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":317,"Q_Id":40663830,"Users Score":1,"Answer":"I found the answer for my very specific case, for anyone that may run into this case as well:\nI am using Anaconda (python 3 version) and installing the package with conda install -c package package worked instead of pip install package.\nI hope this helps someone.","Q_Score":1,"Tags":"python,import,undefined-symbol,dawg","A_Id":40664272,"CreationDate":"2016-11-17T19:51:00.000","Title":"Import Error from binary dependency file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Say I am running a Python script in C:\\temp\\templates\\graphics. I can get the current directory using currDir = os.getcwd(), but how can I use relative path to move up in directories and execute something in C:\\temp\\config (note: this folder will not always be in C:\\)?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":930,"Q_Id":40666853,"Users Score":0,"Answer":"Try this one:\nos.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), \"config\")","Q_Score":1,"Tags":"python,file,directory,relative-path","A_Id":40666955,"CreationDate":"2016-11-17T23:24:00.000","Title":"Move up in directory structure","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"How to remove python 2.6 from Cent OS?\nI tried command yum remove python. After python --version and get again","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":210,"Q_Id":40677670,"Users Score":0,"Answer":"Python is required by many of the Linux distributions. Many system utilities the distro providers combine (both GUI based and not), are programmed in Python.\nThe version of python the system utilities are programmed in I will call the \"main\" python. For Ubuntu 12.04 e.g. this is 2.7.3, the version that you get when invoking python on a freshly installed system.\nBecause of the system utilities that are written in python it is impossible to remove the main python without breaking the system. It even takes a lot of care to update the main python with a later version in the same major.minor series, as you need to take care of compiling it with the same configuration specs as the main python. This is needed to get the correct search paths for the libraries that the main python uses, which is often not exactly what a .configure without options would get you, when you download python to do a python compilation from source.\nInstalling a different version from the major.minor version the system uses (i.e. the main python) normally is not a problem. I.e. you can compile a 2.6 or 3.4 python and install it without a problem, as this is installed next to the main (2.7.X) python. Sometimes a distro provides these different major.minor packages, but they might not be the latest bug-release version in that series.\nThe problems start when you want to use the latest in the main python series (e.g. 2.7.8 on a system with main python version is 2.7.3). I recommend not trying to replace the main python, but instead to compile and install the 2.7.8 in a separate location (mine is in \/opt\/python\/2.7.8). This will keep you on the security fix schedule of your distribution and guarantees someone else tests compatibility of the python libraries and against that version (as used by system utilities!).","Q_Score":0,"Tags":"python,linux,centos","A_Id":40677984,"CreationDate":"2016-11-18T12:54:00.000","Title":"How to remove Python in Cent OS?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to run automated test on my python script using Hudson and testlink. I configured Hudson with my testlink server but the test results are always \"not run\". Do you know how to do this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":299,"Q_Id":40680022,"Users Score":0,"Answer":"I found how to do it : \nI used testLink-API-Python-client.","Q_Score":0,"Tags":"python,automated-tests,hudson,testlink","A_Id":40722012,"CreationDate":"2016-11-18T14:53:00.000","Title":"Automate python test with testlink and hudson","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to say to clients to start my chat bot and send me username and password, then I store chat_id of them, and use it whenever I want to send a message to one of them.\nIs it possible? or chat_id will be expire?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":2478,"Q_Id":40689819,"Users Score":1,"Answer":"When a user register on telegram, server choose a unique chat_id for that user! it means the server do this automatically. thus if the user send \/start message to your bot for the first time, this chat_id will store on bot database (if you code webhook which demonstrates users statastics)\nThe answer is if the user doesnt blocked your bot you can successfully send him\/her a message. on the other hand if the user had delete accounted no ways suggest for send message to new chat id!\ni hope you got it","Q_Score":1,"Tags":"telegram,telegram-bot,python-telegram-bot,php-telegram-bot,lua-telegram-bot","A_Id":41173517,"CreationDate":"2016-11-19T06:14:00.000","Title":"Can I use chat_id to send message to clients in Telegram bot after a period of time?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have written game with base on c++ and which uses python scripts to calculate object properties and draw them. But main problem is that it won't run on pc's without python2.7 installed on them. I'm out of ideas. How i should do that, to make it run on pc's without python on them?","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":158,"Q_Id":40703741,"Users Score":3,"Answer":"Make a game installer which will install all required dependencies.","Q_Score":0,"Tags":"python,c++,python-2.7","A_Id":40703761,"CreationDate":"2016-11-20T11:56:00.000","Title":"Running program on computers without python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've ssh'd into my EC2 instance and have the python script and .txt files I'm using on my local system. What I'm trying to figure out is how to transfer the .py and .txt files to my instance and then run them there? I've not even been able to install python on the instance yet","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":3179,"Q_Id":40711286,"Users Score":1,"Answer":"If your EC2 instance is running a linux OS, you can use the following command to install python:\nsudo apt-get install python*.*\nWhere the * represents the version you want to install, such as 2.7 or 3.4. Then use the python command with the first argument as the location of the python file to run it.","Q_Score":1,"Tags":"python,amazon-ec2","A_Id":40711336,"CreationDate":"2016-11-21T00:50:00.000","Title":"How can I run a python script on an EC2 instance?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to find all possible anagrams from a phrase, for example if I input \"Donald Trump\" I should get \"Darn mud plot\", \"Damp old runt\" and probably hundreds more.\nI have a dictionary of around 100,000 words, no problems there.\nBut the only way I can think of is to loop through the dictionary and add all words that can be built from the input to a list. Then loop through the list and if the word length is less than the length of the input, loop through the dictionary again add all possible words that can be made from the remaining letters that would make it the length of the input or less. And keep looping through until I have all combinations of valid words of length equal to input length.\nBut this is O(n!) complexity, and it would take almost forever to run. I've tried it.\nIs there any way to approach this problem such that the complexity will be less? I may have found something on the net for perl, but I absolutely cannot read perl code, especially not perl golf.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":1207,"Q_Id":40724726,"Users Score":3,"Answer":"I like your idea of filtering the word list down to just the words that could possibly be made with the input letters, and I like the idea of trying to string them together, but I think there are a few major optimizations you could put into place that would likely speed things up quite a bit.\nFor starters, rather than choosing a word and then rescanning the entire dictionary for what's left, I'd consider just doing a single filtering pass at the start to find all possible words that could be made with the letters that you have. Your dictionary is likely going to be pretty colossal (150,000+, I'd suspect), so rescanning it after each decision point is going to be completely infeasible. Once you have the set of words you can legally use in the anagram, from there you're left with the problem of finding which combinations of them can be used to form a complete anagram of the sentence.\nI'd begin by finding unordered lists of words that anagram to the target rather than all possible ordered lists of words, because there's many fewer of them to find. Once you have the unordered lists, you can generate the permutations from them pretty quickly.\nTo do this, I'd use a backtracking recursion where at each point you maintain a histogram of the remaining letter counts. You can use that to filter out words that can't be added in any more, and this essentially saves you the cost of having to check the whole dictionary each time. I'd imagine this recursion will dead-end a lot, and that you'll probably find all your answers without too much effort.\nYou might consider some other heuristics along the way. For example, you might want to start with larger words first to pull out as many letters as possible and keep the branching factor low. To do that, you could sort your word list from longest to shortest and try the words in that order. You could alternatively try to use the most constrained letters up first to decrease the branching factor. These sorts of heuristics will probably work really well in practice.\nOverall you're still looking at exponential work in the worst case, but it shouldn't be too bad for shorter strings.","Q_Score":2,"Tags":"python,string,algorithm,big-o,anagram","A_Id":40732241,"CreationDate":"2016-11-21T16:21:00.000","Title":"Python: Find all anagrams of a sentence","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My pipeline have to write into SFTP as text output.\nI wonder if writing custom sink is the only option for it?\nIs there any other option? (For instance:extending 'TextIO.Write'....)","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":228,"Q_Id":40732698,"Users Score":1,"Answer":"I don't believe there is an existing sink that supports SFTP, so you would need to look at writing a custom sink, possibly based on one of the existing file-based sinks such as TextIO.Write.","Q_Score":1,"Tags":"python,sftp,google-cloud-dataflow","A_Id":40748038,"CreationDate":"2016-11-22T02:07:00.000","Title":"Have someone an experience with write output into SFTP by Data Flow Python SDK?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"For Java there are external report generation tools like extent-report,testNG. The Junit produces the xml format output for individual feature file. To get a detailed report, I don't see an option or wide approach or solution within the Behave framework.\nHow to produce the reports in Behave, do any other tools or framework needs to be added for the report generation in Behave?","AnswerCount":6,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":27370,"Q_Id":40763066,"Users Score":0,"Answer":"To have the possibility of generaring execution reports in an easy way, we have implemented the following wrapper on top of Behave, called BehaveX, that not only generates reports in HTML format, but also in xml and json formats. It also allows us to execute tests in parallel and provides some additional features that simplify the implementation of agile practices:\u00a0https:\/\/github.com\/hrcorval\/behavex","Q_Score":7,"Tags":"python,report,bdd,python-behave","A_Id":72303866,"CreationDate":"2016-11-23T11:19:00.000","Title":"How to generate reports in Behave-Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"On a traditional LAMP stack it's easy to stack up quite a few web sites one a single VPS and get very decent performance, with the VPS serving lots of concurrent requests, thanks to the web server using processes and threads making best use of multi cores cpu despite PHP (as python) being single threaded.\nIs the management of processes and threads the same on a python web stack (uwsgi + ngnix) ? On such a properly configured python stack, is it possible to achieve same result as the LAMP stack and stack several sites on same VPS with good reliability and performance making best use of cpu resources ? Does the GIL make it any different ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":26,"Q_Id":40776231,"Users Score":0,"Answer":"the problem of scaling is always the shared data . ie how your processes are going to communicate with each other so it's not a python (GIL) problem","Q_Score":1,"Tags":"php,python,apache,lamp,uwsgi","A_Id":40776697,"CreationDate":"2016-11-24T00:14:00.000","Title":"Python processes, threads as compared to PHPs for web hosting","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a use case where i want to invoke my lambda function whenever a object has been pushed in S3 and then push this notification to slack. \nI know this is vague but how can i start doing so ? How can i basically achieve this ? I need to see the structure","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1589,"Q_Id":40800757,"Users Score":0,"Answer":"You can use S3 Event Notifications to trigger the lambda function.\nIn bucket's properties, create a new event notification for an event type of s3:ObjectCreated:Put and set the destination to a Lambda function.\nThen for the lambda function, write a code either in Python or NodeJS (or whatever you like) and parse the received event and send it to Slack webhook URL.","Q_Score":3,"Tags":"python,amazon-web-services,lambda","A_Id":65574478,"CreationDate":"2016-11-25T08:40:00.000","Title":"How to write a AWS lambda function with S3 and Slack integration","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I try to use the \"pygubu\" module. I installed it via pip.\nI can import it in my script but pygubu.Builder() throws an attribute error.\nIf I do import it via console and start the script afterwards. There is no error and the script runs. \nIn the internet I found a wrong pythonpath could be the problem but I checked it, the pythonpath is pointing to the installation folder.\nDo you know what could be wrong?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":98,"Q_Id":40807243,"Users Score":0,"Answer":"Problem solved.\nThe problem was my script was named \"pygubu.py\"(same as the module i tried to import), after renaming it, everything worked. Thanks to Bryan Oakley for that info.","Q_Score":0,"Tags":"python,import,attributes","A_Id":40859783,"CreationDate":"2016-11-25T14:32:00.000","Title":"Python attribut error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any automated way to test that code is compatible with both Python 2 and 3? I've seen plenty of documentation on how to write code that is compatible with both, but nothing on automatically checking. Basically a kind of linting for compatibility between versions rather than syntax\/style.\nI have thought of either running tests with both interpreters or running a tool like six or 2to3 and checking that nothing is output; unfortunately, the former requires that you have 100% coverage with your tests and I would assume the latter requires that you have valid Python 2 code and would only pick up issues in compatibility with Python 3.\nIs there anything out there that will accomplish this task?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":4817,"Q_Id":40815079,"Users Score":1,"Answer":"Could you not look at the output from 2to3 to see if any code changes may be necessary ?","Q_Score":4,"Tags":"python,python-2.7,python-3.x,version","A_Id":40815167,"CreationDate":"2016-11-26T04:57:00.000","Title":"Checking code for compatibility with Python 2 and 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any automated way to test that code is compatible with both Python 2 and 3? I've seen plenty of documentation on how to write code that is compatible with both, but nothing on automatically checking. Basically a kind of linting for compatibility between versions rather than syntax\/style.\nI have thought of either running tests with both interpreters or running a tool like six or 2to3 and checking that nothing is output; unfortunately, the former requires that you have 100% coverage with your tests and I would assume the latter requires that you have valid Python 2 code and would only pick up issues in compatibility with Python 3.\nIs there anything out there that will accomplish this task?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":4817,"Q_Id":40815079,"Users Score":4,"Answer":"There is no \"fool-proof\" way of doing this other than running the code on both versions and finding inconsistencies. With that said, CPython2.7 has a -3 flag which (according to the man page) says:\n\nWarn about Python 3.x incompatibilities that 2to3 cannot trivially fix.\n\nAs for the case where you have valid python3 code and you want to backport it to python2.x -- You likely don't actually want to do this. python3.x is the future. This is likely to be a very painful problem in the general case. A lot of the reason to start using python3.x is because then you gain access to all sorts of cool new features. Trying to re-write code that is already relying on cool new features is frequently going to be very difficult. Your much better off trying to upgrade python2.x packages to work on python3.x than doing things the other way around.","Q_Score":4,"Tags":"python,python-2.7,python-3.x,version","A_Id":40815143,"CreationDate":"2016-11-26T04:57:00.000","Title":"Checking code for compatibility with Python 2 and 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a cache object designed to hold variables shared across modules.\nConcurrent threads are accessing & writing to that cache object using a cache handler that uses variable locking to keep the cache integrity.\nThe cache holds all variables under a unique session id. When a new session id is created, it has to reference the old one, copying some of the variables into a new session.\nSome session ids will be running concurrently too.\nI need to clear out the cache as soon as all concurrent threads are done referencing it, and all new sessions have copied the variables from it into their session.\nThe problem...\nI don't know when it's safe to clear the cache.\nI have hundreds of threads making API calls of variable time. New sessions will spawn new threads. I can't just look at active threads to determine when to clear the cache. \nMy cache will grow to infinite size & eventually crash the program.\nI believe this must be a common problem. And those far smarter then me have through I through.\nAny ideas how to best solve this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":56,"Q_Id":40823017,"Users Score":1,"Answer":"You can solve this issue with locking... create a Cleaner thread that sometimes locks the cache (take all the locks that you have on it) and clears it, then release the locks...\n(if you have many locks for different part of the cache, you can also lock & clear the cache piece by piece...)","Q_Score":0,"Tags":"multithreading,caching,concurrency,python-multithreading","A_Id":41227442,"CreationDate":"2016-11-26T20:50:00.000","Title":"Cache growing infinitely large because of concurrent threads","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm wondering how it's possible to not hard-code a string, for example, an IP in some software, or in remote connection software.\nI heared about a Cyber Security Expert which found the IP of someone who was hacking people in hes software, and with that they tracked him.\nSo, how can I avoid hardcoding my IP in to the software, and how do people find my IP if I do hardcode it?","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":933,"Q_Id":40851318,"Users Score":0,"Answer":"You could do any of these: 1) read the string from a file, 2) read the string from a database, 3) pass the string as a command line argument","Q_Score":0,"Tags":"python,string,hardcoded","A_Id":40851410,"CreationDate":"2016-11-28T18:44:00.000","Title":"How to not hardcode a String in a software?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm wondering how it's possible to not hard-code a string, for example, an IP in some software, or in remote connection software.\nI heared about a Cyber Security Expert which found the IP of someone who was hacking people in hes software, and with that they tracked him.\nSo, how can I avoid hardcoding my IP in to the software, and how do people find my IP if I do hardcode it?","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":933,"Q_Id":40851318,"Users Score":0,"Answer":"One option is to use asymmetric encryption, you can request the private string from a server using it (see SSL\/TLS).\nIf you want to do it locally you should write\/read to a file (OS should take care of authorization, by means of user access)","Q_Score":0,"Tags":"python,string,hardcoded","A_Id":40851444,"CreationDate":"2016-11-28T18:44:00.000","Title":"How to not hardcode a String in a software?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm wondering how it's possible to not hard-code a string, for example, an IP in some software, or in remote connection software.\nI heared about a Cyber Security Expert which found the IP of someone who was hacking people in hes software, and with that they tracked him.\nSo, how can I avoid hardcoding my IP in to the software, and how do people find my IP if I do hardcode it?","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":933,"Q_Id":40851318,"Users Score":0,"Answer":"If you want to hide it, Encrypt it, you see this alot on github where people accidently post their aws keys or what not to github because they didnt use it as a \"secret\".\nalways encrypt important data, never use hardcoded values like ip as this can easily be changed, some sort of dns resolver can help to keep you on route.\nin this specific case you mentioned using a DNS to point to a proxy will help to mask the endpoint ip.","Q_Score":0,"Tags":"python,string,hardcoded","A_Id":43877881,"CreationDate":"2016-11-28T18:44:00.000","Title":"How to not hardcode a String in a software?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm wondering how it's possible to not hard-code a string, for example, an IP in some software, or in remote connection software.\nI heared about a Cyber Security Expert which found the IP of someone who was hacking people in hes software, and with that they tracked him.\nSo, how can I avoid hardcoding my IP in to the software, and how do people find my IP if I do hardcode it?","AnswerCount":4,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":933,"Q_Id":40851318,"Users Score":1,"Answer":"There are several ways to obscure a hard-coded string. One of the simplest is to XOR the bits with another string or a repeated constant. Thus you could have two hardcoded short arrays that, when XORed together, produce the string you want to obscure.","Q_Score":0,"Tags":"python,string,hardcoded","A_Id":40852193,"CreationDate":"2016-11-28T18:44:00.000","Title":"How to not hardcode a String in a software?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently opened an account with PythonAnywhere and learnt it is an online IDE and web hosting service but as a beginner in python 3.4, what exactly can i do with it?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3662,"Q_Id":40867474,"Users Score":5,"Answer":"PythonAnywhere dev here, \nYou can use PythonAnywhere to do most of the things you can do on your own computer with Python\n\nstart a Python interactive console (from the \"Consoles\" tab)\nedit a python file and run it (from the \"Files\" tab)\n\nThe exception is that, if you want to do things with graphics, like use pygame, that won't work on PythonAnywhere. But most text-based console things will work.\nYou can also do some more funky things, like host a web application (\"Web\"), and schedule tasks to run at regular intervals (\"Schedule\"). If you upgrade to a premium account, you can also run \"Jupyter Notebooks\", which are popular in the scientific commmunity.\nIf you need help with anything, drop us a line to support@pythonanywhere.com","Q_Score":1,"Tags":"python-3.x,pythonanywhere","A_Id":40895650,"CreationDate":"2016-11-29T13:44:00.000","Title":"What is Python Anywhere used for?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running a very simple code to test cx_Freeze module but when running appears the error above. \nI am using Python 3.5 and the new version (5.0) of cx_Freeze. \nCODE:\nCalling cx_Freeze: \nfrom cx_Freeze import setup \nExecutable setup( name = \"Prueba\", version = \"0.1\", description = \"My application!\" \nexecutables = [Executable(\"pruebas.py\")]) \npruebas.py: text='Hello' print(text)\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":761,"Q_Id":40871841,"Users Score":0,"Answer":"there is 2 type cx_freeze installation package: amd64 or win32\nMake sure that what you have is the good version. I firstly installed the version amd64,but apperently my python version is 32bits. So i met the same pb as yours. Try another one, maybe you can success.","Q_Score":0,"Tags":"python,module","A_Id":42648333,"CreationDate":"2016-11-29T17:15:00.000","Title":"Python cx_Freeze error \u201cNo module named 'cx_Freeze.util'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to include in my source .rst file literal producing text like:\n\n::\n\n @reboot myscript\n\nHowever @reboot appears in boldface. Did not find how to avoid it.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":33,"Q_Id":40887074,"Users Score":0,"Answer":"Very easy -- just precede with the following line:\n.. highlight:: none\nOtherwise Sphinx assumes it is Python code (default)!","Q_Score":0,"Tags":"python-sphinx","A_Id":41701850,"CreationDate":"2016-11-30T11:22:00.000","Title":"Character @ in a :: literal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am debugging decode_raw_op_test from TensorFlow. The test file is written in python however it executes code from underlying C++ files. \nUsing pdb, I could debug python test file however it doesn't recognize c++ file. Is there a way in which we can debug underlying c++ code?\n(I tried using gdb on decode_raw_op_test but it gives \"File not in executable format: File format not recognized\")","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3923,"Q_Id":40889221,"Users Score":0,"Answer":"Adding on mrry's answer, in today's TF2 environment, the main entry point would be TFE_Execute, this should be where you add the breakpoint.","Q_Score":6,"Tags":"python,gdb,tensorflow,pdb","A_Id":68941661,"CreationDate":"2016-11-30T13:08:00.000","Title":"Debugging TensorFlow tests: pdb or gdb?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"C's read:\n\nThe read() function shall attempt to read nbyte bytes from the file associated with the open file descriptor, fildes, into the buffer pointed to by buf.\nUpon successful completion, these functions shall return a non-negative integer indicating the number of bytes actually read. Otherwise, the functions shall return \u22121 and set errno to indicate the error.\n\nPython's read:\n\nRead at most n characters from stream.\nRead from underlying buffer until we have n characters or we hit EOF.\n If n is negative or omitted, read until EOF.\n\nBold fonts are mine. Basically Python will insist on finding EOF if currrently available data is less than buffer size... How to make it simply return whatever is available?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1069,"Q_Id":40894943,"Users Score":3,"Answer":"By \"Python's read\" I assume you mean the read method of file objects. That method is closer in spirit to C's fread: it implements buffering and it tries to satisfy the requested amount, unless that is impossible due to an IO error or end-of-file condition.\nIf you really need to call the read() function available in many C environments, you can call os.read() to invoke the underlying C function. The only difference is that it returns the data read as a byte string, and it raises an exception in the cases when the C function would return -1.\nIf you call os.read(), remember to give it the file descriptor obtained using the fileno method on file objects, or returned by functions in the os module such as os.open, os.pipe, etc. Also remember not to mix calls to os.open() and file.open(), since the latter does buffering and can cause later calls to os.open() not to return the buffered data.","Q_Score":1,"Tags":"python,c","A_Id":40895004,"CreationDate":"2016-11-30T17:47:00.000","Title":"What's Python's equivalent to C's read function?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"If I were to create a module that was called for example imp_mod.py and inside it contained all (subjectively used) relevant modules that I frequently used.\nWould importing this module into my main program allow me access to the imports contained inside imp_mod.py?\nIf so, what disadvantages would this bring? \nI guess a major advantage would be a reduction of time spent importing even though its only a couple of seconds saved...","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2324,"Q_Id":40896575,"Users Score":0,"Answer":"As lucasnadalutti mentioned, you can access them by importing your module.\nIn terms of advantages, it can make your main program care less about where the imports are coming from if the imp_mod handles all imports, however, as your program gets more complex and starts to include more namespaces, this approach can get more messy. You can start to handle a bit of this by using __init__.py within directories to handle imports to do a similar thing, but as things get more complex, personally, I feel it add a little more complexity. I'd rather just know where a module came from to look it up.","Q_Score":2,"Tags":"python","A_Id":40896863,"CreationDate":"2016-11-30T19:25:00.000","Title":"What benefits or disadvantages would importing a module that contains 'import' commands?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Right, i have a bot that has 2 shards, each on their own server. I need a way to share data between the two, preferably as files, but im unsure how to achieve this.\n\nThe bot is completely python3.5 based\nThe servers are both running Headless Debian Jessie\nThe two servers arent connected via LAN, so this has to be sharing data over the internet\nThe data dosent need to be encrypted, as no sensitive data is shared","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":27,"Q_Id":40898087,"Users Score":0,"Answer":"Probably the easiest to achive, that is also secure is to use sshfs between the servers.","Q_Score":0,"Tags":"debian,python-3.5,file-sharing","A_Id":40911268,"CreationDate":"2016-11-30T20:58:00.000","Title":"Share data between two scripts on different servers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How would you start SimpleHTTPServer when the Pi boots up?\nI made a startup.sh with python -m SimpleHTTPServer & but no luck","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":231,"Q_Id":40963218,"Users Score":2,"Answer":"Did you try using @restart \"your command\" in your crontab?\nTry crontab -e, and see add @restart python -m SimpleHTTPServer","Q_Score":2,"Tags":"python,raspberry-pi,raspbian","A_Id":40967869,"CreationDate":"2016-12-04T20:21:00.000","Title":"Run Python SimpleHTTPServer when raspberry Pi turns on","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Does allure plugin for python have setup\/teardown facilities, like those of python unittest module?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":539,"Q_Id":40971318,"Users Score":1,"Answer":"Allure just add addtitional categories like steps for tests and features\/stories for group of test. Test fixture is responsibility of testing framework not reporting like Allure.","Q_Score":1,"Tags":"python,python-unittest,allure","A_Id":41627450,"CreationDate":"2016-12-05T09:46:00.000","Title":"Does allure plugin for python have setup\/teardown facilities?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Does allure plugin for python have setup\/teardown facilities, like those of python unittest module?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":539,"Q_Id":40971318,"Users Score":1,"Answer":"There are no such facilities like setUp or tearDown in allure.\nBut you can use the py.test fixtures to implement setUp and tearDown by yourself.","Q_Score":1,"Tags":"python,python-unittest,allure","A_Id":45822745,"CreationDate":"2016-12-05T09:46:00.000","Title":"Does allure plugin for python have setup\/teardown facilities?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I failed to get approval for my application that I started to write against the TradeMe API. My API access was not approved. I'm therefore looking for alternatives.\nAny NZ property for sale APIs out there? I have seen realestate.co.nz which according to the github repo, might provide something in PHP and Ruby, but the Ruby repo hasn't been touched in several years. Google API perhaps?\nI'm specifically interested in obtaining geo-location information for the properties on sale.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":453,"Q_Id":40973950,"Users Score":0,"Answer":"realestate.co.nz seems to have both Javascript and Ruby APIs. I'm going to investigate the possibility of building a Python port as their code is on github\/realestate.co.nz \nI have no financial interest in either TradeMe or realestate.co.nz, for the record. Just a guy trying to avoid screen scraping.","Q_Score":0,"Tags":"python,rest,gis","A_Id":41084870,"CreationDate":"2016-12-05T12:07:00.000","Title":"NZ Property for sale API","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I failed to get approval for my application that I started to write against the TradeMe API. My API access was not approved. I'm therefore looking for alternatives.\nAny NZ property for sale APIs out there? I have seen realestate.co.nz which according to the github repo, might provide something in PHP and Ruby, but the Ruby repo hasn't been touched in several years. Google API perhaps?\nI'm specifically interested in obtaining geo-location information for the properties on sale.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":453,"Q_Id":40973950,"Users Score":0,"Answer":"The sandbox should let you access trademe without the need to access the main server.","Q_Score":0,"Tags":"python,rest,gis","A_Id":41067476,"CreationDate":"2016-12-05T12:07:00.000","Title":"NZ Property for sale API","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm new to AWS Lambda and pretty new to Python. \nI wanted to write a python lambda that uses the AWS API.\nboto is the most popular python module to do this so I wanted to include it.\nLooking at examples online I put import boto3 at the top of my Lambda and it just worked- I was able to use boto in my Lambda.\nHow does AWS know about boto? It's a community module. Are there a list of supported modules for Lambdas? Does AWS cache its own copy of community modules?","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":70,"Q_Id":40981908,"Users Score":3,"Answer":"AWS Lambda's Python environment comes pre-installed with boto3. Any other libraries you want need to be part of the zip you upload. You can install them locally with pip install whatever -t mysrcfolder.","Q_Score":1,"Tags":"python,amazon-web-services,aws-lambda","A_Id":40981986,"CreationDate":"2016-12-05T19:33:00.000","Title":"How does AWS know where my imports are?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Currently, I am doing a project about Nao Robot. I am having problem with importing the python class file into choregraphe. So anyone knows how to do this? \nError message\n\n[ERROR] behavior.box :init:8 _Behavior__lastUploadedChoregrapheBehaviorbehavior_127183361\u200c\u200b6__root__RecordSound\u200c\u200b_3__RecSoundFile_4: ALProxy::ALProxy Can't find service:","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":272,"Q_Id":40989958,"Users Score":0,"Answer":"You can add any path to the PYTHONPATH environment variable from within your behavior. However, this has bad side effects, like:\n\nIf you forget to remove the path from the environment right after importing your module, you won't know anymore where you are importing modules from, since there is only one Python context for the whole NAOqi and all the behaviors.\nFor the same reason (a single Python context), you'll need to restart NAOqi if you change the module you are trying to import.","Q_Score":0,"Tags":"python,ibm-cloud,nao-robot","A_Id":41919816,"CreationDate":"2016-12-06T07:26:00.000","Title":"How to import IBM Bluemix Watson speech-to-text in Choregraphe?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Let's say that I have a python function that only sends email to myself, that I want to call whenever the user clicks on a button in a template, without any redirection (maybe just a popup messege).\nIs there a way to do that?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":981,"Q_Id":41020807,"Users Score":0,"Answer":"In your views you can handle any incoming get\/post requests. And based on handler for that button (and this button obviously must send something to server) you can call any function.","Q_Score":0,"Tags":"python,django,django-templates,django-views","A_Id":41021233,"CreationDate":"2016-12-07T15:03:00.000","Title":"Django: call python function when clicking on button","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to run a python script which executes a GUI on startup(as pi boots up). But I don't see any GUI on screen but when I open terminal my program executes automatically and GUI appears. Also, my program requires an internet connection on execution but pi connects to wifi later and my script executes first and ends with not connecting to the internet. \nIs there any way my python script executes after pi boots up properly and pi connected with internet","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":7947,"Q_Id":41021109,"Users Score":3,"Answer":"Without knowing you Pi setup it's a bit difficult. But with the assumption you're running raspbian with its default \"desktop\" mode:\n\nOpen a terminal on your Pi, either by sshing to it or connecting a monitor\/keyboard. \nFirst we need to allow you to login automatically, so sudo nano \/etc\/inittab to open the inittab for editing.\nFind the line 1:2345:respawn:\/sbin\/getty 115200 tty1 and change it to #1:2345:respawn:\/sbin\/getty 115200 tty1\nUnder that line, add 1:2345:respawn:\/bin\/login -f pi tty1 <\/dev\/tty1 >\/dev\/tty1 2>&1. Type Ctrl+O and then Ctrl+X to save and exit\nNext, we can edit the rc.local. sudo nano \/etc\/rc.local\nAdd a line su -l pi -c startx (replacing pi with the username you want to launch as) above the exit 0 line. This will launch X on startup, which allows other applications to use graphical interfaces.\nAdd the command you'd like to run below the previous line (e.g python \/path\/to\/mycoolscript.py &), but still above the exit 0 line.\nNote the & included here. This \"forks\" the process, allowing other commands to run even if your script hasn't exited yet. Ctrl+O and Ctrl+X again to save and exit.\n\nNow when you power on your Pi, it'll automatically log in, start X, and then launch the python script you've written!\n\nAlso, my program requires an internet connection on execution but pi connects to wifi later and my script executes first and ends with not connecting to the internet.\n\nThis should be solved in the script itself. Create a simple while loop that checks for internet access, waits, and repeats until the wifi connects.","Q_Score":2,"Tags":"python,user-interface,terminal,raspberry-pi","A_Id":41022529,"CreationDate":"2016-12-07T15:17:00.000","Title":"raspberry pi : Auto run GUI on boot","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to get pySerial to communicate with a microcontroller over an FTDI lead at a baud rate of 500,000. I know my microcontroller and FTDI lead can both handle it as can my laptop itself, as I can send to a putty terminal at that baud no problem. However I don't get anything when I try to send stuff to my python script with pySerial, although the same python code works with a lower baud rate.\nThe pySerial documentation says:\n\"The parameter baudrate can be one of the standard values: 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200. These are well supported on all platforms.\nStandard values above 115200, such as: 230400, 460800, 500000, 576000, 921600, 1000000, 1152000, 1500000, 2000000, 2500000, 3000000, 3500000, 4000000 also work on many platforms and devices.\"\nSo, I'm assuming why it's not working is because my system doesn't support it, but how do I check what values my system supports\/is there anything I can do to make it work? I unfortunately do need to transmit at least 250,000 and at a nice round number like 250,000 or 500000 (to do with clock error on the microcontroller).\nThanks in advance for your help!","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":3411,"Q_Id":41022923,"Users Score":2,"Answer":"So I found that the rounded numbers didn't work i.e. 100000, 200000, 250000 but the multiples of 115200 do. i.e. 230400, 460800\nI tried to use 230400 at first but the baud rate my microcontroller can produce is either 235294 or 222222. 235294 yields an error of -2.1% and 222222 yields an error of 3.55%. I naturally picked the one with the lower error however it didn't work and didn't bother trying 222222. For some reason 222222 works when 235294 though. So I don't actually have to use the 250000 baud rate I initially thought I'd have to.\nI still don't know why pyserial doesn't work with those baud rates when putty does, so clearly my laptop can physically do it. Anyway will know in future to try more standard baud rates as well as when using microcontrollers which can't produce the exact baud rate required to try frequencies both above and below.","Q_Score":3,"Tags":"python,pic,pyserial,ftdi","A_Id":41058265,"CreationDate":"2016-12-07T16:45:00.000","Title":"PySerial - Max baud rate for platform (windows)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have gone through many source code of functional test cases written in python. Many of the code uses assert for testing equality, why so?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":224,"Q_Id":41024605,"Users Score":3,"Answer":"In most test runners, a test failure is indicated by raising an exception - which is what the assert() function does if its argument evaluates to False.\nThus assert(1 == 0) will fail, and abort that specific test with an AssertionError exception. This is caught by the test framework, and the test is marked as having failed. \nThe framework\/test-runner then moves on to the next test.","Q_Score":0,"Tags":"python","A_Id":41024664,"CreationDate":"2016-12-07T18:21:00.000","Title":"Use of assert statement in test cases written in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm processing a bulk of midi files that are made for existing pop songs using music21.\nWhile channel 10 is reserved for percussions, melodic tracks are all over different channels, so I was wondering if there is an efficient way to pick out the main melody (vocal) track.\nI'm guessing one way to do it is to pick a track that consists of single notes rather than overlapping harmonics (chords), and the one that plays throughout the song, but is there any other efficient way?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1661,"Q_Id":41038457,"Users Score":0,"Answer":"The SMF format has no restrictions on how events are organized into tracks. It is common to have one track per channel, but it's also possible to have multiple channels in one track, or multiple tracks with events for the same channel.\nThe organization of the tracks is entirely determined by humans. It is unlikely that you can write code that can correctly determine how some random brain works.\nAll you have to go on are conventions (e.g., melody is likely to be in the first track(s), or has a certain structure), but you have to know if these conventions are actually used in the files you're handling.","Q_Score":3,"Tags":"python,midi,music21","A_Id":41043154,"CreationDate":"2016-12-08T11:32:00.000","Title":"music21: picking out melody track","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wrote an optimization function in Julia 0.4 and I want to call it from Python. I'm storing the function in a .jl file in the same working directory as the Python code. The data to be transferred is numeric, and I think of using Numpy arrays and Julia arrays for calls. Is there a tutorial on how to make this work?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":569,"Q_Id":41041998,"Users Score":2,"Answer":"In my experience, calling Julia using the Python pyjulia package is difficult and not a robust solution outside HelloWorld usage. \n1) pyjulia is very neglected. \nThere is practically no documentation aside the source code. For example, the only old tutorials I've found still use julia.run() that was replaced by julia.eval(). pyjulia is not registered on PyPI, the Python Package Index. Many old issues have few or no responses. And buggy, particularly with heavy memory usage and you could run into mysterious segfaults. Maybe, garbage collector conflicts...\n2) You should limit pyjulia use to Julia functions that return simple type\nJulia objects imported to python using pyjulia are difficult to use. pyjulia doesn't import any type constructors. For example, pyjulia seems to convert complex Julia types into plain python matrix.\n3) If you can isolate the software modules and manage the I\/O, you should consider the shell facility, particularly in Linux \/ Unix environment.","Q_Score":1,"Tags":"python,julia","A_Id":45740595,"CreationDate":"2016-12-08T14:37:00.000","Title":"Calling a Julia 0.4 function from Python. How i can make it work?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Our software is modular and I have about 20 git repos in one project.\nIf a test fails, it is sometimes hard to find the matching commit since several developers work on these 20 repos.\nI know the test worked yesterday and fails reproachable today.\nSometimes I use git-bisec, but this works only for one git repo.\nOften changes in two git repos make a test fail.\nI could write a dirty script which loops over my N git repos myself, but before doing so, I would like to know how experts would solve this.\nI use Python, Django and pytest, but AFAIK this does not matter for this question.","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":670,"Q_Id":41056925,"Users Score":3,"Answer":"There is category of QA tool for \"reverse dependency\" CI builds. So your higher level projects get rebuilt every time a lower level change is made. At scale it can be resource intensive. \nThe entire class of problem is removed if you stop dealing with repo-to-repo relationships and start following version release methodology for the subcomponents. Then you can track the versions of lower-level dependencies and know when you go to upgrade that it broke. Your CI could build against several versions of dependencies if you wanted to systematize it.\nGit submodules accomplish that tracking for individual commits, so you again get to decide when to incorporate changes from lower levels. (Notably, that can also be used like released versions if you only ever update to tagged release commits.)","Q_Score":8,"Tags":"python,git,debugging,git-bisect","A_Id":41160672,"CreationDate":"2016-12-09T09:19:00.000","Title":"git-bisect, but for N repos","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using a python script (3.5.2) and a RabbitMQ worker queue to process data. There is a queue that is filled with user requests of an external system. These user requests will be processed by my python script, each user request results in several output messages. I use the acknoledge functionality to ensure that the incoming message will be deleted only after processing it. This ensures that the message will be reassigned if the worker occasionally dies. But if the worker dies during sending out messages it could be possible that some messages of this user request are already sent to the queue and others wont be sent. Is there a way to send several messages atomically, i. e. sent all messages or none?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":134,"Q_Id":41064321,"Users Score":0,"Answer":"Yes, there is - wrap all messages in response to a request as a transaction.","Q_Score":0,"Tags":"python,python-3.x,rabbitmq","A_Id":41069086,"CreationDate":"2016-12-09T15:59:00.000","Title":"Make message sending to RabbitMQ atomic","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"How can you write a python script to read Tensorboard log files, extracting the loss and accuracy and other numerical data, without launching the GUI tensorboard --logdir=...?","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":18729,"Q_Id":41074688,"Users Score":8,"Answer":"To finish user1501961's answer, you can then just export the list of scalars to a csv file easily with pandas pd.DataFrame(ea.Scalars('Loss)).to_csv('Loss.csv')","Q_Score":37,"Tags":"python,machine-learning,tensorflow,tensorboard","A_Id":44529522,"CreationDate":"2016-12-10T10:53:00.000","Title":"How do you read Tensorboard files programmatically?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm fairly new to the language and am wondering if it's possible to see the functions that are being used in a certain Python 3 module?\nSpecifically the ones in the \"ipaddress\" module, thanks!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":48,"Q_Id":41082947,"Users Score":1,"Answer":"In addition to getting the source code online, if you have a standard Python install it should be already sitting in an easily found location on your hard-drive. In my case it is found as a file in C:\\Python34\\Lib. Needless to say, if you go this route you need to be careful to not modify (or, even worse, delete) the file.","Q_Score":0,"Tags":"python,python-3.x","A_Id":41083279,"CreationDate":"2016-12-11T04:17:00.000","Title":"Is there any way to see source functions in Python 3 Modules?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know how to send email through Outlook\/Gmail using the Python SMTP library. However, I was wondering if it was possible to receive replys from those automated emails sent from Python.\nFor example, if I sent an automated email from Python (Outlook\/Gmail) and I wanted the user to be able to reply \"ok\" or \"quit\" to the automated email to either continue the script or kick off another job or something, how would I go about doing that in Python?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":308,"Q_Id":41107643,"Users Score":0,"Answer":"SMTP is only for sending. To receive (read) emails, you will need to use other protocols, such as POP3, IMAP4, etc.","Q_Score":0,"Tags":"python,email,outlook","A_Id":41108481,"CreationDate":"2016-12-12T18:57:00.000","Title":"Python SMTP Send Email and Receive Reply","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm thinking of ways to break unit test and can't figure out a way for a unit test to return positive even when it shouldn't all the time regardless of whether you know the tests or not.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":20,"Q_Id":41111612,"Users Score":0,"Answer":"The easiest way to do this is to not even evaluate the test. If you are going to just return that it passed anyway, just remove the if statement from your code, and replace it with just the return.","Q_Score":0,"Tags":"python-3.x,unit-testing","A_Id":41235098,"CreationDate":"2016-12-12T23:53:00.000","Title":"Is there a way to make unit test return that every test passed even when it didn't? (Python 3)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm parsing PDFs with pdfMiner, using it as a library in my python script.\nIn most of these PDFs there is a table, where one of the columns is named \"company\".\nIs there a way to:\n1) detect the existence of that table in the PDF.\n2) get all the company names (i.e. all the entries in the 2nd column of the table).\nThanks for your help\nAC","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":416,"Q_Id":41139417,"Users Score":0,"Answer":"The best method I found so far is to use the HTMLconverter class in the pdfminer lib. This allows you to convert the pdf in HTML format, and it is easier to figure out tables, rows and columns. In my case at least: it may work with all kinds of tables in a PDF file.","Q_Score":1,"Tags":"python,parsing,pdf,pdfminer","A_Id":41146378,"CreationDate":"2016-12-14T09:47:00.000","Title":"pdfminer - accessing PDF table","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using the Pydev plugin for eclipse to create a small python script. I need to write some data into excell sheets using python .Searching on the internet ,i got xlwt to be the best solution for this .\nI downloaded and unpacked the package for xlwt and installed it using easy_install.But still after this i am not able to import the package into my pydev project in eclipse .\nIs there something that I am missing here ? \nIf not xlwt ,is there some other way in which I can write data to excell ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":97,"Q_Id":41163207,"Users Score":0,"Answer":"I got the thing working .Turns out XLWT dooesnt support Python 3.X ,they have a different version XLWT-future for3.X versions. The new one is working now .","Q_Score":0,"Tags":"python,eclipse,pydev","A_Id":41178965,"CreationDate":"2016-12-15T11:36:00.000","Title":"Working with XLWT in pydev","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running Android Studio 2.2.3\nI need to run Python scripts during my development to process some data files. The final apk does not need to run Python in the device.\nAt the moment I run the scripts from a terminal or from PyDev for Eclipse, but I was looking for a way of doing it from Android Studio.\nThere seems to be a way to do this, as when I right-click on a .py file and select the 'Run' option, an 'Edit configuration' dialog opens where I can configure several options. The problem is that I cannot specify the Python interpreter, having to select it from a combo box of already configured Python SDKs. While there is no interpreter selected, there is an error message stating \"Error: Please select a module with a valid Python SDK\". \nI managed to create Java modules for my project, but not Python ones (I do have the Python Community Edition plugin installed).Does anybody know how to achieve this?.\nTIA.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":25025,"Q_Id":41166406,"Users Score":6,"Answer":"If you only need to run the scripts and not to edit them, the easiest way to do so is to configure an external tool through Settings | Tools | External Tools. This doesn't require the Python plugin or any Python-specific configuration; you can simply specify the command line to execute. External tools appear as items in the Tools menu, and you can also assign keyboard shortcuts to them using Settings | Keymap.","Q_Score":9,"Tags":"python,android-studio","A_Id":41166600,"CreationDate":"2016-12-15T14:19:00.000","Title":"Running Python scripts inside Android Studio","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using green for my python project. I have a problem on knowing which part of the code that still uncovered with the unit test. When I run the green using green -vvv --run-coverage, on the result, it only shows the percentage of the covered code. How could I know which part of the code that were not covered? Is there any additional syntax that I can use in order to show the uncovered code?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":231,"Q_Id":41182536,"Users Score":2,"Answer":"Sorry for the delay! I didn't see this question come in!\nCoverage 4.1 changed default internal behavior which disabled the missing line output in coverage through Green. This was fixed in Green 2.5.3.\nSo either use Coverage < 4.1 or Green >= 2.5.3 and you should get the missing lines output.","Q_Score":3,"Tags":"python,unit-testing,python-green","A_Id":43283913,"CreationDate":"2016-12-16T10:40:00.000","Title":"Show code coverage in python using green","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to make an ai following the alpha-beta pruning method for tic-tac-toe. I need to make checking a win as fast as possible, as the ai will goes through many different possible game states. Right now I have thought of 2 approaches, neither which is very efficient.\n\nCreate a large tuple for scoring every possible 4 in a row win conditions, and loop through that. \nUsing for loops, check horizontally, vertically, diag facing left, and diag facing right. This seems like it would be much slower that #1.\n\nHow would someone recommend doing it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":812,"Q_Id":41185646,"Users Score":0,"Answer":"From your question, it's a bit unclear how your approaches would be implemented. But from the alpha-beta pruning, it seems as if you want to look at a lot of different game states, and in the recursion determine a \"score\" for each one. \nOne very important observation is that recursion ends once a 4-in-a-row has been found. That means that at the start of a recursion step, the game board does not have any 4-in-a-row instances. \nUsing this, we can intuitively see that the new piece placed in said recursion step must be a part of any 4-in-a-row instance created during the recursion step. This greatly reduces the search space for solutions from a total of 69 (21 vertical, 24 horizontal, 12+12 diagonals) 4-in-a-row positions to a maximum of 13 (3 vertical, 4 horizontal, 3+3 diagonal).\nThis should be the baseline for your second approach. It will require a maximum of 52 (13*4) checks for a naive implementation, or 25 (6+7+6+6) checks for a faster algorithm. \nNow it's pretty hard to beat 25 boolean checks for this win-check I'd say, but I'm guessing that your #1 approach trades some extra memory-usage to enable less calculation per recursion step. The simplest way of doing this would be to store 8 integers (single byte is fine for this application) which represent the longest chains of same-color chips that can be found in any of the 8 directions. \nUsing this, a check for win can be reduced to 8 boolean checks and 4 additions. Simply get the chain lengths on opposite sides of the newly placed chip, check if they're the same color as the chip, and if they are, add their lengths and add 1 (for the newly placed chip).\nFrom this calculation, it seems as if your #1 approach might be the most efficient. However, it has a much larger overhead of maintaining the data structure, and uses more memory, something that should be avoided unless you can pass by reference. Also (assuming that boolean checks and additions are similar in speed) the much harder approach only wins by a factor 2 even when ignoring the overhead. \nI've made some simplifications, and some explanations maybe weren't crystal clear, but ask if you have any further questions.","Q_Score":0,"Tags":"python,performance,python-3.x,artificial-intelligence","A_Id":41199608,"CreationDate":"2016-12-16T13:35:00.000","Title":"fastest Connect 4 win checking method","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have my project settings in settings.py file. There are database names, user names, host names etc. defined there. In project files I do import settings and then use the constants where needed like settings.HOST. For unit testing I would like to use different settings. How should I override the settings? I am not using django.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":431,"Q_Id":41211357,"Users Score":0,"Answer":"I suppose the easiest way would be to move your settings.py to another folder for safekeeping and then make a new one, and edit that for debugging.","Q_Score":1,"Tags":"python,testing,settings","A_Id":41211379,"CreationDate":"2016-12-18T18:10:00.000","Title":"Override settings.py for testing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I host a flask web app on a Raspberry Pi that has controls for my LED light strip. It all works great when I run the server with python as the root user, but I am having difficulty deploying it with Apache mod_wsgi. I want to use htttps, so deploying it seems to be necessary, but Apache doesn't seem to allow running servers with root privileges. Root is necessary to control the lights through a library that is imported in the flask server. \nIs there any way to deploy a flask server with root privileges? If not, it it possible to use https (from letsencrypt.org) without deploying? Are there any other ways to get around this problem?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4412,"Q_Id":41215036,"Users Score":2,"Answer":"I would not run the web server as root for security reasons. \nInstead, I suggest to:\n\nAdd the web user to \/etc\/sudoers - no password. Ideally, only allow the commands you want to run as root. \nrun the command with sudo [command]\n\nYou mention deployment, if you are packaging this into an rpm, I would put the sudo definitions in \/etc\/sudoers.d\/youpackage\nAnother option would be to split you app and use some sort of messaging system - either by having rows in a database table or use a messaging server such as rabbit mq (there are other servers but I find it very easy to setup). A separate process running as root would do the actual turning on\/off the lights. Your frontend would simply send a message like \"lights off\" and the other process -which could be running as root- would get a message when needed. The advantage with this approach is that the web process never has any root privilege and even if it has a hole, damage is limited.","Q_Score":3,"Tags":"python,apache,flask,mod-wsgi","A_Id":41215183,"CreationDate":"2016-12-19T02:32:00.000","Title":"Deploying a Flask app with root privileges","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"What is the fast enough way (about 40~50Hz) to send large data (RGB image data: 320*240*3) from c++ process to python process (and small size of float data from python to c++) on Linux? Note: the two processes are running at the same PC.\nI have tried:\n\nUDP\nshared memory\n\nFor UDP:\nThe message to be sent is larger than the UDP message constrain (65535), so directly using sendto() will get error: Message too long. And I also doubt whether it is a fast way (about 40~50Hz is ok).\nFor shared memory:\nShared memory seems to be a fast way to send image from c++ to c++. But since there is no pointer in python, I do not find a way to read and write data in shared memory.\nSo is there a fast way to do IPC things above? Or maybe a good way to read and write unsigned char and float type values to shared memory in python?","AnswerCount":3,"Available Count":1,"Score":-0.0665680765,"is_accepted":false,"ViewCount":899,"Q_Id":41217464,"Users Score":-1,"Answer":"you can combine both applications memory with tools like swig.\nalso you can use namedpipe","Q_Score":0,"Tags":"python,c++,linux,ipc","A_Id":41218658,"CreationDate":"2016-12-19T07:11:00.000","Title":"How to send LARGE data from c++ to python in a fast way on Linux?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a project mainly for a bit of fun.\nI set up a twitter account and wrote a python script to write tweets.\nInitially i hard-coded the twitter credentials for my app into my script (tweet.py)\nNow i want to share the project so i have removed my app's credentials from tweet.py and added them to a config file. I have added the config file to .gitignore.\nMy question is, if someone forks my project, can they somehow checkout an old version of tweet.py which has the credentials? If so, what steps can i take to cover myself in this case?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":36,"Q_Id":41219491,"Users Score":1,"Answer":"Yes, anyone can see the old files in version history in git-hub free version. If you want to make your project secure, you have to pay for private repository in github.\nIf you dont wana pay, follow what @Stijin suggested.","Q_Score":0,"Tags":"python,git,twitter","A_Id":41219615,"CreationDate":"2016-12-19T09:31:00.000","Title":"Git security - private information in previous commits","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to add the Python 2.7 bin folder to my path in order to run elastic beanstalk. Here is some output from my Terminal:\n\u279c ~ echo $PATH\n~\/Library\/Python\/2.7\/bin:\/usr\/local\/bin:\/usr\/bin:\/bin:\/usr\/sbin:\/sbin\n\u279c ~ ~\/Library\/Python\/2.7\/bin\/eb --version\nEB CLI 3.8.9 (Python 2.7.1)\n\u279c ~ eb --version\nzsh: command not found: eb\nAnd here is my export statement in .zshrc:\nexport PATH=\"\/usr\/local\/bin:\/usr\/bin:\/bin:\/usr\/sbin:\/sbin\"\nexport PATH=\"~\/Library\/Python\/2.7\/bin:$PATH\"\nCan anyone tell me what's wrong? EB seems to be installed fine, and the path variable seems to point to it.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":106,"Q_Id":41227982,"Users Score":0,"Answer":"The tilde character wasn't being expanded within the double-quoted string. If you had tried to execute \"~\/Library\/Python\/2.7\/bin\/eb\" --version in your second example it wouldn't have worked either.\nYou could have set your path using something like export PATH=\"\/Users\/peter\/Library\/Python\/2.7\/bin:$PATH\", or potentially export PATH=~\/\"Library\/Python\/2.7\/bin:$PATH\" (notice the tilde is outside the double-quotes.) I'd prefer the former, however.","Q_Score":0,"Tags":"macos,python-2.7,amazon-elastic-beanstalk","A_Id":41230657,"CreationDate":"2016-12-19T17:31:00.000","Title":"I am having issues adding Python folder to my path","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Currently I have written a PID controller (with pulse width modification) which sends the current temperature to a server each duty cycle. However, this is written in series and so there is a brief delay between each cycle which makes the temperature control less effective.\nFurthermore it is hard to terminate the temperature controller externally once the program is called.\nIs there an alternative way where I can run the PID controller and the server communication separately to reduce this delay? I could always write the data to the csv file and have another script read from said file. However it doesn't strike me as the most elegant or effective solution.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":57,"Q_Id":41256392,"Users Score":0,"Answer":"Besides scheduling, I recommend using a preemptive OS, which is the only way to assure a fixed timebase. One free option is the Wind River Linux.\nI would be grateful if someone could point other good free alternatives.","Q_Score":0,"Tags":"python,multithreading","A_Id":48301814,"CreationDate":"2016-12-21T06:22:00.000","Title":"How to deal with delays when using Python for control systems","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to run python unit tests in jenkins using tox's virtualenv. I am behind a proxy so I need to pass HTTP_PROXY and HTTPS_PROXY to tox, else it has problems with downloading stuff.\nI found out that I can edit tox.ini and add passenv=HTTP_PROXY HTTPS_PROXY under [testenv], and than using the Create\/Update Text File Plugin I can override the tox.ini(as a build step) whenever Jenkins job fetches the original file from repository. This way I can manually copy content of tox.ini from workspace, add the passenv= line below [testenv] and update the file with the plugin mentioned above. But this is not the proper solution. I don't want to edit the tox.ini file this way, because the file is constantly updated. Using this solution would force me to update the tox.ini content inside the plugin everytime it is changed on the git repository and I want the process of running unit tests to be fully automated. And no, I can't edit the original file on git repository.\nSo is there a way that I can pass the passenv = HTTP_PROXY HTTPS_PROXY in the Shell nature command? This is how my command in Virtualenv Builder looks like:\npip install -r requirements.txt -r test-requirements.txt\npip install tox\ntox --skip-missing-interpreter module\/tests\/\nI want to do something like this: \ntox --skip-missing-interpreter --[testenv]passenv=HTTP_PROXY HTTPS_PROXY module\/tests\nHow to solve this?\nNOTE:\nI think there might be a solution with using the {posargs}, but I see that there is a line in the original tox.ini containing that posargs already: python setup.py testr --testr-args='{posargs}' help...","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1397,"Q_Id":41259308,"Users Score":2,"Answer":"I thought about a workaround: \nCreate a build step in Jenkins job, that will execute bash script, that will open the tox.ini find line [testenv] and input one line below passenv = HTTP_PROXY HTTPS_PROXY. That would solve the problem. I am working on this right now but anyway if You guys know a better solution please let me know. cheers\nOk so this is the solution:\n\nAdd a build step Execute shell\nInput this: sed -i.bak '\/\\[testenv\\]\/a passenv = HTTP_PROXY HTTPS_PROXY' tox.ini This will update the tox.ini file (input the desired passenv line under [testenv] and save changes). And create a tox.ini.bak backup file with the original data before sed's change.","Q_Score":2,"Tags":"python,unit-testing,jenkins,environment-variables,tox","A_Id":41262440,"CreationDate":"2016-12-21T09:30:00.000","Title":"How to add passenv to tox.ini without editing the file but by running tox in virtualenv shell nature script in Jenkins behind proxy (python)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Telegram BOT API has functions to send audio files and documents ,But can it play from an online sound streaming URL?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3630,"Q_Id":41285298,"Users Score":0,"Answer":"It will just show preview of link and if it's an audio, an audio bar will be shown. so the answer is yes, but it will not start automatically and user should download and play it.","Q_Score":3,"Tags":"telegram,telegram-bot,python-telegram-bot,php-telegram-bot","A_Id":41792018,"CreationDate":"2016-12-22T14:23:00.000","Title":"Can the Telegram bot API play sound from an online audio streaming URL?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Telegram BOT API has functions to send audio files and documents ,But can it play from an online sound streaming URL?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3630,"Q_Id":41285298,"Users Score":0,"Answer":"No, you can't with Telegram Bot APIs. \nYou must download the file and upload it on Telegram servers.","Q_Score":3,"Tags":"telegram,telegram-bot,python-telegram-bot,php-telegram-bot","A_Id":41324053,"CreationDate":"2016-12-22T14:23:00.000","Title":"Can the Telegram bot API play sound from an online audio streaming URL?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a new optimizer, and I managed to work out most of the process. Only thing I'm stuck on currently is finding gen_training_ops.\nApparently this file is crucial, because in both implementations of Gradient Descent, and Adagrad optimizers they use functions that are imported out of a wrapper file for gen_training_ops (training_ops.py in the python\/training folder).\nI can't find this file anywhere, so I suppose I don't understand something and search in the wrong place. Where can I find it? (Or specifically the implementations of apply_adagrad and apply_gradient_descent)\nThanks a lot :)","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":719,"Q_Id":41285440,"Users Score":1,"Answer":"If you find it, youll realize it just jumps to pyhon\/framework, where the actual update is just an assign operation and then gets grouped","Q_Score":2,"Tags":"python,optimization,tensorflow,deep-learning,jupyter-notebook","A_Id":54832398,"CreationDate":"2016-12-22T14:30:00.000","Title":"Can't find \"gen_training_ops\" in the tensorflow GitHub","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed trac using BitNami the other day and after restarting my computer I'm not able to get it running as a service today. I see in the error log this error\n\n[Fri Dec 02 08:52:40.565865 2016] [:error] [pid 4052:tid 968] C:\\Bitnami\\trac-1.0.13-0\\python\\lib\\site-packages\\setuptools-7.0-py2.7.egg\\pkg_resources.py:1045: UserWarning: C:\\WINDOWS\\system32\\config\\systemprofile\\AppData\\Roaming\\Python-Eggs is writable by group\/others and vulnerable to attack when used with get_resource_filename. Consider a more secure location (set with .set_extraction_path or the PYTHON_EGG_CACHE environment variable).\n\nEveryone's suggestion is to move the folder path PYTHON_EGG_CACHE to the C:\\egg folder or to suppress the warning at the command line. \nI've already set the PYTHON_EGG_CACHE for the system, I set it in trac's setenv.bat file, and in the trac.wsgi file but it's not picking up on the changes when I try to start the service.\nAlternately I can't change the permissions on the folder in Roaming using chmod like in Linux, and I can't remove any more permissions on the folder in Roaming (myself, Administrators, System) as Corporate IT doesn't allow for Administrators to be removed and this isn't an unreasonable policy.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":400,"Q_Id":41287312,"Users Score":0,"Answer":"I found out that there was another service running on the 8080 port that I had setup trac on and that was causing the trouble. The error in the logs was not pointing to that as being the issue however.","Q_Score":0,"Tags":"python,trac,bitnami","A_Id":41288887,"CreationDate":"2016-12-22T16:08:00.000","Title":"\"Python-Eggs is writable by group\/others\" Error in Windows 7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am currently embedding Python3 into my C++ application.\nWe also ships a defined version of Python3. Currently Py_Initialize finds the system python in \/usr\/lib\/python3.5 (which we do not want). I could not yet figure out how I can strip the search path before calling Py_Initialize and force it to search in my custom path.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":34,"Q_Id":41304164,"Users Score":2,"Answer":"It can be done with Py_SetPythonHome.","Q_Score":1,"Tags":"python-3.5,python-embedding","A_Id":41304207,"CreationDate":"2016-12-23T15:38:00.000","Title":"Embedding specific Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Here is my issue: my RC522 module is connected to my Pi2 via SPI and I'm able to read all [64 blocks \/ 16 sectors] using both MFRC522-python and pi-rc522 libraries. Also I'm able to write and change all the blocks(63 blocks) except for Block 0 (including UID) of a Chinese Mifare 1K card that I bought from ebay and it supposed to be Block 0 \/ UID writable.\nQuestion is: using the available python libraries(mentioned above), is it possible to write Block 0 on a Chinese writable Mifare 1K card at all or not.\nNote: when I received the card the sector trailer access bits were on transport configuration (FF 07 80 -> 001 for sector trailer and 000 for data blocks), which it means normally I could be able to change the data blocks (including Block 0) using KeyA or KeyB, but I couldn't. I changed the access bits to (7F 0F 88 -> 000 for data blocks) and used KeyA\/KeyB, it didn't work, and block 0 remained unchanged. I also tried (78 77 88 -> 000 for data blocks) with KeyA or KeyB, same result.\nAgain, setting proper access bits, I'm able to read\/write all the other blocks except for block 0.\nThanks, A.","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":12984,"Q_Id":41326384,"Users Score":6,"Answer":"There are 2 types of UID writeble cards:\n\nBlock 0 writable cards: you can write block 0 at any moment\nBackdoored cards\n\nIf writing block 0 does not work, you probably have a backdoored card:\nTo enable the backdoor, you need to send the following sequence to the card:\n(everything in hexadecimal)\n\nRC522 > Card: 50 00 57 cd (HLTA + CRC)\nRC522 > Card: 40 (7 bits only)\nCard > RC522: A (4 bits only)\nRC522 > Card: 43\nCard > RC522: A (4 bits only)\n\nThen you can write to block 0 without authentication.\nIf it still does not work, your card is probably not UID changeable.\nTo answer your question: There are no reason for Python libraries to refuse writing block 0.\nIt your library can write any block except block 0, it's that your card refuses to write the block.\nDo your card sends back a NACK or nothing when trying to write block 0?","Q_Score":3,"Tags":"python,rfid,mifare","A_Id":42299452,"CreationDate":"2016-12-26T04:18:00.000","Title":"re-writing uid and block 0 on Chinese (supposed to be writable) MIFARE 1K card in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Thanks in advance.\nWe have a Maximo automation script (python) that approves all labor transactions when it runs from a scheduled escalation. \"mbo.approveLaborTransaction()\" is the entire script. No problems with the automation script or the escalation. \nBut, instead of approving ALL labor, when it runs, we would like to only approve labor where the start date is over 21 days ago. (This will give employees time to edit their labor records. Approved labor can't be edited.)\nIs this conditional approval of labor records possible through the python script? And if so, how?\nIf not, is it possible to put conditions on the escalation that calls the automation script? Currently, there is a condition, 'GENAPPRSERVRECEIPT=0', on the escalation. (which means where labor NOT approved) I tried adding '...AND (STARTDATETIME < (SYSDATE - 21))', but that did not work.\nI'm open to other methods as well. Thanks. Ryan","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":905,"Q_Id":41352692,"Users Score":2,"Answer":"Applying the conditional approval of labor records (all labor started over 21 days ago) can be done in the escalation. I'm not saying it can't be done in the automation script. But, it is easy enough to write the SQL filter in the \"Condition\" box, I found out. I had started down this path first, but had used the wrong database field in my expression.\nNote, while using the \"Condition\" writer tool, Maximo shows a drop down of fields to choose from to apply to the filter. Don't use these. Go to the database itself and find the correct field you need to use. In this case, 'StartDate' instead of 'StartDateTime'. \nHere is my updated expression used in the escalation:\nGENAPPRSERVRECEIPT=0 and ( STARTDATE < (TRUNC(SYSDATE) - 21))","Q_Score":0,"Tags":"python,maximo,escalation","A_Id":41363700,"CreationDate":"2016-12-27T21:58:00.000","Title":"Maximo 7.6 - Conditionally approving labor transactions with automation script and escalation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using eclipse program to run selenium python, but there is an issue that when I run over 1000 TCs in one times, only 1000 first TC have test result. If I separate these TCs to many parts with each part is less than 1000 TC, the test result is received completely. I think the issue is not from coding, how can I fix this ? :(","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":40,"Q_Id":41357580,"Users Score":0,"Answer":"which unit test framework you are using, and why you are running from eclipse, i mean it's good for testing but eventually you will have to integrate that with Jenkins or other software so can you try running from command line and see what's happening. \nby the way, what error you are getting?","Q_Score":0,"Tags":"python,eclipse,selenium,automated-tests","A_Id":41359710,"CreationDate":"2016-12-28T07:43:00.000","Title":"Cannot get test result if running over 1000 Test cases in selenium python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to send bulk SMS on WhatsApp without creating broadcast list.\nFor that reason, I found pywhatsapp package in python but it requires WhatsApp client registration through yowsup-cli.\nSo I've run yowsup-cli registration -r sms -C 00 -p 000000000000 which resulted in the error below:\n\nINFO:yowsup.common.http.warequest:{\"status\":\"fail\",\"reason\":\"old_version\"}\nstatus: fail reason: old_version\n\nWhat did I do wrong and how can I resolve this?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1399,"Q_Id":41364998,"Users Score":0,"Answer":"The error you get clearly points out the nature of the challenge you are facing: it has to do with your version of yowsup-cli; it's an old version.\nIt means that your project requires a version of yowsup-cli higher than what you currently have so as to work effectively as require.\nWhat you need to do so as to resolve it is: to update your yowsup-cli application to a more recent version.","Q_Score":0,"Tags":"python,whatsapp","A_Id":41365717,"CreationDate":"2016-12-28T15:25:00.000","Title":"How to send bulk sms on whatsapp","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to send bulk SMS on WhatsApp without creating broadcast list.\nFor that reason, I found pywhatsapp package in python but it requires WhatsApp client registration through yowsup-cli.\nSo I've run yowsup-cli registration -r sms -C 00 -p 000000000000 which resulted in the error below:\n\nINFO:yowsup.common.http.warequest:{\"status\":\"fail\",\"reason\":\"old_version\"}\nstatus: fail reason: old_version\n\nWhat did I do wrong and how can I resolve this?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1399,"Q_Id":41364998,"Users Score":0,"Answer":"The problem is with the http headers that are sent to whatsapp servers, these are found in env\/env.py\nThe name of headers are manually provided, therefore due to new updates whatsapp servers only serve or authenticate to updated devices which is identified with their http\/https\/etc headers, in this case you need to update some constants in the above file(env\/env.py) in your yowsup folder.","Q_Score":0,"Tags":"python,whatsapp","A_Id":41424293,"CreationDate":"2016-12-28T15:25:00.000","Title":"How to send bulk sms on whatsapp","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I was wondering, I'm interested in using the Python Yahoo Finance API on my website, I'm using iPage as my webhost, how can I install APIs there, I just today found out how can I code the website using python","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":604,"Q_Id":41365358,"Users Score":0,"Answer":"You will need to copy the scripts to your \/cgi-bin\/ directory. \nYou can find further reference in your iPage Control Panel, under \"Additional Resources\/CGI and Scripted Language Support\". Then look for \"Server Side Includes and CGI\", and you will find the supported Python version and other relevant directory paths for your setup.","Q_Score":1,"Tags":"python,api","A_Id":41819998,"CreationDate":"2016-12-28T15:47:00.000","Title":"Using Python APIs on ipage?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a service that I'm writing in Python that allows users to schedule a task to happen at different intervals. Examples of tasks would be:\n\nTask A: do a status check for every 10 seconds\nTask B: do a status check for every 3 seconds\nTask C: do a status check for every 15 seconds\n\nThe tasks should run independently of each other. I also want to make sure that Task A can't run again until it's previous attempt is complete. Remember that the number of tasks is dynamic, and so in the interval at which they run.\nI've looked at RabbitMQ, but am having a hard time deciding if it's capable of this sort of thing.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":60,"Q_Id":41388846,"Users Score":1,"Answer":"I have been using celery recently to do what you are trying to achieve. With celery you can create tasks which are essentially functions that you are distributed to a task queue. You can also make celery tasks run periodically, whether that means every x seconds or a more crontab style approach.\nLook for periodic tasks in the celery documentation to see if it suits what you are trying to do. Celery uses rabbitmq or redis (primarily). Each task runs in its own separated thread from the main program.","Q_Score":0,"Tags":"python,rabbitmq","A_Id":41388885,"CreationDate":"2016-12-29T23:56:00.000","Title":"Best tool for scheduling tasks at intervals?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have made a custom python module (say awesome-lib.py), which is to be imported and used by the multiple other python modules(module1.py, module2.py etc). The problem is that all the modules need to be in separate folders and each of them should have a copy of awesome-lib.py for them to import it. I thought of two options for doing this: \n\nEach module folder will have a copy of awesome-lib.py in it. That way I can import awesome-lib and used it in each module. But issue is when I have to make any changes in awesome-lib.py. I would have to copy the file in each module folder separately, so this might not be a good approach.\nI can package the awesome-lib.py using distutils. Whenever I make the change in the module, I will update awesome-lib.py in each module using some script. But still I want the awesome-lib distribution package to be individually included in each module folder.\n\nCan anyone please tell me an efficient way to achieve this? So that I can easily change one file and the changes are reflected in all the modules separately.\nP.S: I want the awesome-lib.py in each module folder separately because I need to zip the contents of it and upload each module on AWS Lambda as a Lambda zip package.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":770,"Q_Id":41395396,"Users Score":0,"Answer":"let only one copy of awesome-lib.py placed where it is placed and append it's path in other modules. let sample path is \"\/home\/user\/awesome-lib.py\"\nAdd following code in every other module you want to import awesome-lib.py\nimport sys\nsys.path.append('home\/user\/awesome-lib')\nimport awesome-lib\nNote: path of awesome-lib may differ on your choice","Q_Score":0,"Tags":"python,aws-lambda,python-module","A_Id":41395518,"CreationDate":"2016-12-30T11:18:00.000","Title":"Include a custom python module in multiple modules separately","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am learning Python programming language. Currently\nI am experimenting i-o files. I imported sys module and\n in sys.path list I saw two kinds of paths:\n\n\/data\/data\/org.qpython.qpy3....\n\/storage\/sdcard0\/qpthon...\n\nThe former path does not exist physically on my device\n(Tablet), although I can create\/read files using this\npath through python.\nI want to know about these paths.\nWhat are they called?\nWhat are they for? etc.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":43,"Q_Id":41413303,"Users Score":0,"Answer":"The first path, \/data\/data\/org.qpython.qpy3, this is where the actual QPython app is stored on your device. I don't believe you can access this path without having root access.\nThe second path, \/storage\/sdcard0\/qpthon, this is where QPython saves files by default. It uses this location because it can be easily accessed with normal user privileges.","Q_Score":0,"Tags":"file,python-3.x,path","A_Id":41413400,"CreationDate":"2017-01-01T04:12:00.000","Title":"Directory path which does not physically exist on my device","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Ok, so I've looked around on how to do this and haven't really found an answer that showed me examples that I could work from. \nWhat I'm trying to do is have a script that can do things like:\n-Log into website\n-Fill out forms or boxes etc.\nSomething simple that might help me in that I though of would be for example if I could write a script that would let me log into one if those text message websites like textnow or something like that, and then fill out a text message and send it to myself. \nIf anyone knows a good place that explains how to do something like this, or if anyone would be kind enough to give some guidance of their own then that would be greatly appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":58,"Q_Id":41528141,"Users Score":1,"Answer":"So after some good answers and further research, I have found that selenium is the thing that best suits my needs. It works not only with python, but supports other languages as well. If anyone else is looking for something that I had been when I asked the my question, a quick Google search for \"selenium\" should give them all the information they need about the tool that I found best for what I needed.","Q_Score":0,"Tags":"python,html,python-3.x,web","A_Id":44302397,"CreationDate":"2017-01-08T00:26:00.000","Title":"How to have python interact automatically with a web site","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"can't find anyone posting a similar situation so thought I'd ask and see. Currently trying to automate unit tests within our continuous deployment environment. \nWe do the typical python setup.py test command from our virtualenv. However, we have our own internal pypi server for some of our internal libraries. pip.conf is configured so when explicitly running pip install it will check the internal pypi server. But when running setup.py test, it tries to use pip to install requirements and appears to not be aware of the pip.conf file. I've place the pip.conf at the global level (\/etc\/pip.config), virtualenv level, and the user level but to no avail. It's almost like it's calling a different pip, which I would assume would be the base install (not virtualenv), but it ignores the global pip.conf also. Any ideas? Thanks in advance!","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":766,"Q_Id":41556981,"Users Score":-1,"Answer":"Any time I have problems like this, I find that writing the explicit path to the executable helps a great deal, no matter the level I place the executable. So instead of running pip ~do something~ try \/etc\/pip ~do something~.","Q_Score":1,"Tags":"python,python-3.x,pip,ubuntu-14.04,setup.py","A_Id":41557048,"CreationDate":"2017-01-09T21:09:00.000","Title":"running python setup.py test pip not finding pip.conf to install internal requirements","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is really troublesome for me. I have a telegram bot that runs in django and python 2.7. During development I used django sslserver and everything worked fine. Today I deployed it using gunicorn in nginx and the code works very different than it did on my localhost. I tried everything I could since I already started getting users, but all to no avail. It seems to me that most python objects lose their state after each request and this is what might be causing the problems. The library I use has a class that handles conversation with a telegram user and the state of the conversation is stored in a class instance. Sometimes when new requests come, those values would already be lost. Please has anyone faced this? and is there a way to solve the problem quick? I am in a critical situation and need a quick solution","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":210,"Q_Id":41559470,"Users Score":2,"Answer":"Gunicorn has a preforking worker model -- meaning that it launches several independent subprocesses, each of which is responsible for handling a subset of the load.\nIf you're relying on internal application state being consistent across all threads involved in offering your service, you'll want to turn the number of workers down to 1, to ensure that all those threads are within the same process.\n\nOf course, this is a stopgap -- if you want to be able to scale your solution to run on production loads, or have multiple servers backing your application, then you'll want to be modify your system to persist the relevant state to a shared store, rather than relying on content being available in-process.","Q_Score":1,"Tags":"python,django,nginx,wsgi,gunicorn","A_Id":41559760,"CreationDate":"2017-01-10T00:47:00.000","Title":"Python objects lose state after every request in nginx","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"there is some really strange problem.\n\nTraceback (most recent call last):\n File \"mnist.py\", line 17, in \n import lasagne.nonlinearities as nonlinearities\n File \"\/usr\/local\/lib\/python2.7\/dist-packages\/lasagne\/init.py\", line 17, in \n from . import nonlinearities\n ImportError: cannot import name nonlinearities\n\nAs I go to this folder, I find there is it(the name).but for some unkown reason,(I guess path problem). It does not work.\nthis may be raised by my mistaking operation, but my mistaking command was not executed.\nin detail,originally,my lasagne==0.1.and there is some module can not import..so i solved it by installing the leasted version lasagne==0.2.dev1...then it works.for some reason ,i break my program.before i run it again,i had done some unexecuted mistaking command,now the error is there as you see.i guess it because of two version of lasagne under the path \/usr\/local\/lib\/python2.7\/dist-packages\/..so i uninstall all of them,then i reinstall the one version.but the error is still there..\nadditional..the following command is ok\n python\n import lasagne\n import lasagne.nonlinearites as nonl","AnswerCount":1,"Available Count":1,"Score":0.761594156,"is_accepted":false,"ViewCount":2149,"Q_Id":41569406,"Users Score":5,"Answer":"this can be solved by first import lasagne then import theano..\nif exchange the import order,then the error arise...\nthis is very strange.i am not sure what happens,but it does work","Q_Score":5,"Tags":"python-2.7,lasagne","A_Id":41593958,"CreationDate":"2017-01-10T12:58:00.000","Title":"from . import nonlinearities cannot import name nonlinearities","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new in robotics and I am working on a project where I need to pass the coordinates from the camera to the robot.\nSo the robot is just an arm, it is then stable in a fixed position. I do not even need the 'z' axis because the board or the table where everything is going on have always the same 'z' coordinates.\nThe webcam as well is always in a fixed position, it is not part of the robot and it does not move.\nThe problem I am having is in the conversion from 2D camera coordinates to a 3D robotic arm coordinates (2D is enough because as stated before the 'z' axis is not needed as is always in a fixed position).\nI'd like to know from you guys, which one is the best approach to face this kind of problems so I can start to research.\nI've found lot of information on the web but I am getting a lot of confusion, I would really appreciate if someone could address me to the right way. \nI don't know if this information are useful but I am using OpenCV3.2 with Python\nThank you in advance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1200,"Q_Id":41599283,"Users Score":0,"Answer":"Define your 2D coordinate on the board, create a mapping from the image coordinate (2D) to the 2D board, and also create a mapping from the board to robot coordinate (3D). Usually, robot controller has a function to define your own coordinate (the board).","Q_Score":0,"Tags":"python,opencv,coordinates,robotics,coordinate-transformation","A_Id":41604196,"CreationDate":"2017-01-11T19:34:00.000","Title":"Translation from Camera Coordinates System to Robotic-Arm Coordinates System","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have recorded some Selenium Scripts using the Selenium IDE Firefox add-on.\nI'd like to add these to the unit test cases for my Django project. Is it possible to somehow turn these into a Python unit test case?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":81,"Q_Id":41603576,"Users Score":1,"Answer":"If you are recording scripts in Python formatting, those are already converted to unit test cases. Save each scripts and run them in batch mode.","Q_Score":0,"Tags":"python,unit-testing,selenium,selenium-webdriver,selenium-ide","A_Id":41607809,"CreationDate":"2017-01-12T01:15:00.000","Title":"Using Selenium Scripts in a Python unit test","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"protobuf generates C++\/Java classes, and these are static typed class, enough for encoding\/decoding. Why it generates python classes with metaclass attribute: I would suppose ordinary class will be enough to do rpc, like C++\/Java generated classes.\nWhy python should use dynamic class?\nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":357,"Q_Id":41616827,"Users Score":3,"Answer":"Mostly, because it's easier to read.\nThe code generators for C++ and Java are really hard to understand and edit, because you have to follow both the generator code and the code being generated at the same time.\nThe Python code generator could have been done the same way. However, because Python is a dynamic language, it's possible to use metaclasses instead. Essentially, this allows most of the code to be constructed at runtime. The metaclass is much easier to read and edit than a code generator because it is all straight Python, with no ugly print statements.\nNow, you might argue that Java could have done something similar: Generate very simple classes, and then use reflection to read and write the fields. The problem with that is that Java is a compiled language. Compiled code will perform much better than reflection-based code. Python, however, is not compiled, so there's not much penalty for using a reflection approach (it's slow either way). In fact, because Python is designed to be dynamic, you can do a lot of neat tricks that wouldn't be possible in other languages (but, again, it's slow either way).","Q_Score":2,"Tags":"python,linux,class,protocol-buffers,meta","A_Id":41629972,"CreationDate":"2017-01-12T15:22:00.000","Title":"Why protobuf generates python class with __metaclass__ attribute?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"EDIT Removed BOTO from question title as it's not needed.\nIs there a way to find the security groups of an EC2 instance using Python and possible Boto?\nI can only find docs about creating or removing security groups, but I want to trace which security groups have been added to my current EC2 instance.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":842,"Q_Id":41620292,"Users Score":1,"Answer":"You can check it from that instance and execute below command \ncurl http:\/\/169.254.169.254\/latest\/meta-data\/security-groups \nor from aws-cli also\naws ec2 describe-security-groups","Q_Score":1,"Tags":"python,amazon-web-services,amazon-ec2","A_Id":41620629,"CreationDate":"2017-01-12T18:21:00.000","Title":"How do I list Security Groups of current Instance in AWS EC2?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"i run a cgi script on an apache server (xampp). The script basically runs in an infinte loop. After like 3 minutes i get the error message \"script timed out before returning headers\". I've searched through the internet and found stuff like:\n\nchange MAX_EXECUTION_TIME to 0 -> didn't work\nset_time_limit(0) -> didn't work\nsocket.setdefaulttimeout(0) -> didn't work\n\nI think the error is caused because my script never returns anything to the website, but that's just like it's intended. Basically the script should be started through a website and run until i tell it to stop (it's done with the script constantly checking for a file).\nOne solution i thought about was a script that restarts my script if it's terminated. But a far more elegant solution would be that the script runs without being terminated by the server.\nI hope everything is explained well and somebody can help me because i'm stuck with this problem for far too long and it's starting to annoy me.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2514,"Q_Id":41621209,"Users Score":1,"Answer":"One thing you could try:\n\nReturn a proper HTML header\nPrint a dot . every few seconds, just to keep the connection alive\ndisable mod_deflate in your Apache server to prevent HTTP compression\nadd SetEnv no-gzip to your .htaccess file","Q_Score":1,"Tags":"python,apache,cgi","A_Id":41621284,"CreationDate":"2017-01-12T19:18:00.000","Title":"script timed out before returning headers cgi","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm creating a program in python (2.7) and I want to protect it from reverse engineering.\nI compiled it using cx_freeze (supplies basic security- obfuscation and anti-debugging)\nHow can I add more protections such as obfuscation, packing, anti-debugging, encrypt the code recognize VM.\nI thought maybe to encrypt to payload and decrypt it on run time, but I have no clue how to do it.","AnswerCount":3,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":12365,"Q_Id":41633039,"Users Score":6,"Answer":"There's no way to make anything digital safe nowadays.\nWhat you CAN do is making it hard to a point where it's frustrating to do it, but I admit I don't know python specific ways to achieve that. The amount of security of your program is not actually a function of programsecurity, but of psychology.\nYes, psychology.\nGiven the fact that it's an arms race between crackers and anti-crackers, where both continuously attempt to top each other, the only thing one can do is trying to make it as frustrating as possible. How do we achieve that?\nBy being a pain in the rear!\nEvery additional step you take to make sure your code is hard to decipher is a good one.\nFor example could you turn your program into a single compiled block of bytecode, which you call from inside your program. Use an external library to encrypt it beforehand and decrypt it afterwards. Do the same with extra steps for codeblocks of functions. Or, have functions in precompiled blocks ready, but broken. At runtime, utilizing byteplay, repair the bytecode with bytes depending on other bytes of different functions, which would then stop your program from working when modified.\nThere are lots of ways of messing with people's heads and while I can't tell you any python specific ways, if you think in context of \"How to be difficult\", you'll find the weirdest ways of making it a mess to deal with your code.\nFunnily enough this is much easier in assembly, than python, so maybe you should look into executing foreign code via ctypes or whatever.\nSummon your inner Troll!","Q_Score":4,"Tags":"python,debugging,assembly,reverse-engineering,obfuscation","A_Id":41637182,"CreationDate":"2017-01-13T10:59:00.000","Title":"protect python code from reverse engineering","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm creating a program in python (2.7) and I want to protect it from reverse engineering.\nI compiled it using cx_freeze (supplies basic security- obfuscation and anti-debugging)\nHow can I add more protections such as obfuscation, packing, anti-debugging, encrypt the code recognize VM.\nI thought maybe to encrypt to payload and decrypt it on run time, but I have no clue how to do it.","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":12365,"Q_Id":41633039,"Users Score":3,"Answer":"Story time: I was a Python programmer for a long time. Recently I joined in a company as a Python programmer. My manager was a Java programmer for a decade I guess. He gave me a project and at the initial review, he asked me that are we obfuscating the code? and I said, we don't do that kind of thing in Python. He said we do that kind of things in Java and we want the same thing to be implemented in python. Eventually I managed to obfuscate code just removing comments and spaces and renaming local variables) but entire python debugging process got messed up.\nThen he asked me, Can we use ProGuard? I didn't know what the hell it was. After some googling I said it is for Java and cannot be used in Python. I also said whatever we are building we deploy in our own servers, so we don't need to actually protect the code. But he was reluctant and said, we have a set of procedures and they must be followed before deploying.\nEventually I quit my job after a year tired of fighting to convince them Python is not Java. I also had no interest in making them to think differently at that point of time.\nTLDR; Because of the open source nature of the Python, there are no viable tools available to obfuscate or encrypt your code. I also don't think it is not a problem as long as you deploy the code in your own server (providing software as a service). But if you actually provide the product to the customer, there are some tools available to wrap up your code or byte code and give it like a executable file. But it is always possible to view your code if they want to. Or you choose some other language that provides better protection if it is absolutely necessary to protect your code. Again keep in mind that it is always possible to do reverse engineering on the code.","Q_Score":4,"Tags":"python,debugging,assembly,reverse-engineering,obfuscation","A_Id":41635003,"CreationDate":"2017-01-13T10:59:00.000","Title":"protect python code from reverse engineering","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently building my NGS pipeline using Snakemake and have an issue regarding the loading of R libraries. Several of the scripts, that my rules call, require the loading of R libraries. As I found no way of globally loading them, they are loaded inside of the R scripts, which of course is redundant computing time when I'm running the same set of rules on several individual input files. \nIs there a way to keep one R session for the execution of several rules and load all required libraries priorly?\nCheers,\nzuup","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":239,"Q_Id":41639782,"Users Score":1,"Answer":"I'm afraid not. This has performance reasons on (a) local systems (circumventing the Python GIL) and (b) cluster systems (scheduling to separate nodes).\nEven if there was a solution on local machines, it would need to take care that no sessions are shared between parallel jobs. If you really need to safe that time, I suggest to merge those scripts.","Q_Score":1,"Tags":"python,r,snakemake","A_Id":41672695,"CreationDate":"2017-01-13T17:01:00.000","Title":"Globally load R libraries in Snakemake","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am doing MIT6.00.1x course from edX and in it, Professor Grimson talks about primitives of a programming language.\nWhat does it actually mean and secondly, how it is different from the tokens of a programming language?\nPlease answer with reference to Python language.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1225,"Q_Id":41640308,"Users Score":0,"Answer":"It depends on the context, but usually:\n\nprimitives refers to built in data types of a language, that is, types that you can represent without creating an object. In python (and most other languages) such types are booleans, strings, floats, integers\ntokens refers to a \"word\" (anything between spaces): identifiers, string\/number literals, operators. They are used by the interpeter\/compiler","Q_Score":2,"Tags":"python,token,primitive","A_Id":41640398,"CreationDate":"2017-01-13T17:34:00.000","Title":"Primitive operations provided by a programming language?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to make a Python script run as a service.\nIt need to work and run automatically after a reboot.\nI have tried to copy it inside the init.d folder, But without any luck.\nCan anyone help?(if it demands a cronjob, i haven't configured one before, so i would be glad if you could write how to do it)\n(Running Centos)","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":6891,"Q_Id":41662821,"Users Score":0,"Answer":"There is no intrinsic reason why Python should be different from any other scripting language here.\nHere is someone else using python in init.d: blog.scphillips.com\/posts\/2013\/07\/\u2026 In fact, that deals with a lot that I don't deal with here, so I recommend just following that post.","Q_Score":2,"Tags":"python,linux,centos","A_Id":41662958,"CreationDate":"2017-01-15T15:27:00.000","Title":"How to run python script at startup","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am using the telepot python library, I know that you can send a message when you have someone's UserID(Which is a number).\nI wanna know if it is possible to send a message to someone without having their UserID but only with their username(The one which starts with '@'), Also if there is a way to convert a username to a UserID.","AnswerCount":5,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":131355,"Q_Id":41664810,"Users Score":73,"Answer":"Post one message from User to the Bot.\nOpen https:\/\/api.telegram.org\/bot\/getUpdates page.\nFind this message and navigate to the result->message->chat->id key.\nUse this ID as the [chat_id] parameter to send personal messages to the User.","Q_Score":39,"Tags":"visual-studio-code,python,telegram,telegram-bot,python-telegram-bot","A_Id":50736131,"CreationDate":"2017-01-15T18:38:00.000","Title":"How can I send a message to someone with my telegram bot using their Username","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using the telepot python library, I know that you can send a message when you have someone's UserID(Which is a number).\nI wanna know if it is possible to send a message to someone without having their UserID but only with their username(The one which starts with '@'), Also if there is a way to convert a username to a UserID.","AnswerCount":5,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":131355,"Q_Id":41664810,"Users Score":14,"Answer":"It is only possible to send messages to users whom have already used \/start on your bot. When they start your bot, you can find update.message.from.user_id straight from the message they sent \/start with, and you can find update.message.from.username using the same method.\nIn order to send a message to \"@Username\", you will need them to start your bot, and then store the username with the user_id. Then, you can input the username to find the correct user_id each time you want to send them a message.","Q_Score":39,"Tags":"visual-studio-code,python,telegram,telegram-bot,python-telegram-bot","A_Id":42990824,"CreationDate":"2017-01-15T18:38:00.000","Title":"How can I send a message to someone with my telegram bot using their Username","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python cgi file on server and it imports some packages that installed only locally by anaconda(because I've no root privilege on the server). The problem is when I call the file from web, it can not be executed because of those \"missing\" packages. How can I get through this if I can't have root privilege?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":614,"Q_Id":41671657,"Users Score":0,"Answer":"If you can control the environment in which your server runs you can set PYTHONPATH to the path of some directory you have permissions to write in, and then install your third-party modules in that directory.","Q_Score":0,"Tags":"python,cgi,virtualenv,anaconda","A_Id":41747994,"CreationDate":"2017-01-16T07:48:00.000","Title":"run python cgi from web with local packages installed by anaconda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to use libFTDI (www.intra2net.com\/en\/developer\/libftdi\/download\/libftdi1-1.2.tar.bz2)\nfor a project that I'm working on. All my current modules have been written in python2 and so i want libFTDI to work with python2 too, but the installation process automatically selects python3.5. Cmake is used to build the project. I can't seem to get it to work and apparently no one else has faced this problem before.\nAny help would be appreciated!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":401,"Q_Id":41680144,"Users Score":1,"Answer":"It worked after i uninstalled all versions of python3 and the python3-dev package.","Q_Score":0,"Tags":"python,linux,cmake,ftdi","A_Id":41735460,"CreationDate":"2017-01-16T15:50:00.000","Title":"Is there a way to force libFTDI to make the python packages according to python2.7 instead of python3?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a long term project, for learning purposes, which is creating a virtual assistent, such as Siri or Google Now, but to control my home automation. I'll have an arduino controling some hardware (such lamps, sensors, etc.), and the assistent I'll write in Python. Until this step, I have the knowledge to do this.\nBut thinking forward, when this is functional, would be great if I could add the feature to control remotely by mobile app and\/or webpage, and not just by my desktop.\nThe problem is I don't know which knowledge I need have to do this.\nI want to have a web page, or a mobile app that show me this webpage, where I can program buttons to turn on\/off stuff, check the sensors data, etc.\nI should like to use PHP, cause as I said, this is for learning purposes.\nI supose that I'll need set a server in my home, and then access him through this app\/page.\nSo, which programming skills I need to accomplish this (considering that arduino runs in C and the assistent will be scripted in Python)?\nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":164,"Q_Id":41680964,"Users Score":1,"Answer":"The web site could be created in any number of languages, PHP being one good choice. The server could be local, or if you want to be able to interface globally, on a hosted server.\nHow your Arduino connects to the server is the most telling part. If you use a WiFi or Ethernet shield, you can have it poll the server to get information (ie. turn something on\/off) and to post info (ie. temp\/humidity). In you want the server to be the controlling factor, have it use curl to poll a web server on the Arduino. The Arduino would respond with data, look for parameters for control, etc.\nI've written several projects that use the Arduino and Witty ESP8266 micro-controllers and interface with a web server. It's not that hard if you know everything you need to know about creating a web site, writing Arduino code, and HTTP communications. If you don't, there's a steep learning curve.","Q_Score":0,"Tags":"php,python,web,automation","A_Id":41681979,"CreationDate":"2017-01-16T16:35:00.000","Title":"Setting a remote control panel page for home automation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is there a way to call allureCLI from Python? I would like to use python instead than shell scripting to run multiple reports.\nI could use Popen but I am having so many issues with it, that I would rather avoid it unless there is no other way around","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":824,"Q_Id":41689872,"Users Score":1,"Answer":"Since the Allure CLI script calls a java application makes it a Python to Java problem. There are a few solutions like Py4J that can help you with that. Keep in mind that most solutions rely on the Java app already running inside the secondary application before being called from Python.","Q_Score":1,"Tags":"python,allure","A_Id":41712644,"CreationDate":"2017-01-17T05:52:00.000","Title":"allure command line from python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Both RevitPythonShell scripts and Revit Python Macros are relying on Iron Python. In both cases, at least in Revit 15, neither require the installation of IronPython. I believe RevitPythonShell installs with the capacity to process the ironPython script (rpsruntime.dll). Revit must install with the same capacity. \nTherefore, I assume the two programming environments are being executed from separate sources. Is this accurate?\nHow would I be able to install an external module as I would typically use pip for? Another words, if I wanted to use the docx, pypdf2, tika, or other library - is this possible?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":369,"Q_Id":41696268,"Users Score":3,"Answer":"I agree with your assumption that these two environments are probably completely separate and independent of each other.\nSince the Python code that you write within them is pure .NET, it is easy to reference other .NET modules, assemblies, libraries, whatever you want to call them. They would reside in .NET assembly DLLs.\nUsing pip to add external Python libraries is a completely different matter, however, and rather removed from the end user environment offered by these two.\nTo research that, you will have to dive into the IronPython documentation and see how that can be extended 'from within' so to speak.","Q_Score":1,"Tags":"python,revit,revitpythonshell","A_Id":41714110,"CreationDate":"2017-01-17T11:44:00.000","Title":"Revit Python Macros and RevitPythonShell Modules, or loaded packages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Both RevitPythonShell scripts and Revit Python Macros are relying on Iron Python. In both cases, at least in Revit 15, neither require the installation of IronPython. I believe RevitPythonShell installs with the capacity to process the ironPython script (rpsruntime.dll). Revit must install with the same capacity. \nTherefore, I assume the two programming environments are being executed from separate sources. Is this accurate?\nHow would I be able to install an external module as I would typically use pip for? Another words, if I wanted to use the docx, pypdf2, tika, or other library - is this possible?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":369,"Q_Id":41696268,"Users Score":1,"Answer":"For pure-python modules, it could be as easy as having a CPython installation (e.g. Anaconda) and pip installing to that, then adding the site-packages of that installation to the search path in RPS.\nFor modules that include native code (numpy and many others), this gets more tricky and you should google how to install those for IronPython. In the end, adding the installed module to your search path will give you access in RPS.","Q_Score":1,"Tags":"python,revit,revitpythonshell","A_Id":41719461,"CreationDate":"2017-01-17T11:44:00.000","Title":"Revit Python Macros and RevitPythonShell Modules, or loaded packages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When using the dir() method in python, why are some of the methods I am returned with surrounded with underscores? Am I supposed to use these methods?\nFor Example, dir([1,2,3,4,5,6]) returns:\n['__add__',\n '__class__',\n '__contains__',\n '__delattr__',\n '__delitem__',\n '__delslice__',\n '__doc__',\n '__eq__',\n '__format__',\n '__ge__',\n '__getattribute__',\n '__getitem__',\n '__getslice__',\n '__gt__',\n '__hash__',\n '__iadd__',\n '__imul__',\n '__init__',\n '__iter__',\n '__le__',\n '__len__',\n '__lt__',\n '__mul__',\n '__ne__',\n '__new__',\n '__reduce__',\n '__reduce_ex__',\n '__repr__',\n '__reversed__',\n '__rmul__',\n '__setattr__',\n '__setitem__',\n '__setslice__',\n '__sizeof__',\n '__str__',\n '__subclasshook__',\n 'append',\n 'count',\n 'extend',\n 'index',\n 'insert',\n 'pop',\n 'remove',\n 'reverse',\n 'sort']\nThe last nine of these methods are the ones which are conventionally used.\nWhen I check the documentation, I see very little in regards to what these methods are:\n\nIf the object has a method named __dir__(), this method will be called and must return the list of attributes. This allows objects that implement a custom __getattr__() or __getattribute__() function to customize the way dir() reports their attributes.\n\nThank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":159,"Q_Id":41724719,"Users Score":2,"Answer":"Differently form other languages (Java, C++), there are no \"private\" methods in Python (i.e. methods that cannot be called outside of the class that defines them). So, any caller can call internal methods from any object.\nConventionally, you should not call those methods of an object, to avoid unwanted consequences not predicted by the class' programmer.","Q_Score":1,"Tags":"python,methods","A_Id":41724860,"CreationDate":"2017-01-18T16:37:00.000","Title":"What is the difference between underscored methods and non-underscored methods, specifically those that are listed by the dir() method?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am in Python3. I have a bunch of Python2 .py files. For each of these files, I need to check whether the contents are valid Python2 code and return it as a boolean. The files are small scripts, sometimes they may import things or have a function or class, but mostly they are pretty simple.\nHow can I do this?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":279,"Q_Id":41732396,"Users Score":1,"Answer":"Do you do it at build time? If so, you can try run 2to3 and parse its output to determine if the file is valid Python 2 code.","Q_Score":0,"Tags":"python-2.7,python-3.x,validation,syntax","A_Id":41732436,"CreationDate":"2017-01-19T01:42:00.000","Title":"How to validate syntax of Python2 code from Python3?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know it is frowned upon to post questions without code, but I have been stuck for days thinking of how to handle this issue and cant think of a solution. \nMy setup is this:\n\n\nArduino Mega w\/ 4G + GPS Shield from Cooking Hacks\nDjango Server set up with Python\nPostgresql Database\n\n\nBecause the 4G + GPS shield has the capability for http commands, I want to use http POST to send gps data to my Django Server and store that information in my Postgresql database. Another thing to keep in mind is I am running a Django test server on my Localhost, so I need to POST to that local host. \nBecause I am not posting through a form and it is not synchronous I am really confused as to how the Django server is supposed to handle this asynchronous POST. It will look like this (I imagine):\nArduino (POST) --> Django Server (Localhost) --> Postgresql Database\nSo I have 2 questions:\n1) In order to successfully send a POST to my local Django Server, should my host be my public router IP and the Port be the same as that which I am running my server on? Is there something else I am missing?\n2) Do I need to use Django REST Framework to handle the POST request? if not, how would I implement this in my views.py?\nI am trying to get a reference point on the problem in order to visualize how to do it. I DONT need coded solutions. Any help on this would be greatly appreciated, and if you have any other questions I will be quick to answer.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1484,"Q_Id":41748325,"Users Score":0,"Answer":"1)Depends, if your arduino is on the same local network than your Django Server then you don't need a public IP, otherwise you would have to forward your Django Server IP & port so its accesible from internet.\n2) Not really, you can do a traditional POST request to a normal view on Django.","Q_Score":1,"Tags":"django,postgresql,python-3.x,post,arduino","A_Id":41748434,"CreationDate":"2017-01-19T17:43:00.000","Title":"HTTP POST Data from Arduino to Django Database","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm using Jenkins with python code as follows.\nAfter detecting a change to the GIT dev branch:\n\nCheckout GIT repository dev branch code\nPerform Unit tests \/ code coverage\nIf build passes, check code into the production branch of the same repo\n\nWhat I want to add, is the ability to keep track of the previous code version (the python code package stores the version number in the setup.py file ) and if the version in the latest build job is incremented compared to the saved version, only then check the passed code into the production branch.\nAny thoughts on how best to achieve this?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":140,"Q_Id":41751050,"Users Score":0,"Answer":"I've made use of the following plugins to achieve this:\n\nFlexible Publish Plugin\nRun Condition Plugin","Q_Score":0,"Tags":"python,git,jenkins","A_Id":41751932,"CreationDate":"2017-01-19T20:25:00.000","Title":"Jenkins - Store code previous version number, and take actions if version number changes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working with Python in the command line and want to import the module 'twitter'. twitter is in this directory: C:\\Users\\U908153\\AppData\\Local\\Enthought\\Canopy32\\User\\Lib\\site-packages\nsys.path tells me that the above directory is in sys.path.\nStill, when I write import twitter, I get ImportError: No module named twitter.\nWhat is going wrong? Thanks in advance!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1693,"Q_Id":41766948,"Users Score":0,"Answer":"A few things that commonly result in this error:\n\nModule is not in PYTHONPATH. Since you have checked this with sys.path, I will assume that it is there already. However, for future reference, you can manually add it to your profile or bashrc file in the home directory.\nIt may be that the module that you are using doesn't have a __init__.py file or the module path in PYTHONPATH doesn't point to the uppermost directory with __init__.py. You can fix this by adding a blank __init__.py file where necessary or editing the module path.\nAnother possibility is that the python interpreter that you used sys.path is not the same python in which the module was installed. Commonly, this is due to two different versions of python installed on the same machine. Make sure that your module is installed for the correct python interpreter or switch into the correct (usually not default) python using source activate.\n\nHope this helps!","Q_Score":0,"Tags":"python,command-line,python-import,importerror","A_Id":41767558,"CreationDate":"2017-01-20T15:19:00.000","Title":"Python ImportError when module is in sys.path","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I install mayavi2 using sudo apt-get install mayavi2 as shown below:\npi@raspberrypi:~ $ sudo apt-get install mayavi2\nReading package lists... Done\nBuilding dependency tree\nReading state information... Done\nThe following package was automatically installed and is no longer required:\npython-enthoughtbase\nUse 'apt-get autoremove' to remove it.\nThe following extra packages will be installed:\npython-envisage\nSuggested packages:\nipython python-chaco\nThe following packages will be REMOVED:\npython-envisagecore python-envisageplugins\nThe following NEW packages will be installed:\nmayavi2 python-envisage\n0 upgraded, 2 newly installed, 2 to remove and 3 not upgraded.\nNeed to get 0 B\/18.5 MB of archives.\nAfter this operation, 34.9 MB of additional disk space will be used.\nDo you want to continue? [Y\/n] y\n(Reading database ... 160193 files and directories currently installed.)\nRemoving python-envisagecore (3.2.0-2) ...\nRemoving python-envisageplugins (3.2.0-2) ...\nSelecting previously unselected package python-envisage.\n(Reading database ... 158978 files and directories currently installed.)\nPreparing to unpack ...\/python-envisage_4.4.0-1_all.deb ...\nUnpacking python-envisage (4.4.0-1) ...\nSelecting previously unselected package mayavi2.\nPreparing to unpack ...\/mayavi2_4.3.1-3.1_armhf.deb ...\nUnpacking mayavi2 (4.3.1-3.1) ...\nProcessing triggers for man-db (2.7.0.2-5) ...\nSetting up python-envisage (4.4.0-1) ...\nSetting up mayavi2 (4.3.1-3.1) ...\nNow\nI try to run mayavi2 but there is error as shown below.\npi@raspberrypi:~ $ mayavi2\nTraceback (most recent call last):\nFile \"\/usr\/bin\/mayavi2\", line 493, in \nraise ImportError(msg)\nImportError: No module named _py2to3\nCould not load envisage. You might have a missing dependency.\nDo you have the EnvisageCore and EnvisagePlugins installed?\nIf you installed Mayavi with easy_install, try 'easy_install '.\n'easy_install Mayavi[app]' will also work.\nIf you performed a source checkout and installed via 'python setup.py develop',\nbe sure to run the same command in the EnvisageCore and EnvisagePlugins folders.\nIf these packages appear to be installed, check that your numpy and\nconfigobj are installed and working. If you need numpy, 'easy_install numpy'\nwill install numpy. Similarly, 'easy_install configobj' will install\nconfigobj.\nI install envisage, EnvisageCore, and EnvisagePulgins using\nsudo apt-get install python-envisage\nsudo apt-get install python-EnvisageCore\nsudo apt-get install python-EnvisagePlugins\npi@raspberrypi:~ $ mayavi2\nbash: \/usr\/bin\/mayavi2: No such file or directory\nHi is there a way to get past this error?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":388,"Q_Id":41814520,"Users Score":0,"Answer":"as your mayavi2 executable has been removed (this is typically the case with the message bash: \/usr\/bin\/mayavi2: No such file or directory), it likely means that apt-get removed it when updating python-envisage, python-EnvisageCore and python-EnvisagePlugins.\nFirst steps: apt-get update, apt-get install mayavi2 (both as root or using sudo) and check if the errors are the same. The first error you had was about a missing _py2to3 module that normally comes with the packages python-traits and `python-traitsui. Are they installed?","Q_Score":0,"Tags":"python-3.x,raspberry-pi2,mayavi","A_Id":41827272,"CreationDate":"2017-01-23T19:56:00.000","Title":"mayavi2 does not work","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I must load the Oracle \"instant client\" libraries as part of my AWS lambda python deployment zip file.\nProblem is, many of the essential libraries (libclntsh.so.12.1 is 57MB libociei.so is 105MB) and Amazon only allows deployment zip files under 50MB. \nI tried: my script cannot connect to Oracle using cx_Oracle without that library in my local ORACLE_HOME and LD_LIBRARY_PATH. \nHow can I get that library into Lambda considering their zip file size limitation? Linux zip just doesn't compress them enough.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":846,"Q_Id":41833790,"Users Score":3,"Answer":"If you can limit yourself to English error messages and a restricted set of character sets (which does include Unicode), then you can use the \"Basic Lite\" version of the instant client. For Linux x64 that is only 31 MB as a zip file.","Q_Score":1,"Tags":"python,oracle,amazon-web-services,lambda,cx-oracle","A_Id":41837986,"CreationDate":"2017-01-24T16:48:00.000","Title":"AWS python Lambda script that can access Oracle: Driver too big for 50MB limit","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am getting ImportError: No module named 'Crypto' error when trying to run. I have installed pycrypto using pip install pycrypto and updated it also. Everything I have tried to far has been unsuccessful.\nTried:\n\nreinstalling pycrypto, \nupdating both python and pycrypto\n\nAny suggestions?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":922,"Q_Id":41895868,"Users Score":0,"Answer":"Is python defined properly on your machine?\nMake sure PATH environment variable has python's installation folder in it","Q_Score":0,"Tags":"python,python-3.x,ubuntu,importerror,pycrypto","A_Id":41896166,"CreationDate":"2017-01-27T14:08:00.000","Title":"Getting ImportError: No module named 'Crypto' after installation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know. Maybe this question isn't in its correspondig area, but as long it's linked with programming (In this case, python2.7), it seems quite logical to me to post it here...\nIn fact, That's the main question. \nShould it be necessary to translate debug info to other languages?\nIt's quite a trivial question, but it's something I've faced recently, and I don't know if I should do it or not.\nP.S: By \"Debug Info\" I refer to text like \"[TimeStamp] Handshake completed!\" or \"[TimeStamp] Download progress: %64\"","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":61,"Q_Id":41918526,"Users Score":2,"Answer":"It simply depends on the information of who is the debug info for?\nIn case of devs only, any dev should know english I think.\nIn case of end users and a multilanguage app, it might be worth the translation. But what are the endusers gonna do with the debug info anyway?\nIn case of multicultural large project, it might be useful, but my experience, we always agree on a common dev language and that includes debug info.","Q_Score":0,"Tags":"python-2.7,localization,internationalization,translation,globalization","A_Id":41918548,"CreationDate":"2017-01-29T07:15:00.000","Title":"Does debug info deserves to be translated?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know. Maybe this question isn't in its correspondig area, but as long it's linked with programming (In this case, python2.7), it seems quite logical to me to post it here...\nIn fact, That's the main question. \nShould it be necessary to translate debug info to other languages?\nIt's quite a trivial question, but it's something I've faced recently, and I don't know if I should do it or not.\nP.S: By \"Debug Info\" I refer to text like \"[TimeStamp] Handshake completed!\" or \"[TimeStamp] Download progress: %64\"","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":61,"Q_Id":41918526,"Users Score":2,"Answer":"I would base the answer on the following simple question: Is the information to be interpreted by the end user (\u2192 translate) or by the developer (\u2192 don't translate).\nNormally, debug messages fall squarely into the second category (if they don't, it might be worth looking at the UI design) \u2013 but that's for you to decide.\nEven if it is the end user who will be expected to relay debug messages to the developers, I would refrain from translating them as long as the user is not expected to interpret and act based on the content of the messages. This will simplify both the localisation (and localisation update) process and, perhaps more importantly, the interpretation of user-submitted logs.","Q_Score":0,"Tags":"python-2.7,localization,internationalization,translation,globalization","A_Id":41926272,"CreationDate":"2017-01-29T07:15:00.000","Title":"Does debug info deserves to be translated?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to use my Raspberry Pi for some programming. (never done it before, I want to get into Python.) If I can transfer my programs yo my Windows 8.1 computer and run them there also, that would be perfect. Can I do that? Thanks!","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":41926293,"Users Score":0,"Answer":"Yes! Python code is mostly platform independent. Only some specific libs must be compiled in the Maschine. These should be installed using pip (if needed). More info in Google.","Q_Score":0,"Tags":"python,windows,raspberry-pi3","A_Id":41926309,"CreationDate":"2017-01-29T21:43:00.000","Title":"Will Python programs created on a Raspberry Pi running Raspbian work on a Windows 8.1 machine?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I would like to use my Raspberry Pi for some programming. (never done it before, I want to get into Python.) If I can transfer my programs yo my Windows 8.1 computer and run them there also, that would be perfect. Can I do that? Thanks!","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":41926293,"Users Score":0,"Answer":"Short answer: mostly yes, but it depends.\nObviously, the Raspberry Pi specific libraries for controlling its peripherals won't work on ms-windows.\nYour Pi is probably running a Linux distribution that has package management and comes with a functioning toolchain. That means that installing (python) packages and libraries will be a breeze. Tools like pip and setup.py scripts will mostly Just Work.\nThat is not necessarily the case on ms-windows.\nInstalling python libraries that contain extensions (compiled code) or require external shared libraries is a frustrating epxerience for technical reasons pertaining to the microsoft toolchain. On that OS it is generally easier to use a python distribution like Anaconda that has its own package manager, and comes with packages for most popular libraries.\nFurthermore, if you look into the documentation for Python's standard library you will see that sometimes a function is only available on UNIX or only on ms-windows. And due to the nature of how ms-windows creates new processes, there are some gotchas when you are using the multiprocessing module.\nIt would be a good idea to use the same Python version on both platforms. Currently that would be preferably 3.6 or 3.5.","Q_Score":0,"Tags":"python,windows,raspberry-pi3","A_Id":41927152,"CreationDate":"2017-01-29T21:43:00.000","Title":"Will Python programs created on a Raspberry Pi running Raspbian work on a Windows 8.1 machine?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am building a program to run several different analyses on a dataset. The different kinds of analysis are each represented by a different kind of analysis tool object (e.g. \"AnalysisType1\" and \"AnalysisType2\"). The analysis tools share many of the same parameters. The program is operated from a GUI, in which all the parameters are set by the user. What I'm trying to figure out, is what is the most elegant\/best way to share the parameters between all the components of the program. Options I can think of include:\n\nKeep all the parameters in the GUI, and pass to each analysis tool when it is executed.\nKeep parameters in each of the tools, and update the parameters in all the tools every time they are changed in the GUI. Then they are ready to go whenever an analysis is executed.\nCreate a ParameterSet object that holds all the parameters for all the components. Give a reference to this ParameterSet object to every component that needs it, and update its parameters whenever they are changed in the GUI.\n\nI've already tried #1, followed by #2, and as the complexity is growing, I'm considering moving to #3. Are there any reasons not to take this approach?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":52,"Q_Id":41958927,"Users Score":1,"Answer":"How about creating a parent class to all Analysis that will have common attributes (maybe static) and methods?\nThis way when you implement a new AnalysisType you inherit all the parameters and you can change them in a single place.","Q_Score":1,"Tags":"python,python-2.7","A_Id":41958983,"CreationDate":"2017-01-31T13:32:00.000","Title":"Sharing Parameters between Objects","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We are looking for a solution which uses minimum read\/write units of DynamoDB table for performing full backup, incremental backup and restore operations. Backup should store in AWS S3 (open to other alternatives). We have thought of few options such as:\n1) Using python multiprocessing and boto modules we were able to perform Full backup and Restore operations, it is performing well, but is taking more DynamoDB read\/write Units.\n2) Using AWS Data Pipeline service, we were able to perform Full backup and Restore operations.\n3) Using Dynamo Streams and kinesis Adapter\/ Dynamo Streams and Lambda function, we were able to perform Incremental backup.\nAre there other alternatives for Full backup, Incremental backup and Restore operations. The main limitation\/need is to have a scalable solution by utilizing minimal read\/write units of DynamoDb table.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1135,"Q_Id":41973955,"Users Score":1,"Answer":"Option #1 and #2 are almost the same- both do a Scan operation on the DynamoDB table, thereby consuming maximum no. of RCUs.\nOption #3 will save RCUs, but restoring becomes a challenge. If a record is updated more than once, you'll have multiple copies of it in the S3 backup because the record update will appear twice in the DynamoDB stream. So, while restoring you need to pick the latest record. You also need to handle deleted records correctly.\nYou should choose option #3 if the frequency of restoring is less, in which case you can run an EMR job over the incremental backups when needed. Otherwise, you should choose #1 or #2.","Q_Score":3,"Tags":"python-2.7,amazon-web-services,amazon-dynamodb,amazon-dynamodb-streams","A_Id":42009940,"CreationDate":"2017-02-01T07:14:00.000","Title":"How to perform AWS DynamoDB backup and restore operations by utilizing minimal read\/write units?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is there a way to automate checking Google Page Speed scores?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2435,"Q_Id":41988762,"Users Score":0,"Answer":"Anybody using this guide (as of April 2022) will need to update to the following:\nhttps:\/\/www.googleapis.com\/pagespeedonline\/v5\/runPagespeed?url={YOUR_SITE_URL}\/&filter_third_party_resources=true&locale=en_US&screenshot=false&strategy=desktop&key={YOUR_API_KEY}\nThe difference is the \"\/v2\/\" needs to be replaced with \"\/v5\/\"","Q_Score":1,"Tags":"python,selenium,automated-tests","A_Id":71752003,"CreationDate":"2017-02-01T20:08:00.000","Title":"How to automate Google PageSpeed Insights tests using Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just followed the instructions on the site and installed aerospike (on linux mint). I'm able to import the aerospike python client module from python 2.7 but not from 3.6 (newly installed). I'm thinking that I need to add the directory to my \"python path\" perhaps??, but having difficulty understanding how this works. I want to be able to run aerospike and matplotlib in 3.6.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":154,"Q_Id":41989455,"Users Score":1,"Answer":"I figured it out. I just needed to use pip3 instead of pip to install it to correct version of python (though I was only able to get it onto 3.5, not 3.6 for some reason).","Q_Score":1,"Tags":"aerospike,python-3.6","A_Id":41991031,"CreationDate":"2017-02-01T20:47:00.000","Title":"newbie installing aerospike client to both my python versions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I need to use delete_all_cookies in my code. I have some concerns:\nDo I need to place before opening the url\nor before quit\nCan anyone clarify the same? A lot of cache has been created during my test runs. My main objective is to clear cache in test server machine.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":33,"Q_Id":42000361,"Users Score":0,"Answer":"This depends to some degree on the browser you're using. If you are using a current version of Chrome or Firefox, deleting all cookies before starting testing won't make sense, as every driver instance will start with a separate, temporary profile without any cookies anyway.\nDeleting all cookies after running the tests is equally unnecessary in those browsers, as the next test will start up with a clean profile again anyway. There only real scenario where deleting cookies makes sense is if you do multiple things in the same test (i.e., with the same driver instance) where you know that at some point the app sets a cookie that you don't want to be there at a later stage in the test. That's more of an edge case, though.","Q_Score":0,"Tags":"python,firefox,selenium-webdriver","A_Id":42038226,"CreationDate":"2017-02-02T10:56:00.000","Title":"At which point should I place delete_all_cookies","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have upgraded my Community version of PyCharm to 2016.3.2, and I'm not positive it was this exact version, but when I went to run files that had unittests in them, only some of them are recognized as UnitTests that I can right click and run.\nI have looked to make sure that my classes implement unittest.TestCase\nclass clWorkflowWebClientTest(unittest.TestCase):\nall of my tests begin with test_blahblah()\nIf I go into Edit Configurations and add one manually, I can right click and run it from the project tree, and it runs as a UnitTest. But I don't get the \"Run UnitTests in Blah' dialog when I right click the file.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":37,"Q_Id":42008704,"Users Score":0,"Answer":"This turned out to be an issue I caused myself. we had added a folder called 'UnitTest' and introducing this to the path caused issues with PyCharm knowing what was a true UnitTest file.\nI still don't know exactly what caused some files to work, but there appears to be one method in those files that did work that was probably being imported from another file that had the proper pathing.","Q_Score":0,"Tags":"intellij-idea,pycharm,python-unittest","A_Id":42026672,"CreationDate":"2017-02-02T17:33:00.000","Title":"Did something Change with Pycharm 2016.3.2 - UnitTests no longer auto discovered","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python program I want to run when a specific user logs into my Ubuntu Server. Previously, I tried to do this via the command useradd -m -s \/var\/jumpbox\/jumpbox.py jumpbox. This ran the program, but it didn't work the same way it did when I call it via .\/jumpbox.py from the \/var\/jumpbox directory. The problem is, this is a curses menu and when an option is selected, another .py file is called to run. Using the useradd method to run jumpbox.py, my menu was the part the worked, but it never called my other .py files when an option was selected. What is the best way to go about running my \/var\/jumpbox\/jumpbox.py file is run when the jumpbox user (and only this user) logs into the server?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":65,"Q_Id":42009558,"Users Score":0,"Answer":"It was the path of the .py file being called inside jumpbox.py. I was referencing it only as the filename, without the full path, since it was in the same directory. os.system(\"python .py\") made it work perfectly.\nThanks @Hannu","Q_Score":0,"Tags":"python,ubuntu","A_Id":42010021,"CreationDate":"2017-02-02T18:20:00.000","Title":"Ubuntu Server Run Script at Login for Specific User","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm currently building a website where the users would enter their credentials for another web service that I'm going to scrape to get their data.\nI want to make sure that when I save their credentials in my database, I'm using the best encryption possible and the best architecture to ensure the highest level of security.\nThe first idea that I had in mind was to encrypt the data using an RSA pub key (PBKDF2, PKCS1_OAEP, AES 256bit... ???) and then allowing my scrapping script to use the private key to decrypt the credentials and use them.\n\nBut if my server is hacked, the hacker would have access to both the database and the private key, since it will be kept on my server that runs the scrapping script and hosts the DB. Is there an architecture pattern that solves this ?\nI've read that that there should be a mix of hashing and encryption to enable maximum security but hashing is uni directional and it doesn't fit my use case since I will have to reuse the credentials. If you can advise me with the best encryption cypher\/pattern you know it could be awesome.\n\nI'm coding in python and I believe PyCrypto is the go-to library for encryption. (Sorry I have very little knowledge about cryptography so I might be confusing technologies)","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":207,"Q_Id":42023939,"Users Score":0,"Answer":"Do the encryption and decryption on the second server (encryption server).\nPass the password to the encryption server along with an id for encryption and it returns the encrypted password to store in the DB.\nWhen the password is needed pass the encrypted password to the encryption server for decryption.\nHave the encryption server monitor request activity, if an unusual number of requests are received sound an alarm and in extreme cases stop processing requests.\nMake the second server very secure. No Internet access, minimal access accounts, 2-factor authentication.\nThe encryption server becomes a poor-man's HSM (Hardware Encryption Module).","Q_Score":0,"Tags":"python,security,encryption,cryptography","A_Id":42026136,"CreationDate":"2017-02-03T12:07:00.000","Title":"Encrypting credentials and reusing them securely","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a python-based lambda function which triggers on s3 put operations based on a kinesis firehose stream which sends data at the rate of around 10k records per minute. Right now the lambda function just performs some small fixups of the data and delivers it to a logstash instance in batches of 100. The lambda execution time is 5-12 secs which is fine as it runs every minute.\nWe're looking at enriching the streamed data with some more info before sending it to logstash. Each message coming in has an \"id\" field, and we'd like to lookup that id against a db of some sort, grab some extra info from the db and inject that into the object before passing it on.\nProblem is, I cannot make it go fast enough.\nI tried loading all the data (600k records) into DynamoDB, and perform lookups on each record loop in the lambda function. This slows down the execution way too much. Then I figured we don't have to lookup the same id twice, so i'm using a list obj to hold already \"looked-up\" data - this brought the execution time down somewhat, but still not nearly close to what we'd like.\nThen I thought about preloading the entire DB dataset. I tested this - simply dumping all 600 records from dynamodb into a \"cache list\" object before starting to loop thru each record from the s3 object. The data dumps in about one minute, but the cache list is now so large that each lookup against it takes 5 secs (way slower than hitting the db).\nI'm at a loss on what do do here - I totally realize that lambda might not be the right platform for this and we'll probably move to some other product if we can't make it work, but first I thought I'd see if the community had some pointers as to how to speed up this thing.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":623,"Q_Id":42035082,"Users Score":1,"Answer":"Preload the data into a Redis server. This is exactly what Redis is good at.","Q_Score":2,"Tags":"python,amazon-web-services,aws-lambda,amazon-kinesis-firehose","A_Id":42035255,"CreationDate":"2017-02-04T00:21:00.000","Title":"Fast data access for AWS Lambda function","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm getting started out creating a website where users can store and get (on user request) private information they store on the server. Since the information is private, I would also like to provide 256 bit encryption. So, how should I go about it? Should I code the back end server stuff in node.js or Python, since I'm comfortable with both languages? How do I go about providing a secure server to the user? And if in the future, I would like to expand my service to mobile apps for Android and iOS, what would be the process?\nPlease try explaining in detail since that would be a great help :)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":30,"Q_Id":42036307,"Users Score":1,"Answer":"You don't need to create your own encrypted communication protocol. Just serve all traffic over https.\nIf you also wish to encrypt the data before storing it on a database you can encrypt it on arrival to the server.\nCheck out Express.js for the server, Passport.js for authentication and search for 256-bit encryption on npm. There are quite a few implementations.","Q_Score":1,"Tags":"python,node.js,web-applications,server","A_Id":42036454,"CreationDate":"2017-02-04T03:58:00.000","Title":"Build a Server to Receive and Send User's Private Information","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am looking for an approach \/ design through which i want to automate the process of FTP from windows location to IFS location present on AS400 environment when ever there is a new file added to windows path. \nBelow is the approach I thought, Please refine it if needed.\n\nWe have an option WRKJOBSCDEthrough which we can run a CL program in a scheduled threshold of 1hr.\nTo write a CL program which invokes a script(pyton\/shell) to talk to windows location(say X:drive having its IP as xx.xxx.xx.xx).\nShell script has to search for latest file in the location X:drive and FTP that jar(of size 5mb max) to IFS location(say \/usr\/dta\/ydrive) on AS400 machine.\nThus, CL program we invoked in STEP2 has to mail to me using SNDDSTthe list of all the jars ftp'd by the scheduler job that runs every 1 hr in STEP1.\n\n\n\nAll I am new to CL programming\/RPGLE . Please help me with some\n learning stuff and also design of such concepts.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":500,"Q_Id":42044560,"Users Score":0,"Answer":"The CL command RUNRMTCMD can be used to invoke a command on a PC running a rexec() client. iSeries Access for Windows offers such a client, and there are others available. With the iSeries client, the output of the PC command is placed in a spool file on the AS\/400, which should contain the results of the FTP session.\nYou can copy the spool file to a file using the CPYSPLF command and SNDDST it to yourself, but I am not sure the contents will be converted from EBCDIC to ASCII.\nCheck out Easy400.net for the MMAIL programs developed by Giovanni Perotti. This package includes an EMAILSPL command to email a spool file. I believe you will need to pay $50 for the download.\nI think you are on the right track, but the are a lot of details.","Q_Score":0,"Tags":"shell,python-3.x,ftp,ibm-midrange","A_Id":42054160,"CreationDate":"2017-02-04T19:19:00.000","Title":"FTP Jar file from share path on windows to IFS location in AS400?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to setup a salt-master\/salt-cloud on Centos 7. The issue that I am having is that I need Python 2.7.13 to use salt-cloud to clone vm in vmware vcenter (uses pyvmomi). CentOS comes with Python 2.7.5 which salt has a known issue with (SSL doesn't work).\nI have tried to find a configuration file on the machine to change which python version it should use with no luck.\nI see two possible fixes here,\nsomehow overwrite the python 2.7.5 with 2.7.13 so that it is the only python available. \nOR \nIf possible change the python path salt uses.\nAny Ideas on how to do either of these would be appreciated? \n(Or another solution that I haven't mentioned above?)","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1084,"Q_Id":42103374,"Users Score":1,"Answer":"The salt packages are built using the system python and system site-packages directory. If something doesn't work right, file a bug with salt. You should avoid overwriting the stock python, as that will result in a broken system in many ways.","Q_Score":1,"Tags":"python,python-2.7,salt,salt-stack,salt-cloud","A_Id":42263855,"CreationDate":"2017-02-08T01:58:00.000","Title":"How to change Default Python for Salt in CentOS 7?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a idea for a small project where I will try to transfer real time sensor data that is captured and converted to digital signal using MCP3008 to the NodeJS server that is installed on Raspberry PI. \nMy question is: what is the most efficient and\/or fastest way for data transfer from Python program to NodeJS server to be displayed in webpage.\nThanks for you advices","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":648,"Q_Id":42114174,"Users Score":0,"Answer":"Depending on the amount of data and the complexity\/simplicity that you want to achieve, you can e.g.\n\nhit HTTP endpoint of your Node server from the Python program every time there's ne data\nconnect with WebSocket and send new data as messages\nconnect with TCP once and send new data as new lines\nconnect with TCP every time when there's new data\nsend a UDP packet with every new data\nif the Node and Python programs are running on the same system then you can use IPC, named pipes etc.\nthere are more ways to do it\n\nAll of those can be done with Node and Python.","Q_Score":0,"Tags":"node.js,python-2.7,stream,sensors,raspberry-pi3","A_Id":42114793,"CreationDate":"2017-02-08T13:13:00.000","Title":"Data transfer between Python and NodeJS in Raspberry Pi","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a really weird problem with embedding python. If I don't specify PYTHONPATH, Py_Initialize fails with ImportError: No module named site.\nIf I set PYTHONPATH in cmd and then run my program, it works!\nIf I set PYTHONPATH programmatically (_putenv_s \/ SetEnvironmentVariable) it fails with ImportError again.\nI've checked that the value is set with system(\"echo %PYTHONPATH%\");, I've made sure multiple times that it is the correct path. I have no idea why it's failing... any ideas appreciated.\nSetup: win10 x64, stackless python 2.7 x86 embedded in a C program.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2090,"Q_Id":42142261,"Users Score":0,"Answer":"Turns out I had to set PYTHONPATH before, then load the dll with a delay. The python library I have seems to be non-standard \/ modified.","Q_Score":0,"Tags":"python,c,winapi,python-stackless","A_Id":42142752,"CreationDate":"2017-02-09T16:44:00.000","Title":"Embedded python not picking up PYTHONPATH","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been reading about Python-Mixin and come to know that it adds some features (methods) to class. Similarly, Java-Interfaces also provide methods to class. \nOnly difference, I could see is that Java-interfaces are abstract methods and Python-Mixin carry implementation.\nAny other differences ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":699,"Q_Id":42143261,"Users Score":9,"Answer":"Well, the 'abstract methods' part is quite important.\nJava is strongly typed. By specifying the interfaces in the type definition, you use them to construct the signature of the new type. After the type definition, you have promised that this new type (or some sub-class) will eventually implement all the functions that were defined in the various interfaces you specified.\nTherefore, an interface DOES NOT really add any methods to a class, since it doesn't provide a method implementation. It just adds to the signature\/promise of the class.\nPython, however, is not strongly typed. The 'signature' of the type doesn't really matter, since it simply checks at run time whether the method you wish to call is actually present.\nTherefore, in Python the mixin is indeed about adding methods and functionality to a class. It is not at all concerned with the type signature.\nIn summary:\n\nJava Interfaces -> Functions are NOT added, signature IS extended.\nPython mixins -> Functions ARE added, signature doesn't matter.","Q_Score":2,"Tags":"java,python,interface,mixins","A_Id":42143613,"CreationDate":"2017-02-09T17:33:00.000","Title":"Difference between Java Interfaces and Python Mixin?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to write a script in python which delivers functionality of ink coverage same as Ghostscript. I dont know where to start. Can someone please guide me?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":92,"Q_Id":42156136,"Users Score":1,"Answer":"This depends on whether you want to handle PostScript or PDF as an input.\nIn either event you will need to write an interpreter for the language, and a rendering library. Its believed that an interpreter and rendering library for PostScript is around 5 man years work. Although PDF is at first sight simpler, because it is a description language, not a programming language, the more complex graphics model (transparency for example) and complications like annotations, optional content etc will likely make this a task of similar or greater magnitude.\nluser droog, who has written an at least reasonably complete PostScript ineterpreter, can possibly provide more detailed estimates of the effort involved.\nSo, once you can interpret the input, and render it, then you can count the number of pixels of each colour in your rendered output. That will give you the ink coverage. That part is very simple....\nOf course, even more simply, just use Ghostscript and take advantage of something like 100 man years of development that's already been done.","Q_Score":0,"Tags":"python,ghostscript","A_Id":42156701,"CreationDate":"2017-02-10T09:43:00.000","Title":"Ghostscript ink coverage function in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Python and took on a small project for the firehouse.\nI am looking to make a \"Calls YTD\" Sign.\nThe initial thought was a raspberry Pi connected to the a touch screen.\nAfter some playing around and learning how to use python a little I realized one very important fact... I am way over my head.\nLooking for some direction.\nIn order for this to display on the touch screen I will need to build it into a GUI. Should I stop right there and instead get a 12x12 LED and keep it more simple? \nOtherwise the goal would be to display the current call number \"61\" for example, with an up and down arrow to simply advance or retract a number .\nAdding the ability to display last years call volume would be cool but not necessary.\nWhat I am looking for ultimately, is some direction if python and raspberry pi is the way to go or should I head in another direction.\nThank you in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":67,"Q_Id":42179424,"Users Score":0,"Answer":"For a gui you could always take a look into Tkinter.\nYou could test the gui without having the actual raspberry pi.\nSwitching to leds would require an LED matrix, which is more demanding in terms of electrical engineering. Raspberry pi would be my recommendation.","Q_Score":0,"Tags":"python,raspberry-pi,touch","A_Id":42180008,"CreationDate":"2017-02-11T18:11:00.000","Title":"Counter Display Design","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any way to delete a message sent by anyone other than the bot itself, the documentation seems to indicate that it is possible\n\nYour own messages could be deleted without any proper permissions. However to delete other people\u2019s messages, you need the proper permissions to do so.\n\nBut I can't find a way to target the message to do so in an on_message event trigger, am I missing something or is it just not possible?","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":87622,"Q_Id":42182243,"Users Score":0,"Answer":"if you're trying to delete the last sent message, e.g if a user is calling a command and you want to remove their message and then send the command.\nUse this \"await ctx.message.delete()\" at the top of your command, it will find the last sent message and delete it.","Q_Score":10,"Tags":"python,discord","A_Id":69640480,"CreationDate":"2017-02-11T23:00:00.000","Title":"Deleting User Messages in Discord.py","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So i've run a heroku create command on my django repo, and currently it is living on Heroku. What I didnt do prior was create my own local git repo. I run git init, create a .gitignore to filter out my pycharm ide files, all the fun stuff.\nI go to run git add . to add everything to the initial commit. Odd...it returns: \n[1] 4270 killed git add.\nSo i run git add . again and get back this:\nfatal: Unable to create \/Users\/thefromanguard\/thefromanguard\/app\/.git\/index.lock': File exists.\n\"Another git process seems to be running in this repository, e.g.\nan editor opened by 'git commit'. Please make sure all processes\nare terminated then try again. If it still fails, a git process\nmay have crashed in this repository earlier:\nremove the file manually to continue.\"\nSo I go and destroy the file, run it again; same error. Removed the whole repo, repeated the process, still got the same message. \nIs Heroku running in the background where ps can't see it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":110,"Q_Id":42195983,"Users Score":2,"Answer":"I would start over.\n\nDestroy the heroku app\nheroku apps:destroy --app YOURAPPNAME\nRemove the whole repo (I would even remove the directory)\nCreate new directory, copy files over (do NOT copy old git repo artifacts that may be left over, anything starting with .git)\nInitialize your git repo, add files, and commit, then push upstream to your remote (like github, if you're using one) git init && git add . && git commit -m 'initial commit' and optionally git push origin master\nThen perform the heroku create\n\nThat should remove the conflict.","Q_Score":0,"Tags":"python,django,heroku,heroku-toolbelt","A_Id":42214216,"CreationDate":"2017-02-13T02:57:00.000","Title":"Is Heroku blocking my local git commands?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have installed Crypto , using pip install pycrypto.\nIt got installed perfectly in CentOS. Able to see all module files under Crypto folder. \/usr\/lib64\/python2.7\/site-packages\/Crypto.\nin terminal, when importing Crypto. Able to do it.\nBut getting error for importing Ciper from Crypto with below \nfrom Crypto.Ciper import AES\nSays below error:\nTraceback (most recent call last):\n File \"\", line 1, in \nImportError: No module named Ciper\nBut no import error for other modules in Crypto\n\n\n\nfrom Crypto import Hash\nfrom Crypto import Signature\nfrom Crypto import Util\nfrom Crypto import Ciper\n\n\n\nTraceback (most recent call last):\n File \"\", line 1, in \nImportError: cannot import name Ciper\nSee for detailed imports in my terminal\nPython 2.7.5 (default, Nov 6 2016, 00:28:07)\n[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux2\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n\n\n\nimport os\nimport Crypto\nprint Crypto.file\n\n\n\n\/usr\/lib64\/python2.7\/site-packages\/Crypto\/init.pyc\n\n\n\nprint dir(Crypto)\n\n\n\n['all', 'builtins', 'doc', 'file', 'name', 'package', 'path', 'revision', 'version', 'version_info']\n\n\n\nprint os.listdir(os.path.dirname(Crypto.file))\n\n\n\n['Protocol', 'Util', 'pct_warnings.py', 'init.pyc', 'init.py', 'Signature', 'PublicKey', 'Cipher', 'Hash', 'SelfTest', 'pct_warnings.pyc', 'Random']\nAny ideas how to resolve this issue ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":78,"Q_Id":42196378,"Users Score":0,"Answer":"That module is available as an RPM package from the EPEL repository. Uninstall what you have with pip first, then run yum install python-crypto.","Q_Score":1,"Tags":"python-2.7,import,centos,importerror,pycrypto","A_Id":42263629,"CreationDate":"2017-02-13T03:45:00.000","Title":"Only Ciper is not importing , importerror but not for other modules like Random in Crypto","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a meteor project that includes python scripts in our private folder of our project. We can easily run them from meteor using exec, we just don't know how to install python modules on our galaxy server that is hosting our app. It works fine running the scripts on our localhost since the modules are installed on our computers, but it appears galaxy doesn't offer a command line or anything to install these modules. We tried creating our own command line by calling exec commands on the meteor server, but it was unable to find any modules. For example when we tried to install pip, the server logged \"Unable to find pip\".\nBasically we can run the python scripts, but since they rely on modules, galaxy throws errors and we aren't sure how to install those modules. Any ideas?\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":192,"Q_Id":42216640,"Users Score":0,"Answer":"It really depends on how horrible you want to be :)\nNo matter what, you'll need a well-specified requirements.txt or setup.py. Once you can confirm your scripts can run on something other than a development machine, perhaps by using a virtualenv, you have a few options:\n\nI would recommend hosting your Python scripts as their own independent app. This sounds horrible, but in reality, with Flask, you can basically make them executable over the Internet with very, very little IT. Indeed, Flask is supported as a first-class citizen in Google App Engine.\nAlternatively, you can poke at what version of Linux the Meteor containers are running and ship a binary built with PyInstaller in your private directory.","Q_Score":1,"Tags":"python,node.js,meteor,meteor-galaxy","A_Id":42284125,"CreationDate":"2017-02-14T02:02:00.000","Title":"Installing python modules in production meteor app hosted with galaxy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"Can anyone tell difference between iPerf and iPerf3? while using it with client-server python script,what are the dependencies?And what are the alternatives to iPerf?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2323,"Q_Id":42218537,"Users Score":0,"Answer":"iperf vs iperf3 from wikipedia\n\nA rewrite of iperf from scratch, with the goal of a smaller, simpler\n code base and a library version of the functionality that can be used\n in other programs, called iperf3, was started in 2009. The first\n iperf3 release was made in January 2014. The website states: \"iperf3\n is not backwards compatible with iperf2.x\".\n\nAlternatives are Netcat, Bandwidth Test Controller (BWCTL), ps-performance toolkit, iXChariot, jperf, Lanbench, NetIO-GUI, Netstress.","Q_Score":0,"Tags":"python-2.7","A_Id":42813821,"CreationDate":"2017-02-14T05:28:00.000","Title":"Iperf3 commands with python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I execute a Python 3 script inside my Raspberry Pi 3 and it uses time.sleep(wait), it only works interactively. If I background the process using &, the script doesn't seem to work at all and I don't see any output in my CSV file the script writes to. It stays at file size 0 forever.\nI've tried this by running a script directly (read-sensor >\/var\/lib\/envirophat\/sensor.csv &) and the same inside a Docker container (I'm using HypriotOS).\nHow can I read the sensor faster than once per minute (using crontab) but not continuously without any kind of sleep?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":514,"Q_Id":42231337,"Users Score":1,"Answer":"Looks like the output buffering was in fact the issue. It was working but never outputting anything so I couldn't tell. Using python3 -u seems to do the trick. I updated my Docker image to reflect this.","Q_Score":1,"Tags":"python-3.x,docker,raspberry-pi3","A_Id":42259134,"CreationDate":"2017-02-14T16:30:00.000","Title":"Using Python 3 time.sleep in Raspberry Pi 3 hangs process","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've installed python 2.7.13 from sources according to their readme file on CentOS 6.6. (just following the configure\/make procedure). I run these python from the command line and seems to work fine. However, as it doesn't come with pip and setuptools, I downloaded get-pip.py and tried to run it this way:\n\/share\/apps\/Python-2.7.13\/bin\/python2.7 get-pip.py \nThen I get the following error:\nTraceback (most recent call last):\n File \"get-pip.py\", line 28, in \n import tempfile\n File \"\/share\/apps\/Python-2.7.13\/lib\/python2.7\/tempfile.py\", line 32, in \n import io as _io\n File \"\/share\/apps\/Python-2.7.13\/lib\/python2.7\/io.py\", line 51, in \n import _io\nImportError: \/share\/apps\/Python-2.7.13\/lib\/python2.7\/lib-dynload\/_io.so: undefined symbol: _PyCodec_LookupTextEncoding\nI tried the same with Python 2.7.12 with identical results.\nHowever, if I run get-pip.py with a prebuilt python 2.7.12 release, it works fine.\nEDIT: I checked the library \/share\/apps\/Python-2.7.13\/lib\/python2.7\/lib-dynload\/_io.so with nm -g and the symbol seems to be there (I found U _PyCodec_LookupTextEncoding)\nAny help will be greatly appreciated,\nthanks in advance,\nBernab\u00e9","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":465,"Q_Id":42233903,"Users Score":1,"Answer":"After digging a bit more, I found the problem.\nThe symbol was undefined in _io.so. I ldd this library and learned that it was pointing to an older libpython2.7.so (which is the library that happens to define the symbol in its new version). This was because I had the old \/opt\/python\/lib in my LDD_LIBRARY_PATH:\nlinux-vdso.so.1 => (0x00007fffb68d5000)\n libpython2.7.so.1.0 => \/opt\/python\/lib\/libpython2.7.so.1.0 (0x00007f4240492000)\n libpthread.so.0 => \/lib64\/libpthread.so.0 (0x00007f424025f000)\n libc.so.6 => \/lib64\/libc.so.6 (0x00007f423fecb000)\n libdl.so.2 => \/lib64\/libdl.so.2 (0x00007f423fcc7000)\n libutil.so.1 => \/lib64\/libutil.so.1 (0x00007f423fac3000)\n libm.so.6 => \/lib64\/libm.so.6 (0x00007f423f83f000)\n \/lib64\/ld-linux-x86-64.so.2 (0x000000337b000000)\n\nI fixed this and it solved the problem.","Q_Score":1,"Tags":"python,c,linux,pip,centos6","A_Id":42234395,"CreationDate":"2017-02-14T18:44:00.000","Title":"Undefined symbol after Running get-pip on fresh Python source installation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm grabbing some zip files from an S3 bucket and then converting them to gzip. The zipped files are about 130 megs. When uncompressed they are about 2 Gigs so I'm hitting the '[Errno 28] No space left on device' error.\nIs it possible to use a different scratch space? maybe an EBS volume?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":330,"Q_Id":42238406,"Users Score":0,"Answer":"The accepted answer is no longer accurate due to at least two new AWS features added since the posting. There are many configuration options and costs to consider, but both would work for the OP's needs.\n\nLambda functions can now attach an Elastic File System (EFS) volume. Write to EFS instead of \/tmp.\nLambda functions now let you configure the size of \/tmp. Simply increase the size to handle your largest expected file.","Q_Score":2,"Tags":"python,amazon-web-services,amazon-s3,aws-lambda","A_Id":71913507,"CreationDate":"2017-02-14T23:54:00.000","Title":"Is there a way to change the 'scratch' (\/tmp) space location of an AWS lambda function?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to import and use dataset package of python at AWS Lambda. The dataset package is about MySQL connection and executing queries. But, when I try to import it, there is an error.\n\"libmysqlclient.so.18: cannot open shared object file: No such file or directory\"\nI think that the problem is because MySQL client package is necessary. But, there is no MySQL package in the machine of AWS Lambda.\nHow to add the third party program and how to link that?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":131,"Q_Id":42267553,"Users Score":0,"Answer":"You should install your packages in your lambda folder :\n$ pip install YOUR_MODULE -t YOUR_LAMBDA_FOLDER \nAnd then, compress your whole directory in a zip to upload in you lambda.","Q_Score":1,"Tags":"mysql,python-2.7,amazon-web-services,aws-lambda","A_Id":42268813,"CreationDate":"2017-02-16T07:30:00.000","Title":"How to use the package written by another language in AWS Lambda?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have python script that checks if the server is up or down, and if it's down it sends out an email along with few system logs. \nWhat I want is to keep checking for the server every 5 minutes, so I put the cronjob as follows:\n*\/5 * * * * \/python\/uptime.sh\nSo whenever the server's down, it sends an email. But I want the script to stop executing (sending more emails) after the first one. \nCan anyone help me out with how to do this? \nThanks.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":227,"Q_Id":42271330,"Users Score":0,"Answer":"Simple solution is, you can set some Bash env variable MONITORING=true and let your python script to check that variable using os.environ[\"MONITORING\"]. If that variable is true then check if the server is up or down else don't check anything. Once server down is found, set that variable to false from script like os.environ[\"MONITORING\"] = false. So it won't send emails until you set that env variable again true.","Q_Score":0,"Tags":"python,cron,crontab","A_Id":42271741,"CreationDate":"2017-02-16T10:32:00.000","Title":"Running cronjob every 5 minutes but stopped after first execution?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have python script that checks if the server is up or down, and if it's down it sends out an email along with few system logs. \nWhat I want is to keep checking for the server every 5 minutes, so I put the cronjob as follows:\n*\/5 * * * * \/python\/uptime.sh\nSo whenever the server's down, it sends an email. But I want the script to stop executing (sending more emails) after the first one. \nCan anyone help me out with how to do this? \nThanks.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":227,"Q_Id":42271330,"Users Score":0,"Answer":"write an empty While True script that runs forever (ex: \"mailtrigger.py\")\nrun it with -nohup mailtrigger.py from shell in infinite loop\nonce the server is down check if mailtrigger.py is running, if its\nnot then terminate mailtrigger.py (kill process id)\n\nyour next iterations will not send mails since mailtrigger.py is not running.","Q_Score":0,"Tags":"python,cron,crontab","A_Id":42295869,"CreationDate":"2017-02-16T10:32:00.000","Title":"Running cronjob every 5 minutes but stopped after first execution?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have successfully tested basic DroneKit scripts on a companion computer (Raspberry Pi) to achieve autonomous flight on Pixhawk controlled 3DR ArduCopter. The RPi is also connected to various sensors, and crunches that data in real time in the same python script- to influence the flight. \nIs it possible to pilot the drone manually with a Taranis as usual, while RPi (with DroneKit running) remains connected to Pixhawk and overrides the radio when needed? For example, a background prevention mechanism that takes control and moves the copter away if the pilot is about to crash into a wall (which is easily sensed using a LIDAR).\nThank you!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":266,"Q_Id":42330006,"Users Score":1,"Answer":"While your vehicle is in any mode other than GUIDED, your dronekit script will not be able to control behaviour. However, the script can change the mode of the copter to GUIDED, send some commands, and then set the mode back to the previous mode when it is done.\nThe example you gave of using lidar for obstacle avoidance is already a feature in progress, being built directly into normal flight modes. Perhaps it's not documented well enough yet, but maybe try digging into the code to see how it works.","Q_Score":1,"Tags":"dronekit-python,dronekit","A_Id":42332432,"CreationDate":"2017-02-19T16:51:00.000","Title":"Is it possible to control Pixhawk quadcopter with a Taranis and a DroneKit script simultaneously?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I did notice something strange on my python server running jenkins. Basically if I run a script, which has dependencies (I use python via Brew), from console, it works fine.\nBut when I run it via Jenkins, I get an error because that package was not found.\nWhen I call the script, I use python -m py.test -s myscript.py\nIs there a gotcha when using Jenkins, and call python as I do? I would expect that a command called in the bash section of Jenkins, would execute as if it was running in console, but from the result that I get, it seems that is not true.\nWhen I check for which python, I get back \/usr\/local\/bin\/python; which has the symlink to the brew version. If I echo $PYTHONPATH I get back the same path.\nOne interesting thing though, is that if on Jenkins I call explicitly either \/usr\/local\/bin\/python -m or \/usr\/bin\/python ; I get an error saying that there is no python there; but if I just use python -m, it works. This makes no sense to me.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":859,"Q_Id":42339728,"Users Score":1,"Answer":"Jenkins is running your jobs as a different user, and typically on a different host (unless you let your Jenkins run on your local host and don't use slaves to run your jobs). Resulting from these two aspects you will have also a different environment (variables like HOME, PATH, PYTHONPATH, and all the other environment stuff like locales etc.).\nTo find out the host, let a shell in the job execute hostname.\nTo find out the Jenkins user, let a shell in the job execute id.\nTo find out the environment, let a shell in the job execute set (which will produce a lot of output).\nMy guess would be that in your case the modules you are trying to use are not installed on the Jenkins host.","Q_Score":0,"Tags":"python,jenkins","A_Id":42340973,"CreationDate":"2017-02-20T08:33:00.000","Title":"is Python called differently via Jenkins?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"One of the first things I do on a new project is to knock up a quick script to parse a log file and generate a message sequence chart, as I believe that picture is worth a thousand words.\nNew project, and it is mandated that we use only Enterprise Architect. I have no idea what its save file format is.\nIs it possible to generate a file which will open in EA from Python?\nIf so, where can I find an example or a tutorial?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1220,"Q_Id":42350592,"Users Score":3,"Answer":"EA is using a RDBMS to store it's repository. In the simplest case, this is a MS Access database renamed to .EAP. You can modify this RDBMS directly, but only if you know what you're doing. The recommended way is to use the API. Often a mix of both is the preferred way. You can use Python in both cases without issues.\nShameless self plug: I have published books about EA's internal and also its API on LeanPub.","Q_Score":3,"Tags":"python,enterprise-architect","A_Id":42353157,"CreationDate":"2017-02-20T17:15:00.000","Title":"Can I generate Enterprise Architect diagrams from Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"If I am on my host machine, I can kickoff a script inside a Docker container using:\ndocker exec my_container bash myscript.sh\nHowever, let's say I want to run myscript.sh inside my_container from another container bob. If I run the command above while I'm in the shell of bob, it doesn't work (Docker isn't even installed in bob).\nWhat's the best way to do this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":775,"Q_Id":42352104,"Users Score":1,"Answer":"Simply launch your container with something like\ndocker run -it -v \/var\/run\/docker.sock:\/var\/run\/docker.sock -v \/usr\/bin\/docker:\/usr\/bin\/docker ...\nand it should do the trick","Q_Score":2,"Tags":"python,shell,ubuntu,docker","A_Id":42352587,"CreationDate":"2017-02-20T18:44:00.000","Title":"Run shell script inside Docker container from another Docker container?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"So everyday, I need to login to a couple different hosts via ssh and run some maintenance commands there in order for the QA team to be able to test my features.\nI want to use a python script to automate such boring tasks. It would be something like:\n\nssh host1\ndeploy stuff\nlogout from host1\nssh host2\nrestart stuff\nlogout from host2\nssh host3\ncheck health on stuff\nlogout from host3\n...\n\nIt's killing my productivity, and I would like to know if there is something nice, ergonomic and easy to implement that can handle and run commands on ssh sessions programmatically and output a report for me.\nOf course I will do the code, I just wanted some suggestions that are not bash scripts (because those are not meant for humans to be read).","AnswerCount":3,"Available Count":1,"Score":-0.0665680765,"is_accepted":false,"ViewCount":9599,"Q_Id":42375396,"Users Score":-1,"Answer":"If these manual stuffs is too many, then I may look into some server configuration managements like Ansible. \nI have done this kinda automation using:\n\nAnsible \nPython Fabric \nRake","Q_Score":4,"Tags":"python,linux,ssh","A_Id":42375591,"CreationDate":"2017-02-21T18:40:00.000","Title":"Automate ssh commands with python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I tried to test getting toast message on android device with Appium 1.6.3, but it is disappointed for me,the rate to correct get toast is very low. Is there anyone help me?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":509,"Q_Id":42384577,"Users Score":0,"Answer":"1.It depends upon how dynamic data is coming.\n2. If you want to get toast data while swiping than it becomes hard to get accurate data.","Q_Score":0,"Tags":"python,selenium-webdriver,automated-tests,ui-automation,python-appium","A_Id":42408979,"CreationDate":"2017-02-22T06:52:00.000","Title":"How to improve get toast correct rate on Appium 1.6.3 with uiautomator2?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an application I am currently working on for which I am integrating Travis CI. I am running into the problem of API keys being accessed by Travis. Given below is my current setup (without Travis):\nI have a config.py (and is git ignored) that has API keys for all my interfacing applications. I use ConfigParser to read this file and get the required keys. \nTravis asks me to look at environment variables as an option to encrypt the keys and add them to .travis.yml. How would Travis know or what needs to be done in order to make travis know that a particular key belongs to a specific interfacing application. Does there need to be changes to the code?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":51,"Q_Id":42397764,"Users Score":0,"Answer":"You would read these important variables into your application as system variables.\nHowever, this will only work for builds that are run against master. These environment variables aren't available for builds that are run as part of pull requests.","Q_Score":0,"Tags":"python-2.7,github,travis-ci","A_Id":42401328,"CreationDate":"2017-02-22T16:59:00.000","Title":"API Keys on .travis.yml and using it in code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hi every one but first let me say sorry about my english. I hope you guys will understand what I mean :)\n\n\nQuestion :\n\nIs it possible that RaspberryPi with RASPBIAN OS can communicates with PZEM-004T Energy monitor via USB port. I want to use Python to send Hexadecimal Code to request such as voltage, current, power and energy then read data that reply from module(PZEM-004T) and keep it into phpMyadmin.\n\n\nFor example\n\n\nIf I send hex command code : B1 C0 A8 01 01 00 1B, \nmodule will replys data back : A1 00 11 20 00 00 D2.\nThen convert replied data to decimal and keep it into database.\nplease suggest me what is the best way to success this challenge :)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":593,"Q_Id":42423373,"Users Score":0,"Answer":"Yes you can do this by using libraries such as pyserial like Leon said for the serial communication.\nFor the SQL database, you can use sqlalchemy to manage it.\nThis module (PZEM-004T) uses TTL serial communication, so if yours is not selled with an USB adapter you need one like a FTDI232 based one for example.\nI don't know what your program is intended for, but as it's a datalogger, if you want it to run every time your raspberry pi reboot you can call it in your \/etc\/rc.local","Q_Score":0,"Tags":"c#,python,hex,usb,raspberry-pi3","A_Id":42424805,"CreationDate":"2017-02-23T18:21:00.000","Title":"Is it possible? Python send Hex code via usb port (raspberry pi)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have many telegram channels, 24\\7 they send messages in the format \n\n\"buy usdjpy sl 145.2 tp 167.4\" \n\"eurusd sell sl 145.2 tp 167.4\" \n\"eurusd sl 145.2 tp 167.4 SELL\"\n\nor these words in some order\nMy idea is to create app that checks every channel's message, and redirects it to my channel if it is in the above format.\nDoes telegram api allow it?","AnswerCount":8,"Available Count":3,"Score":0.024994793,"is_accepted":false,"ViewCount":36182,"Q_Id":42430232,"Users Score":1,"Answer":"Got the solution to this problem. \nHere is bot which automatically forwards messages from one channel to another without the forward tag. \nMoreover the copying speed is legit!\n@copythatbot\nThis is the golden tool everyone is looking for.","Q_Score":3,"Tags":"telegram,telegram-bot,python-telegram-bot","A_Id":56536495,"CreationDate":"2017-02-24T03:29:00.000","Title":"How can I redirect messages from telegram channels that are in certain format?[telegram bot]","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have many telegram channels, 24\\7 they send messages in the format \n\n\"buy usdjpy sl 145.2 tp 167.4\" \n\"eurusd sell sl 145.2 tp 167.4\" \n\"eurusd sl 145.2 tp 167.4 SELL\"\n\nor these words in some order\nMy idea is to create app that checks every channel's message, and redirects it to my channel if it is in the above format.\nDoes telegram api allow it?","AnswerCount":8,"Available Count":3,"Score":0.0996679946,"is_accepted":false,"ViewCount":36182,"Q_Id":42430232,"Users Score":4,"Answer":"You cannot scrape from a telegram channel with a bot, unless, the bot is an administrator in the channel, which only the owner can add.\nOnce that is done, you can easily redirect posts to your channel by listening for channel_post updates.","Q_Score":3,"Tags":"telegram,telegram-bot,python-telegram-bot","A_Id":42467337,"CreationDate":"2017-02-24T03:29:00.000","Title":"How can I redirect messages from telegram channels that are in certain format?[telegram bot]","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have many telegram channels, 24\\7 they send messages in the format \n\n\"buy usdjpy sl 145.2 tp 167.4\" \n\"eurusd sell sl 145.2 tp 167.4\" \n\"eurusd sl 145.2 tp 167.4 SELL\"\n\nor these words in some order\nMy idea is to create app that checks every channel's message, and redirects it to my channel if it is in the above format.\nDoes telegram api allow it?","AnswerCount":8,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":36182,"Q_Id":42430232,"Users Score":2,"Answer":"This is very easy to do with Full Telegram API.\n\nfirst on your mobile phone subscribe to all the interested channels\nNext you develop a simple telegram client the receives all the updates from these channels\nNext you build some parsers that can understand the channel messages and filter out what you are interested in\nFinally you send the filtered content (re-formatted) to your own channel.\n\nthat's all that is required.","Q_Score":3,"Tags":"telegram,telegram-bot,python-telegram-bot","A_Id":42441369,"CreationDate":"2017-02-24T03:29:00.000","Title":"How can I redirect messages from telegram channels that are in certain format?[telegram bot]","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Tableau report with several dropdowns lists. I want to look at particular dropdowns and verify if list values I am seeing is what I want to see. \n Is there a way to automate testing on this part of the report? If so, please give me some pointers. I am pretty new to Tableau and I feel doing manual testing on a dropdown with several hundred values is exhausting. Please suggest possible solutions. Thanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1048,"Q_Id":42431816,"Users Score":0,"Answer":"Automated testing is not really supported by Tableau and can be quite difficult to implement on your own. There are commercial solutions for this at kinesis-ci.com. They can automate functional testing and integrate with Jenkins or other CI tools.","Q_Score":0,"Tags":"python,selenium,automated-tests,tableau-api","A_Id":42894435,"CreationDate":"2017-02-24T05:59:00.000","Title":"Automated Testing of Tableau Reports","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"appreciate any help I can get. I have searched page after page and have not found a solution that works for my code. Sorry to ask a some what of a redundant question.\nI am using Python 3.6.0 and for the life of me cannot get the darn thing to read my special characters. I have a text file with \"\u0101\" and am trying to have my module read how many of \u0101 are in the line and the location of them. I have the text file saved as utf-8 encoding and have added utf-8 encoding just about everywhere I can think and it still will not read that the character exists. I am not getting a trace back error or any error at all, that's probably why I'm stumped. \nimport sys\nimport re\n# coding=utf-8 \nwith open(\"text1.txt\",\"r\", encoding='utf-8') as rf, open('text2.txt','w', encoding='utf-8') as wf:\n y = '\u0101'\n for line in rf:\n VarTest = line.count(y)\n if VarTest == 1:\n VarLocation = [pos for pos, char in enumerate(line) if char == y]\n\nThe counter will not count that the character was on the line and I'm pretty sure my code for \"VarLocation\" is incorrect, but VarTest won't even read\/count the darn thing.\nAny help would be appreciated thank you!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":644,"Q_Id":42452980,"Users Score":0,"Answer":"HaHa yes, thank you. I also realized I had 2.7.13 python open and as soon as I closed it. The module started working both ways. Thank you again!!","Q_Score":0,"Tags":"python,python-3.x,encoding,utf-8","A_Id":42453222,"CreationDate":"2017-02-25T06:53:00.000","Title":"Python: Text File Reading Special Characters Issues","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a raspberry pi, which is setup as a audio streaming server. I have used websockets and python as programming language. The client can listen to the live audio stream by connecting to the server hosted on raspberry pi. The system works well in localhost environment. Now, I want to access the server from the internet and by searching I got to know about STUN. I tried to use pystun but I couldn't get the proper port for NAT punching. So can anyone help me to implement STUN?\nNote: server is listening at localhost:8000","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3652,"Q_Id":42453445,"Users Score":0,"Answer":"NAT punching is used for peer-to-peer (P2P) communication and your audio streaming server seems to be a client-server implementation.\nHow and if this is going to work heavily depends on your NAT device (which kind of NAT is implemented). Chances are high that your NAT device has short timeouts and you need to punch holes for every client connection (from your raspberry pi).\nAs you stated you're using WebSockets and these are always TCP, pystun isn't going to work because pystun only supports UDP.\nI'd suggest to create a port forwarding in your NAT device, tunnel your traffic using a P2P VPN or host your audio streaming server on a different network.","Q_Score":0,"Tags":"python,websocket,nat,stun","A_Id":64177395,"CreationDate":"2017-02-25T07:52:00.000","Title":"How to implement stun with python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to setup pytest on Eclipse and I get the following error\n\nusage: runfiles.py [options] [file_or_dir] [file_or_dir] [...]\n runfiles.py: error: unrecognized arguments: --verbosity inifile:\n None rootdir: D:\\EclipseWorkspace\\SeleniumPyTest\\PyTestSelenium\n\nI have con\nI am not looking for an alternative IDE I only want to use Eclipse.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1215,"Q_Id":42457330,"Users Score":1,"Answer":"I did on mac.\nGo to \"Preferences\"\nAfter that \"PyDev\"\nGo to \"PyUnit\"\nSelect \"Py.test runner\"\nIn the text field \"Parameters for test runner\" delete key \"--verbosity 0\"\nAlso you can delete this key then setup debug or runner config for your test:\n\"Edit configuration\"\n\"python unittest\"\nselect your config\ngo to \"arguments\"\ncheck \"override PyUnit\"\nand delete key \"--verbosity 0\"","Q_Score":0,"Tags":"python,eclipse,pytest","A_Id":44041455,"CreationDate":"2017-02-25T14:32:00.000","Title":"Eclipse PyTest runfiles.py: error: unrecognized arguments: --verbosity","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"As I understood in order to generate XML, we gotta gather negative and positive images. In every tutorial I read\/saw, all images; positive or negative, are resized to the same size, where the negative is usually double the size of the positive. \nMy question is as follow; can I have different sizes for positive images? I know it is going to be tedious since you need to specify the size of each image every time. But is it possible? Or would the detection of the object fail?\nImagine I am detecting an object, lets say a bed. A bed can be single or double, king size, queen size , .. etc. You got my point. \nSo is it better to create a different XML for each of these sizes? Or I can put them in one positive directory and adjust the parameters accordingly to the size? \nReasons I am using Haar Cascade features is that it is fast and I need the detection to be done later on in real-time on Raspberry. If there any other way, I am open to any other suggestion too. \nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":378,"Q_Id":42473655,"Users Score":0,"Answer":"Yes it is possible to have different sizes for positive images and you are right its a very tedious task but what you see in all the tutorials they will just tell to keep all the images in a same size because it takes a lot of time to specify all the different sizes for each images so they try to keep the code simple and clean but if want to try out with different sizes u can do it but before doing it first try it out with the a same size then if it works then only try with the different sizes. blindly don't try it make sure you are on the right way.","Q_Score":0,"Tags":"python,xml,opencv,raspberry-pi,object-recognition","A_Id":42484540,"CreationDate":"2017-02-26T20:10:00.000","Title":"creating Haar cascade XML - different sizes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently got a Raspberry Pi for use with a college project, I'm fairly well versed coding Python but not with Raspberry Pi's unfortunately. What's the best compiler for Raspberry Pi app creation? What I need it to do is connect with a database and another application I have developed for Android. Is it possible to do this? Or am i better to program it on my PC and FTP the files across?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":454,"Q_Id":42505621,"Users Score":0,"Answer":"One thing to watch out for on the Raspberrry Pi is memory usage. I tend to have lots of browser tabs, terminal windows, etc. running. Pi gets very unhappy (i.e. slows to crawl) when it runs low on memory. Even a long scroll-back on Idle can do it (e.g., logging lots to the shell)\nI put the resource monitors on the top right of the task bar - memory usage shows in red. As it approaches the top, it's time to close some things!\nRight-click on task bar, select \"Add \/ Remove Panel Items\", \"Panel Applets\", \"Add\", scroll down to \"Resource Monitors\", select and \"Add\". It defaults to showing CPU, so click \"Preferences\" and click \"Display RAM usage\", \"OK\", \"OK\"","Q_Score":0,"Tags":"android,python,database,raspberry-pi3","A_Id":42584122,"CreationDate":"2017-02-28T10:02:00.000","Title":"Programming Python on a Raspberry Pi","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to put together a small build system in Python that generates Ninja files for my C++ project. Its behavior should be similar to CMake; that is, a bldfile.py script defines rules and targets and optionally recurses into one or more directories by calling bld.subdir(). Each bldfile.py script has a corresponding bld.File object. When the bldfile.py script is executing, the bld global should be predefined as that file's bld.File instance, but only in that module's scope.\nAdditionally, I would like to take advantage of Python's bytecode caching somehow, but the .pyc file should be stored in the build output directory instead of in a __pycache__ directory alongside the bldfile.py script.\nI know I should use importlib (requiring Python 3.4+ is fine), but I'm not sure how to:\n\nLoad and execute a module file with custom globals.\nRe-use the bytecode caching infrastructure.\n\nAny help would be greatly appreciated!","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1152,"Q_Id":42542214,"Users Score":1,"Answer":"I studied importlib's source code and since I don't intend to make a reusable Loader, it seems like a lot of unnecessary complexity. So I just settled on creating a module with types.ModuleType, adding bld to the module's __dict__, compiling and caching the bytecode with compile, and executing the module with exec. At a low level, that's basically all importutil does anyway.","Q_Score":3,"Tags":"python,python-module,python-importlib","A_Id":42545218,"CreationDate":"2017-03-01T21:17:00.000","Title":"How do I load a Python module with custom globals using importlib?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have trouble running my a little bit complex python program in a remote directory, mounted by SSHFS. It takes a few seconds to perform imports when executing in a remote directory and a fraction of a second in a local directory. The program should not access anything in the remote directory on its own, especially in the import phase.\nBy default, there is current (remote) directory I sys.path, but when I remove it before (other) imports, speed does not change. I confirmed with python -vv that this remote directory is not accessed in the process of looking for modules. Still, I can see a stable flow of some data from the network with an external network monitor during the import phase.\nMoreover, I can't really identify what exectly it is doing when consuming most time. It seems to happen after one import is finished, according to my simple printouts, and before a next import is started...\nI'm running Fedora 25 Linux","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":1102,"Q_Id":42570494,"Users Score":-1,"Answer":"In my case it were the Cern ROOT libraries import. When importing, they look in the current directory, no matter what I do. So the solution is to \n\nstore the current directory\ncd to some really local directory, like \"\/\" or \"\/home\" before imports\ncome back to the stored directory after imports","Q_Score":0,"Tags":"python,import,sshfs,fedora-25,remote-host","A_Id":43487256,"CreationDate":"2017-03-03T04:07:00.000","Title":"Python script very slow in a remote directory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I've read the API documentation and there seem to be no way to get user email.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":67,"Q_Id":42573079,"Users Score":0,"Answer":"if you can see a page witch contains your needed data with your eyes. you can use web scraping to gather them.","Q_Score":0,"Tags":"php,python","A_Id":42573390,"CreationDate":"2017-03-03T07:29:00.000","Title":"Is there any way to extract a list of users and their email ids from wattpad?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a simple python webserver but I want to use the CGI script for file download and upload according to client-request .But I couldnt find the any way of adjusting the CGI except using apache2 ,nginx or etc... Is there any way to adjust cgi script to my python webserver with Bash script or with other way ? Can you give me any advice about it?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":74,"Q_Id":42608362,"Users Score":0,"Answer":"Why are you not try to pass the address\/location of your file which you want to download as a argument to the class and then use that in the < a href> tag to convert that into the link and implement the download functionality","Q_Score":0,"Tags":"python,bash,nginx,webserver,cgi","A_Id":42608590,"CreationDate":"2017-03-05T12:28:00.000","Title":"CGI Script For Python Webserver","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"When I need to work on one of my pet projects, I simply clone the repository as usual (git clone ), edit what I need, run the tests, update the setup.py version, commit, push, build the packages and upload them to PyPI.\nWhat is the advantage of using pip install -e? Should I be using it? How would it improve my workflow?","AnswerCount":3,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":71689,"Q_Id":42609943,"Users Score":39,"Answer":"For those who don't have time:\nIf you install your project with an -e flag (e.g. pip install -e mynumpy) and use it in your code (e.g. from mynumpy import some_function), when you make any change to some_function, you should be able to use the updated function without reinstalling it.","Q_Score":113,"Tags":"python,pip","A_Id":68885989,"CreationDate":"2017-03-05T15:05:00.000","Title":"What is the use case for `pip install -e`?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I need to work on one of my pet projects, I simply clone the repository as usual (git clone ), edit what I need, run the tests, update the setup.py version, commit, push, build the packages and upload them to PyPI.\nWhat is the advantage of using pip install -e? Should I be using it? How would it improve my workflow?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":71689,"Q_Id":42609943,"Users Score":89,"Answer":"I find pip install -e extremely useful when simultaneously developing a product and a dependency, which I do a lot.\nExample:\nYou build websites using Django for numerous clients, and have also developed an in-house Django app called locations which you reuse across many projects, so you make it available on pip and version it.\nWhen you work on a project, you install the requirements as usual, which installs locations into site packages.\nBut you soon discover that locations could do with some improvements. \nSo you grab a copy of the locations repository and start making changes. Of course, you need to test these changes in the context of a Django project.\nSimply go into your project and type:\npip install -e \/path\/to\/locations\/repo\nThis will overwrite the directory in site-packages with a symbolic link to the locations repository, meaning any changes to code in there will automatically be reflected - just reload the page (so long as you're using the development server).\nThe symbolic link looks at the current files in the directory, meaning you can switch branches to see changes or try different things etc...\nThe alternative would be to create a new version, push it to pip, and hope you've not forgotten anything. If you have many such in-house apps, this quickly becomes untenable.","Q_Score":113,"Tags":"python,pip","A_Id":59667164,"CreationDate":"2017-03-05T15:05:00.000","Title":"What is the use case for `pip install -e`?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So this one is a doozie, and a little too specific to find an answer online.\nI am writing to a file in C++ and reading that file in Python at the same time to move a robot. Or trying to.\nWhen I try running both programs at the same time, the C++ one runs first and then the Python one runs.\nHere's the command I use:\n.\/ColorFollow & python fileToHex.py\nThis happens even if I switch the order of commands.\nEven if I run them in different terminals (which is the same thing, just covering all bases).\nBoth the Python and C++ code read \/ write in 'infinite' loops, so these two should run until I say stop.\nThe code works fine; when the Python script finally runs the robot moves as intended. It's just that the code doesn't run at the same time. \nIs there a way to make this happen, or is this impossible?\nIf you need more information, lemme know, but the code is pretty much what you'd expect it to be.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":281,"Q_Id":42617816,"Users Score":0,"Answer":"If you are using Linux, & will release bash session and in this case, CollorFlow and fileToXex.py will run in different bash sessions.\nAt the same time, composition .\/ColorFollow | python fileToHex.py looks interesting, cause you redirect stdout of ColorFollow to fileToHex.py stdin - it can syncronize scripts by printing some code string upon exit, then reading it by fileToHex.py and exit as well.\nI would create some empty file like \/var\/run\/ColorFollow.flag and write there 1 when one of processes exit. Not a pipe - cause we do not care which process will start first. So, if next loop step of ColorFollow sees 1 in the file, it deletes it and exits (means that fileToHex already exited). The same - for fileToHex - check flag file each loop step and exit if it exists, after deleting flag file.","Q_Score":0,"Tags":"python,c++","A_Id":42618540,"CreationDate":"2017-03-06T04:57:00.000","Title":"Simultaneous Python and C++ run with read and write files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We have asynchronous python application (telegram bot), and we want to add localization: user selects language when he starts dialog with bot, then bot translates all messages for him.\nDjango allows to change language for every request, it is working normally, because Django create separate process for each request. But it will not work in async bot \u2014 there is only one process and we should handle multiple users with different languages inside of it.\nWe can do simple thing \u2014 store user's preferences in Database, load the preferred language from DB with each incoming message, and them pass this settings to all inside functions \u2014 but it is quite complicated, because our bot is complex and there can be more than dozen included function calls.\nHow we can implement language switching in the asynchronous application with elegant way?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":703,"Q_Id":42619597,"Users Score":0,"Answer":"Okay, we solved problem using with that provide us with context to all inner function calls.","Q_Score":2,"Tags":"python,asynchronous,localization,internationalization,gettext","A_Id":42623529,"CreationDate":"2017-03-06T07:13:00.000","Title":"Localization for Async Python Telegram bot","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"For some reasons, my producer sends at the same time X messages to rabbit MQ. These messages are just notification that say \"i update something, do your stuff\"\nBut my consumer shall not call his callback for all messages, only one (and not wait all messages indefinitely). Is it possible to do that?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":57,"Q_Id":42646540,"Users Score":0,"Answer":"It depends on the specific details so I'll try to address some example scenarios. I assume messages are not all created equal and the last one is the right one (e.g. updated data).\n\nX is fixed, the time delta between first and last message is m seconds 99% of the time, processing a message more than one time is ok\nIn this case you know you'll get not 1 but n messages, so every time you receive a new (unique) message, you queue it up and when you have received n you can process it; if the process takes up more than m seconds you process it right away; if a late message arrives it will processed again after m seconds timeout with no problem.\n\nX is variable, the time delta between first and last message is m seconds < 50% of the time, processing a message more than one time is ok\nSame as previous case, you just need to tune the timeout carefully to achieve acceptable time-to-message-processed time while still keeping re-processing of messages low enough.\n\nprocessing a message more than once is NOT ok, the last message after a timeout is the good one\nI relaxed the requirement to process the last message and made it into the last message in a time interval.\nThis way you can queue messages up and wait for the last in the allowed time frame, then process it. You'll also need to keep a cache of processed messages so late ones can get recognized and discarded without being re-processed, as that would not be ok.\n\n\nThese are some scenarios, which can of course be combined to achieve more possibilities, but in the end it all depends on the specific details on how messages are generated and delivered and the requirements on which message gets to be processed.","Q_Score":1,"Tags":"python,rabbitmq","A_Id":42646951,"CreationDate":"2017-03-07T11:01:00.000","Title":"Wait all message and run callback","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to run a python script from a webserver(apache) using php. I used the following command \nexec (python test.py $arg1 $arg2 , $output, $result)\nIt executes successfully when I put the test.py in the document root directory. However, I wanted to run the python script from another subdirectory so that it would be easy for me to manage the outout of the python script.\nwhat the python script does is\n\ncreates a folder\ncopy a file from the same directory the python script resides into the folder created (1)\nzip the folder\n\nThe document root and the subdirectory for the python script have the same permission.\nsince it keeps on looking for the files to be copied from the documentroot, it generates \"no such file or directory\" error (in the apache error log file)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":341,"Q_Id":42649784,"Users Score":0,"Answer":"if your python file and php file in same folder:\n$command_to_run = \"test.pyw $arg1 $arg2 , $output, $result\";\n $response = shell_exec($command_to_run);\nelse:\n$command_to_run = \"\/scripts\/python\/test.pyw $arg1 $arg2 , $output, $result\";\n $response = shell_exec($command_to_run);","Q_Score":0,"Tags":"php,python","A_Id":45730408,"CreationDate":"2017-03-07T13:37:00.000","Title":"From which directory to run python Script in webserver","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I use nosetests and allure framework for reporting purposes. In order to make the report look like I want, I have to add @nose.allure.feature('some feature') decorator to each test. The problem is that I have over 1000 test. Is there any way to modify tests before execution? \nI was thinking about custom nose plugin, but not sure how can it be implemented.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":279,"Q_Id":42667584,"Users Score":0,"Answer":"How about adding the decorator to the test classes instead?\nNot sure if it will work, but sometimes works nicely for @patch.","Q_Score":0,"Tags":"python,nose,allure","A_Id":42684514,"CreationDate":"2017-03-08T09:32:00.000","Title":"Nosetest: add decorator for tests before execution","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My question is: \nhow to join my telegram bot to a telegram public channel that I am not administrator of it, and without asking the channel's admin to add my bot to the channel?\nmaybe the chatId of channel or thru link of channel?\nThank you in advance :)\nedit------\nI have heard that some people claim to do this join their bot to channels, and scrape data.\nSo if Telegram does not allow it, how can they do it? can you think of any work around?\nAppreciate your time?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":24623,"Q_Id":42674340,"Users Score":10,"Answer":"Till today, only the Channel Creator can add a bot (as Administrator or Member) to the Channel, whether public or private. Even the other Channel Administrators cannot add a normal member leave alone adding a bot, rather they can only post into the channel.\nAs far as joining the bot via the invite link, there is yet no such method in Bot API to do so. All such claims of adding the bot to a channel by non Creator are false.","Q_Score":16,"Tags":"python,telegram,telegram-bot,python-telegram-bot","A_Id":42696153,"CreationDate":"2017-03-08T14:44:00.000","Title":"How to join my Telegram Bot to PUBLIC channel","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been reading about base64 conversion, and what I understand is that the encoded version of the original data will be 133% of the original size.\nThen, I'm reading about how YouTube is able to have unique identifiers to their videos like FJZQSHn7fc and the reason was: an 11 character base64 string can map to a huge number.\nWait, say a huge number contains 20 characters, then wouldn't a base64 encoded string be 133% of that size, not shorter?\nI'm very confused. Are there different types of base64 conversion (string to base64 vs. decimal to base64), once resulting in a bigger, and the other in a smaller resulting string?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":2669,"Q_Id":42701912,"Users Score":1,"Answer":"You are confusing what things are being compared.\nThere are 2 statements, both comparing different things:\n\n\"base64 encoding is 133% bigger than original size\"\n\"An 11 character base64 string can encode a huge number\"\n\nIn the case of 1, they are normally referring to a string encoded maybe with ASCII using 8bits a character, and comparing that with the same string encoded in base64. That is 133% bigger, because in base64 you can't use all 255 bit combinations in every byte.\nIn the case of 2, they are comparing using a numeric identifier, and then either encoding it as base64, or base10. In this case, base64 is a lot shorter than base10.\nYou can also think of the (1) case as comparing base256 against base64, and the (2) case as comparing base10 against base64.","Q_Score":1,"Tags":"python,encoding,character-encoding,language-agnostic,base64","A_Id":42821384,"CreationDate":"2017-03-09T17:35:00.000","Title":"Base64 conversion decimals","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been reading about base64 conversion, and what I understand is that the encoded version of the original data will be 133% of the original size.\nThen, I'm reading about how YouTube is able to have unique identifiers to their videos like FJZQSHn7fc and the reason was: an 11 character base64 string can map to a huge number.\nWait, say a huge number contains 20 characters, then wouldn't a base64 encoded string be 133% of that size, not shorter?\nI'm very confused. Are there different types of base64 conversion (string to base64 vs. decimal to base64), once resulting in a bigger, and the other in a smaller resulting string?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":2669,"Q_Id":42701912,"Users Score":1,"Answer":"Think of it like this: you have a 64bit number (called long in Java, for example). \nNow, you can print that number in different ways:\n\nAs a binary number (base 2), printing 64 '0' or '1'\nAs a decimal number (base 10), printing up to 20 decimal digits\nAs a hexadecimal number (base 16), printing 16 hexadeciaml digits\nAs a number in base 64, printing 11 \"digits\" in that base. You can use any graphical symbols as digits.\n... you understand by now that there are many more possibilities ...\n\nIt seems like they use the same base-64 numbers as the ones that are used in base64 encoding, that is, uppercase and lowercase letters, ordinary digits and 2 extra chars. Each character represents a 6-bit value. So you get 66 bits, and depending on the algorithm used, either the leading or trailing 2 bits are cut off to get a nice long value back.","Q_Score":1,"Tags":"python,encoding,character-encoding,language-agnostic,base64","A_Id":42816749,"CreationDate":"2017-03-09T17:35:00.000","Title":"Base64 conversion decimals","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to program a raspberry pi 3 to run a traffic light on a breadboard.I also have a sensor that detects color of the traffic light, which is connected to the same raspberry pi. Can anyone help me with this? How would I do that, and also HOW can I send that detected information to another raspberry pi? \nThank you!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":89,"Q_Id":42729062,"Users Score":1,"Answer":"You can use messaging protocol like RabbitMQ, MQTT tech to make an easy communication between the raspberries.\nBut another Simplest way is to develop HTTP REST endpoints if you don't have stron background in messaging protocols (MQTT).\nEasy way is develop HTTP REST endpoints using python flask.\n\nSuppose you have a method in python flask as turnOnLED() bind with a URL as \/on on Raspberry PI X. Now you can call this REST Endpoint using the IP of this raspberry X from another Raspberry Y.\nYou can similarly write a method in python to interact with **GPIO** and make that method available through your URL (ip\/endpoints) to another Raspberry. From other Raspberry you can call that method by calling the URL for the first one.\n\n\nMake research on RESTful APIs using Python, GPIO, PGPIOD, WiringPI, Pythong flask or any other framework to write REST Endpoints rapidly.\nYou need knowledge in all these buddy.","Q_Score":0,"Tags":"python,raspberry-pi","A_Id":42729722,"CreationDate":"2017-03-10T22:52:00.000","Title":"Running Traffic Light with Pi and Sending that info to another Pi","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've studied Python and Django, building a homepage.\nAnd I've been using a virtual memory on Ubuntu server(apache2 2.4.18\/ php-7.0\/ MariaDB 10.0.28 with phpMyAdmin\/ FTP) offered for developers.\nThe server hadn't allowed users to use python, but I asked the server administrator to give me a permission and I got it.\nThe problem was, however, that I was not allowed to use not only any sudo command line but also basic commands like apt-get and python.\nThe only administrator can do so, therefore it seems that I cannot install any neccessary things-virtualenv, django, and so on- by myself. \nJust to check whether .py file works or not, I added on the header of index.php about the test.py where only print \"python test\"(meaning only python 2 is installed on this server) is written. It works. That is, I guess, all I can do is uploading .py file with Filezilla.\nIn this case, can I make a homepage with Python on this server efficiently? I was thinking about using Bottle Framework, but also not sure. \nI am confused with wondering whether I should use PHP on this server and using Python on PythonAnywhere in the end.\nI am a beginner. Any advice will be appreciated :)","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":38,"Q_Id":42730059,"Users Score":1,"Answer":"Have you thought about asking the admin to start a virtualenv for you and give you permissions to work in that environment?","Q_Score":0,"Tags":"python,django","A_Id":42730116,"CreationDate":"2017-03-11T00:50:00.000","Title":"Is it possible to build a homepage with python on virtual server when the sudo command is disabled?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I would like to use ANTLR4 with Python 2.7 and for this I did the following:\n\nI installed the package antlr4-4.6-1 on Arch Linux with sudo pacman -S antlr4.\nI wrote a MyGrammar.g4 file and successfully generated Lexer and Parser Code with antlr4 -Dlanguage=Python2 MyGrammar.g4\nNow executing for example the generated Lexer code with python2 MyGrammarLexer.py results in the error ImportError: No module named antlr4. \n\nWhat could to be the problem? FYI: I have both Python2 and Python3 installed - I don't know if that might cause any trouble.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":13812,"Q_Id":42737716,"Users Score":1,"Answer":"The problem was that antlr4 was only installed for Python3 and not Python2. I simply copied the antlr4 files from \/usr\/lib\/python3.6\/site-packages\/ to \/usr\/lib\/python2.7\/site-packages\/ and this solved the problem!","Q_Score":5,"Tags":"python,antlr,antlr4","A_Id":42750891,"CreationDate":"2017-03-11T16:33:00.000","Title":"No module named antlr4","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have question that I am having a hard time understanding what the code might look like so I will explain the best I can. I am trying to view and search a NUL byte and replace it with with another NUL type byte, but the computer needs to be able to tell the difference between the different NUL bytes. an Example would be Hex code 00 would equal NUL and hex code 01 equals SOH. lets say I wanted to create code to replace those with each other. code example\n\nTextFile1 = Line.Replace('NUL','SOH')\nTextFile2.write(TextFile1)\n\nYes I have read a LOT of different posts just trying to understand to put it into working code. first problem is I can't just copy and paste the output of hex 00 into the python module it just won't paste. reading on that shows 0x00 type formats are used to represent that but I'm having issues finding the correct representation for python 3.x\n\nPrint (\\x00)\noutput = nothing shows #I'm trying to get output of 'NUL' or as hex would show '.' either works fine --Edited\n\nso how to get the module to understand that I'm trying to represent HEX 00 or 'NUL' and represent as '.' and do the same for SOH, Not just limited to those types of NUL characters but just using those as exmple because I want to use all 256 HEX characters. but beable to tell the difference when pasting into another program just like a hex editor would do. maybe I need to get the two programs on the same encoding type not really sure. I just need a very simple example text as how I would search and replace none representable Hexadecimal characters and find and replace them in notepad or notepad++, from what I have read, only notepad++ has the ability to do so.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4065,"Q_Id":42740284,"Users Score":0,"Answer":"another equivalent way to get the value of \\x00 in python is chr(0) i like that way a little better over the literal versions","Q_Score":1,"Tags":"python,python-3.x,nul","A_Id":58441607,"CreationDate":"2017-03-11T20:31:00.000","Title":"Nul byte representation in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"EDIT I was being stupid. Just type help('package_name'.'pyb_name') which worked.\nI would like to find out what is actually in a python package I have locally downloaded and installed with pip. \nTyping help(package_name) just lists NAME, FILE (where the init.py is) and PACKAGE CONTENTS which is just one .pyd file.\nI can't open the .pyd file to check what's inside(tbh not all that familiar with .pyds). These two with a 159byte init.pyc are the only files in the package. \nI need to use this (not widely available) package for some university work. \nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":143,"Q_Id":42748382,"Users Score":0,"Answer":"You can't know what a python package does unless it is stated in its docs (on PyPI or in the repository) or without reading the code. A Python package can be anything that has a setup.py and either a single module or multiple files under a folder with a __init__.py file in it.\nThe fact that the __init__.py is empty doesn't mean anything other than the fact that its existence means there's a python package involved.\nAny specific package you want to know about, you should look up for documentation or read the code to get a sense of its purpose.","Q_Score":1,"Tags":"python,module,package","A_Id":42748427,"CreationDate":"2017-03-12T14:08:00.000","Title":"How to find out what a python package does","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing a web python application with tornado framework on a raspberry pi.\nWhat i actually do is to connect to my raspberry with ssh. I am writing my source code with vi, on the raspberry.\nWhat i want to do is to write source code on my development computer but i do not know how to synchronize (transfer) this source code to raspberry.\nIt is possible to do that with ftp for example but i will have to do something manual.\nI am looking for a system where i can press F5 on my IDE and this IDE will transfer modified source files. Do you know how can i do that ?\nThanks","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":334,"Q_Id":42787560,"Users Score":0,"Answer":"Following a couple of bad experiences where I lost code which was only on my Pi's SD card, I now run WinSCP on my laptop, and edit files from Pi on my laptop, they open in Notepad++ and WinSCP automatically saves edits to Pi. And also I can use WinSCP folder sync feature to copy contents of SD card folder to my latop. Not perfect, but better what I was doing before","Q_Score":0,"Tags":"python,version-control,raspberry-pi","A_Id":42787653,"CreationDate":"2017-03-14T13:38:00.000","Title":"Synchronize python files between my development computer and my raspberry","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am writing a web python application with tornado framework on a raspberry pi.\nWhat i actually do is to connect to my raspberry with ssh. I am writing my source code with vi, on the raspberry.\nWhat i want to do is to write source code on my development computer but i do not know how to synchronize (transfer) this source code to raspberry.\nIt is possible to do that with ftp for example but i will have to do something manual.\nI am looking for a system where i can press F5 on my IDE and this IDE will transfer modified source files. Do you know how can i do that ?\nThanks","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":334,"Q_Id":42787560,"Users Score":0,"Answer":"I have done this before using bitbucket as a standard repository and it is not too bad. If you set up cron scripts to git pull it's almost like continuous integration.","Q_Score":0,"Tags":"python,version-control,raspberry-pi","A_Id":54502688,"CreationDate":"2017-03-14T13:38:00.000","Title":"Synchronize python files between my development computer and my raspberry","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm using raspberry pi 3 to communicate with an android app through websocket. I installed tornado on my raspberry and the installation was succesfull but if I use it with python 2.7 I haven't any kind of problem but I need to use it with python 3 and when I just write \"import tornado\" I get an ImportError: No module named \"tornado\". It is like if it is installed in python 2 but not in 3. Both python 2 and 3 are preinstalled on raspberry. Somebody can help me? Thanks in advance\nSorry for my bad english","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":299,"Q_Id":42791422,"Users Score":0,"Answer":"In these days the website of tornado has some problem. I downloaded the tar.gz file from another website and installed from there. Instead of use command \"python\" use \"python3\"","Q_Score":0,"Tags":"python,linux,raspberry-pi3","A_Id":42820278,"CreationDate":"2017-03-14T16:27:00.000","Title":"Error import tornado in python 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I need implement a uploading function which can continue from the point from last interruption via sftp. \nI'm trying paramiko. but I cannot fond any example about this. Can anybody give me some advices?\nBest regards","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":41,"Q_Id":42802024,"Users Score":1,"Answer":"SFTP.open(mode='a') opens a file in appending mode. So first you can call SFTP.stat() to get the current size of the file (on remote side) and then open(mode='a') it and append new data to it.","Q_Score":0,"Tags":"python,sftp,paramiko","A_Id":42807503,"CreationDate":"2017-03-15T05:53:00.000","Title":"can paramiko has the function to implememt uploading continue from the point from last interruption","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python file named abc.py. I can run it in mongodb with the help of robomongo but i couldnt run it in cmd. Can anyone tell me how to run a .py file in mongodb using cmd ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":82,"Q_Id":42853347,"Users Score":0,"Answer":"First you need to ensure that your directory is in the correct folder.\nfor example you can write cd name_of_folder\nthen to run it you need to typepython your_filen_name.py","Q_Score":0,"Tags":"python,mongodb,pymongo","A_Id":65763003,"CreationDate":"2017-03-17T09:13:00.000","Title":"how to run python file in mongodb using cmd","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"We are using Bitbucket for version control and we have two repositories. One (rep C) has C++ code that we re-compile rarely, and the other one (rep P) has Python code which calls the C++ code. This is where most of the work happens.\nI want to set up pipelines so that when we push code in rep P, it runs all the unit tests.\nMy problem is that the python code requires the compiled C++ binaries of rep C.\nIs there a way to set up BitBucket pipelines such that when we push code in rep P it compiles the code of rep C, so that the unit tests of rep P can use those binaries? Is it necessary to add the binaries and their libraries in rep P for that to happen?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":66,"Q_Id":42864636,"Users Score":2,"Answer":"You can create a deployment key in rep C and add the key as an environment variable in rep P. Then, rep P is able to checkout the code from rep C and do whatever it needs\/wants to do with it.\nThe checkout could either use a fixed branch such as \u201cmaster\u201d, or dynamically checkout a branch whose name is derived from $BITBUCKET_BRANCH in rep P.","Q_Score":4,"Tags":"python,bitbucket,bitbucket-pipelines","A_Id":42899528,"CreationDate":"2017-03-17T18:21:00.000","Title":"How to use data that is not in the repository on BitBucket Pipelines","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"i am working with pyside and trying to do asynchronous serial communication with it but the QtSerialPort is not yet available,\ni have used pyserial and moved the serial communication to another thread using\nmoveToThread() but i have to check if there there is a message regularly, so i used a QTimer to handle that every 200 ms,but this solution is over kill, if i can have Qt send a readyRead signal every time there is data available, the question is precisely is : \nis there is a ready module that help with without breaking my whole code depenedency on pyside?\nif there isn't, what is your tips for quickly implementing one? \nthanks in advance.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1533,"Q_Id":42867232,"Users Score":0,"Answer":"i found a workaround which is using PyQt5 serial port module and building a standalone module that handle serial communication and communicating with my main application using Inter Process Communication (IPC) or a local network socket, that will do it for now, and i have no problem open sourcing this serial communication module, and my main application is intact.","Q_Score":0,"Tags":"python,qt,serial-port,pyside,qtserialport","A_Id":42908493,"CreationDate":"2017-03-17T21:16:00.000","Title":"asynchronous serial communication using pyside","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"i have published my website using python-php mysql hosting server. Now they told me to create an virtualenv after that i was able to install my required packages like pypi newspaper. My python scripts are totally dependent on pypi newspaper.\nNow the issue is that when i call my index.php from publi_html and call my python script it shows me following error:\n\nTraceback (most recent call last):\" [1]=> string(79) \" File\n \"\/home\/adpnewsi\/public_html\/adpScripts\/getImage.py\", line 3, in \"\n [2]=> string(33) \" from newspaper import Article\" [3]=> string(38)\n \"ImportError: No module named newspaper\" }","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":50,"Q_Id":42871961,"Users Score":0,"Answer":"You are probably not using the virtual python environment. \nIn your terminal type which python. \nIf the output is \/usr\/bin\/python you need to switch to your virtual environment.\nGo to the directory where you created your virtualenv and in terminal enter source bin\/activate. Then use which python to verify your are now using your virtual environment to run the server.","Q_Score":0,"Tags":"php,python,mysql","A_Id":42872603,"CreationDate":"2017-03-18T08:02:00.000","Title":"error while executing python script from php","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm currently part of a team working on a Hadoop application, parts of which will use Spark, and parts of which will use Java or Python (for instance, we can't use Sqoop or any other ingest tools included with Hadoop and will be implementing our own version of this). I'm just a data scientist so I'm really only familiar with the Spark portion, so apologies for the lack of detail or if this question just sucks in general - I just know that the engineering team needs both Java and Python support. I have been asked to look into using Cucumber (or any other BDD framework) for acceptance testing our app front to back once we're further along. I can't find any blogs, codebases, or other references where cucumber is being used in a polyglot app, and barely any where Hadoop is being used. Would it be possible to test our app using Cucumber or any other existing BDD framework? We already plan to do unit and integration testing via JUnit\/PyUnit\/etc as well.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":994,"Q_Id":42909952,"Users Score":0,"Answer":"To use cucumber to test desktop applications you can use specflow which uses a framework in visual studio called teststack.white. Just google on cucumber specflow, teststack.white, etc and you should be able to get on track","Q_Score":0,"Tags":"java,python,hadoop,cucumber,cucumber-jvm","A_Id":43516507,"CreationDate":"2017-03-20T17:18:00.000","Title":"Can I use Cucumber to test an application that uses more than one language?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently part of a team working on a Hadoop application, parts of which will use Spark, and parts of which will use Java or Python (for instance, we can't use Sqoop or any other ingest tools included with Hadoop and will be implementing our own version of this). I'm just a data scientist so I'm really only familiar with the Spark portion, so apologies for the lack of detail or if this question just sucks in general - I just know that the engineering team needs both Java and Python support. I have been asked to look into using Cucumber (or any other BDD framework) for acceptance testing our app front to back once we're further along. I can't find any blogs, codebases, or other references where cucumber is being used in a polyglot app, and barely any where Hadoop is being used. Would it be possible to test our app using Cucumber or any other existing BDD framework? We already plan to do unit and integration testing via JUnit\/PyUnit\/etc as well.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":994,"Q_Id":42909952,"Users Score":0,"Answer":"The feature files would be written using Gherkin. Gherkin looks the same if you are using Java or Python. So in theory, you are able to execute the same specifications from both Java end Python. This would, however, not make any sense. It would just be a way to implement the same behaviour in two different languages and therefore two different places. The only result would be duplication and miserable developers.\nWhat you can do is to use BDD and Gherkin to drive the implementation. But different behaviour in different languages. This will lead you to use two different sets of features. That is possible and probably a good idea given the context you describe.","Q_Score":0,"Tags":"java,python,hadoop,cucumber,cucumber-jvm","A_Id":42931219,"CreationDate":"2017-03-20T17:18:00.000","Title":"Can I use Cucumber to test an application that uses more than one language?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When thinking of the why a interpeter work:\nparse code -> producer machine byte code -> allocate exec mem -> run\nhow can it be done in wasm?\nthanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":763,"Q_Id":42919339,"Users Score":4,"Answer":"If you are actually implementing an interpreter then you don't need to generate machine code at runtime, so everything can stay within Wasm.\nWhat you actually seem to have in mind is a just-in-time compiler. For that, you indeed have to call back into the embedder (i.e., JavaScript in the browser) and create and compile new Wasm modules there on the fly, and link them into the running program -- e.g., by adding new functions to an existing table. The synchronous compilation\/instantiation interface exists for this use case.\nIn future versions it may be possible to invoke the compilation API directly from within Wasm, but for now going through JavaScript is the intended approach.","Q_Score":3,"Tags":"javascript,python,c,webassembly","A_Id":42920349,"CreationDate":"2017-03-21T05:50:00.000","Title":"Compile a JIT based lang to Webassembly","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Is there a way to get a list of all tweets sent to a twitter user?\nI know I can get all tweets sent by the user using api.GetUserTimeline(screen_name='realDonaldTrump'), but is there a way to retrieve tweets to that user?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":397,"Q_Id":42937469,"Users Score":0,"Answer":"Use: api.GetSearch(raw_query='q=to%3ArealDonaldTrump')","Q_Score":0,"Tags":"twitter,python-twitter","A_Id":44587156,"CreationDate":"2017-03-21T20:24:00.000","Title":"Get all tweets to user python-twitter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have 3 remote workers, each one is running with default pool (prefork) and single task.\nA single task is taking 2 to 5 minutes for completion as it runs on many different tools and inserts database in ELK.\nworker command:\ncelery -A project worker -l info\nWhich pool class should I use to make processing faster?\nis there any other method to improve performance?","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":6858,"Q_Id":42948547,"Users Score":20,"Answer":"funny that this question scrolled by.\nWe just switched from eventlet to gevent. Eventlet caused hanging broker connections which ultimately stalled the workers.\nGeneral tips:\n\nUse a higher concurreny if you're I\/O bound, I would start with 25, check the cpu load and tweak from there, aim for 99,9% cpu usage for the process.\nyou might want to use --without-gossip and --without-mingle if your workforce grows.\ndon't use RabbitMQ as your result backend (redis ftw!), but RabbitMQ is our first choice when it comes to a broker (the amqp emulation on redis and the hacky async-redis solution of celery is smelly and caused a lot of grief in our past).\n\n\nMore advanced options to tune your celery workers:\n\npin each worker process to one core to avoid the overhead of moving processes around (taskset is your friend)\nif one worker isn't always working, consider core-sharing with one or two other processes, use nice if one process has priority","Q_Score":13,"Tags":"python,celery,celery-task","A_Id":43895350,"CreationDate":"2017-03-22T10:12:00.000","Title":"Which pool class should i use prefork, eventlet or gevent in celery?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Basically I have two raspberry pi's and I want one to publish data obtained from a dictionary in a python file and the the other to subscribe to this dictionary data. Apologies if this is a very bland question but I can't find any info on the internet regarding this.","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":1588,"Q_Id":42956237,"Users Score":2,"Answer":"I would recommend you read a basic MQTT tutorial if you have not done that already. That will help you decide what your topics and data should be like.\nTo get you started, here is an example of how you could publish and subscribe for your use case.\nThe publisher could iterate through the keys in the dictionary and publish data to topic \"keys\/$key_name\" with the message being the value for that key in the dictionary.\nThe subscriber could subscribe to topic \"keys\/#\". This way the subscriber will get all the keys and the corresponding data and reconstruct the dictionary.\nThere are many more ways you could publish data depending on the nature of data in your dictionary.","Q_Score":1,"Tags":"python,dictionary,mosquitto","A_Id":42965278,"CreationDate":"2017-03-22T15:34:00.000","Title":"How does one send data from a dictionary over an mqtt broker","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Basically I have two raspberry pi's and I want one to publish data obtained from a dictionary in a python file and the the other to subscribe to this dictionary data. Apologies if this is a very bland question but I can't find any info on the internet regarding this.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1588,"Q_Id":42956237,"Users Score":1,"Answer":"If you want to send a dictionary directly from a python script on Host A to a python script on Host B there is a way. \n\nConvert your dictionary into a string.\nSend the string as a payload from Host A to the broker.\nSubscribe to the broker with Host B and receive the payload.\nEvaluate the string with ast.literal_eval() which will convert it back into a dictionary.\n\nIf that explanation is unclear I could post some example code.\nI would probably use JSON or multiple topics instead but the above procedure will work.","Q_Score":1,"Tags":"python,dictionary,mosquitto","A_Id":43082905,"CreationDate":"2017-03-22T15:34:00.000","Title":"How does one send data from a dictionary over an mqtt broker","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hello everyone I am learning Python. While using Spyder I finished writing my own function (test.py) I saved the script in a new folder. In Spyder I made sure to change my working directory to where the test.py is located as well as the PYTHON PATH. Now when I try to import test it says in the console that there are no modules named 'test'. Any help will be appreciated thank you","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1277,"Q_Id":42962995,"Users Score":1,"Answer":"Thank you Alex yeah the problem was I was not working in the same directory as the package I made so I opened up the command prompt in Spyder, went into the correct directory and was able to import\/install it with no issues!!!","Q_Score":0,"Tags":"python,function,spyder","A_Id":42965330,"CreationDate":"2017-03-22T21:29:00.000","Title":"Python : Importing my custom script in Spyder to use with another script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an application written in Python which runs on RPi. I want it to auto update itself by downloading the latest code into the directory where it is installed...which may vary from user to user. It will also need to run a SQL script on occasion. What is the best approach for this? How do I ensure the code downloads to the right directory?\nGitHub tutorials I have seen are focused on updating the central repository. I want the reverse to occur. Is git the best tool or would SVN or a simple HTTP download from my site be better?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":493,"Q_Id":42963066,"Users Score":0,"Answer":"As per the comments I eventually managed to get this to work using urllib.urlretrieve to download a zip and then use zipfile to unzip and overwrite.","Q_Score":0,"Tags":"python,svn,github,auto-update","A_Id":44626580,"CreationDate":"2017-03-22T21:34:00.000","Title":"How to auto update code via python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to test some API created in Python Play Framework. While using PHP I used Postman, what is the similar tool to be used to check Play API's?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":91,"Q_Id":42968895,"Users Score":1,"Answer":"There is no difference in testing REST servers, you can use Postman with Play as with node.js or your PHP server","Q_Score":0,"Tags":"python,playframework","A_Id":42971068,"CreationDate":"2017-03-23T06:38:00.000","Title":"How to test Play Framework APIs and perform Unit Testing over it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"apologies upfront. I am an extreme newbie and this is probably a very easy question. After much trial and error, I set up an app on Heroku that runs a python script that scrapes data off of a website and stores it in a text file. (I may switch the output to a .csv file). The script and app are running on a Heroku Scheduler, so the scraping takes place on a schedule and the data automatically gets written to the file that is on the Heroku platform. I simply want to download the particular output file occasionally so that I can look at it. (Part of the data that is scraped is being tweeted on a twitter bot that is part of the script.)\n(Not sure that this is relevant but I uploaded everything through Git.)\nMany thank in advance.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1626,"Q_Id":42989247,"Users Score":1,"Answer":"Not just ephemeral, but immutable, which means you can't write to the file system. You'll have to put the file in something like S3, or just put the data into a database like Postgres.","Q_Score":1,"Tags":"python,heroku","A_Id":43195564,"CreationDate":"2017-03-24T00:16:00.000","Title":"How to Access text files uploaded to Heroku that is running with Python Script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"apologies upfront. I am an extreme newbie and this is probably a very easy question. After much trial and error, I set up an app on Heroku that runs a python script that scrapes data off of a website and stores it in a text file. (I may switch the output to a .csv file). The script and app are running on a Heroku Scheduler, so the scraping takes place on a schedule and the data automatically gets written to the file that is on the Heroku platform. I simply want to download the particular output file occasionally so that I can look at it. (Part of the data that is scraped is being tweeted on a twitter bot that is part of the script.)\n(Not sure that this is relevant but I uploaded everything through Git.)\nMany thank in advance.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1626,"Q_Id":42989247,"Users Score":1,"Answer":"You can run this command heroku run cat path\/to\/file.txt, but keep in mind that Heroku uses ephemeral storage, so you don't have any guarantee that your file will be there.\nFor example, Heroku restarts your dynos every 24 hours or so. After that you won't have that file anymore. The general practice is to store files on some external storage provider like Amazon S3.","Q_Score":1,"Tags":"python,heroku","A_Id":42989347,"CreationDate":"2017-03-24T00:16:00.000","Title":"How to Access text files uploaded to Heroku that is running with Python Script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am sending some emails from Python using smtplib MIMEtext; and have the often noted problem that Outlook will \"sometimes\" remove what it considers \"extra line breaks\".\nIt is odd, because I print several headers and they all break find, but the text fields in a table are all smooshed - unless the recipient manually clicks Outlook's \"restore line breaks\".\nBecause some come through alright, I wonder what is Outlook's criteria for \"extra\", and thus how to avoid it?\nDo I need to format the message as HTML?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":795,"Q_Id":43005000,"Users Score":0,"Answer":"You won't be able to fix this. Outlook does it no matter how many line breaks you put in there in my experience. You might be able to trick it by adding spaces on each line, or non-breaksping space characters. It's a dumb feature of outlook....","Q_Score":0,"Tags":"python,email,outlook","A_Id":43005956,"CreationDate":"2017-03-24T16:49:00.000","Title":"python sending email - line breaks removed by Outlook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can I conveniently view class structure and methods description in python? I know about help(method) method, but it's not easy for use. F.e. I have download a library, and I know that it hase class Foo. I wanna see methods and meaning, have I to look for documentation or other way exists?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":363,"Q_Id":43039310,"Users Score":2,"Answer":"Use pydoc in the form $ pydoc [.[.]]. To get information about requests's Reponse object, for example, you would do $ pydoc requests.models.Response.\npydoc is installed in any standard Python distribution.","Q_Score":0,"Tags":"python,documentation","A_Id":43040351,"CreationDate":"2017-03-27T06:29:00.000","Title":"Python class and method description","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have problems with my PyCharm (it is running extremely slow) so I decided to change to eclipse. However, the import which worked in PyCharm suddenly don't work in eclipse. I am talking about numpy and tensorflow (which were appropriately installed). \nPlease, can anyone can give me a hint?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":61,"Q_Id":43052100,"Users Score":0,"Answer":"Found the solution: need to define the same interpreter as in PyCharm. Thanks everyone anyway!","Q_Score":0,"Tags":"python,eclipse,numpy,tensorflow,pycharm","A_Id":43055489,"CreationDate":"2017-03-27T16:47:00.000","Title":"Why Python import works on pycharm but not on eclipse","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have followed a few posts on here trying to run either a python or shell script on my ec2 instance after every boot not just the first boot. \nI have tried the:\n[scripts-user, always] to \/etc\/cloud\/cloud.cfg file\n\nAdded script to .\/scripts\/per-boot folder\n\nand\nadding script to \/etc\/rc.local\n\nYes the permissions were changed to 755 for \/etc\/rc.local\n\nI am attempting to pipe the output of the file into a file located in the \/home\/ubuntu\/ directory and the file does not contain anything after boot. \nIf I run the scripts (.sh or .py) manually they work. \nAny suggestions or request for additional info to help?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4018,"Q_Id":43056007,"Users Score":0,"Answer":"I read that the use of rc.local is getting deprecated. One thing to try is a line in \/etc\/crontab like this: \n@reboot full-path-of-script\nIf there's a specific user you want to run the script as, you can list it after @reboot.","Q_Score":2,"Tags":"python,linux,amazon-web-services,amazon-ec2","A_Id":43056995,"CreationDate":"2017-03-27T20:35:00.000","Title":"ec2 run scripts every boot","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"How much time does it take to train the Ubuntu Dialog Corpus with chatterbot? How many examples are needed to train the bot well?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":776,"Q_Id":43076878,"Users Score":1,"Answer":"Current chatterbot train based on your input file size, if the train file is bigger it will take more time to train the bot.\nThere is no specific examples to train the bot, it will learn past user inputs and responds your answers","Q_Score":1,"Tags":"python,chatterbot","A_Id":44412516,"CreationDate":"2017-03-28T18:08:00.000","Title":"Training The Ubuntu Dialog Corpus with chatterbot","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working with a Python script and I have some problems on delaying the execution of a Bash script.\nMy script.py lets the user choose a script.sh, and after the possibility to modify that, the user can run it with various options. \nOne of this option is the possibility to delay of N seconds the execution of the script, I used time.sleep(N) but the script.py totally stops for N seconds, I just want to retard the script.sh of N seconds, letting the user continue using the script.py. \nI searched for answers without success, any ideas?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2353,"Q_Id":43078256,"Users Score":0,"Answer":"You should run sleep using subprocess.Popen before calling script.sh.","Q_Score":1,"Tags":"python,linux,bash","A_Id":43078388,"CreationDate":"2017-03-28T19:26:00.000","Title":"How to delay the execution of a script in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm working on a robot that uses a CNN that needs much more memory than my embedded computer (Jetson TX1) can handle. I was wondering if it would be possible (with an extremely low latency connection) to outsource the heavy computations to EC2 and send the results back to the be used in a Python script. If this is possible, how would I go about it and what would the latency look like (not computations, just sending to and from).","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":99,"Q_Id":43107807,"Users Score":1,"Answer":"Possible: of course it is.\nYou can use any kind of RPC to implement this. HTTPS requests, xml-rpc, raw UDP packets, and many more. If you're more interested in latency and small amounts of data, then something UDP based could be better than TCP, but you'd need to build extra logic for ordering the messages and retrying the lost ones. Alternatively something like Zeromq could help.\nAs for the latency: only you can answer that, because it depends on where you're connecting from. Start up an instance in the region closest to you and run ping, or mtr against it to find out what's the roundtrip time. That's the absolute minimum you can achieve. Your processing time goes on top of that.","Q_Score":2,"Tags":"python,amazon-web-services,amazon-ec2,hpc,grid-computing","A_Id":43107922,"CreationDate":"2017-03-30T03:08:00.000","Title":"Possible to outsource computations to AWS and utilize results locally?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I'm working on a robot that uses a CNN that needs much more memory than my embedded computer (Jetson TX1) can handle. I was wondering if it would be possible (with an extremely low latency connection) to outsource the heavy computations to EC2 and send the results back to the be used in a Python script. If this is possible, how would I go about it and what would the latency look like (not computations, just sending to and from).","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":99,"Q_Id":43107807,"Users Score":1,"Answer":"I think it's certainly possible. You would need some scripts or a web server to transfer data to and from. Here is how I think you might achieve it:\n\nSend all your training data to an EC2 instance \nTrain your CNN \nSave the weights and\/or any other generated parameters you may need\nConstruct the CNN on your embedded system and input the weights\nfrom the EC2 instance. Since you won't be needing to do any training\nhere and won't need to load in the training set, the memory usage\nwill be minimal. \nUse your embedded device to predict whatever you may need\n\nIt's hard to give you an exact answer on latency because you haven't given enough information. The exact latency is highly dependent on your hardware, internet connection, amount of data you'd be transferring, software, etc. If you're only training once on an initial training set, you only need to transfer your weights once and thus latency will be negligible. If you're constantly sending data and training, or doing predictions on the remote server, latency will be higher.","Q_Score":2,"Tags":"python,amazon-web-services,amazon-ec2,hpc,grid-computing","A_Id":43107931,"CreationDate":"2017-03-30T03:08:00.000","Title":"Possible to outsource computations to AWS and utilize results locally?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am going to create search api for Android and iOS developers.\nOur client have setup a lambda function in AWS. \nNow we need to fetch data using jwplatform Api based on search keyword passed as parameter. For this, I have to install jwplatform module in Lambda function or upload zip file of code with dependencies. So that i want to run python script locally and after getting appropriate result i will upload zip in AWS Lambda.\nI want to use the videos\/list (jwplatform Api) class to search the video library using python but i don't know much about Python. So i want to know how to run python script? and where should i put the pyhton script ?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":514,"Q_Id":43111193,"Users Score":1,"Answer":"I am succeed to install jwplatform module locally.\nSteps are as follows:\n1. Open command line\n2. Type 'python' on command line\n3. Type command 'pip install jwplatform'\n4. Now, you can use jwplatform api. \nAbove command added module jwplatform in python locally\nBut my another challenge is to install jwplatform in AWS Lambda. \nAfter research i am succeed to install module in AWS Lambda. I have bundled module and code in a directory then create zip of bundle and upload it in AWS Lambda. This will install module(jwplatform) in AWS Lambda.","Q_Score":0,"Tags":"python,python-2.7,amazon-web-services,aws-lambda,jwplayer","A_Id":43133422,"CreationDate":"2017-03-30T07:26:00.000","Title":"how to use jwplatform api using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"1) I am working on a project on Raspberry pi. Once I finished my all stuff, I want my SD card\/code to be properly locked. so that no one is able to read and write code just like we locked other small microcontrollers(AVR\/PIC).Please help to do that.\n2) I am generating logs in my code using logging library, will I be able to write logs if my SD card\/code is write\/read protected.\nMy objective is no one be able to steal my code or make modifications to the code. What should I do to protect my code from stealing and make changes into the code?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":172,"Q_Id":43133642,"Users Score":0,"Answer":"Someone correct me on this if I'm wrong but python being interpreted in most common implementations, I don't believe you're going to be able to make it unreadable.\nAssuming that you are running linux on your raspberry pi, you might be able to get the tiniest bit of security using chmod 100 on it, but I do not know enough to confirm or deny this for sure.","Q_Score":0,"Tags":"python,raspberry-pi","A_Id":43133737,"CreationDate":"2017-03-31T06:13:00.000","Title":"Raspberry pi : Make RPI code Read and Write Protected","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to pass a constant in a C preprocessor style but with a Python script.\nThis constant is already declared with AC_DEFINE in my configure.ac file and used in my C program, and now I need to pass it to a Python script too.\nI tried with a custom target in my Makefile.am with a sed call to preprocess a specific symbol in my Python script, but it seems dirty-coding to me.\nHow can I achieve this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":149,"Q_Id":43136997,"Users Score":5,"Answer":"Create a config.py.in with some contents like MYVAR = '''@MYVAR@''' and add it to AC_CONFIG_FILES in your configure.ac. You can then import config in your other Python scripts.\nThis fulfills much the same function as config.h does for C programs.","Q_Score":2,"Tags":"python,autotools,automake","A_Id":43163111,"CreationDate":"2017-03-31T09:20:00.000","Title":"autotools: pass constant from configure.ac to python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Each time TEST_DEBUG.EXE loaded at 0x04000000 base in IDA-Modules, but\nTEST_DEBUG.DLL file loaded at any randoms base like 0x0C120000, 0x0C710000 , 0x0ABC0000 \nHow i say to IDA debugger, load TEST_DEBUG.DLL every time at 0x0ABC0000 BASE ?\nPS:\nTEST_DEBUG.EXE load many DLLS, and one of them is TEST_DEBUG.DLL","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":590,"Q_Id":43168438,"Users Score":0,"Answer":"NO ONE KNOW ?\nC:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\bin\\x86_arm>EDITBIN \/REBASE:BASE=0x61000000 mydll.dll","Q_Score":0,"Tags":"python,debugging,reverse-engineering,ida","A_Id":43170113,"CreationDate":"2017-04-02T12:41:00.000","Title":"How IDA will load DLL at constant memory segment at debug process?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a slight problem. I have a project that I'm working on and that requires two programs to read\/write into some .txt files. \nPython writes into one .txt file, C++ reads from it. C++ does what it needs to do and then writes its own information into another .txt file that Python has to read. \nWhat I want to know is how can I check with C++ if Python has closed the .txt file before opening the same file, as Python may still be writing stuff into it and vice versa? \nIf you need any extra information about this conundrum, feel free to contact me.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":78,"Q_Id":43169118,"Users Score":0,"Answer":"You might consider having each \"writer\" process write its output to a temporary file, close the file, then rename it to the filename that the \"reader\" process is looking for.\nIf the file is present, then the respective reader process knows that it can read from it.","Q_Score":0,"Tags":"python,c++","A_Id":43173531,"CreationDate":"2017-04-02T13:50:00.000","Title":"Has .txt file been closed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a github project available to others. One of the scripts, update.py, checks github everyday (via cron) to see if there is a newer version available.\nLocally, the script is located at directory \/home\/user\/.Project\/update.py\nIf the version on github is newer, then update.py moves \/home\/user\/.Project\/ to \/home\/user\/.OldProject\/, clones the github repo and moves\/renames the downloaded repo to \/home\/user\/.Project\/\nIt has worked perfectly for me about five times, but I just realized that the script is moving itself while it is still running. Are there any unforeseen consequences to this approach, and it there a better way?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":24,"Q_Id":43177320,"Users Score":2,"Answer":"As long as all of the code used by the script has been compiled and loaded into the Python VM there will be no issue with the source moving since it will remain resident in memory until the process ends or is replaced (or swapped out, but since it is considered dirty data it will be swapped in exactly the same). The operating system, though, may attempt to block the move operation if any files remain open during the process.","Q_Score":2,"Tags":"python,github,directory","A_Id":43177411,"CreationDate":"2017-04-03T05:47:00.000","Title":"Are there any negative consequences if a python script moves\/renames its parent directory?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm reading from a \"bookazine\" which I purchased from WHSmiths today and its said\nduring the setup I need to type in these commands into the terminal (or the Command Prompt in my case) in order to make a script without needing to do it manually. One of these commands is chmod +x (file name) but because this is based of Linux or Mac and I am on Windows I am not sure how to make my script executable, how do I?\nThanks in advance.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":492,"Q_Id":43219217,"Users Score":0,"Answer":"You don't have shell scripts on Windows, you have batch or powershell. \nIf your reading is teaching Unix things, get a virtual machine running (insert popular Linux distribution here). \nRegarding python, you just execute python script.py","Q_Score":0,"Tags":"python,windows,executable","A_Id":43219241,"CreationDate":"2017-04-04T23:10:00.000","Title":"How would I go about making a Python script into an executable?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a chef recipe say A which contains three recipes B, C and D. Now i what is to run D in parallel wrt sequential execution of B and C. One hack i know is write is to write logic of B, C and D in python(B.py, C.py and D.py) and execute them in parallel( All.py ) in some script and make a consolidated recipe that calls All.py. But the code is too large to convert. Is there any hack to run recipes in parallel in chef using the same recipes?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":541,"Q_Id":43223984,"Users Score":1,"Answer":"No, Chef does not support concurrent execution in the general case. Chef-provisioning specifically supports concurrent handling for VM creation but that's a special case.","Q_Score":0,"Tags":"python,chef-infra","A_Id":43225019,"CreationDate":"2017-04-05T06:58:00.000","Title":"Is it possible to run a recipe in parallel with others in chef with some hack?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python script that checks the temperature every 24 hours, is there a way to leave it running if I shut the computer down\/log off.","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":8836,"Q_Id":43237879,"Users Score":1,"Answer":"The best way to accomplish this is to have your program run on some type of server that your computer can connect to. A server could be anything from a raspberry pi to an old disused computer or a web server or cloud server. You would have to build a program that can be accessed from your computer, and depending on the server and you would access it in a lot of different ways depending the way you build your program and your server.\nDoing things this way means your script will always be able to check the temperature because it will be running on a system that stays on.","Q_Score":0,"Tags":"python","A_Id":43238045,"CreationDate":"2017-04-05T17:29:00.000","Title":"Is there a way to leave python code running when the computer is shutdown?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python script that checks the temperature every 24 hours, is there a way to leave it running if I shut the computer down\/log off.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":8836,"Q_Id":43237879,"Users Score":0,"Answer":"Scripts are unable to run while your computer is powered off. What operating system are you running? How are you collecting the temperature? It is hard to give much more help without this information.\nOne thing I might suggest is powering on the system remotely at a scheduled time, using another networked machine.","Q_Score":0,"Tags":"python","A_Id":43238020,"CreationDate":"2017-04-05T17:29:00.000","Title":"Is there a way to leave python code running when the computer is shutdown?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python script that checks the temperature every 24 hours, is there a way to leave it running if I shut the computer down\/log off.","AnswerCount":4,"Available Count":3,"Score":0.0996679946,"is_accepted":false,"ViewCount":8836,"Q_Id":43237879,"Users Score":2,"Answer":"Shutdown - no.\nLogoff - potentially, yes.\nIf you want to the script to automatically start when you turn the computer back on, then you can add the script to your startup folder (Windows) or schedule the script (Windows tasks, cron job, systemd timer).\nIf you really want a temperature tracker that is permanently available, you can use a low-power solution like the Raspberry Pi rather than leaving your pc on.","Q_Score":0,"Tags":"python","A_Id":43238017,"CreationDate":"2017-04-05T17:29:00.000","Title":"Is there a way to leave python code running when the computer is shutdown?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to create a telegram bot for a home project and i wish the bot only talk to 3 people, how can I do this?\nI thought to create a file with the chat id of each of us and check it before responding to any command, I think it will work. the bot will send the correct info if it's one of us and \"goodbye\" to any other\nBut is there any other way to block any other conversation with my bot?\nPd: I'm using python-telegram-bot","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":986,"Q_Id":43240152,"Users Score":1,"Answer":"For the first part of your question you can make a private group and add your bot as one of its administrators. Then it can talk to the members and answer to their commands. \nEven if you don't want to do so, it is possible by checking the chatID of each update that the bot receives. If the chatID exists in the file, DataBase or even in a simple array the bot answers the command and if not it just ignores or sends a simple text like what you said good-bye.\n\nNote that bots cannot block people they can only ignore their\n messages.","Q_Score":3,"Tags":"telegram,telegram-bot,python-telegram-bot","A_Id":43241747,"CreationDate":"2017-04-05T19:37:00.000","Title":"Telegram-bot user control","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"as of right now I have a file called song.mp3 that I have integrated into a Python program which will act as an alarm. I would like it so that whenever I send the Raspberry Pi a new song via Bluetooth, it will just automatically rename this song to be song.mp3, thereby overwriting the previous song. That way I don't have to change my alarm program for different songs. Any help?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":141,"Q_Id":43267632,"Users Score":0,"Answer":"Assuming that the mp3 files are all in the same directory, you could perhaps have a cron job running that periodically renames the most recent file and so something like:\nmv $(ls -1t *.txt | head -1) song.mp3\nThis is a quick example. It would be more preferable to add the ablve to a script and add some \"belts and braces\" to ensure that the script doesn't crash.","Q_Score":0,"Tags":"python,bash,bluetooth,rename,overwrite","A_Id":43277093,"CreationDate":"2017-04-07T00:00:00.000","Title":"Automatically overwrite existing file with an incoming file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm a newbie in automation testing. \nCurrently doing a manual testing and trying to automate the process with Selenium Webdriver using Pyhton.\nI'm creating a test suite which will run different scripts. Each script will be running tests on different functionality.\nAnd I got stuck.\nI'm working on financial web application. The initial scrip will create financial deal, and all other scripts will be testing different functionality on this deal.\nI'm not sure how to handle this situation. Should I just pass the URL from the first script (newly created deal) into all other scripts in the suite, so all the tests were run on the same deal, and didn't create a new one for each test? How do I do this?\nOr may be there is a better way to do this? \nDeeply appreciate any advise!!! Thank you!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":284,"Q_Id":43327551,"Users Score":0,"Answer":"Preferably you would have each test be able to run in isolation. If you have a way to create the deal through an API or Database rather than creating one through the UI, you could call that for each test. And, if possible, also clean up that data after your test runs.\nIf this is not possible, you could also record some data from a test in a database, xml, or json file. Then your following tests could read in that data to get what it needs to run the test. In this case it would be some reference to your financial deal.\nThe 2nd option is not ideal, but might be appropriate in some cases.","Q_Score":1,"Tags":"python,selenium,webdriver","A_Id":43327713,"CreationDate":"2017-04-10T15:43:00.000","Title":"How to run all the tests on the same deal. Selenium Webdriver + Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm a newbie in automation testing. \nCurrently doing a manual testing and trying to automate the process with Selenium Webdriver using Pyhton.\nI'm creating a test suite which will run different scripts. Each script will be running tests on different functionality.\nAnd I got stuck.\nI'm working on financial web application. The initial scrip will create financial deal, and all other scripts will be testing different functionality on this deal.\nI'm not sure how to handle this situation. Should I just pass the URL from the first script (newly created deal) into all other scripts in the suite, so all the tests were run on the same deal, and didn't create a new one for each test? How do I do this?\nOr may be there is a better way to do this? \nDeeply appreciate any advise!!! Thank you!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":284,"Q_Id":43327551,"Users Score":0,"Answer":"There's a couple of approaches here that might help, and some of it depends on if you're using a framework, or just building from scratch using the selenium api.\n\nUse setup and teardown methods at the suite or test level.\n\nThis is probably the easiest method, and close to what you asked in your post. Every framework I've worked in supports some sort of setup and teardown method out of the box, and even if it doesn't, they're not hard to write. In your case, you've got a script that calls each of the test cases, so just add a before() method at the beginning of the suite that creates the financial deal you're working on.\nIf you'd like a new deal made for each individual test, just put the before() method in the parent class of each test case so they inherit and run it with every case.\n\nUse Custom Test Data\n\nThis is probably the better way to do this, but assumes you have db access or a good relationship with your dbm. You generally don't want the success of one test case to rely on the success of another(what the first answer meant by isolaton). If the creation of the document fails in some way, every single test downstream of that will fail as well, even though they're testing a different feature that might be working. This results in a lot of lost coverage.\nSo, instead of creating a new financial document every time, speak to your DBM and see if it's possible to create a set of test data that either sits in your test db or is inserted at the beginning of the test suite.\nThis way you have 1 test that tests document creation, and X tests that verify it's functionality based on the test data, and those tests do not rely on each other.","Q_Score":1,"Tags":"python,selenium,webdriver","A_Id":43328191,"CreationDate":"2017-04-10T15:43:00.000","Title":"How to run all the tests on the same deal. Selenium Webdriver + Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So a few hours ago I built python (3.6) from source on a raspberry pi (raspbian). Now trying to install modules I find out I do not have the SSL module. Looking around at other questions there seams to be no other way other than to rebuild it with the arg --with-ssl or something. \nI don't want to do that again as it took about 3 and a half hours to complete. Unless you can multi-thread the make process across all four cores? However the pi thermals will probably hold it back.\nI there a way to install it? On python 2 you could with pip install ssl, me been stupid tried pip3 install ssl but that is still python 2 ssl module so throws syntax errors. Then tried with ssl3 but that does not exist.\nAny suggestions?\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1001,"Q_Id":43332985,"Users Score":1,"Answer":"In standard python 3 installation ssl is considered a built-in, so there's no option to install it.\nProbably rebuilding is the only solution then.","Q_Score":1,"Tags":"python,ssl,build,installation","A_Id":50069365,"CreationDate":"2017-04-10T21:13:00.000","Title":"Install the SSL module on Python 3.6 without rebuilding","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"xunitmerge create duplicate tests when merged the py.test results of two different set of tests.\nI have two test folders and ran them separately using py.test, which created results-1.xml &results-2.xml. after that i am merging as below.\nxunitmerge results-1.xml results-2.xml results.xml\nwhich created results.xml, when i publish the results using jenkins (publish xunit results) i see the tests recorded shown them as duplicate though the tests of results-1.xml and results-2.xml are unique.\nHow to avoid duplicate test results during merge?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":272,"Q_Id":43351833,"Users Score":0,"Answer":"Check that you didn't include the original results-1.xml and results-2.xml file in the path that Jenkins scan for results.\nIf you're not sure about it, try to delete the origin files after the merge (and before running the xunit-report action)","Q_Score":0,"Tags":"python,unit-testing,jenkins,pytest,xunit","A_Id":45173514,"CreationDate":"2017-04-11T16:47:00.000","Title":"xunitmerge does creates duplicate tests when merged the py.test results of two different set of tests","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a simple (and maybe silly) question about binary data files. If a simple type is used (int\/float\/..) it is easy to imagine the structure of the binary file (a sequence of floats, with each float written using a fixed number of bytes). But what about structures, objects and functions ? Is there some kind of convension for each language with regards to the order in which the variables names \/ attributes \/ methods are written, and if so, can this order be changed and cusotomized ? otherwise, is there some kind of header that describes the format used in each file ?\nI'm mostly interested in python and C\/C++. When I use a pickled (or gzipped) file for example, python \"knows\" whether the original object has a certain method or attribute without me casting the unpickled object or indicating its type and I've always wondered how is that implemented. I didn't know how to look this up on Google because it may have something to do with how these languages are designed in the first place. Any pointers would be much appreciated.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":62,"Q_Id":43352671,"Users Score":1,"Answer":"Binary files contain data. \nThere are a plethora of data layouts of binary files. Some examples are JPEG, Executables, Word Processor, Raw Text and archive files. \nA file may have an extension that may indicate the layout. For example, a \".png\" would would most likely follow the PNG format. A \"bin\" or \"dat\" extension is to generic. One could zip up files and name the archive with a \"png\" extension. \nIf there is no file extension or the OS doesn't store the type of a file, then the format of the file is based on discovery (or trying random formats). Some file formats have integrity values in them to help verify correctness. Knowing the integrity value and how it was calculated, can assist in classify the format type. Again, there is no guarantee.\nBTW, file formats are independent of the language to used to read them. One could read a gzipped file using FORTRAN or BASIC.","Q_Score":0,"Tags":"python,c++,binaryfiles","A_Id":43355184,"CreationDate":"2017-04-11T17:33:00.000","Title":"Binary files structure for objects and structs in C++\/Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have configured credentials using aws configure.\naws configure list looks fine.Python\/django is able to locate the credentials in the shell_plus but unable to locate credentials when django is being run through gunicorn \/ supervisor.\nThis is weired","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1139,"Q_Id":43361364,"Users Score":2,"Answer":"When you run aws configure you will write files linked to your profile as they will be written in ~\/.aws\/config and ~\/.aws\/credentials.\nWhen you run your application, the application will look for those files using the same logic, ie.~\/.aws\/credentials.\nWhen in a shell, the interpreter will try to translate ~ to an absolute path based on $(whoami).\nTL;DR - You must run aws configure with the same user as your application is running with.","Q_Score":0,"Tags":"python,django,amazon-web-services,boto3","A_Id":43364021,"CreationDate":"2017-04-12T05:55:00.000","Title":"AWS credentials : unable to locate credentials in django python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"What local development configuration is suggested for testing python web apps before deploying to pythonanywhere?\nMay be some XAMPP\/LAMP analogue for uWSGI is exist?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":147,"Q_Id":43401116,"Users Score":2,"Answer":"In a dev setting you can just use uWSGI as your app and web server, or you can use one of the many Python WSGI servers.","Q_Score":3,"Tags":"uwsgi,pythonanywhere","A_Id":43477460,"CreationDate":"2017-04-13T20:24:00.000","Title":"Local development configuration to test web app before deploy to pythonanywhere","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Usually I run python script python myscript.py,\nI want to run script directly without type python,\nI already Add shebang: #!\/usr\/bin\/env python at the top of my script.\nAnd then give the file permission to execute by: chmod +x SleepCalc.py\nbut it still tell me \"Command not found\"\nIs anything I need to change in cshell?or anything I did wrong?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":81,"Q_Id":43407803,"Users Score":1,"Answer":"Are you running it from the same folder using .\/SleepCalc.py command?\nSleepCalc.pyonly will not work.","Q_Score":0,"Tags":"python","A_Id":43407826,"CreationDate":"2017-04-14T08:17:00.000","Title":"Run python script without type pythonat the front","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am interested in the performance of Pyomo to generate an OR model with a huge number of constraints and variables (about 10e6). I am currently using GAMS to launch the optimizations but I would like to use the different python features and therefore use Pyomo to generate the model.\nI made some tests and apparently when I write a model, the python methods used to define the constraints are called each time the constraint is instanciated. Before going further in my implementation, I would like to know if there exists a way to create directly a block of constraints based on numpy array data ? From my point of view, constructing constraints by block may be more efficient for large models.\nDo you think it is possible to obtain performance comparable to GAMS or other AML languages with pyomo or other python modelling library ?\nThanks in advance for your help !","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":4313,"Q_Id":43413067,"Users Score":6,"Answer":"While you can use NumPy data when creating Pyomo constraints, you cannot currently create blocks of constraints in a single NumPy-style command with Pyomo. Fow what it's worth, I don't believe that you can in languages like AMPL or GAMS, either. While Pyomo may eventually support users defining constraints using matrix and vector operations, it is not likely that that interface would avoid generating the individual constraints, as the solver interfaces (e.g., NL, LP, MPS files) are all \"flat\" representations that explicit represent individual constraints. This is because Pyomo needs to explicitly generate representations of the algebra (i.e., the expressions) to send out to the solvers. In contrast, NumPy only has to calculate the result: it gets its efficiency by creating the data in a C\/C++ backend (i.e., not in Python), relying on low-level BLAS operations to compute the results efficiently, and only bringing the result back to Python. \nAs far as performance and scalability goes, I have generated raw models with over 13e6 variables and 21e6 constraints. That said, Pyomo was designed for flexibility and extensibility over speed. Runtimes in Pyomo can be an order of magnitude slower than AMPL when using cPython (although that can shrink to within a factor of 4 or 5 using pypy). At least historically, AMPL has been faster than GAMS, so the gap between Pyomo and GAMS should be smaller.","Q_Score":10,"Tags":"python,mathematical-optimization,pyomo","A_Id":43420032,"CreationDate":"2017-04-14T13:59:00.000","Title":"Performance of pyomo to generate a model with a huge number of constraints","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have bash shell script which is internally calling python script.I would like to know how long python is taking to execute.I am not allowed to do changes in python script.\nAny leads would be helpful thanks in advance.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":884,"Q_Id":43416606,"Users Score":0,"Answer":"Call the python script with \/usr\/bin\/time script. This allows you to track CPU and wall-clock time of the script.","Q_Score":0,"Tags":"python,bash,shell","A_Id":43416717,"CreationDate":"2017-04-14T17:49:00.000","Title":"Capture run time of python script executed inside shell script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I need telegram bot which can delete message in group channel\ni googled it but did not find a solution\nCould you tell the library and the method for this, if you know, thank you in advance?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":14759,"Q_Id":43416724,"Users Score":0,"Answer":"In the bot API 3.0 the method used is \"deleteMessage\" with parameters chat_id and message_id\nNot yet officially announced","Q_Score":1,"Tags":"python,bots,telegram","A_Id":43864589,"CreationDate":"2017-04-14T17:56:00.000","Title":"How to delete message on channel telegram?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have seen in Firebug that my browser sends requests even for all static files. This happened when I have enabled caching for static files.\nI also saw the server response with 304 status code.\nNow, my question:\nWhy should the browser send requests for all static files when the cache is enabled?\nIs there a way that the browser does not send any request for static files until the expiration of the cache?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":149,"Q_Id":43424090,"Users Score":-1,"Answer":"Browsers still send requests to the server in case the files are cached to get to know whether there are new contents to fetch. Note that the response code 304 comes from the server telling the browser that the contents it has cached are still valid, so it doesn't have to download them again.","Q_Score":0,"Tags":"caching,browser,static,python-requests","A_Id":43425459,"CreationDate":"2017-04-15T08:50:00.000","Title":"Why does browser send requests for static files?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have over a thousand audio files, and I want to check if their sample rate is 16kHz. To do it manually would take me forever. Is there a way to check the sample rate using python?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":19259,"Q_Id":43490887,"Users Score":0,"Answer":"!pip install pydub\n\nfrom pydub.utils import mediainfo\ninfo=mediainfo(\"abc.wav\")\nprint(info)","Q_Score":11,"Tags":"python,audio,sample-rate","A_Id":68753091,"CreationDate":"2017-04-19T08:52:00.000","Title":"Check audio's sample rate using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How to check if the proxy have a high anonymity level or a transparent level in Python? \nI am writing a script to sort the good proxies but I want to filter only the high anonymity ones (elite proxies).","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":784,"Q_Id":43493600,"Users Score":1,"Answer":"Launch test site in the internet. It will perform only one operation: save received request with all the headers into a database or a file. Each request should have your signature to be sure it's yours original request.\nConnect with your Python script via proxy being tested to the site. Send all headers you want to see on that side.\nCheck data received - are there some headers or some date what can break your anonymity.","Q_Score":1,"Tags":"python,proxy,anonymity","A_Id":43558215,"CreationDate":"2017-04-19T10:50:00.000","Title":"How to check proxy's anonymity level?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using PyPy 2.2.1 on Ubuntu 14.04.\nI want to use the xlrd module for my program but running the programming with pypy throws me an import error. How do I fix this?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2701,"Q_Id":43499164,"Users Score":1,"Answer":"You might need to install a new pip for PyPy as it has a different space for storing modules.","Q_Score":3,"Tags":"python-2.7,xlrd,pypy","A_Id":43505371,"CreationDate":"2017-04-19T14:50:00.000","Title":"PyPy: \"ImportError: No module named xlrd\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have about 30,000 very short posts to make in Wordpress. I built them using a SQLlite database and python script, and was uploading them via the wordpress_xmlrpc library in python. But my site goes down after 100-200 posts, because the server thinks this is a DoS attack.\nMy server is a linux box to which I have SSH access. I'm looking for a way to easily upload the posts into Wordpress more directly, say by interacting directly with its database, or using a local process that happens directly on the server. Can anyone offer any ideas?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":129,"Q_Id":43520502,"Users Score":0,"Answer":"Found another way, in case anyone else stumbles on this. Dump all the posts to a csv file and use a \"csv to post\" widget. I'm using Ultimate CSV Importer Free. Very simple.","Q_Score":1,"Tags":"php,python,wordpress,xml-rpc","A_Id":43566010,"CreationDate":"2017-04-20T13:09:00.000","Title":"Uploading 30,000 posts into Wordpress without causing an XML-RPC crash","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Appium-Python with AWS Device farm. And I noticed that AWS run my tests in a random order.\nSince my tests are part dependent I need to find a way to tell AWS to run my tests in a specific order.\nAny ideas about how can I accomplish that?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":251,"Q_Id":43520574,"Users Score":0,"Answer":"I work for the AWS Device Farm team. \nThis seems like an old thread but I will answer so that it is helpful to everyone in future. \nDevice Farm parses the test in a random order. In case of Appium Python it will be the order what is received from pytest --collect-only. \nThis order may change across executions. \nThe only way to guarantee an order right now is to wrap all the test calls in a new test which will be the only test called. Although not the prettiest solution this is the only way to achieve this today.\nWe are working on bringing more parity between your local environment and Device Farm in the coming weeks.","Q_Score":1,"Tags":"pytest,python-appium,aws-device-farm","A_Id":44378193,"CreationDate":"2017-04-20T13:12:00.000","Title":"AWS Device Farm- Appium Python - Order of tests","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I would like to get the code completion in Eclipse with PyDev for the attributes of a class which is dynamically generated.\nBasically, I have a class which is defined by reading out an XML document. Depending on what is written in this XML document, the class has different attributes dynamically defined (the XML-tags).\nI would like to activate the code completion after calling the constructor of the class in my code.\nThe problem I see is that I have no control on the attributes of the class, which means : before running the code, I have no idea which attributes might be available. Does anyone have an idea ?\nI tried to add the library to the Forces-Built In without success.\nRegards","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":323,"Q_Id":43520772,"Users Score":0,"Answer":"Ok, i found yersterday some example with pypredef, and I started with this solution, and for now on it works well.\nThe only thing you need to care about is the identation. It looks like when you are implementing your .pypredef in Eclipse, you need to use 4 spacings als ident instead of a tab.","Q_Score":0,"Tags":"python,eclipse,pydev,code-completion","A_Id":43610458,"CreationDate":"2017-04-20T13:20:00.000","Title":"Eclipse PyDev Code completion of dynamic class attributes?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"working on a website built with python and angular but after every single change I need to hard reset browser to see it. I see this is a problem in general so what's the best approach for caching js and css resources ? right now I dont care if each file will be called on every single page if there is no other option.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":129,"Q_Id":43523750,"Users Score":1,"Answer":"Are you referring to development time? If so, this can often be set in the browser. Which browser are you using? For Chrome: \n\nOpen the developer tools.\nSelect the network tab.\nCheck the Disable cache checkbox","Q_Score":0,"Tags":"python,angularjs,angular,caching,browser-cache","A_Id":43525479,"CreationDate":"2017-04-20T15:23:00.000","Title":"angular\/python - browser caching issue on each change","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"For one of my pet projects I would like to create an arbitrary number of different integer hashes. After a bit of research I figured that universal hashing is the way to go. However, I struggle with the (numpy) implementation. Say I'm trying to use the hash family h(a,b)(x) = ((a * x + b) mod p) mod m and my x can be anywhere in the range of uint32. Then choosing p >= max(x) and a, b < p means that in the worst case a * x + b overflows not only uint32 but also uint64. I tried to find an implementation which solves this problem but only found clever ways to speed up the modulo operation and nothing about overflow.\nAny suggestions for how to implement this are greatly appreciated. Thanks :-)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":189,"Q_Id":43531607,"Users Score":1,"Answer":"(x + y) % z == ((x % z) + (y % z)) % z. So you could take the modulus before doing the sum:\n\nCast a and x to uint64. (Multiply two uint32 will never overflow uint64).\nCompute h = (a * x) % p + b\nReturn (h - p) if h > p else h. (Alternatively: return h % p)","Q_Score":1,"Tags":"python,numpy,hash","A_Id":43531728,"CreationDate":"2017-04-20T23:40:00.000","Title":"Integer overflow in universal hashing implementation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm doing a learn python the hardway tutorial, and they are using python2.7\nI got it downloaded but unable to switch back from 3.3 to 2.7\nI manipulated PATH variable, adding C:\\Python27 but this was no use\nany other suggestion?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":120,"Q_Id":43534537,"Users Score":0,"Answer":"Rename the python interpreter executables to their respective versions. The OS is just executing the first 'python' executable it finds in the path, which is probably the 3.x version. So in command line, you can type python2 or python3 to select the version of interpreter you want.","Q_Score":0,"Tags":"python","A_Id":43534609,"CreationDate":"2017-04-21T05:24:00.000","Title":"i have both python2 and 3, I want to use python2 but on powershell I'm using python3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created a compiled python file. When I am executing the file using python command, then it is working fine like below. \n$ python file.pyc \nBut, when I am putting .\/ before the filename (file.pyc) like running a .sh file, then it is not working.It is throwing error.\n$ .\/file.pyc\nIt is having all the privileges (777). \nIs there any way to execute the test.pyc file like we do with a test.sh file?\nRegards,\nSayantan","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2249,"Q_Id":43591526,"Users Score":1,"Answer":"Is there a specific reason you're using the .pyc file? Normally, you'd just add a shebang to the top of your script like so: #!\/usr\/bin\/env python, modify permissions (777 is not necessary, 755 or even 744 would work), and run it $ .\/file.py","Q_Score":0,"Tags":"python-2.7,pyc","A_Id":43591665,"CreationDate":"2017-04-24T15:00:00.000","Title":"How can i run a compiled python file like a shell script in Unix?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Using Windows \/ ipython v6.0.0\nI am running ipcontroller and a couple of ipengines on a remote host and all appears to work fine for simple cases.\nI try to adjust the pythonpath on the remote host (where the ipengines run) such that it can locate python user packages installed on the remote host. For some reason the ipengine does not accept this. \nI can't figure out where each ipengine gets its pythonpath from. Starting a command prompt, changing the pythonpath and then starting an ipengine in that environment does not help.\nIn fact, this does not seem to apply to the pythonpath, but also to all other environment variables. All come from somewhere and apparently can't changed such that the ipengine uses these values. \nThe only option seems to be is to add all packages, required binaries etc, in the directory where the ipengine is started from (since that directory is added to the pythonpath).\nThis seems rather crude and not very elegant at all. Am I missing something here?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":175,"Q_Id":43597253,"Users Score":0,"Answer":"Eventually, I managed to solve this using a startup script for the ipengines (see ipengine_config.py). The startup script defines the path, pythonpath etc prior to starting each ipengine. \nHowever, it is still unclear to me why the same result cannot be achieved by setting these variables prior to starting an ipengine (in the same environment).","Q_Score":0,"Tags":"python,python-3.x,environment-variables,ipython-parallel","A_Id":43619292,"CreationDate":"2017-04-24T20:35:00.000","Title":"How can I set the pythonpath and path of an ipengine (using ipyparallel)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm using g2.2 xlarge instance of amazon.\nI'm having this function that takes 3 minutes to run on my laptop which is so slow.\n However, when running it on EC2 it takes the same time , sometimes even more.\nSeeing the statistics , I noticed EC2 uses at its best 25% of CPU.\nI paralleled my code, It's better but I get the same execution time between my laptop and EC2.\nfor my function:\nI have an image as input,I run my function 2 times(image with and without image processing) that I managed to run them in parallel. I then extract 8 text fields from that image using 2 machine learning algorithms(faster-rcnn(field detection)+clstm(text reading) and then the text is displayed on my computer.\nAny idea how to improve performance (processing time) in EC2?","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":1356,"Q_Id":43607466,"Users Score":4,"Answer":"I think you need to profile your code locally and ensure it really is CPU bound. Could it be that time is spent on the network or accessing disk (e.g. reading the image to start with). \nIf it is CPU bound then explore how to exploit all the cores available (and 25% sounds suspicious - is it maxing out one core?). Python can be hard to parallelise due to the (in)famous GIL. However, only worry about this when you can prove it's a problem, profile first!","Q_Score":1,"Tags":"python,python-2.7,amazon-web-services,amazon-ec2","A_Id":43607778,"CreationDate":"2017-04-25T09:58:00.000","Title":"Why amazon EC2 is as slow as my machine when running python code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm needing to capture the raw data (every few miliseconds) that the microphone provides. For preference on Python, but it can be in C\/C++ too. I'm using Linux\/macOS.\nHow do I capture the audio wave (microphone input) and what kind of data it will be? Pure bytes? An array with some data?\nI want to make real time maginitude analysis and (if magnitude reachs a determined value) real time fft of the microphone signal, but I don't know the concepts about what data and how much data the microphone provides me.\nI see a lot of code that sets to capture 44.1kHz of the audio, but does it capture all this data? The portion of data taken depends of how it was programmed?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1426,"Q_Id":43631564,"Users Score":3,"Answer":"\"I'm needing to capture the raw data (every few milliseconds) that the microphone provides\"\nNo, you don't. That wouldn't work. Even if you captured that data every millisecond, at exactly a multiple of 1000 microseconds (no jitter), you would have an audio quality that's utterly horrible. A sample frequency of 1000 Hz (once per millisecond) limits the Nyquist frequency to 500 Hz. That's horribly low.\n\"I want to make real time maginitude analysis\". Well, you're ignoring the magnitude of components above 500 Hz, which is about 98% of the audible frequencies.\n\"real time fft\" - same problem, that too would miss 98%. \nYou can't handle raw audio like that. You must rely on the sound card to do the heavy lifting, to get the timing rights. It can sample sounds every 21 microseconds, with microsecond accuracy. You can talk to the audio card using ALSA or PulseAudio, or a few other options (that's sound on Linux for you). But recommendations there would be off-topic.","Q_Score":2,"Tags":"python,c++,c,linux,signal-processing","A_Id":43632432,"CreationDate":"2017-04-26T10:28:00.000","Title":"How to capture the microphone buffer raw data?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"A python program P running on server S1, listening port 8443.\nSome other services can send id_isa, ip pair to P. P could use this pair and make a ssh connection to the ip (create a ssh process).\nHow to make protect the id_rsa file even the machine S1 is cracked ? How to let root user can't get the id_rsa content (It seems ssh can use -i keyfile only)?\nThe main problem is P must save the id_rsa file to the disk,so that ssh can use it to conect to the ip.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":48,"Q_Id":43633459,"Users Score":0,"Answer":"Why don't you just add an ssh-daemon on Port 8443 and use ssh-Agent forwarding?\nThat way the private key never gets written down on P and you don't have to write and maintain your own program.","Q_Score":1,"Tags":"python,linux,security,ssh","A_Id":43633928,"CreationDate":"2017-04-26T11:53:00.000","Title":"how to design this security demands?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I exported my documents from Alfresco 4.x and now i need to import them to Alfreco 5.1, however i had different content models. So only think i need is to rewrite types and base url, i have similar types in my new Alfresco, but not the same name and prefix, url. So my question is:\nHow to rewrite metadata which is stored in ACP file in python or maybe java?\nI tried to use zipFile in python, but it gives me only errors and keep convincing me that i dont have zip file. I can't open it in notepad++ because it is not readable. I tried to just read content of file but python give blank line when i try to print it.\nEDIT:\nHere is a link to my file that i need to open and edit.\nDELETED no need for this anymore.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":115,"Q_Id":43638497,"Users Score":2,"Answer":"If it is a single archive your best bet is to unpack the acp (just a normal zip file, so any zip tool will work) and manipulate the .XML file inside it, which contains all the metadata, types, associations... \nYou could then use an XSLT to change the XML file and types and properties inside and rezip it with the rest of the content package.\nAnother approach can be to add the missing properties and aspects in a new 'legacy'-content model and add it to Alfresco 5.1. Once it is imported you can write a script to transfer the properties to the new model.\nOnce you are sure everything is copied you can remove the old model.","Q_Score":0,"Tags":"java,python,import,export,alfresco","A_Id":43650006,"CreationDate":"2017-04-26T15:28:00.000","Title":"Edit content of acp in python\/java","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I exported my documents from Alfresco 4.x and now i need to import them to Alfreco 5.1, however i had different content models. So only think i need is to rewrite types and base url, i have similar types in my new Alfresco, but not the same name and prefix, url. So my question is:\nHow to rewrite metadata which is stored in ACP file in python or maybe java?\nI tried to use zipFile in python, but it gives me only errors and keep convincing me that i dont have zip file. I can't open it in notepad++ because it is not readable. I tried to just read content of file but python give blank line when i try to print it.\nEDIT:\nHere is a link to my file that i need to open and edit.\nDELETED no need for this anymore.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":115,"Q_Id":43638497,"Users Score":0,"Answer":"I'm sorry i see today that i did bad export it had 0 kb so python was right it is empty i don't know how it happened. Thank you all, now i can work with as a zipFile and i will edit xml with metadatas im happy now :)","Q_Score":0,"Tags":"java,python,import,export,alfresco","A_Id":43651233,"CreationDate":"2017-04-26T15:28:00.000","Title":"Edit content of acp in python\/java","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using numexpr for simple array addition on a remote cluster. My computer has 8 cores and the remote cluster has 28 cores. Numexpr documentation says that \"During initialization time Numexpr sets this number to the number of detected cores in the system\" But the cluster gives this output.\ndetect_number_of_cores() = 28\ndetect_number_of_threads()=8\nALthough when I try to set the number of threads manually to something else(set_num_threads=20) , array operation seems to run faster. But detect_number_of_threads() still gives 8 as output. \nIs this a bug?","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":5204,"Q_Id":43641247,"Users Score":-1,"Answer":"I\u00b4m not sure, how numexpr actually works internally, when detect_number_of_threads is called, but maybe it reads out the number of threads that is available to openmp and not the number of threads that were locally set.","Q_Score":2,"Tags":"python,arrays,cluster-computing,python-multithreading,numexpr","A_Id":46969923,"CreationDate":"2017-04-26T17:50:00.000","Title":"Numexpr detecting number of threads less than number of cores","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"\/\/For my project, I first collected tweets(specific count) using Python and Tweepy\n\/\/Did pre-processing to keep meaningful data.\n\/\/The next step is to search for tweets which have assertive sentences.\nPlease Help","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":32,"Q_Id":43646796,"Users Score":0,"Answer":"The term assertive is rather relative. However, you have to define certain boundaries for what you think assertiveness is.\nI would then gather a few phrases or words that I think are assertive, and use them to filter the existing tweets.","Q_Score":0,"Tags":"python,twitter,nlp","A_Id":43656235,"CreationDate":"2017-04-27T00:44:00.000","Title":"How can we filter out tweets from Twitter that contains assertions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have problems with importing some functions in the file stored in other directories and importing random method from Crypto library.\nI installed Python34 and PyCrypto 2.6.1 in window 7.\nHere is my file structure\nmy_project\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\/dh\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\/__pycache__\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\/__init__.py\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0.\/lib\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\/__init__.py\n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\/helpers.py\nIn the \/dh\/__init__.py file\nI have three import statements as follows\nfrom Crypto.Hash import SHA256 -> it is fine\n\n\nfrom Crypto.Random import random -> gives me error \"from Crypto.Random import OSRNG ImportError: cannot import name 'OSRNG' \"\n\n\nfrom lib.helpers import read_hex --> gives me error \"from lib.helpers import read_hex ImportError: No module named 'lib' \"\nI found out that there is not such file or folder OSRNG in Python34\/Lib\/sit-packages\/Crypto\/Random\/\nHow can I fix these two errors?\nThanks guys","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":107,"Q_Id":43651453,"Users Score":0,"Answer":"Adding an answer as I don't have enough reputation to comment.\nI tried this in my system, I am able to import all the modules\/Classes mentioned in the question. I do see the OSRNG directory.\nAre you sure you installed it properly? Try reinstalling it. \nAlso, are you using a virtualenv? If so, may be you forgot to activate it?","Q_Score":0,"Tags":"python,import","A_Id":43654049,"CreationDate":"2017-04-27T07:38:00.000","Title":"Python file structure about importing from other directories","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using the Pi3 and the last jessie-lite OS, and I want to manage the brightness of the screen like Kodi does with the dim screensaver. \nAfter some google searching I found some tips but nothing works.\nI'll be using an external light sensor and I want to manage the brightness proportionally at the value sent by the light sensor.\nFor the moment, I develop in Python2.7 but the issue can use another language or by shell.\nThank you very much!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":678,"Q_Id":43651565,"Users Score":0,"Answer":"ideally what you want would have been for the Kodi json api to support setting the screensaver, from what I understand it doesn't.\nthat said if your familiar with Python, and I'm not, you can develop a plug in that opens a socket (or communicates otherwise) with your program running on your pi, because from what I understand plugins have the ability to set the screensaver.\nin other words, make a plug in that sends and receives message to and from the pi. \nthis is not really an answer because im not familiar with creating Kodi plugins, but I know it's possible because there are other plugins that do it...","Q_Score":1,"Tags":"python,raspberry-pi,screen,light,kodi","A_Id":43728785,"CreationDate":"2017-04-27T07:43:00.000","Title":"Dim a display with a raspberry","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've researched this on different places, including stackoverflow, and I can't find an answer that helps me.\nI'm using Windows 7, 64 bit, with Atom for 64 bit Windows. I have Python 3.6.1 installed in the directory C:\\Users\\Austin\\Documents\\Python. When I try to run a simple script to test Python in Atom, it says\n\n'python' is not recognized as an internal or external command,\n operable program or batch file.\n [Finished in 0.083s]\n\nI tried to run the same script in the command line, and it said the same thing. I'm new to programming, so please try to be a little patient.","AnswerCount":7,"Available Count":6,"Score":0.0285636566,"is_accepted":false,"ViewCount":24120,"Q_Id":43669897,"Users Score":1,"Answer":"Adding python to my path, (installed as C:\\Program Files\\Python39\\Python.exe) worked, but only after restarting Atom. Make sure you do that. Looks like it doesn't dynamically watch and reload the path variable from the system \u00af\\_(\u30c4)_\/\u00af","Q_Score":4,"Tags":"python,atom-editor","A_Id":69393225,"CreationDate":"2017-04-28T00:10:00.000","Title":"Why can't Python run in Atom?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I've researched this on different places, including stackoverflow, and I can't find an answer that helps me.\nI'm using Windows 7, 64 bit, with Atom for 64 bit Windows. I have Python 3.6.1 installed in the directory C:\\Users\\Austin\\Documents\\Python. When I try to run a simple script to test Python in Atom, it says\n\n'python' is not recognized as an internal or external command,\n operable program or batch file.\n [Finished in 0.083s]\n\nI tried to run the same script in the command line, and it said the same thing. I'm new to programming, so please try to be a little patient.","AnswerCount":7,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":24120,"Q_Id":43669897,"Users Score":0,"Answer":"None of the above answers worked for me. What did work, is installing Python from the Microsoft Store instead of downloading from the web and installing from an installer.","Q_Score":4,"Tags":"python,atom-editor","A_Id":71393101,"CreationDate":"2017-04-28T00:10:00.000","Title":"Why can't Python run in Atom?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I've researched this on different places, including stackoverflow, and I can't find an answer that helps me.\nI'm using Windows 7, 64 bit, with Atom for 64 bit Windows. I have Python 3.6.1 installed in the directory C:\\Users\\Austin\\Documents\\Python. When I try to run a simple script to test Python in Atom, it says\n\n'python' is not recognized as an internal or external command,\n operable program or batch file.\n [Finished in 0.083s]\n\nI tried to run the same script in the command line, and it said the same thing. I'm new to programming, so please try to be a little patient.","AnswerCount":7,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":24120,"Q_Id":43669897,"Users Score":0,"Answer":"I solved this issue, by put the good python path in Atom ide-Python\nsimply i put D:\\my_python_folder\\Python.exe","Q_Score":4,"Tags":"python,atom-editor","A_Id":62619959,"CreationDate":"2017-04-28T00:10:00.000","Title":"Why can't Python run in Atom?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I've researched this on different places, including stackoverflow, and I can't find an answer that helps me.\nI'm using Windows 7, 64 bit, with Atom for 64 bit Windows. I have Python 3.6.1 installed in the directory C:\\Users\\Austin\\Documents\\Python. When I try to run a simple script to test Python in Atom, it says\n\n'python' is not recognized as an internal or external command,\n operable program or batch file.\n [Finished in 0.083s]\n\nI tried to run the same script in the command line, and it said the same thing. I'm new to programming, so please try to be a little patient.","AnswerCount":7,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":24120,"Q_Id":43669897,"Users Score":0,"Answer":"Reinstall the latest Python version. One of the first installation screens has a toggle box at the bottom that you can click to add the directory to Path. This worked for me when I ran into the same problem. You have to manually click though and it's easy to ignore it.","Q_Score":4,"Tags":"python,atom-editor","A_Id":46919992,"CreationDate":"2017-04-28T00:10:00.000","Title":"Why can't Python run in Atom?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I've researched this on different places, including stackoverflow, and I can't find an answer that helps me.\nI'm using Windows 7, 64 bit, with Atom for 64 bit Windows. I have Python 3.6.1 installed in the directory C:\\Users\\Austin\\Documents\\Python. When I try to run a simple script to test Python in Atom, it says\n\n'python' is not recognized as an internal or external command,\n operable program or batch file.\n [Finished in 0.083s]\n\nI tried to run the same script in the command line, and it said the same thing. I'm new to programming, so please try to be a little patient.","AnswerCount":7,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":24120,"Q_Id":43669897,"Users Score":0,"Answer":"In very direct terms, it means that there is no executable file named python.exe in any dictionary in your search path (which I think is the PATH environment variable on Windows).\nFirst of all, try executing python from the installation directory. If that works, you know that you have it installed properly, and that the problem is the search path. If that fails, try again with the full path name, such as C:\\Users\\Austin\\Documents\\Python\\python.exe.\nDoes that move you closer to a solution?","Q_Score":4,"Tags":"python,atom-editor","A_Id":43669935,"CreationDate":"2017-04-28T00:10:00.000","Title":"Why can't Python run in Atom?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I've researched this on different places, including stackoverflow, and I can't find an answer that helps me.\nI'm using Windows 7, 64 bit, with Atom for 64 bit Windows. I have Python 3.6.1 installed in the directory C:\\Users\\Austin\\Documents\\Python. When I try to run a simple script to test Python in Atom, it says\n\n'python' is not recognized as an internal or external command,\n operable program or batch file.\n [Finished in 0.083s]\n\nI tried to run the same script in the command line, and it said the same thing. I'm new to programming, so please try to be a little patient.","AnswerCount":7,"Available Count":6,"Score":1.2,"is_accepted":true,"ViewCount":24120,"Q_Id":43669897,"Users Score":8,"Answer":"Your issue is probably that your Python command is not listed in your PATH environment variable.\nEnvironment Variables are paths, values and other information stored by your operating system and used globally by the OS and different applications you use.\nThe best example for a command listed in the PATH environment variable is cmd or ping. try to tap Win+R and type cmd, note how it opens a new Command Line even though you don't really know where cmd.exe is stored on your hard drive? That is because the path C:\\Windows\\System32 is stored in your PATH variable.\nSo, we know you installed python, but you want to be able to run it without specifying it's path, how can we do that? Simply add it to our environment variables:\n\nUse the keyboard shortcut Win+Pause\nClick on Advanced system settings\nAt the bottom of the window click on Environment Variables...\nIn the System Variables section find the PATH variable\nDouble click it\nA new window with a text box has opened, go to it's end with the end button\nPaste the path C:\\Users\\Austin\\Documents\\Python at it's end (be sure to add a ; before pasting if there isn't one there.\nClick ok\nOpen a new cmd window\nTry and type python you should be all set now, on the command line and in Atom.\n\nIf it isn't clear, the win button is the button on your keyboard with the windows icon on it.","Q_Score":4,"Tags":"python,atom-editor","A_Id":43669978,"CreationDate":"2017-04-28T00:10:00.000","Title":"Why can't Python run in Atom?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a work to do on numerical analysis that consists on implementing algorithms for root-finding problems. Among them are the Newton method which calculates values for a function f(x) and it's first derivative on each iteraction. \nFor that method I need a way to the user of my application enter a (mathematical) function and save it as a variable and use that information to give values of that function on different points. I know just the very basic of Python programming and maybe this is pretty easy, but how can I do it?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":239,"Q_Id":43711437,"Users Score":1,"Answer":"If you trust the user, you could input a string, the complete function expression as it would be done in Python, then call eval() on that string. Python itself evaluates the expression. However, the user could use that string to do many things in your program, many of them very nasty such as taking over your computer or deleting files.\nIf you do not trust the user, you have much more work to do. You could program a \"function builder\", much like the equation editor in Microsoft Word and similar programs. If you \"know just the very basic of Python programming\" this is beyond you. You might be able to use a search engine to find one for Python.\nOne more possibility is to write your own evaluator. That would also be beyond you, and you also might be able to find one you can use.\nIf you need more detail, show some more work of your own then ask.","Q_Score":1,"Tags":"python,math,mathematical-expressions","A_Id":43711560,"CreationDate":"2017-04-30T21:20:00.000","Title":"Mathematical functions on Python 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm doing a tweepy crawling.\nI want the program to run automatically every 12 hours\nCould you tell me the syntax?\nI'm doing it with Python, and I have all the tweepy crawling code.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":59,"Q_Id":43730867,"Users Score":1,"Answer":"You can try executing\/calling your program by the command line interface and schedule a task using the embedded in windows- Windows Scheduler. There are many alternatives but that is the easiest I found when I did such task few months ago.","Q_Score":2,"Tags":"python,twitter,save,tweepy","A_Id":43730944,"CreationDate":"2017-05-02T05:43:00.000","Title":"i want your help abut program to run automatically every 12 hours","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a ubuntu server where a number of users login, i need to monitor who logs in. I am thinking of a pythonic way or anything better because i need to send the notification to slack.\nSo what i meant is , a python script sends notification to slack only when a user successfully logs in. I can write the slack integration but i am not sure how the script will be triggered on login?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":365,"Q_Id":43741348,"Users Score":1,"Answer":"Ubuntu will keep track of any authentication (either login or sudo) attempts through \/var\/log\/auth.log. Keep track of that file (or read up on how log entries are written to it) and you can then send notification to any other channel as the entries arrive.","Q_Score":0,"Tags":"python,ubuntu,slack","A_Id":43741656,"CreationDate":"2017-05-02T15:06:00.000","Title":"How to run a python script and see who logged in","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Lambda functions have access to disk space in their own \/tmp directories. My question is, where can I visually view the \/tmp directory? \nI\u2019m attempting to download the files into the \/tmp directory to read them, and write a new file to it as well. I actually want see the files I\u2019m working with are getting stored properly in \/tmp during execution.\nThank you","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":26323,"Q_Id":43768290,"Users Score":1,"Answer":"Try to use a S3 bucket to store the file and read it from the AWS Lambda function, you should ensure the AWS Lambda role has access to the S3 bucket.","Q_Score":12,"Tags":"python,python-2.7,amazon-web-services,aws-lambda","A_Id":43768891,"CreationDate":"2017-05-03T19:18:00.000","Title":"Python\/AWS Lambda Function: How to view \/tmp storage?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Why is my Python script running twice in the background when I try to execute it at startup of my Raspberry Pi by adding the command to \/etc\/profile?\nI have a command written at the end of the file \/etc\/profile for a Python script to run at startup of my Raspberry Pi, \"sudo python \/path\/filename.py &\", and for some reason it runs twice, every time. When I comment the line out and execute it manually from the command line it runs normally. Why does that happen and what can I do to prevent that from happening?\nI know for fact that it is running twice in the background because in my code I have a buzzer that beeps twice at times and 3 times at others, and it beeps 4 times instead of 2 and 6 times instead of 3. Also the code ends up contradicting itself, clearly because each script run is trying to do something else at the same time.\nThanks in advance.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1752,"Q_Id":43779636,"Users Score":1,"Answer":"I'm answering my own question with a better method for running scripts at boot\/startup.\nI'm not exactly sure why this was happening, but I did learn that executing scripts on startup with this method is a bad practice and is best avoided.\nI started using the Crontab instead.\nThis is what you need to do:\n\ncrontab -e\n\nThis opens up the crontab, then add the following line:\n\n@reboot python \/filelocation\/filename.py\n\nThis will execute the script as soon as the Pi boots up.\nNo more double script runs!","Q_Score":4,"Tags":"python,linux,unix,raspberry-pi,startup","A_Id":54028966,"CreationDate":"2017-05-04T09:56:00.000","Title":"Why is my Python script running twice in the background when I try to execute it at startup of my Raspberry Pi by adding the command to \/etc\/profile?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How do you detect \"bounceed\" email replies and other automated responses for failed delivery attempts in Python?\nI'm implementing a simple server to relay messages between email and comments inside a custom web application. Because my comment model supports a \"reply to all\" feature, if two emails in a comment thread become invalid, there would possibly be an infinite email chain where my system would send out an email, get a bounceback email, relay this to the other invalid email, get a bounceback email, relay this back to the first, ad infinitum.\nI want to avoid this. Is there a standard error code used for bounced or rejected emails that I could check for, ideally with Python's imaplib package?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2370,"Q_Id":43782851,"Users Score":0,"Answer":"Avoid reacting to messages whose Return-Path isn't in From, or that contain an Auto-Submitted or X-Loop header field, or that have a bodypart with type multipart\/report.\nYou may also want to specify Auto-Submitted: auto-generated on your outgoing mail. I expect that if you do as Max says that'll take care of the problem, but Auto-Submitted isn't expensive.","Q_Score":2,"Tags":"python,email,imap","A_Id":43785616,"CreationDate":"2017-05-04T12:24:00.000","Title":"How to detect bounce emails","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an AWS EC2 machine that has been running nightly google analytics scripts to load into a database. It has been working fine up for months until this weekend. I have not made any changes to the code.\nThese are the two errors that are showing up in my logs:\n\/venv\/lib\/python3.5\/site-packages\/oauth2client\/_helpers.py:256: UserWarning: Cannot access analytics.dat: No such file or directory\n warnings.warn(_MISSING_FILE_MESSAGE.format(filename))\nFailed to start a local webserver listening on either port 8080\nor port 8090. Please check your firewall settings and locally\nrunning programs that may be blocking or using those ports.\nFalling back to --noauth_local_webserver and continuing with\nauthorization.\nIt looks like it is missing my analytics.dat file but I have checked and the file is in the same folder as the script that calls the GA API. I have been searching for hours trying to figure this out but there are very little resources on the above errors for GA.\nDoes anyone know what might be going on here? Any ideas on how to troubleshoot more?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":913,"Q_Id":43787699,"Users Score":1,"Answer":"I am not sure why this is happening, But I have a list of steps which might help you.\n\ncheck if this issue is caused by google analytics API version, google generally deprecates the previous versions of their API.\nI am guessing that you are running this code on cron on your EC2 serv, make sure that you include the path to the folder where the .dat file is.\n3.check whether you have the latest credentials in the .dat file.\n\nAuthentication to the API will happen through the .dat file.\nHope this solves your issue.","Q_Score":6,"Tags":"python,amazon-web-services,amazon-ec2,oauth-2.0,google-analytics-api","A_Id":48089379,"CreationDate":"2017-05-04T15:56:00.000","Title":"Google analytics .dat file missing, falling back to noauth_local_webserver","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to deploy a Flask app on an EC2 instance running Ubuntu. I have my WSGI file set up, but I'm having some issues running gunicorn. At first, I installed gunicorn with sudo apt-get install gunicorn. However, it ran with the wrong version of python, and it threw import errors for each of the modules my Flask app uses. I ascertained that this was due to the fact that I use conda as an environment manager, and because installing with apt-get placed gunicorn outside of the purview virtual environment. So, I uninstalled gunicorn (sudo apt-get purge gunicorn) and reinstalled it through conda (conda install gunicorn). Now, when I run gunicorn (gunicorn --bind 0.0.0.0:8000 wsgi:app), I don't get a 50 line traceback. I do, however, get the following error: -bash: \/usr\/bin\/gunicorn: No such file or directory. I tried uninstalling gunicorn and reinstalling with pip, but I still get the same error. I've tried searching Google and StackOverflow for solutions, but all I've discovered is that I should be installing gunicorn within a virtual environment to overcome this error (which, I beleive, I'm already doing). I'm guessing there's an easy fix to this, and that the problem is related to my ineptitude, as opposed to conda or something else. Any suggestions would be much appreciated. Thanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3262,"Q_Id":43809618,"Users Score":5,"Answer":"So, I was right - the problem is entirely related to my own ineptitude. Rather than deleting this question, though, I'm going to answer it myself and leave it here in case any future fledgling developers run into the same problem. The issue, as it turns out, is that I was running gunicorn --bind 0.0.0.0:8000 wsgi:app in the wrong directory. After I cd into the directory containing wsgi.py, gunicorn works just fine. The takeaway: gunicorn must be run from within the directory containing wsgi.py.","Q_Score":4,"Tags":"python,ubuntu,gunicorn,conda","A_Id":43809861,"CreationDate":"2017-05-05T16:21:00.000","Title":"Running gunicorn on Ubuntu in a conda environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I would like to serve a Captive Portal - page that would prompt the user to agree to certain terms before starting browsing the web from my wireless network (through WiFi) using http.server on my Raspberry Pi that runs the newest version of Raspbian.\nI have http.server (comes with Python3) up an running and have a webpage portal.html locally on the Pi. This is the page that I want users to be redirected to when they connect to my Pi. Lets say that the local IP of that page is 192.168.1.5:80\/portal.html\nMy thought is that I would then somehow allow their connection when they have connected and accepted the terms and conditions.\nHow would I go about that?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2404,"Q_Id":43849370,"Users Score":0,"Answer":"You need to work out the document in question, with all the necessary terms and conditions that will link the acceptance of the conditions to a specific user. You can implement a simple login, and link a String (Name - ID) to a Boolean for example, \"accepted = true\". If you don't need to store the user data, just redirect yo your document and when checked \"agree\", then you allow the user connection.","Q_Score":4,"Tags":"python-3.x,networking,simplehttpserver,captivenetwork,captiveportal","A_Id":43850242,"CreationDate":"2017-05-08T13:46:00.000","Title":"How do I implement a simple Captive Portal with `http.server`?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have written a python file containing some unit tests (testfile.py). \nWhen I run 'python testfile.py' the tests run fine and there are no errors.\nBut when I run 'nosetests testfile.py', I get a TypeError of the form \nTypeError: func_name() takes exactly 3 arguments (1 given).\nCan you please help me understand what might be going on and how can I modify the python file so that it can be run using both python and nosetests.\nThanks in advance,\nAmbarish.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":590,"Q_Id":43903569,"Users Score":0,"Answer":"I figured out what the problem was. I had a non-test function which included 'test' in its name even it id did not start with 'test_', as a result of which it was treated as a test function by nose. When I modified the name of the function, the problem was solved.","Q_Score":0,"Tags":"python,unit-testing,nose","A_Id":43927343,"CreationDate":"2017-05-10T22:17:00.000","Title":"unit test runs with python but fails with nosetests","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have written a python file containing some unit tests (testfile.py). \nWhen I run 'python testfile.py' the tests run fine and there are no errors.\nBut when I run 'nosetests testfile.py', I get a TypeError of the form \nTypeError: func_name() takes exactly 3 arguments (1 given).\nCan you please help me understand what might be going on and how can I modify the python file so that it can be run using both python and nosetests.\nThanks in advance,\nAmbarish.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":590,"Q_Id":43903569,"Users Score":0,"Answer":"Yeah, you're getting hung on how discovery works differently on the different tools. It trips me up all the time. Go into the directory with your tests and do:\n$ nosetests testfile\n(no .py on the end of testfile)\nYou can also use the python unittest module:\n$ python -m unittest testfile","Q_Score":0,"Tags":"python,unit-testing,nose","A_Id":43903654,"CreationDate":"2017-05-10T22:17:00.000","Title":"unit test runs with python but fails with nosetests","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"On AWS, I created a new lambda function. I added a role to the lambda that has the policy, AWSLambdaVPCAccessExecutionRole. I placed the lambda in the same VPC as my EC2 instance and made sure the security group assigned to the lambda and EC2 instance have the same default VPC security group created by AWS which allows all traffic within the vpc. On my EC2 instance, I have a tomcat app running on port 8080. I tried to hit the URL by two methods in my lambda function:\n\nUsing my load balancer, which has the same assigned security group\nHitting the IP address of the EC2 box with port 8080\n\nBoth of these options do not work for the lambda function. I tried it on my local computer and it is fine.\nAny suggestions?\nSecurity Group for Inbound\n\nType = All Traffic\nProtocol = All\nPort Range = All\nSource = Group ID of Security Group","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1713,"Q_Id":43923482,"Users Score":0,"Answer":"has the security group 8080 port open to internet?\nTo connect Lambdas with VPC you can't use the default VPC, you have to create one with a nat gateway. \nEDIT: Only if the Lambda fucntion needs to access to internet and VPC.","Q_Score":0,"Tags":"python,amazon-web-services,tomcat,amazon-ec2,aws-lambda","A_Id":43923646,"CreationDate":"2017-05-11T18:51:00.000","Title":"AWS Lambda function can't communicate with EC2 Instance","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to run a python script on a remote server which i dont trust. The script contains a password that is kind of important.\nWhat would be a good way to protect that code\/password?\nI would give it as an argument or i could prompt input on the terminal but that would be saved in history.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2212,"Q_Id":43923747,"Users Score":0,"Answer":"Store password with code on untrustworthy server, that definitely unsafe. You have to change the way like below if you can. \n\non the server you control, encrypt password with pub_key\n\ngeneral the different pub_key\/private_key every request\n\nthe client you don't trust get id and encrypt_msg with auth\nthe password_required server get the id and private_key and decrypt encrypt_msg from client and compare the password.\ndelete the auth if the client is useless any more.","Q_Score":0,"Tags":"python,linux,encryption,console,passwords","A_Id":45161150,"CreationDate":"2017-05-11T19:06:00.000","Title":"Protect python code including a password, encrypt?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to pylint a project against unused imports to make upgrading a module easier (W0611).","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":736,"Q_Id":43928063,"Users Score":9,"Answer":"just figured it out from some trial and error, a little hard to figure out by reading the docs only:\npylint --disable=all --enable=W0611","Q_Score":7,"Tags":"python,pylint","A_Id":43928076,"CreationDate":"2017-05-12T01:46:00.000","Title":"Is it possible to pylint for a specific error code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a large python test file using unittest that I run from the command line. Some tests take a while to run. This is a mild pain point because I'm often only concerned with the last test I added. What I want is this: \n\nadd test. \nrun tests (one fails because I haven't written the code to make it pass)\nimplement the behaviour\nrun only the test that failed last time \nfix the silly error I made when implementing the code\nrun only the failing test, which passes this time\nrun all the tests to find out what I broke. \n\nIs it possible to do this from the command line?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1455,"Q_Id":43942997,"Users Score":0,"Answer":"Just run the test with --last-failed option (you might need pytest)","Q_Score":5,"Tags":"python,unit-testing,tdd","A_Id":56775200,"CreationDate":"2017-05-12T17:01:00.000","Title":"Python unittest, running only the tests that failed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Emacs 24 and elpy to run some Python 3 code. However, after I open a shell with C-U-C-C-C-Z and then run my code with C-U-C-C-C-C, I get the error in my command line: \n\nCannot open load file: no such file or directory, pylint\n\nThis is odd, as I've made no recent changes to Emacs, but it always tends to be finicky about if it wants to run any code. The python shell works fine, so that shouldn't be the issue. Thanks.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":277,"Q_Id":43956820,"Users Score":0,"Answer":"Refer to @Ehvince's comment. Make sure that pylint, is in fact, installed using the command line.","Q_Score":0,"Tags":"python,python-3.x,emacs","A_Id":43966958,"CreationDate":"2017-05-13T18:49:00.000","Title":"Emacs fails to run Python code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm using Emacs 24 and elpy to run some Python 3 code. However, after I open a shell with C-U-C-C-C-Z and then run my code with C-U-C-C-C-C, I get the error in my command line: \n\nCannot open load file: no such file or directory, pylint\n\nThis is odd, as I've made no recent changes to Emacs, but it always tends to be finicky about if it wants to run any code. The python shell works fine, so that shouldn't be the issue. Thanks.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":277,"Q_Id":43956820,"Users Score":1,"Answer":"Do you mean that it used to work ? To me this error means that the elisp pylint package was not installed or not \"required\". Try installing it with M-x package-install (and be sure to have the pypi pylint package installed in the current virtual env too, if you use one inside emacs -this is a current elpy installation shortcoming).\n(made an answer of my comment)","Q_Score":0,"Tags":"python,python-3.x,emacs","A_Id":43969466,"CreationDate":"2017-05-13T18:49:00.000","Title":"Emacs fails to run Python code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to understand the logic behind flink's slots and parallelism configurations in .yaml document.\nOfficial Flink Documentation states that for each core in your cpu, you have to allocate 1 slot and increase parallelism level by one simultaneously. \nBut i suppose that this is just a recommendation. If for a example i have a powerful core(e.g. the newest i7 with max GHz), it's different from having an old cpu with limited GHz. So running much more slots and parallelism than my system's cpu maxcores isn't irrational. \nBut is there any other way than just testing different configurations, to check my system's max capabilities with flink? \nJust for the record, im using Flink's Batch Python API.","AnswerCount":2,"Available Count":2,"Score":0.3799489623,"is_accepted":false,"ViewCount":1748,"Q_Id":43969594,"Users Score":4,"Answer":"There are several interesting points in your question.\n\nFirst, the slots in Flink are the processing capabilities that each taskmanager brings to the cluster, and they limit, first, the number of applications that can be executed on it, as well as the number of executable operators at the same time. Tentatively, a computer should not provide more processing power than CPU units present in it. Of course, this is true if all the tasks that run on it are computation intensive in CPU and low IO operations. If you have operators in your application highly blocking by IO operations there will be no problem in configuring more slots than CPU cores available in your taskmanager as @Till_Rohrmann said.\nOn the other hand, the default parallelism is the number of CPU cores available to your application in the Flink cluster, although it is something you can specify as a parameter manually when you run your application or specify it in your code. Note that a Flink cluster can run multiple applications simultaneously and it is not convenient that only one block entire cluster, unless it is the target, so, the default parallelism is usually less than the number of slots available in your Cluster (the sum of all slots contributed by your taskmanagers).\nHowever, an application with parallelism 4 means, tentatively, that if it contains an stream: input().Map().Reduce().Sink() there should be 4 instances of each operator, so, the sum of cores used by the application Is greater than 4. But, this is something that the developers of Flink should explain ;)","Q_Score":2,"Tags":"python,parallel-processing,apache-flink","A_Id":44073887,"CreationDate":"2017-05-14T23:05:00.000","Title":"Flink Slots\/Parallelism vs Max CPU capabilities","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to understand the logic behind flink's slots and parallelism configurations in .yaml document.\nOfficial Flink Documentation states that for each core in your cpu, you have to allocate 1 slot and increase parallelism level by one simultaneously. \nBut i suppose that this is just a recommendation. If for a example i have a powerful core(e.g. the newest i7 with max GHz), it's different from having an old cpu with limited GHz. So running much more slots and parallelism than my system's cpu maxcores isn't irrational. \nBut is there any other way than just testing different configurations, to check my system's max capabilities with flink? \nJust for the record, im using Flink's Batch Python API.","AnswerCount":2,"Available Count":2,"Score":0.4621171573,"is_accepted":false,"ViewCount":1748,"Q_Id":43969594,"Users Score":5,"Answer":"It is recommended to assign each slot at least one CPU core because each operator is executed by at least 1 thread. Given that you don't execute blocking calls in your operator and the bandwidth is high enough to feed the operators constantly with new data, 1 slot per CPU core should keep your CPU busy.\nIf on the other hand, your operators issue blocking calls (e.g. communicating with an external DB), it sometimes might make sense to configure more slots than you have cores.","Q_Score":2,"Tags":"python,parallel-processing,apache-flink","A_Id":43973809,"CreationDate":"2017-05-14T23:05:00.000","Title":"Flink Slots\/Parallelism vs Max CPU capabilities","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is the major difference in these test classes django.test.TestCase and rest_framework.test.APITestCase . which is Better to test my views.py ?\ncan you suggest me documentations to understand about these.\nThank you in advance. :-)","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1881,"Q_Id":43973305,"Users Score":1,"Answer":"APITestCase in rest_framework.test is to test the api's in the rest. It is specific for the api operations and api calls.\nDjango.test.TestCase is used to test the Django classes.","Q_Score":2,"Tags":"python-3.x,unit-testing,django-rest-framework,django-testing,web-api-testing","A_Id":43977762,"CreationDate":"2017-05-15T07:04:00.000","Title":"what is difference between `django.test.APITestCase` and `rest_framework.test.TestCase` in `python-django`","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"pycrypto is installed (when I run pip list one of the result is pycrypto (2.6.1))\nand it works but when I would like to use the MODE_CCM it returns: module 'Crypto.Cipher.AES' has no attribute 'MODE_CCM'\nMy Python version: Python 3.5.2 :: Anaconda 4.2.0 (x86_64)","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":14474,"Q_Id":43987779,"Users Score":3,"Answer":"By using python 3, i solved it by installing pycryptodome (pip3 install pycryptodome).\n No need to replace Crypto by Cryptodome","Q_Score":8,"Tags":"python,package,pycrypto","A_Id":62125607,"CreationDate":"2017-05-15T19:56:00.000","Title":"python: module 'Crypto.Cipher.AES' has no attribute 'MODE_CCM' even though pycrypto installed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"pycrypto is installed (when I run pip list one of the result is pycrypto (2.6.1))\nand it works but when I would like to use the MODE_CCM it returns: module 'Crypto.Cipher.AES' has no attribute 'MODE_CCM'\nMy Python version: Python 3.5.2 :: Anaconda 4.2.0 (x86_64)","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":14474,"Q_Id":43987779,"Users Score":1,"Answer":"You can use dir(AES) to see the list of supported MODE_xxx.","Q_Score":8,"Tags":"python,package,pycrypto","A_Id":54408843,"CreationDate":"2017-05-15T19:56:00.000","Title":"python: module 'Crypto.Cipher.AES' has no attribute 'MODE_CCM' even though pycrypto installed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Currently, I\u2019ve scheduled a python script on Linux by adding the following: *\/10 * * * * \/file\/testscripts\/test_script.py to crontab -e. \nIt did not run after 10 minutes, so I wrote some code to write the current time on there but wasn\u2019t being updated either. \nWhat could be the issue? And how can I determine my python script has been scheduled for a cron job properly? \nThank you in advance and will accept\/upvote answer","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":542,"Q_Id":43987799,"Users Score":-1,"Answer":"Try with 10 * * * * yourscript name.Then check if crontab -l is include your script. Then you can check crontab logs.","Q_Score":0,"Tags":"python,linux,automation,cron,crontab","A_Id":43987885,"CreationDate":"2017-05-15T19:58:00.000","Title":"Python + Linux: How to determine cron job is scheduled?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to make a site like Codeacademy. Where users can learn Python online,\nsolve problems and master theory.\nFramework for the server is Ruby On Rails\nI am trying to understand how can I translate python's code to the server, then execute this code on the server? Any python's interpreters created in Ruby? I totally can not understand how this should work.\nPython's version: 2.7 or 3.5 (Not fundamentally)\nThank you for attention","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":81,"Q_Id":44000085,"Users Score":0,"Answer":"As other have stated, there are serious security implications for letting users blindly run things on your server, but if you really wanted to, you could write the python to a file and then execute the python using system \"python #{file_path}\".\nI'm not too familiar with python, but you could probably switch stdout and stderr to write to files and then read those files to get any print statements.","Q_Score":0,"Tags":"python,ruby-on-rails,ruby","A_Id":44006799,"CreationDate":"2017-05-16T11:20:00.000","Title":"Python embedded in RubyOnRails","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am currently trying to load function from another .py file. I have in the same folder: algo.py and test_algo.py. I need to import all functions from algo in test_algo so I use the command:\nfrom algo import *\nThe import is succesful however one function do_sthg() takes 3 arguments in algo but the imported version requires 4 arguments which was the case in a very old version of the code. I deleted all .py~ related files and there are not any other scripts with the name algo on my computer. How is that possible and how can i solve this issue?\n(I can not specify the full links to my script as it should change over time, I am using 2.7 version of Python) \nAny help would be appreciated.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":875,"Q_Id":44005182,"Users Score":1,"Answer":"I have not been able to determine where the problem was so I just specificied the full path using the command getcwd from os. It has worked so far. It means I must have a hidden .pyc or .py~ file somewhere.","Q_Score":1,"Tags":"python","A_Id":44025088,"CreationDate":"2017-05-16T15:06:00.000","Title":"Old version of a script is imported using import on Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently in the process of hacking together a bit of bash and python3 to integrate my Minecraft server with my friends Discord. I managed to power through most of the planned features with nary a hitch, however now I've gotten myself stuck halfway into the chat integration. I can send messages from the Discord to the server no problem, but I have no idea how to read the console output of the server instance, which is running in a screen session.\nI would appreciate some pointers in the right direction, if you know how this sort of thing is done. Ideally I would like a solution that is capable of running asynchronously, so I don't have to do a whole lot of busy-waiting to check for messages.\nP.S.: Sorry if this belongs on superuser instead, I wasn't sure where to put it.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":254,"Q_Id":44010155,"Users Score":1,"Answer":"Well, the ideal solution would be to write a bukkit plugin\/forge mod to do this, rather than doing this entirely from outside the actual server. That being said, however, your best bet is probably watching the log files, as JNevill says in the comment.","Q_Score":1,"Tags":"linux,bash,python-3.x,minecraft,gnu-screen","A_Id":44896034,"CreationDate":"2017-05-16T19:37:00.000","Title":"How do I grab console output from a program running in a screen session?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to make a program in c++, but i cant make the program because in one part of the code I need to run a python program from c++ and I dont know how to do it. I've been trying many ways of doing it but none of them worked. So the code should look sometihnglike this:somethingtoruntheprogram(\"pytestx.py\"); or something close to that. Id prefer doing it without python.h. I just need to execute this program, I need to run the program because I have redirected output and input from the python program with sys.stdout and sys.stdin to text files and then I need to take data from those text files and compare them. I am using windows.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":362,"Q_Id":44023863,"Users Score":0,"Answer":"There's POSIX popen and on Windows _popen, which is halfway between exec and system. It offers the required control over stdin and stdout, which system does not. But on the other hand, it's not as complicated as the exec family of functions.","Q_Score":0,"Tags":"python,c++,python-3.x,c++11","A_Id":44025218,"CreationDate":"2017-05-17T11:41:00.000","Title":"How to run a python program from c++","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I was trying to execute an appium test suite i have created, which consists of multiple test files within the suite.\nCan anyone please help, i'm unable to execute the second test script after the execution of first script. It restarts the app and starts afresh. I need to start from where it left off in the first script.\nI've tried session-override flag, also tried launch_app().","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1731,"Q_Id":44027154,"Users Score":1,"Answer":"If you use the full reset option as false in desired capabilities, then the app won't be started fresh every time. I used the following in my desired capabilities.\ncapabilities.setCapability(\"fullReset\", false); \nIf you are using appium 1.5.3 GUI, check the box against No reset in iOS\/Android settings.","Q_Score":0,"Tags":"testing,automation,automated-tests,appium,python-appium","A_Id":44125346,"CreationDate":"2017-05-17T14:04:00.000","Title":"How to execute multiple appium test scripts one after the other?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was trying to execute an appium test suite i have created, which consists of multiple test files within the suite.\nCan anyone please help, i'm unable to execute the second test script after the execution of first script. It restarts the app and starts afresh. I need to start from where it left off in the first script.\nI've tried session-override flag, also tried launch_app().","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1731,"Q_Id":44027154,"Users Score":1,"Answer":"You need to add the above capability in the main method where you have mentioned the other capabilities such as device name, app path, .. so that the main method will install the app in your device first and start execute the first test method freshly followed by the other test methods in the suite without reset.I am using this in my automation both in iOS and Android. Uninstall the app if you have already before running the test in the test device.","Q_Score":0,"Tags":"testing,automation,automated-tests,appium,python-appium","A_Id":44171420,"CreationDate":"2017-05-17T14:04:00.000","Title":"How to execute multiple appium test scripts one after the other?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was having some SSL connectivity issues while connecting to a secured URL, Later I fixed this problem by providing .pem file path for verifying. ie, verify=\"file\/path.pem\" \nMy doubt is should this file be stored in a common place on the server or should this file be part of the project source code and hence version control.\nPlease advise.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":513,"Q_Id":44037702,"Users Score":4,"Answer":"In most cases a .pem file contains sensitive information and is environment specific, it should not be part of the project source code. It should be available in a secured server and downloadable with appropriate authorization.","Q_Score":0,"Tags":"python,version-control,pem","A_Id":44037794,"CreationDate":"2017-05-18T02:39:00.000","Title":"Python: Should I version control .pem files?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am building a python 3.6 AWS Lambda deploy package and was facing an issue with SQLite. \nIn my code I am using nltk which has a import sqlite3 in one of the files.\nSteps taken till now:\n\nDeployment package has only python modules that I am using in the root. I get the error:\nUnable to import module 'my_program': No module named '_sqlite3'\nAdded the _sqlite3.so from \/home\/my_username\/anaconda2\/envs\/py3k\/lib\/python3.6\/lib-dynload\/_sqlite3.so into package root. Then my error changed to:\nUnable to import module 'my_program': dynamic module does not define module export function (PyInit__sqlite3)\nAdded the SQLite precompiled binaries from sqlite.org to the root of my package but I still get the error as point #2.\n\nMy setup: Ubuntu 16.04, python3 virtual env\nAWS lambda env: python3\nHow can I fix this problem?","AnswerCount":8,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":7936,"Q_Id":44058239,"Users Score":6,"Answer":"This isn't a solution, but I have an explanation why.\nPython 3 has support for sqlite in the standard library (stable to the point of pip knowing and not allowing installation of pysqlite). However, this library requires the sqlite developer tools (C libs) to be on the machine at runtime. Amazon's linux AMI does not have these installed by default, which is what AWS Lambda runs on (naked ami instances). I'm not sure if this means that sqlite support isn't installed or just won't work until the libraries are added, though, because I tested things in the wrong order.\nPython 2 does not support sqlite in the standard library, you have to use a third party lib like pysqlite to get that support. This means that the binaries can be built more easily without depending on the machine state or path variables. \nMy suggestion, which you've already done I see, is to just run that function in python 2.7 if you can (and make your unit testing just that much harder :\/).\nBecause of the limitations (it being something baked into python's base libs in 3) it is more difficult to create a lambda-friendly deployment package. The only thing I can suggest is to either petition AWS to add that support to lambda or (if you can get away without actually using the sqlite pieces in nltk) copying anaconda by putting blank libraries that have the proper methods and attributes but don't actually do anything.\nIf you're curious about the latter, check out any of the fake\/_sqlite3 files in an anaconda install. The idea is only to avoid import errors.","Q_Score":23,"Tags":"python-3.x,amazon-web-services,sqlite,aws-lambda","A_Id":44076628,"CreationDate":"2017-05-18T21:43:00.000","Title":"sqlite3 error on AWS lambda with Python 3","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am building a python 3.6 AWS Lambda deploy package and was facing an issue with SQLite. \nIn my code I am using nltk which has a import sqlite3 in one of the files.\nSteps taken till now:\n\nDeployment package has only python modules that I am using in the root. I get the error:\nUnable to import module 'my_program': No module named '_sqlite3'\nAdded the _sqlite3.so from \/home\/my_username\/anaconda2\/envs\/py3k\/lib\/python3.6\/lib-dynload\/_sqlite3.so into package root. Then my error changed to:\nUnable to import module 'my_program': dynamic module does not define module export function (PyInit__sqlite3)\nAdded the SQLite precompiled binaries from sqlite.org to the root of my package but I still get the error as point #2.\n\nMy setup: Ubuntu 16.04, python3 virtual env\nAWS lambda env: python3\nHow can I fix this problem?","AnswerCount":8,"Available Count":2,"Score":0.024994793,"is_accepted":false,"ViewCount":7936,"Q_Id":44058239,"Users Score":1,"Answer":"My solution may or may not apply to you (as it depends on Python 3.5), but hopefully it may shed some light for similar issue.\nsqlite3 comes with standard library, but is not built with the python3.6 that AWS use, with the reason explained by apathyman and other answers.\nThe quick hack is to include the share object .so into your lambda package:\nfind ~ -name _sqlite3.so\nIn my case:\n\/home\/user\/anaconda3\/pkgs\/python-3.5.2-0\/lib\/python3.5\/lib-dynload\/_sqlite3.so\nHowever, that is not totally sufficient. You will get: \nImportError: libpython3.5m.so.1.0: cannot open shared object file: No such file or directory\nBecause the _sqlite3.so is built with python3.5, it also requires python3.5 share object. You will also need that in your package deployment:\nfind ~ -name libpython3.5m.so*\nIn my case:\n\/home\/user\/anaconda3\/pkgs\/python-3.5.2-0\/lib\/libpython3.5m.so.1.0\nThis solution is likely not work if you are using _sqlite3.so that is built with python3.6, because the libpython3.6 built by AWS will likely not support this. However, this is just my educational guess. If anyone has successfully done, please let me know.","Q_Score":23,"Tags":"python-3.x,amazon-web-services,sqlite,aws-lambda","A_Id":49342276,"CreationDate":"2017-05-18T21:43:00.000","Title":"sqlite3 error on AWS lambda with Python 3","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a large binary file (~4 GB) containing a series of image and time stamp data. I want to find the image that most closely corresponds to a user-given time stamp. There are millions of time stamps in the file, though. In Python 2.7, using seek, read, struct.unpack, it took over 900 seconds just to read all the time stamps into an array. Is there an efficient algorithm for finding the closest value that doesn't require reading all of the values? They monotonically increase, though at very irregular intervals.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":40,"Q_Id":44075041,"Users Score":0,"Answer":"First attempt. It works, seemingly every time, but I don't know if it's the most efficient way:\n\nTake first and last time stamps and number of frames to calculate an average time step.\nUse average time step and difference between target and beginning timestamps to find approximate index.\nCheck for approximate and 2 surrounding timestamps against target.\nIf target falls between, then take index with minimum difference.\n If not, set approximate index as new beginning or end, accordingly, and repeat.","Q_Score":0,"Tags":"python","A_Id":44166939,"CreationDate":"2017-05-19T16:39:00.000","Title":"Finding closest value in a binary file","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Key points:\n\nI need to send roughly ~100 float numbers every 1-30 seconds from one machine to another.\nThe first machine is catching those values through sensors connected to it.\nThe second machine is listening for them, passing them to an http server (nginx), a telegram bot and another program sending emails with alerts.\n\nHow would you do this and why?\nPlease be accurate. It's the first time I work with sockets and with python, but I'm confident I can do this. Just give me crucial details, lighten me up!\nSome small portion (a few rows) of the core would be appreciated if you think it's a delicate part, but the main goal of my question is to see the big picture.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":274,"Q_Id":44115291,"Users Score":2,"Answer":"Main thing here is to decide on a connection design and to choose protocol. I.e. will you have a persistent connection to your server or connect each time when new data is ready to it.\nThen will you use HTTP POST or Web Sockets or ordinary sockets. Will you rely exclusively on nginx or your data catcher will be another serving service.\nThis would be a most secure way, if other people will be connecting to nginx to view sites etc.\nWrite or use another server to run on another port. For example, another nginx process just for that. Then use SSL (i.e. HTTPS) with basic authentication to prevent anyone else from abusing the connection.\nThen on client side, make a packet every x seconds of all data (pickle.dumps() or json or something), then connect to your port with your credentials and pass the packet.\nPython script may wait for it there.\nOr you write a socket server from scratch in Python (not extra hard) to wait for your packets.\nThe caveat here is that you have to implement your protocol and security. But you gain some other benefits. Much more easier to maintain persistent connection if you desire or need to. I don't think it is necessary though and it can become bulky to code break recovery.\nNo, just wait on some port for a connection. Client must clearly identify itself (else you instantly drop the connection), it must prove that it talks your protocol and then send the data.\nUse SSL sockets to do it so that you don't have to implement encryption yourself to preserve authentication data. You may even rely only upon in advance built keys for security and then pass only data.\nDo not worry about the speed. Sockets are handled by OS and if you are on Unix-like system you may connect as many times you want in as little time interval you need. Nothing short of DoS attack won't inpact it much.\nIf on Windows, better use some finished server because Windows sometimes do not release a socket on time so you will be forced to wait or do some hackery to avoid this unfortunate behaviour (non blocking sockets and reuse addr and then some flo control will be needed).\nAs far as your data is small you don't have to worry much about the server protocol. I would use HTTPS myself, but I would write myown light-weight server in Python or modify and run one of examples from internet. That's me though.","Q_Score":0,"Tags":"python,python-2.7,python-3.x","A_Id":44116325,"CreationDate":"2017-05-22T14:19:00.000","Title":"Efficient way to send results every 1-30 seconds from one machine to another","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a module that I use to hold specific testcase classes. I would like to implement an easy way to run them all or one by one.\nI did notice that if I run pytest passing the whole module, all the test will run; but I would like also to pass one single testcase, if I want to.\nIs this possible or do I need one module per testcase class?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":74,"Q_Id":44142810,"Users Score":0,"Answer":"Thanks to Chanda for giving me a solution.\ntest markers are very useful! Also another way to run a specific test class is to have the -k option, which will run only a specific testcase class in a module, skipping the others","Q_Score":0,"Tags":"python,pytest","A_Id":44164747,"CreationDate":"2017-05-23T18:49:00.000","Title":"multiple testcase classes in the same module, how to run them as whole or single test with pytest","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python script: \/usr\/bin\/doxypy.py\nI have added #!\/usr\/local\/bin\/python as first line and given full permission to script with chmod 777 \/usr\/bin\/doxypy.py.\nIf I want to run it as a linux command, let's say, I want to run it with only doxypy, is there any way to achieve this?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1422,"Q_Id":44167842,"Users Score":2,"Answer":"Yes, rename it to \/usr\/bin\/doxypy","Q_Score":2,"Tags":"python,python-2.7","A_Id":44167881,"CreationDate":"2017-05-24T20:24:00.000","Title":"How can I run python script as linux command","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a python script: \/usr\/bin\/doxypy.py\nI have added #!\/usr\/local\/bin\/python as first line and given full permission to script with chmod 777 \/usr\/bin\/doxypy.py.\nIf I want to run it as a linux command, let's say, I want to run it with only doxypy, is there any way to achieve this?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":1422,"Q_Id":44167842,"Users Score":1,"Answer":"Rename the file to doxpy and put it in a folder of $PATH, e.g. \/usr\/bin","Q_Score":2,"Tags":"python,python-2.7","A_Id":44167906,"CreationDate":"2017-05-24T20:24:00.000","Title":"How can I run python script as linux command","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Is it possible to only install part of a python package such as scipy to reduce the total size. The latest version (0.19.0) appears to be using 174MB, I'm only using it for its spectrogram feature. I'm putting this on AWS Lambda and I'm over the 512MB storage limit.\nI realize there are other options I could take, e.g. using another spectrogram implementation, manually removing scipy files, etc. I'm wondering if there is any automated way to do this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":68,"Q_Id":44168336,"Users Score":1,"Answer":"There is no supported way of doing it. You may try removing manually some parts which you do not use. However, you're on your own if you go down this route.","Q_Score":0,"Tags":"python,scipy,aws-lambda","A_Id":44195826,"CreationDate":"2017-05-24T20:57:00.000","Title":"modular scipy install to fit on space constrained environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to spawn a mapreduce job using the mrjob library from AWS Lambda. The job takes longer than the 5 minute Lambda time limit, so I want to execute a remote job. Using the paramiko package, I ssh'd onto the server and ran a nohup command to spawn a background job, but this still waits until the end of job. Is there anyway to do this with Lambda?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":441,"Q_Id":44184942,"Users Score":0,"Answer":"Instead of using SSH I've solved this before by pushing a message onto a SQS queue that a process on the server monitors. This is much simpler to implement and avoids needing to keep credentials in the lambda function or place it in a VPC.","Q_Score":0,"Tags":"python,amazon-web-services,aws-lambda,paramiko,mrjob","A_Id":44213779,"CreationDate":"2017-05-25T16:02:00.000","Title":"How to execute a job on a server on Lambda without waiting for the response?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to automate some stuff I would otherwise have to do manually, so I can run one python script instead of taking a whole bunch of steps. I want to find a way to run a Talend job from the python script.\nHow do I accomplish this? Is it even possible?","AnswerCount":2,"Available Count":2,"Score":-0.0996679946,"is_accepted":false,"ViewCount":1683,"Q_Id":44209681,"Users Score":-1,"Answer":"As soon as you can run a Python script from command line, you should be able to run it from Talend using tSystem component.","Q_Score":0,"Tags":"python,automation,talend","A_Id":44209855,"CreationDate":"2017-05-26T20:27:00.000","Title":"Running Talend jobs with Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to automate some stuff I would otherwise have to do manually, so I can run one python script instead of taking a whole bunch of steps. I want to find a way to run a Talend job from the python script.\nHow do I accomplish this? Is it even possible?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1683,"Q_Id":44209681,"Users Score":2,"Answer":"Oops! sorry. \nFrom the Studio, build the job to get an autonomous job you can launch from command line.\nExtract the files from the generated archive.\nSearch for folder \"script\/yourJobname\".\nCheck the syntax from one of the .bat or .sh depending of which one you prefer.\nLaunch the jar file using subprocess.call (or other way to execute a jar file from Python).\nHope this helps.TRF","Q_Score":0,"Tags":"python,automation,talend","A_Id":44209956,"CreationDate":"2017-05-26T20:27:00.000","Title":"Running Talend jobs with Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Yesterday, I installed an apche web server and phpmyadmin on my raspberry-py. How can I connect my raspberry-pi to databases in phpmyadmin with python? Can I use MySQL? Thank, I hope you understand my question and sorry for my bad english.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":110,"Q_Id":44215404,"Users Score":0,"Answer":"Your question is quite unclear. But from my understanding, here is what you should try doing: (Note: I am assuming you want to connect your Pi to a database to collect data and store in an IoT based application)\n\nGet a server. Any Basic server would do. I recommend DigitalOcean or AWS LightSail. They have usable servers for just $5 per month. I recommend Ubuntu 16.04 for ease of use.\nSSH into the server with your terminal with the IP address you got when you created the server\nInstall Apache, MySQL, Python, PHPMyAdmin on the server. \nWrite your web application in any language\/framework you want. \nDeploy it and write a separate program to make HTTP calls to the said web server. \n\nMySQL is the Database server. Python is the language that is used to execute any instructions. PHPMyAdmin is the interface to view MySQL Databases and Tables. Apache is the webserver that serves the application you have written to deal with requests.\nI strongly recommend understanding the basics of Client-Server model of computing over HTTP. \nAlternatively, you could also use the approach of Using a DataBase-as-a-service from any popular cloud service provider(Eg., AWS RDS), to make calls directly into the DB.","Q_Score":0,"Tags":"python,mysql,apache,raspberry-pi","A_Id":44215522,"CreationDate":"2017-05-27T09:52:00.000","Title":"connect my raspbery-pi to MySQL","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know, that's a long title. However any shorter title would be a duplicate of the tons of other questions of this kind here on StackOverflow.\nI am searching for a scripting language I could embed into my Android application. The user would write a script. Later on I trigger a specific function of this script and process its returned result. The triggering and processing should run without any console - like - gui just in the background while the user is viewing a beautiful android activity. This is what I would like to achieve. However I did not find a language for Android that suits my needs. It should be:\n\nEasy (like Python, etc.)\nProvide direct access to popular android\/java methods (like sl4a does with the Android() module)\nlightweight (as far as possible)\nThere must be a way to call the script (or if not possible, a function defined in the script) and get the returned value from Java\nwould be good, if the language had a good documentation\n\nI found no language, which suits all my needs.\nI found:\n\ndeelang - no built-in access to popular Android SDK methods and bad documentation\nsl4a - I found no way to embed it directly into my app. I cant let the user download the sl4a app. I don't know whether I can get the result of a script and pass paramaters to it.\nandroid-python27 - bad documentation, same as sl4a\nrhino - does not provide built-ins to access popular Android SDK methods\nandrolua - bad documentation, I don't know whether it provides built-in access to the Android SDK\n\nIs there really no language available that suits my needs? Wouldn't we need a language like it which is easy to embed?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":511,"Q_Id":44230567,"Users Score":1,"Answer":"I finally found a project which fits to my needs: BeanShell (beanshell.org) .\nIt is Java-like but more easy. It has direct access to Java libraries and sharing variables between the host app and the script is very easy. It is lightweight. It is quiet popular and has a good documentation (even for android purposes)","Q_Score":1,"Tags":"android,python,scripting,embed","A_Id":44276418,"CreationDate":"2017-05-28T18:22:00.000","Title":"Embeddable Easy Lightweight Scripting Language with direct bindings to java for Android","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Im on Level 2, part 2: (Level 2, 50%)\nAfter I submitted challenge (java) I got nothing - the time stops and status doesn't update.\nLogout\/Clear cash - doesn't work, all looks like I need request the new challenge but I did it twice! And it doesn't work at all!\nI posted bug though Feedback command from foo.bar but who knows where it goes. \nWho knows where I can find foo.bar bug tracker? To understand what is going on.\nAlso I will appreciate any help and advice.\nThanks!\ngoogle-chrome, macos, foobar version 53-17-g6bfce4dd-beta (2017-03-21-22:12+0000)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":405,"Q_Id":44252108,"Users Score":0,"Answer":"After 2 weeks of waiting for any messages from support or new build I have decided to request a new challenge (3rd one) and vuala - the system accepted my solution and promoted me to the 3rd level.","Q_Score":1,"Tags":"java,python,google-chrome","A_Id":44575770,"CreationDate":"2017-05-30T01:25:00.000","Title":"Google Foobar Bug chahallenge resets after submit","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Hi, I declared variables in config and iam using in below test case. the variables are not passing. iam not able to figure out the actual issue.\n\nconfig:\n\n\nvariable_binds: {'user_id': 'ravitej', 'pass': 'password', 'auth': 'plain'}\n\ntest:\n\n\nname:\"login success\"\nurl: \"\/api\/login\"\nmethod: \"POST\"\nbody: '{\"username\": \"$user_id\", \"password\": \"$pass\", \"authtype\": \"$auth\"}'\nheaders: {Content-Type: application\/json}\nexpected_status: [200]\ngroup: \"User\"\n\n\nIn this below case: I'm running 1st test set and I'm getting some auth_token in response this auth_token is saved to auth_key to use in another test set, but this auth_key is not passing to the 2nd test set. it was passing an empty variable. I tried all possible ways wich are posted in Github still I am getting the same problem\n\ntest:\n\nname: \"Registration\"\nurl: \"\/api\/register\"\nmethod: \"POST\"\nbody: '{\"device_id\": \"0080\", \"device_key\": \"imAck\", \"device_name\": \"teja\", \"device_description\": \"Added By Ravi\", \"project_tag\": \"MYSTQ-16\", \"attributes\": \"{}\"}'\nheaders: {Content-Type: application\/json}\nexpected_status: [200]\ngroup: \"Register\"\nextract_binds:\n - 'auth_key': {'jsonpath_mini': 'auth_token'}\n\ntest:\n\nname: \"Status\"\nurl: \"\/api\/status\"\nmethod: \"POST\"\nbody: '{\"attributes\": {\"num_ports\": \"2\", \"model\": \"Phillips\", \"firmware_ver\": \"8.0.1\", \"ipaddress\": \"192.168.0.0\", \"rssi\": \"Not Available\"}}'\nheaders: {Content-Type: application\/json, auth_token: \"$auth_key\"}\nexpected_status: [200]\ngroup: \"Status\"","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":202,"Q_Id":44260604,"Users Score":0,"Answer":"need to use template headers, like\nheaders: {template: {Content-Type: application\/json, auth_token: \"$auth_key\"}}\nExample: \nheaders: {template: {'$headername': '$headervalue', '$cache': '$cachevalue'}}\nits worked fine now","Q_Score":1,"Tags":"python,rest,pyresttest","A_Id":44262032,"CreationDate":"2017-05-30T11:09:00.000","Title":"Variables are not passing from one test set to another?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm working on a project and I just wanted to know what route (If I'm not going down the correct route) I should go down in order to successfully complete this project. \nFerry Time: This application uses boat coordinates and ETA algorithms to determine when a boat will be approaching a certain destination.\nNow, I've worked up a prototype that works, but not the way I want it to. In order for my ETA's to show up on my website accurately, I have a python script that runs every minute to webscrape these coordinates from a specific site, do an algorithm, and spit out an ETA. The ETA is then sent to my database, where I display it on my website using PHP and SQL. \nThe ETA's only update as long as this script is running (I literally run the script on Eclipse and just leave it there)\nNow my question: Is there a way I can avoid running the script? Almost like an API. Or to not use a database at all?\nThanks !","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":71,"Q_Id":44270585,"Users Score":1,"Answer":"If the result of your algorithm only depends on the LAST scrape and not a history of several scrapes, then you could just scrape \"on demand\" and deploy your algo as an AWS lambda function.","Q_Score":0,"Tags":"php,python,api,server","A_Id":44271429,"CreationDate":"2017-05-30T19:38:00.000","Title":"Project using Python Webscraping","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm working on a project and I just wanted to know what route (If I'm not going down the correct route) I should go down in order to successfully complete this project. \nFerry Time: This application uses boat coordinates and ETA algorithms to determine when a boat will be approaching a certain destination.\nNow, I've worked up a prototype that works, but not the way I want it to. In order for my ETA's to show up on my website accurately, I have a python script that runs every minute to webscrape these coordinates from a specific site, do an algorithm, and spit out an ETA. The ETA is then sent to my database, where I display it on my website using PHP and SQL. \nThe ETA's only update as long as this script is running (I literally run the script on Eclipse and just leave it there)\nNow my question: Is there a way I can avoid running the script? Almost like an API. Or to not use a database at all?\nThanks !","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":71,"Q_Id":44270585,"Users Score":0,"Answer":"Even if they had an API you'd still need to run something against it to get the results. If you don't want to leave your IDE open you could use cron to call your script.","Q_Score":0,"Tags":"php,python,api,server","A_Id":44270817,"CreationDate":"2017-05-30T19:38:00.000","Title":"Project using Python Webscraping","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"i'm using a python client that makes request to a push server, and has the option to use certificates with the lib OpenSSL for python(pyopenssl), but this client ask me for the private key(can be on the same file or different path. already checked with another server that i have both cert and key). but for the \"real\" server they are using self-signed cert and they don't have any private key in the same file or another one as far as they told me, they just share with me this cert file, is there any way to use this kind of cert with OpeenSSL in python?, thanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":95,"Q_Id":44293780,"Users Score":0,"Answer":"In order to use a client certificate, you must have a private key. You will either sign some quantity with your private key or engage in encrypted key agreement in order to mutually agree on a key. Either way, the private key is required.\nIt's possible though that rather than using client certificates they use something like username\/password and what they have given you is not a certificate for you to use, but the certificate you should expect from them.","Q_Score":0,"Tags":"python,ssl,pyopenssl","A_Id":44293925,"CreationDate":"2017-05-31T20:05:00.000","Title":"OpenSSL ask for private key","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I don't have a lot of experience coding so I'm sorry if this has been answered before; I couldn't find anything that helped.\nI just completed a project on a Raspberry Pi that runs some RGB LED strips via PWM. I have a program that runs the lights and works fine with a few different modes (rainbow shifting, strobe, solid color) but with each new mode I add the program get longer and more convoluted. I would like to have each separate mode be its own script that gets started or stopped by a sort of master script. That way I could easily add a new mode by simply writing a separate program and adding it to the list on the master script instead of mucking around inside a giant program with everything in it and hoping I don't break something. I guess what I want is a simple way to start a python script with some specific setting (Determined by variables passed from the master script) and be able to kill that script when the master script receives the command to change modes.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":576,"Q_Id":44318030,"Users Score":0,"Answer":"Keeping your code modulable is indeed a good practice ! If your code is not Objet oriented, the best way is to create another python file (let's call it util.py) in the same directory as your \"main\". You can simply include util.py with the following command at the beginning of your main code : \n import util\nAnd then when you want to use a function that you've defined in your util.py file, juste use :\n util.myFunction(param1, param2,...)","Q_Score":0,"Tags":"python,raspberry-pi,led","A_Id":44318102,"CreationDate":"2017-06-01T22:24:00.000","Title":"How to start and stop scripts using another script?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know that I can import a python module by using their file path, but is there a way to import a file relative to the current file's position?\nFor example, it seems like I can \"import file\" only if the script is in the same folder as the one I am working with. How can I import the file if it's in the folder outside of mine, or one below the hierarchy, without giving the full file path? I would like it so that I can move the project folder around and still have everything work.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":446,"Q_Id":44318239,"Users Score":0,"Answer":"I'm afraid that is impossible to import single python files using their paths.\nIn python you have to deal with modules. The finest solution would be to create a module from your outside-folder script and put in your system modules path.","Q_Score":1,"Tags":"python-3.x,python-module","A_Id":44318361,"CreationDate":"2017-06-01T22:47:00.000","Title":"Importing modules in the same project folder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have 3 devices connected to my computer and I want to run pytest in parallel on each of them.\nI there any way to do it, either with pytest or with adb?\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":264,"Q_Id":44343975,"Users Score":0,"Answer":"I think you have to use Selenium Grid for runs on multiple devices.","Q_Score":1,"Tags":"python,parallel-processing,automated-tests,adb,pytest","A_Id":70539100,"CreationDate":"2017-06-03T12:34:00.000","Title":"Running Pytest on Multiple Devices in Parallel","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to create a ChatBot where using Python I interact with Telegram API to get update of previous message and reply suitably. My user's message could be a password which cannot be displayed and need to converted into dots(*****). Is there such feature to convert PW to dots ? Any help would be appreciated.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":956,"Q_Id":44368332,"Users Score":1,"Answer":"Telegram doesn't support this at this time, but you can try to use inline keyboard contain 0-9 number instead of it.","Q_Score":1,"Tags":"telegram,telegram-bot,python-telegram-bot","A_Id":44371412,"CreationDate":"2017-06-05T11:51:00.000","Title":"Telegram API - Password to Dots","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am attempting to read a RS232\/USB input from a Gcode script. Is it possible to perform this from GCode or am I going to have to wrap it in python or something?\nFor reference, my algorithm is essentially:\n-Perform some CNC movements\n-Read\/store\/record variable from RS232 peripheral\n-Repeat a bunch of times in marginally different ways","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":263,"Q_Id":44370165,"Users Score":2,"Answer":"Gcode per se doesn't support reading anything from any peripheral. Gcode is nothing more than a line-oriented textual machine command format, and is typically fed from a storage medium or file into an interpreter. This interpreter determines the axes movements, usually incorporating some trajectory planner. Then the interpreter emits signals to a peripheral device (LPT port, special card, etc.) that are fed to motor controllers. So without more details, based on your question, I think you're going to need something else to handle any serial connection. If you could clarify or add more details a solution may become apparent.","Q_Score":0,"Tags":"python-3.x,serial-port,cnc","A_Id":44370436,"CreationDate":"2017-06-05T13:31:00.000","Title":"GCode and RS232","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to manage problems from Scipy. So does Scipy provide techniques to import and export model files?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":95,"Q_Id":44370237,"Users Score":0,"Answer":"No as Sascha mentioned in the comment. Use other alternatives such as cvxpy\/cvxopt.","Q_Score":0,"Tags":"python,import,scipy,export,linear-programming","A_Id":44379161,"CreationDate":"2017-06-05T13:35:00.000","Title":"Does Scipy have techniques to import&export optimisation model files such as LP?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running a large unit test repository for a complex project.\nThis project has some things that don't play well with large test amounts:\n\ncaches (memoization) that cause objects not to be freed between tests\ncomplex objects at module level that are singletons and might gather data when being used\n\nI am interested in each test (or at least each test suite) having its own \"python-object-pool\" and being able to free it after.\nSort of a python-garbage-collector-problem workaround.\nI imagine a python self-contained temporary and discardable interpreter that can run certain code for me and after i can call \"interpreter.free()\" and be assured it doesn't leak.\nOne tough solution for this I found is to use Nose or implement this via subprocess for each time I need an expendable interpreter that will run a test. So each test becomes \"fork_and_run(conditions)\" and leaks no memory in the original process.\nAlso saw Nose single process per each test and run the tests sequantially - though people mentioned it sometimes freezes midway - less fun..\nIs there a simpler solution?\nP.S.\nI am not interested in going through vast amounts of other peoples code and trying to make all their caches\/objects\/projects be perfectly memory-managed objects that can be cleaned.\nP.P.S\nOur PROD code also creates a new process for each job, which is very comfortable since we don't have to mess around with \"surviving forever\" and other scary stories.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":128,"Q_Id":44391885,"Users Score":0,"Answer":"TL;DR\nModule reload trick I tried worked locally, broke when used on a machine with a different python version... (?!)\nI ended up taking any and all caches I wrote in code and adding them to a global cache list - then clearing them between tests.\nSadly this will break if anyone uses a cache\/manual cache mechanism and misses this, tests will start growing in memory again...\nFor starters I wrote a loop that goes over sys.modules dict and reloads (loops twice) all modules of my code. this worked amazingly - all references were freed properly, but it seems it cannot be used in production\/serious code for multiple reasons:\n\nold python versions break when reloading and classes that inherit meta-classes are redefined (I still don't get how this breaks).\nunit tests survive the reload and sometimes have bad instances to old classes - especially if the class uses another classes instance. Think super(class_name, self) where self is the previously defined class, and now class_name is the redefined-same-name-class.","Q_Score":0,"Tags":"python,unit-testing,memory-management,garbage-collection,virtualization","A_Id":44571401,"CreationDate":"2017-06-06T13:50:00.000","Title":"Temporary object-pool for unit tests?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a quick question in regards to the Netmiko module (based on the Paramiko module). \nI have a for loop that iterates through a bunch of Cisco boxes (around 40)...and once they complete I get the following each time a SSH connection establishes:\nSSH connection established to ip address:22\nInteractive SSH session established\nThis isn't in my print statements or anything, it's obviously hard coded within ConnectionHandler (which I use to make the SSH connections). \nThis output really makes my output muddled and full of 40 extra lines I do not need. Is there any way I can get these removed from the output?\nRegards,","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":384,"Q_Id":44399531,"Users Score":0,"Answer":"Found this answer out through reddit. \nAdd the key 'verbose': False to your network device dictionary. More information on the Netmiko Standard Tutorial page","Q_Score":0,"Tags":"python-3.x,ssh","A_Id":44401977,"CreationDate":"2017-06-06T20:45:00.000","Title":"Remove Netmiko Automatic Output","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using a python script to access to cisco switch using SSH or telnet .. I'm using module pexpect .. the connection done. My problem that, when I want to show all the configuration using \n\ntelconn.sendline(\"sh run \" + \"\\r\")\n\nI can't see all the configuration cuz I face a problem with --more--. So how I can avoid this and what I can do to see all the configuration","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":94,"Q_Id":44409185,"Users Score":1,"Answer":"You need to send terminal length 0 command first. That will disable pagination that is enabled on the router by default.","Q_Score":0,"Tags":"python-2.7,cisco,cisco-ios","A_Id":44484886,"CreationDate":"2017-06-07T09:49:00.000","Title":"Remote access using python 2.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"C++ part\nI have a class a with a public variable 2d int array b that I want to print out in python.(The way I want to access it is a.b)\nI have been able to wrap the most part of the code and I can call most of the functions in class a in python now.\nSo how can I read b in python? How to read it into an numpy array with numpy.i(I find some solution on how to work with a function not variable)? Is there a way I can read any array in the c++ library? Or I have to deal with each of the variables in the interface file.\nfor now b is when I try to use it in python\nps:\n1. If possible I don't want to modify the cpp part.\n\nI'm trying to access a variable, not a function. \n\nSo don't refer me to links that doesn't really answer my question, thanks.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":569,"Q_Id":44424308,"Users Score":0,"Answer":"You'll find that passing things back and forth between languages is much easier if you use a one-dimensional array in which you access elements using, e.g. arr[y*WIDTH+x].\nSince you are operating in C++ you can even wrap these arrays in classes with nice operator()(int x, int y) methods for use on the C++ side.\nIn fact, this is the internal representation which Numpy uses for arrays: they are all one-dimensional.","Q_Score":0,"Tags":"python,c++,arrays,numpy,swig","A_Id":44424756,"CreationDate":"2017-06-07T23:26:00.000","Title":"Reading c++ 2d array in python swig","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm doing a school project to read the temperature through the sensor mlx90615.\nIn my code an error appears:\nTraceback (most recent call last):\n File \"\/home\/p\/12345.py\", line 21, in \n Import i2c\nImporterror: no module named 'i2c'","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":614,"Q_Id":44454668,"Users Score":0,"Answer":"I already did it but it continues with the same error","Q_Score":0,"Tags":"python-3.x,i2c","A_Id":44459253,"CreationDate":"2017-06-09T09:51:00.000","Title":"install i2c library on python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a unit tests for an API client class. \nThere is a class variable self.session that is supposed to hold the session. \nIn my setup method for my test I create a new instance of the client class and then call its authenticate method. However when the tests themselves go to send requests using this object they all return 401 forbidden errors. \nIf I move the authenticate call (but not the creation of the class) into the tests and out of setup everything works great, but I understand that that defeats the purpose of setup().","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":27,"Q_Id":44464654,"Users Score":0,"Answer":"An example of the code you're talking about (with proprietary stuff removed, of course), might help clarify.\nThe variable, self.session, is on the test class itself, rather than the instance? That sounds as if it might end up leaking state between your tests. Attaching it to the instance might help.\nBeyond that, I generally think it makes sense to move as much out of setUp methods as possible. Authentication is part of the important part of your test, and it should probably be done alongside all the other logic.","Q_Score":0,"Tags":"python-3.x,python-requests,python-unittest","A_Id":44464795,"CreationDate":"2017-06-09T18:35:00.000","Title":"Lifetime of Request Sessions in Unit Testing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to send the result of a Python script to the input field of a PHP page? \nI am using a PYTHON script to capture weight data from a scale. I would like to use that data from the python script, placing it into the input field of a PHP page.\nThe name of the input field on the page will remain static, as will the name of the page.\nTo initiate the process (from python script to the input field) I would use an on click command or something similar. \nI am very new to python and very much appreciate any help.\nBob","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":140,"Q_Id":44466061,"Users Score":0,"Answer":"You have to expose the data to the Internet - either create an upload script in PHP that will receive data whenever your Python script captures the new weight (you probably don't want this approach), or write a PHP script that will execute the Python script, take its output and send it back to you. You can then reload the whole page or use JavaScript to update the input field\nHope this helps you, comment if you have any questions","Q_Score":0,"Tags":"php,python","A_Id":44466115,"CreationDate":"2017-06-09T20:15:00.000","Title":"Send output to a PHP input field","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've got a script that uses the Google Assistant Library and has to import some modules from there. I figured out this only works in a Python Virtual Environment, which is really strange. In the same folder I've got a script which uses the GPIO pins and has to use root. They interact with each other, so when I start the GPIO script, the Assistant script is also started. But for some reason the modules in there can't import when the script is started with root. Does anybody know something about this?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":9151,"Q_Id":44484082,"Users Score":0,"Answer":"I ended up just installing the python package as sudo and it worked fine. For my case it was sudo pip3 install findpi and then executed as sudo findpi and worked.","Q_Score":7,"Tags":"python,module,root,gpio,google-assistant-sdk","A_Id":69848425,"CreationDate":"2017-06-11T12:51:00.000","Title":"Python can't find module when started with sudo","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way for manipulating complex numbers in more than floating point precision using python?\nFor example to get a better precision on real numbers I can easily use the Decimal module. However it doesn't appear to work with complex numbers.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1543,"Q_Id":44500275,"Users Score":0,"Answer":"There isn't anything built-in. You'd have to implement it yourself, or use a third-party library.","Q_Score":6,"Tags":"python","A_Id":44500328,"CreationDate":"2017-06-12T13:07:00.000","Title":"Decimal module and complex numbers in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Does anyone know if the raspberry pi 3 is powerful enough to run the SIFT or SURF algorithms for a real-time app (traffic signs recognition) or should I look for something else ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":509,"Q_Id":44530668,"Users Score":1,"Answer":"I tried ORB on Raspberry Pi and got like around 5 FPS at 640 x 480 I think, it was on single thread, could probably get up to like at least 15-20 fps with threads. You're better off using ORB with something like Raspberry Pi. I doubt you can get good FPS using SIFT\/SURF.","Q_Score":1,"Tags":"python,opencv,raspberry-pi3","A_Id":44534024,"CreationDate":"2017-06-13T20:12:00.000","Title":"SIFT SURF on raspberry","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I have a few Packages that I have made and I want to share them with my friends and I want to put them in separate github repositories, now I know how to make a project in eclipse, I already have my packages in the project and I also cloned the empty github repository in my local computer now when i connect the project to the local repository and push it into github it actually copies the complete project into the repository but i want only the packages to be copied i.e.\nright now its like githubrepository\/pythonproject\/pythonpackage\nbut i want it to be githubrepository\/pythonpackage\ncan someone suggest a link or some ways to solve it?am i making a mistake?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":21,"Q_Id":44547072,"Users Score":0,"Answer":"On git, you always work with the repo as a whole (even if you see only a part of it on Eclipse).\nSo, to do what you want, you have to actually create a new repo and copy the sources you want and then push from there (there are ways to do that with git saving the history too if that's important to you).\nYou might want to take a look at git submodules too...","Q_Score":0,"Tags":"python,eclipse,github,pydev,egit","A_Id":44783503,"CreationDate":"2017-06-14T14:04:00.000","Title":"How do I properly share my Python Packages using Eclipse+pydev+egit?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a self-installed python in my user directory in a corporate UNIX SUSE computer (no sudo privilege):\nwhich python\n\/bin\/python\/Python-3.6.1\/python\nI have an executable (chmod 777) sample.py file with this line at the top of the file:\n#!\/bin\/python\/Python-3.6.1\/python\nI can execute the file like this:\npython sample.py\nBut when I run it by itself I get an error:\n\/full\/path\/sample.py\n \/full\/path\/sample.py: Command not found\nI have no idea why it's not working. I'm discombobulated as what might be going wrong since the file is executable, the python path is correct, and the file executes if I put a python command in the front. What am I missing?\nEDIT:\nI tried putting this on top of the file:\n#!\/usr\/bin\/env python\nNow, I get this error:\n: No such file or directory\nI tried this to make sure my env is correct\nwhich env\n \/usr\/bin\/env\nEDIT2:\nYes, I can run the script fine using the shebang command like this:\n\/bin\/python\/Python-3.6.1\/python \/full\/path\/sample.py","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1040,"Q_Id":44555995,"Users Score":2,"Answer":"Your file has DOS line endings (CR+LF). It works if you run python sample.py but doesn't work if you run .\/sample.py. Recode the file so it has Unix line endings (pure LF at the end of every line).","Q_Score":1,"Tags":"python,linux,unix","A_Id":44556361,"CreationDate":"2017-06-14T22:59:00.000","Title":"Executable .py file with shebang path to which python gives error, command not found","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"i'm actually making ajax request that call a php file which call a python file. My main problem is with the imports in the python scripts. I actually work on local.\nI'm on linux. When i do \"$ php myScript.php\" ( which call python script inside ) it's work but when it come from the ajax call then the import of the python files does not work. So i moved some libraries in the current folder of the php and python script. First the import will only work if the library is in a folder, impossible to call a function from my other python script. Then i can't do \" import tweepy \" even if the library is in the current folder. But for pymongo its worked because I do \" from pymongo import MongoClient \". All my script worked when call from php or when executed with python throw command line.\nThoses libraries are also in my current python folder on linux but throw ajax call it never go there. I specify this at the beginning of each python file \"#!\/usr\/bin\/env python2.7\"\nHere the path of my files \nfolder \n----- script.php \n----- script.py \n----- pymongo[FOLDER] \n----- tweepy[FOLDER] \nPs : Sorry english is not my main language","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":104,"Q_Id":44558269,"Users Score":0,"Answer":"I finally succeed. In fact tweepy use the library call \"six\" which is not in my current folder. So i import all the python library in my folder, so i get no more error. \nBut i still don't understand why python does not go search the library in his normal folder instead in the current folder.","Q_Score":0,"Tags":"php,python,ajax,import,directory","A_Id":44577194,"CreationDate":"2017-06-15T03:56:00.000","Title":"executing python throw ajax , import does not work","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Basically we have a Python library with modules and functions that we use in many of our programs. Currently, we checkout the SVN repository directly into C:\\Python27\\Lib so that the library is in the Python path. When someone make modifications to the library, everyone will update to get those modifications.\nSome of our programs are frozen (using cx-Freeze) and delivered so we have to keep tracking of the library version used in the deliveries, but cx-Freeze automatically packages the modules imported in the code.\n\nI don't think it is a good idea to rely on people to verify that they have no uncommitted local changes in the library or that they are up to date before freezing any program importing it.\nThe only version tracking we have is the commit number of the library repository, which is not linked anywhere to the program delivery version, and which should not be used as a delivery version of the library in my opinion.\n\nI was thinking about using a setup.py to build a distribution of a specific version of that library and then indicate that version in a requirements.txt file in the project folder of the program importing it, but then it becomes complicated if we want to make modifications to that library because we would have to build and install a distribution each time we want to test it. It is not that complicated but I think someone will freeze a program with a test version of that library and it comes back to the beginning...\nI kept looking for a best practice for that specific case but I found nothing, any ideas?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":65,"Q_Id":44571879,"Users Score":0,"Answer":"Ultimately you're going to have to trust your users to follow what development process you establish. You can create tools to make that easier, but you'll always end up having some trust.\nThings that have been helpful to a number of people include:\n\nAll frozen\/shipped builds of an executable are built on a central machine by something like BuildBot or Jenkins, not by individual developers. That gives you a central point for making sure that builds are shipped from clean checkouts.\nProvide scripts that do the build and error out if there are uncommitted changes.\nWhere possible it is valuable to make it possible to point PYTHONPATH at your distribution's source tree and have things work even if there is a setup.py that can build the distribution. That makes tests easier. As always, make sure that your tools for building shipped versions check for this and fail if it happens.\n\nI don't personally think that a distribution has a lot of value over a clean tagged subversion checkout for a library included in closed-source applications.\nYou can take either approach, but I think you will find that the key is in having good automation for whichever approach you choose, not in the answer to distribution vs subversion checkout","Q_Score":2,"Tags":"python,windows,python-2.7","A_Id":44571993,"CreationDate":"2017-06-15T15:50:00.000","Title":"What is best practice for working on a Python library package?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have made a dreadful error and am looking for your help!\nI have set up my raspberry pi to run a python script at start up by editing the rc.local file. This would be fine except I have written my script to reboot the raspberry pi when it exits. Now I am stuck in an infinite loop and I can't edit anything. Every time my script ends it reboots the pi and starts again!\nMy program uses Pygame as a GUI and I have a Raspberry Pi 3 running the NOOBS OS that came with it. If you need anymore info please ask.\nAny help stopping my script so I can access the pi without losing any data will be greatly appreciated.\nEdit - What an amazing community. Thank you everyone for sharing your knowledge and time. I was in a bit of a panic and you all came to my assistance really quick. If you are reading this because you are in a similar predicament I found Ben's answer was the quickest and easiest solution, but if that doesn't work for you I think FrostedCookies' idea would be the next thing to try.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":724,"Q_Id":44573728,"Users Score":0,"Answer":"I'd firstly turn it off and on again..\nIf it wont help\n\nps aux | grep -i python\nkillall python - youll probably need to tweak the killall command with the python script name instead or in addition to \"python\"","Q_Score":10,"Tags":"python,python-3.x,raspberry-pi,raspberry-pi3","A_Id":44573796,"CreationDate":"2017-06-15T17:41:00.000","Title":"Python script runs on boot then reboots at end - How to regain control?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have made a dreadful error and am looking for your help!\nI have set up my raspberry pi to run a python script at start up by editing the rc.local file. This would be fine except I have written my script to reboot the raspberry pi when it exits. Now I am stuck in an infinite loop and I can't edit anything. Every time my script ends it reboots the pi and starts again!\nMy program uses Pygame as a GUI and I have a Raspberry Pi 3 running the NOOBS OS that came with it. If you need anymore info please ask.\nAny help stopping my script so I can access the pi without losing any data will be greatly appreciated.\nEdit - What an amazing community. Thank you everyone for sharing your knowledge and time. I was in a bit of a panic and you all came to my assistance really quick. If you are reading this because you are in a similar predicament I found Ben's answer was the quickest and easiest solution, but if that doesn't work for you I think FrostedCookies' idea would be the next thing to try.","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":724,"Q_Id":44573728,"Users Score":5,"Answer":"I'm not sure if this will work (I don't have a Pi right now), but if you can't access a terminal normally while the script is running, try the keyboard shortcut Ctrl+Alt+F1 to open one, then type sudo pkill python to kill the script (this will also kill any other python processes on your machine). Then use a terminal text editor (vi or nano perhaps) to edit your rc.local file so this doesn't happen again.","Q_Score":10,"Tags":"python,python-3.x,raspberry-pi,raspberry-pi3","A_Id":44573870,"CreationDate":"2017-06-15T17:41:00.000","Title":"Python script runs on boot then reboots at end - How to regain control?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have made a dreadful error and am looking for your help!\nI have set up my raspberry pi to run a python script at start up by editing the rc.local file. This would be fine except I have written my script to reboot the raspberry pi when it exits. Now I am stuck in an infinite loop and I can't edit anything. Every time my script ends it reboots the pi and starts again!\nMy program uses Pygame as a GUI and I have a Raspberry Pi 3 running the NOOBS OS that came with it. If you need anymore info please ask.\nAny help stopping my script so I can access the pi without losing any data will be greatly appreciated.\nEdit - What an amazing community. Thank you everyone for sharing your knowledge and time. I was in a bit of a panic and you all came to my assistance really quick. If you are reading this because you are in a similar predicament I found Ben's answer was the quickest and easiest solution, but if that doesn't work for you I think FrostedCookies' idea would be the next thing to try.","AnswerCount":4,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":724,"Q_Id":44573728,"Users Score":8,"Answer":"Probably the easiest way is to take out the SD card from your Pi, mount the SD filesystem onto another computer running linux and edit your rc.local script from there to remove the infinite boot loop. You can also backup your data that way incase something goes wrong.","Q_Score":10,"Tags":"python,python-3.x,raspberry-pi,raspberry-pi3","A_Id":44573812,"CreationDate":"2017-06-15T17:41:00.000","Title":"Python script runs on boot then reboots at end - How to regain control?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm about to convert my python script into an executable with py2exe but I'm concerned that a few modules that I installed via pip (paramiko & xlrd) won't be included in that executable. Does anyone know if those modules that are not from the standard library are included in the script when you move it over to .exe format?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":58,"Q_Id":44574674,"Users Score":0,"Answer":"Yes. The paramiko folder - or any non-standard imported functionality - is located in the directory\n\nC:\\path_to_your_script's_folder\\script_folder\\build\\bdist.win32\\winexe\\collect-2.7\\paramiko\n\nThis folder holds all of the .pyc files that are associated to that imported file (in this case paramiko).\nThanks to @Artyer and @Ofer Sadan for their help!","Q_Score":0,"Tags":"python,pip,py2exe","A_Id":44575124,"CreationDate":"2017-06-15T18:40:00.000","Title":"pip installed modules when packaging python scripts","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently trying to figure out a way to know who invited a user. From the official docs, I would think that the member class would have an attribute showing who invited them, but it doesn't. I have a very faint idea of a possible method to get the user who invited and that would be to get all invites in the server then get the number of uses, when someone joins the server, it checks to see the invite that has gone up a use. But I don't know if this is the most efficient method or at least the used method.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":13355,"Q_Id":44594309,"Users Score":1,"Answer":"In Discord, you're never going to 100% sure who invited the user.\nUsing Invite, you know who created the invite.\nUsing on_member_join, you know who joined.\nSo, yes, you could have to check invites and see which invite got revoked. However, you will never know for sure who invited since anyone can paste the same invite link anywhere.","Q_Score":3,"Tags":"python,discord,discord.py","A_Id":44830944,"CreationDate":"2017-06-16T16:50:00.000","Title":"Discord.py show who invited a user","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently trying to figure out a way to know who invited a user. From the official docs, I would think that the member class would have an attribute showing who invited them, but it doesn't. I have a very faint idea of a possible method to get the user who invited and that would be to get all invites in the server then get the number of uses, when someone joins the server, it checks to see the invite that has gone up a use. But I don't know if this is the most efficient method or at least the used method.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":13355,"Q_Id":44594309,"Users Score":1,"Answer":"Watching the number of uses an invite has had, or for when they run out of uses and are revoked, is the only way to see how a user was invited to the server.","Q_Score":3,"Tags":"python,discord,discord.py","A_Id":45571128,"CreationDate":"2017-06-16T16:50:00.000","Title":"Discord.py show who invited a user","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to get the unix file type of a file specified by path (find out whether it is a regular file, a named pipe, a block device, ...)\nI found in the docs os.stat(path).st_type but in Python 3.6, this seems not to work.\nAnother approach is to use os.DirEntry objects (e. g. by os.listdir(path)), but there are only methods is_dir(), is_file() and is_symlink().\nAny ideas how to do it?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1711,"Q_Id":44595736,"Users Score":1,"Answer":"Python 3.6 has pathlib and its Path objects have methods:\n\nis_dir()\nis_file()\nis_symlink()\nis_socket()\nis_fifo()\nis_block_device()\nis_char_device()\n\npathlib takes a bit to get used to (at least for me having come to Python from C\/C++ on Unix), but it is a nice library","Q_Score":6,"Tags":"python,unix,operating-system","A_Id":44595853,"CreationDate":"2017-06-16T18:24:00.000","Title":"Get unix file type with Python os module","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to build a twitter chat bot which is interactive and replies according to incoming messages from users. Webhook documentation is unclear on how do I receive incoming message notifications. I'm using python.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":662,"Q_Id":44632982,"Users Score":0,"Answer":"Answering my own question.\nWebhook isn't needed, after searching for long hours on Twitter Documentation, I made a well working DM bot, it uses Twitter Stream API, and StreamListener class from tweepy, whenever a DM is received, I send requests to REST API which sends DM to the mentioned recipient.","Q_Score":0,"Tags":"python,api,twitter,twitter-oauth,chatbot","A_Id":44717595,"CreationDate":"2017-06-19T14:15:00.000","Title":"Does twitter support webhooks for chatbots or should i use Stream API?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using mget(keys, *args) to bulk set keys.\n\nI also want to set expiration time to keys. The reason I am using mset is to save calls to redis.\n\nIs there a way to bulk set keys with expiration ?\n\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":2243,"Q_Id":44668928,"Users Score":2,"Answer":"There is no command that sets the TTL for multiple keys, in the fashion that MSET works. You can, however, replace the call to MSET with a Lua script that does SETEX for each key and value passed to it as parameters.","Q_Score":1,"Tags":"python,redis,redis-cluster,redis-py","A_Id":44669252,"CreationDate":"2017-06-21T07:01:00.000","Title":"Is it possible to set expiry to redis keys (bulk operation)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a script which is an automated test. I need to be able to set a run to be X cycles long (or even infinite). What is the best method of doing so ?\nBy the way, currently I am using my IDE to run the whole script and sometimes I use the CLI to run certain code chunks.\nWhich will be needed for my needs","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1877,"Q_Id":44670758,"Users Score":0,"Answer":"python -c 'for i in range(10): print \"hello\"'\n\ntested.\nor your shell\n\nfor i in `seq 10`;do echo hello; done","Q_Score":2,"Tags":"python,python-3.x,selenium-webdriver","A_Id":44672323,"CreationDate":"2017-06-21T08:30:00.000","Title":"What is the recommended way to run a script X times in a row (one at a time)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Self explanatory question here.\nIs this even possible? Can't find any documentation regarding this anywhere.. \nAnd if not, how complicated is it to write a plugin?\nThanks!","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":219,"Q_Id":44671776,"Users Score":1,"Answer":"pytest is not currently in the test framework like JUnit is but since you have a command line you could run your tests manually or create a custom command from the commands tab on the left. \n\nclick the \"+\" under \"TEST\"\nreplace the \"Command Line\" entry that reads echo \"hello\" with \npython ${current.project.relpath}\nclick save\nWith your python test file selected in the Project Explorer, click run on your new custom test shift+F10.","Q_Score":0,"Tags":"python,pytest,codenvy,eclipse-che","A_Id":44780474,"CreationDate":"2017-06-21T09:16:00.000","Title":"Is it possible to run Py.Test tests on Eclipse Che\/Codenvy?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Self explanatory question here.\nIs this even possible? Can't find any documentation regarding this anywhere.. \nAnd if not, how complicated is it to write a plugin?\nThanks!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":219,"Q_Id":44671776,"Users Score":0,"Answer":"Correct, there's no built in UI to run python tests. However, you may use command line approach.","Q_Score":0,"Tags":"python,pytest,codenvy,eclipse-che","A_Id":45098100,"CreationDate":"2017-06-21T09:16:00.000","Title":"Is it possible to run Py.Test tests on Eclipse Che\/Codenvy?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to use Sphinx to create simple documentation for a python module. The first time I ran it, it worked fine. Now I have made some updates to the module, and rerunning the documentation commands:\n$ sphinx-apidoc -P -F -f -e -o . \/path\/to\/module\n$ make html\n\nit always uses the old version of the python module code. I have tried deleting the entire docs directory, moving the module, rechecking it out, updating sphinx - nothing works. \nThe old code is still being reused and cached somewhere. It is driving me absolutely insane.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":363,"Q_Id":44693301,"Users Score":0,"Answer":"Because Sphinx imports the module, it does not seem to find the local copy, but rather imports the older version already installed on my system, and uses that to generate the docs. Running python setup.py install, and then regenerating everything finally worked.","Q_Score":2,"Tags":"caching,python-sphinx","A_Id":44693633,"CreationDate":"2017-06-22T07:48:00.000","Title":"Sphinx is caching python module somewhere: WHERE?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Debian 8 and I would like to be able to only send mail via python without installing a full blown mail server system like postfix or without using gmail. \nI can only see tutorials to send mails with python with full mail system server or via gmail or other internet mail system. Isn't it possible to just send an email and don't care about receiving any?\nThanks.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":197,"Q_Id":44696136,"Users Score":1,"Answer":"Well, you need a mail server. Either locally, on your machine, or somewhere on the internet. This doesn't have to be gmail.","Q_Score":1,"Tags":"python","A_Id":44696211,"CreationDate":"2017-06-22T09:59:00.000","Title":"Sending mail via python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I run a ZeroRPC server and I can connect successfully with a client to the 127.0.0.1 IP. \nHowever when I use the public IP of the server to the client I get the following error:\nzerorpc.exceptions.LostRemote: Lost remote after 10s heartbeat \nI have opened the port from the firewall (using ufw on Ubuntu) but still get the same error. \nDo you have any ideas what the problem might be? \nThanks!!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":311,"Q_Id":44697947,"Users Score":0,"Answer":"What IP address are you binding the server onto? If you want to listen on all interfaces and all addresses, something like tcp:\/\/0.0.0.0:4242 should work.","Q_Score":0,"Tags":"python,zerorpc","A_Id":44765954,"CreationDate":"2017-06-22T11:22:00.000","Title":"python ZeroRPC heartbeat error on public IP","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a flask API, which one of the endpoint is to receive a message and publish it to PubSub. Currently, in order to test that endpoint, I will have to manually spin-up a PubSub emulator from the command line, and keep it running during the test. It working just fine, but it wouldn't be ideal for automated test. \nI wonder if anyone knows a way to spin-up a test PubSub emulator from python? Or if anyone has a better solution for testing such an API?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":768,"Q_Id":44708430,"Users Score":0,"Answer":"This is how I usually do:\n1. I create a python client class which does publish and subscribe with the topic, project and subscription used in emulator.\nNote: You need to set PUBSUB_EMULATOR_HOST=localhost:8085 as env in your python project.\n2. I spin up a pubsub-emulator as a docker container.\nNote: You need to set some envs, mount volumes and expose port 8085.\nset following envs for container:\n\nPUBSUB_EMULATOR_HOST\nPUBSUB_PROJECT_ID\nPUBSUB_TOPIC_ID\nPUBSUB_SUBSCRIPTION_ID\n\n\nWrite whatever integration tests you want to. Use publisher or subscriber from client depending on your test requirements.","Q_Score":1,"Tags":"python,google-cloud-platform,google-cloud-pubsub","A_Id":64239668,"CreationDate":"2017-06-22T20:03:00.000","Title":"How to boot up a test pubsub emulator from python for automated testing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"The title says it all. I am cleaning up python scripts I have written. Sometimes in the writing of scripts I have tried out one library only to replace it, or not use it later. \nI would like to be able to check if a library which is imported is actually used within the script later. Ideally i would do this without having to comment out the import line and run it looking for errors each time. \nDoes anyone know of a resource or script\/library which checks for this? Or what about other tips for cleaning up script to share with others? \nThanks, \nMike","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":718,"Q_Id":44709221,"Users Score":1,"Answer":"Try a Python linter, they will do this for you, for example flake8. Install with pip install flake8 and run by calling flake8 in the root folder of your project.","Q_Score":3,"Tags":"python","A_Id":44709283,"CreationDate":"2017-06-22T20:54:00.000","Title":"How can I check if an imported library is 'used' in a python script?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a webhook that handles any sms messages sent to my Twilio number. However, this webhook only works if there is text in the message (there will be a body in the GET request). \nIs it possible to parse a message if it is a location message? e.g. if I send my current location to my Twilio number and it redirects this message as a GET request to the webhook, could I possibly retrieve that location?\nThis is what my webhook receives if I send my current location on an iPhone:\nat=info method=GET path=\"\/sms\/?ToCountry=US&MediaContentType0=text\/x-vcard&ToState=NJ&SmsMessageSid=MMde62b3369705a8f65f18abe5b7387c2b&NumMedia=1&ToCity=NEWARK&FromZip=07920&SmsSid=MMde62b3369705a8f65f18abe5b7387c2b&FromState=NJ&SmsStatus=received&FromCity=SOMERVILLE&Body=&FromCountry=US&To=%2B18627019482&ToZip=07102&NumSegments=1&MessageSid=MMde62b3369705a8f65f18abe5b7387c2b&AccountSid=ACe72df68a68db79d9a4ac6248df6e981e&From=%2B19083925806&MediaUrl0=https:\/\/api.twilio.com\/2010-04-01\/Accounts\/ACe72df68a68db79d9a4ac6248df6e981e\/Messages\/MMde62b3369705a8f65f18abe5b7387c2b\/Media\/MEcd56717ce17f3a320b06c4ee11df2243&ApiVersion=2010-04-01\"\nFor comparison, here's a normal text message:\nat=info method=GET path=\"\/sms\/?ToCountry=US&ToState=NJ&SmsMessageSid=SM4767dabb915fae749c7d5b59d6f655a2&NumMedia=0&ToCity=NEWARK&FromZip=07920&SmsSid=SM4767dabb915fae749c7d5b59d6f655a2&FromState=NJ&SmsStatus=received&FromCity=SOMERVILLE&Body=Denver+E+union&FromCountry=US&To=%2B18627019482&ToZip=07102&NumSegments=1&MessageSid=SM4767dabb915fae749c7d5b59d6f655a2&AccountSid=ACe72df68a68db79d9a4ac6248df6e981e&From=%2B19083925806&ApiVersion=2010-04-01\"\nIn the normal sms message, I can parse out the Body=Denver+E+union to get the message, but I'm not sure you could do anything with the content of the location message. \nIf I can't get the location, what are some other easy ways I could send a parseable location?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":525,"Q_Id":44728566,"Users Score":2,"Answer":"I solved a similar problem by creating a basic webpage which uses the HTML5 geolocation function to get lat\/lng of the phone. It then submits coordinates to a php script via AJAX.\nMy server geocodes the employees location, calculates travelling time to next job and sends the customer an SMS with ETA information using the Twilio API.\nYou could bypass Twilio altogether and get your server to make the request direct to your webhook, or even via the AJAX call if it's all on the same domain. All depends what you are trying to achieve I guess.","Q_Score":0,"Tags":"python,iphone,location,twilio","A_Id":44731799,"CreationDate":"2017-06-23T19:19:00.000","Title":"iPhone \"Send My Current Location\" to Twilio","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've seen a few posts on this topic with odd hard to reproduce behaviours. Here's a new set of data points.\n\nCurrently the following works\n\ncd .\/hosts\n.\/ec2.py --profile=dev\n\n\nAnd this fails\n\nAWS_PROFILE=dev; ansible-playbook test.yml\nThese were both working a couple days ago. Something in my environment changed. Still investigating. Any guesses?\nError message:\nERROR! The file .\/hosts\/ec2.py is marked as executable, but failed to execute correctly. If this is not supposed to be an executable script, correct this withchmod -x .\/hosts\/ec2.py.\nERROR! Inventory script (.\/hosts\/ec2.py) had an execution error: ERROR: \"Error connecting to AWS backend.\nYou are not authorized to perform this operation.\", while: getting EC2 instances\nERROR! .\/hosts\/ec2.py:3: Error parsing host definition ''''': No closing quotation\n\nNote that the normal credentials error is:\nERROR: \"Error connecting to AWS backend.\nYou are not authorized to perform this operation.\", while: getting EC2 instances\n...\nHmmm. Error message has shifted. \n\nAWS_PROFILE=dev; ansible-playbook test.yml\nERROR! ERROR! .\/hosts\/tmp:2: Expected key=value host variable assignment, got: {","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1445,"Q_Id":44737529,"Users Score":0,"Answer":"Looks like the problem was a temporary file in the hosts folder. After removing it the problems went away. It looks like std ansible behaviour: Pull in ALL files in the hosts folder.","Q_Score":0,"Tags":"python,amazon-ec2,ansible","A_Id":44737817,"CreationDate":"2017-06-24T14:36:00.000","Title":"Ansible ec2.py runs standalone but fails in playbook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"For reference. The absolute path is the full path to some place on your computer. The relative path is the path to some file with respect to your current working directory (PWD). For example:\nAbsolute path: \nC:\/users\/admin\/docs\/stuff.txt\nIf my PWD is C:\/users\/admin\/, then the relative path to stuff.txt would be: docs\/stuff.txt\nNote, PWD + relative path = absolute path.\nCool, awesome. Now, I wrote some scripts which check if a file exists.\nos.chdir(\"C:\/users\/admin\/docs\")\n os.path.exists(\"stuff.txt\")\nThis returns TRUE if stuff.txt exists and it works.\nNow, instead if I write,\nos.path.exists(\"C:\/users\/admin\/docs\/stuff.txt\")\nThis also returns TRUE. \nIs there a definite time when we need to use one over the other? Is there a methodology for how python looks for paths? Does it try one first then the other?\nThanks!","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":29634,"Q_Id":44772007,"Users Score":6,"Answer":"The biggest consideration is probably portability. If you move your code to a different computer and you need to access some other file, where will that other file be? If it will be in the same location relative to your program, use a relative address. If it will be in the same absolute location, use an absolute address.","Q_Score":13,"Tags":"python,path,relative-path,absolute-path,pwd","A_Id":44772227,"CreationDate":"2017-06-27T03:54:00.000","Title":"When to use Absolute Path vs Relative Path in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm running automated tests with Selenium and Python on Macbook and two monitors. The big issue with the tests is that the tests kept appearing wherever I was working. E.g. the test start on monitor A and I was googling or reporting bugs on monitor B. When the test teardown and setup again, but on monitor B. \nIt's very frustrating and restricting me from doing work when the tests are running. I am looking for solutions that can command the tests to stay in one place or on one monitor.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":43,"Q_Id":44783953,"Users Score":2,"Answer":"Run the tests in a virtual machine. They will appear in the window you've logged into the VM with, which you can put anywhere you like or minimize\/iconify and get on with your work.\n(the actual solution I used at work was to hire a junior test engineer to run and expand our Selenium tests, but that doesn't always apply)","Q_Score":2,"Tags":"python,macos,selenium,automated-tests","A_Id":44784204,"CreationDate":"2017-06-27T15:15:00.000","Title":"How to command automated tests to stay at one place of the monitor","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"according to my professor, its boolean, unsigned integer, integer, float, complex, string, and object.\nbut why? how is a float less precise than an integer (for example)? Is it to do with the operations that ca be performed on a given item (ie the ore specific the things that can be performed, the most 'precise' the type is?) I really have nothing more to add since i have really no idea, so any hints appreciated!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":102,"Q_Id":44786571,"Users Score":0,"Answer":"I could think of that he meant, that you should not do calculations with long commma floats, as they will overflow and give you some kind of rounding. If you calculate with integers instead, you wont get them. and you cold shift commas later on. \nas Artyr already mentioned, there is no unsigned Integer in Python, thats more a C\/C++ World.\nI don't realy know what an Objects precision should be.","Q_Score":1,"Tags":"python,floating-point,boolean,precision,abstract-data-type","A_Id":44786761,"CreationDate":"2017-06-27T17:37:00.000","Title":"order of data types from greatest to least precision in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way to disable MMS on a number from Twilio? I only see articles on disabling SMS entirely, and I want to disable MMS as there are additional charges and is not being used.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":244,"Q_Id":44787713,"Users Score":0,"Answer":"I think your best bet is to purchase a phone number that is not MMS compatible.","Q_Score":1,"Tags":"python,twilio","A_Id":44792253,"CreationDate":"2017-06-27T18:47:00.000","Title":"Disabling MMS on Twilio","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I couldn't find 'python-dev' package anywhere. I don't have the luxury to find it via pip or yum, since I don't have internet connection on my computer. I need to locate the 'python-dev' source, download it, and install it in my computer without internet and sudo access.\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1199,"Q_Id":44790807,"Users Score":1,"Answer":"python-dev contains everything you need to build Python extensions. So, it will typically include the Python.h header file, and probably some Python shared object files to link with.\nIf you have a compiler on the target machine, you can probably build that yourself by looking at how python-dev does it for various operating systems.","Q_Score":2,"Tags":"python,unix","A_Id":44790892,"CreationDate":"2017-06-27T22:16:00.000","Title":"How can I install python-dev package in a computer without internet?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a directory tests that includes a lot of different tests named test_*.\nI tried to run coverage run tests but it doesn't work.\nHow can I run a single command to coverage multiple files in the directory?","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":16132,"Q_Id":44812538,"Users Score":7,"Answer":"Use --include to only include files in particular directories. It matches file paths, so it can match a subdirectory.","Q_Score":14,"Tags":"python,coverage.py","A_Id":44812727,"CreationDate":"2017-06-28T21:05:00.000","Title":"How to run coverage.py on a directory?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a directory tests that includes a lot of different tests named test_*.\nI tried to run coverage run tests but it doesn't work.\nHow can I run a single command to coverage multiple files in the directory?","AnswerCount":4,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":16132,"Q_Id":44812538,"Users Score":10,"Answer":"You can achieve that using --source. For example: coverage run --source=tests\/ ","Q_Score":14,"Tags":"python,coverage.py","A_Id":44812899,"CreationDate":"2017-06-28T21:05:00.000","Title":"How to run coverage.py on a directory?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a directory tests that includes a lot of different tests named test_*.\nI tried to run coverage run tests but it doesn't work.\nHow can I run a single command to coverage multiple files in the directory?","AnswerCount":4,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":16132,"Q_Id":44812538,"Users Score":15,"Answer":"Here is a complete example with commands from the same PWD for all phases in one place. With a worked up example, I am also including the testing and the report part for before and after coverage is run. I ran the following steps and it worked all fine on osx\/mojave.\n\n\nDiscover and run all tests in the test directory \n\n\n$ python -m unittest discover \n\nOr\n Discover and run all tests in \"directory\" with tests having file name pattern *_test.py\n\n$ python -m unittest discover -s -p '*_test.py'\n\n\nrun coverage for all modules\n\n\n$ coverage run --source=.\/test -m unittest discover -s \/\n\n\nget the coverage report from the same directory - no need to cd.\n\n\n$ coverage report -m\n\nNotice in above examples that the test directory doesn't have to be\n named \"test\" and same goes for the test modules.","Q_Score":14,"Tags":"python,coverage.py","A_Id":55546164,"CreationDate":"2017-06-28T21:05:00.000","Title":"How to run coverage.py on a directory?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have built a MITM with python and scapy.I want to make the \"victim\" device be redirected to a specific page each time it tried to access a website. Any suggestions on how to do it?\n*Keep in mind that all the traffic from the device already passes through my machine before being routed.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":141,"Q_Id":44851959,"Users Score":0,"Answer":"You can directly answer HTTP requests to pages different to that specific webpage with HTTP redirections (e.g. HTTP 302). Moreover, you should only route packets going to the desired webpage and block the rest (you can do so with a firewall such as iptables).","Q_Score":0,"Tags":"python,scapy","A_Id":44997621,"CreationDate":"2017-06-30T17:24:00.000","Title":"Python : Redirecting device with MITM","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is it possible to control the path etched by the laser and the speed of the motor through python? I'm trying to not use a microcontroller or disassemble the drive. I'm essentially trying to do LightScribe on the bottom of a DVD without LightScribe. It's a long story.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":281,"Q_Id":44857149,"Users Score":0,"Answer":"Long story short, anything is possible when it comes to computers. Long story, unless you can find someone who has developed the code to interface with the drivers specific to the computer and such than it would take a lot of work to do. If I understand what you want to do it would likely end up becoming a whole program, which is what you might want to look for.\nIf you are having a lot of issues with LightScribe (which appears to have a free version) consider running a VM and installing it on there as it may be potentially more stable or simply use another computer.","Q_Score":0,"Tags":"python,dvd,dvd-burning,cddvd","A_Id":44857380,"CreationDate":"2017-07-01T03:47:00.000","Title":"Controlling DVD Drive using Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to create a python script (widget.py) that will get a JSON feed from an arbitrary resource. I can't get the python script to execute on localhost. Here are the steps I have followed:\n\nIn etc\/apache2\/httpd.conf I enabled LoadModule cgi_module libexec\/apache2\/mod_cgi.so\nRestarted Apache sudo apachectl restart\nAdded a .htaccess file to my directory:\n\n Options +ExecCGI\n AddHandler cgi-script .py\n<\/Directory>\nNOTE: I will eventually need to deploy this on a server where I won't have access to the apache2 directory.\nNavigated to http:\/\/localhost\/~walter\/widget\/widget.py\n\nI get a 500 server error. Log file contents:\n[Sat Jul 01 08:51:00.922413 2017] [core:info] [pid 75403] AH00096: removed PID file \/private\/var\/run\/httpd.pid (pid=75403)\n[Sat Jul 01 08:51:00.922446 2017] [mpm_prefork:notice] [pid 75403] AH00169: caught SIGTERM, shutting down\nAH00112: Warning: DocumentRoot [\/usr\/docs\/dummy-host.example.com] does not exist\nAH00112: Warning: DocumentRoot [\/usr\/docs\/dummy-host2.example.com] does not exist\n[Sat Jul 01 08:51:01.449227 2017] [mpm_prefork:notice] [pid 75688] AH00163: Apache\/2.4.25 (Unix) PHP\/5.6.30 configured -- resuming normal operations\n[Sat Jul 01 08:51:01.449309 2017] [core:notice] [pid 75688] AH00094: Command line: '\/usr\/sbin\/httpd -D FOREGROUND'\nDo I need to enable cgi in \/etc\/apache2\/users\/walter\/http.conf? Should I?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3573,"Q_Id":44862432,"Users Score":0,"Answer":"1, 2. Ok.\n\nAre .htaccess files allowed in \/etc\/apache2\/httpd.conf ?\n\n \u2014 I think you want .\n\nLook into error log \u2014 what is the error?","Q_Score":1,"Tags":"python,apache,.htaccess,httpd.conf,macos-sierra","A_Id":44862745,"CreationDate":"2017-07-01T15:12:00.000","Title":"Executing python script on Apache in MacOS Sierra","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am trying to create a python script (widget.py) that will get a JSON feed from an arbitrary resource. I can't get the python script to execute on localhost. Here are the steps I have followed:\n\nIn etc\/apache2\/httpd.conf I enabled LoadModule cgi_module libexec\/apache2\/mod_cgi.so\nRestarted Apache sudo apachectl restart\nAdded a .htaccess file to my directory:\n\n Options +ExecCGI\n AddHandler cgi-script .py\n<\/Directory>\nNOTE: I will eventually need to deploy this on a server where I won't have access to the apache2 directory.\nNavigated to http:\/\/localhost\/~walter\/widget\/widget.py\n\nI get a 500 server error. Log file contents:\n[Sat Jul 01 08:51:00.922413 2017] [core:info] [pid 75403] AH00096: removed PID file \/private\/var\/run\/httpd.pid (pid=75403)\n[Sat Jul 01 08:51:00.922446 2017] [mpm_prefork:notice] [pid 75403] AH00169: caught SIGTERM, shutting down\nAH00112: Warning: DocumentRoot [\/usr\/docs\/dummy-host.example.com] does not exist\nAH00112: Warning: DocumentRoot [\/usr\/docs\/dummy-host2.example.com] does not exist\n[Sat Jul 01 08:51:01.449227 2017] [mpm_prefork:notice] [pid 75688] AH00163: Apache\/2.4.25 (Unix) PHP\/5.6.30 configured -- resuming normal operations\n[Sat Jul 01 08:51:01.449309 2017] [core:notice] [pid 75688] AH00094: Command line: '\/usr\/sbin\/httpd -D FOREGROUND'\nDo I need to enable cgi in \/etc\/apache2\/users\/walter\/http.conf? Should I?","AnswerCount":3,"Available Count":2,"Score":0.2605204458,"is_accepted":false,"ViewCount":3573,"Q_Id":44862432,"Users Score":4,"Answer":"Got it to work. Here are the steps that I followed:\n\nIn etc\/apache2\/httpd.conf I uncommented:\nLoadModule cgi_module libexec\/apache2\/mod_cgi.so\nRestarted Apache sudo apachectl restart\nList itemAdded a .htaccess file to my directory with the following contents:\nOptions ExecCGI\n AddHandler cgi-script .py\n Order allow,deny\n Allow from all\nAdded #!\/usr\/bin\/env python to the top of my python script\nIn terminal enabled execution of the python script using: chmod +x widget.py","Q_Score":1,"Tags":"python,apache,.htaccess,httpd.conf,macos-sierra","A_Id":44865681,"CreationDate":"2017-07-01T15:12:00.000","Title":"Executing python script on Apache in MacOS Sierra","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I couldn't find any API to configure my codeship project :(\nI have multiple repositories, and would like to allow the following steps programatically:\n\nList repositories of my team\ncreate a new repo pipeline (for each microservice I have a seperate repo)\nEdit pipeline steps scripts for newly created project (and for multiple projects \"at once\")\nCustomize a project's environment variables\ndelete an existing project\n\nIs there any way to do it?\nHow do I authenticate?\nEven if I have to do by recording network curls - is there a better way to authenticate other than pasting an existing cookie I copy from my own browsing? OAuth, user-password as header, etc.?\nI'm trying to write a python bot to do it, but will take any example code available!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":30,"Q_Id":44869606,"Users Score":0,"Answer":"Just noticed your question here on SO and figured I'd answer it here as well as your support ticket (so others can see the general answer).\nWe're actively working on a brand new API that will allow access to both Basic and Pro projects. The target for general availability is currently at the beginning of Aug '17. We'll be having a closed beta before then (where you're on the list)","Q_Score":0,"Tags":"python,web-scraping,codeship","A_Id":45087672,"CreationDate":"2017-07-02T10:05:00.000","Title":"configuring codeship via code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"i have a problem, if you have any idea how it may be fixed, please help)\nI have a project, which run by the .sh file, and this .sh refers to a python file.py which uses the Flask for html-reports.\nWhen i run the file.py (for simplify with 'hello world'), but when i run the .sh file, it writes the error \"ImportError: No module named 'flask'\".\nI installed the virtualenv for file.py's folder and .sh folder.\nPlease, give an advice for fix it. Thank's.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":986,"Q_Id":44881128,"Users Score":0,"Answer":"Installing wheel using:\npip install wheel\nworks, not sure what influenced it.","Q_Score":0,"Tags":"python,shell,flask","A_Id":44884067,"CreationDate":"2017-07-03T08:40:00.000","Title":"Run Flask from run.sh","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is there any python\/Shell script to make memory 100% usage for 20 minutes.\nMemory size is very big 4TB. \nOperating System Linux.\nPython version 2.7","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":259,"Q_Id":44882144,"Users Score":0,"Answer":"Is there any python\/Shell script to make memory 100% usage for 20 minutes.\n\nTo be technical, we need to be precise. 100% usage of the whole memory by a single process isn't technically possible. Your memory is shared with other processes. The fact that the kernel is in-memory software debunks the whole idea. \nPlus, a process might start another process, say you run Python from the shell, now you have two processes (the shell and Python) each having their own memory areas.\nIf you mean by that a process that can consume most of ram space, then yes that's not impossible.","Q_Score":0,"Tags":"python,python-2.7,shell","A_Id":44884687,"CreationDate":"2017-07-03T09:31:00.000","Title":"shell\/Python script to utilize memory 100% for 20 mins","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"What is the easiest way to run a python script from google sheets, or alternatively execute the python script when the google sheets opens?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2539,"Q_Id":44892009,"Users Score":0,"Answer":"I'm assuming you have some python asset that you would like to use to modify data on Google Sheets. If that's the case, then I think your best option is to use Google APIs to access Google Sheets from python. You can use any of the following two tutorials by Twilio to achieve that. \nIf you want to add the python asset into Google sheets (Ex. as a custom function), then it will be much easier to rewrite it in JS.","Q_Score":3,"Tags":"python,google-sheets,google-api","A_Id":51015293,"CreationDate":"2017-07-03T18:32:00.000","Title":"Execute python script from within google sheets","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am getting the following error when I am tring to import pytaj in python.\nImportError: \/home\/supriyo\/software\/amber16\/lib\/python2.7\/site-packages\/pytraj\/cpp_options.so: undefined symbol: _Z15SupressErrorMsgb?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":277,"Q_Id":44920110,"Users Score":0,"Answer":"Seems that pytraj was linked to the wrong libcpptraj\nTry\nldd \/home\/supriyo\/software\/amber16\/lib\/python2.7\/site-packages\/pytraj\/cpp_options.so\nand delete the libcpptraj.so from that output.\nIt's better to open and issue in\ngithub.com\/amber-md\/pytraj","Q_Score":0,"Tags":"python,python-2.7,python-3.x","A_Id":45315275,"CreationDate":"2017-07-05T07:50:00.000","Title":"How do I import pytraj in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can I set an environment variable with the location of the pytest.ini, tox.ini or setup.cfg for running pytest by default?\nI created a docker container with a volume pointing to my project directory, so every change I make is also visible inside the docker container. The problem is that I have a pytest.ini file on my project root which won't apply to the docker container. \nSo I want to set an environment variable inside the docker container to specify where to look for the pytest configuration. Does anyone have any idea how could I do that?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":7501,"Q_Id":44958993,"Users Score":6,"Answer":"There is no way to do that. You can use a different pytest configuration using pytest -c but tox.ini and setup.cfg must reside in the top-level directory of your package, next to setup.py.","Q_Score":5,"Tags":"python,docker,pytest,pytest-django","A_Id":44959229,"CreationDate":"2017-07-06T21:16:00.000","Title":"pytest: environment variable to specify pytest.ini location","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am attempting to put the custom method, that would send results of automated tests to JIRA, in the Behave's environment.py. It would be in after_scenario() or after_feature(). So I want it to send the results to JIRA after closing tests. \nIt seems that those methods in environment.py only take in the methods that are part of context class. Is that right? Is there any walkaround this issue?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":452,"Q_Id":45010745,"Users Score":1,"Answer":"Your functions in \"environment.py\" can have any parameter that you like them to have. Only the hooks have a specified signature (as any API function). Therefore, if the feature object is sufficient to your processing, you should avoid to require somebody to pass the context object, too.","Q_Score":0,"Tags":"python,selenium,automated-tests,cucumber,python-behave","A_Id":46268432,"CreationDate":"2017-07-10T11:22:00.000","Title":"Put custom methods in Behave's environment.py","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to create a function using Lambda in Python on Linux. I have tried to use pyad, but it gave me Exception: Must be running Windows in order to use pyad.\nWhat other way can i create user and group in AD?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1731,"Q_Id":45014964,"Users Score":0,"Answer":"I can see 2 aspects that you should pay attention.\n\nLambda runs in a Linux environment. So, if you have some library that uses internal resources from windows, it won't work on AWS Lambda environment. You should search another option, like python-ldap or something similar.\nLambda environment provides only basic python modules. For sure pyad or python-ldap is not included. So, if you want to use it, make sure you will add this module in your zip lambda file.","Q_Score":0,"Tags":"python,linux,lambda,active-directory,aws-lambda","A_Id":45064312,"CreationDate":"2017-07-10T14:38:00.000","Title":"How to create user and group in AD using Lambda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to optimize my usage of Request Units. Say in a span of one minute, is it better to upload 10 0.1MB documents or a single 1MB document? I heard that if the total amount of data is the same, then the RU usage would be the same, but it makes sense to me that if I access the database to write to it more frequently then it would be more costly in terms of RUs.\nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":122,"Q_Id":45037851,"Users Score":0,"Answer":"The RU calculation is based on a variety of factors one of which is document size. Right now you're trying to do micro optimizations on RU when you should be designing based on your read\/write patterns and ensuring that you can efficiently access the data you need. The difference between 10*0.1 and 1.0 in this case should take a backseat as the RU cost difference will be negligible.","Q_Score":0,"Tags":"python,azure,azure-cosmosdb","A_Id":45041022,"CreationDate":"2017-07-11T14:46:00.000","Title":"Azure CosmosDB - Most efficient way to upload documents (size, frequency)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an AWS Lambda handler in Python 2.7 that is deployed from Travis CI. However, when I try running the function I received an error from AWS saying that it cannot import the enum module (enum34). Is there a simple way to resolve this? Should Travis CI include the virtual environment that Python is running in? If not, how do I include that virtualenv?\nAdditionally, when I deploy from Travis CI, it seems to prepend an \"index.\" onto the handler_name field. Does anyone know why this happens, or how to disable it? I can't seem to find an answer.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":297,"Q_Id":45053733,"Users Score":1,"Answer":"Solved it. I was installing the Python modules into a subdirectory of my project root, rather than in the project root itself.\nEssentially was doing this:\npip install -r requirements.txt .\/virtualenv\/\nwhen I should have been doing this:\npip install -r requirements.txt .\/","Q_Score":0,"Tags":"python,amazon-web-services,lambda,virtualenv,travis-ci","A_Id":45054273,"CreationDate":"2017-07-12T09:27:00.000","Title":"Enum Module with AWS Lambda Python 2.7, Deployed with Travis CI","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to know how to send custom header (or metadata) using Python gRPC. I looked into documents and I couldn't find anything.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":12988,"Q_Id":45071567,"Users Score":0,"Answer":"If you metadata has one key\/value you can only use list(eg: [(key, value)]) ,If you metadata has Mult k\/v you should use list(eg: [(key1, value1), (key2,value2)]) or tuple(eg: ((key1, value1), (key2,value2))","Q_Score":9,"Tags":"python,grpc","A_Id":70484074,"CreationDate":"2017-07-13T04:43:00.000","Title":"How to send custom header (metadata) with Python gRPC?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I read the code to make an Alexa skill in python, I am confused by session. Can you tell me what session means in the function? (session_attribute, or session.get('attributes', {}))\nThank you","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":103,"Q_Id":45092884,"Users Score":1,"Answer":"You can use the session object to save data, for example, save the state of the conversation.","Q_Score":0,"Tags":"python,amazon-web-services,aws-lambda,alexa,alexa-skills-kit","A_Id":45093014,"CreationDate":"2017-07-14T00:37:00.000","Title":"What does session mean in the function for Alexa skills?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"In my pyramid app it's useful to be able to log in as any user (for test\/debug, not in production). My normal login process is just a simple bcrypt check against the hashed password.\nWhen replicating user-submitted bug reports I found it useful to just clone the sqlite database and run a simple script which would change everyone's password to a fixed string (just for local testing). Now that I'm switching over to postgresql that's less convenient to do, and I'm thinking of installing a backdoor to my login function.\nBasically I wish to check os.environ (set from the debug.wsgi file which is loaded by apache through mod_wsgi) for a particular variable 'debug'. If it exists then I will allow login using any password (for any user), bypassing the password check.\nWhat are the security implications of this? As I understand it, the wsgi file is sourced once when apache loads up, so if the production.wsgi file does not set that particular variable, what's the likelihood of an attacker (or incompetent user) spoofing it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":64,"Q_Id":45112983,"Users Score":1,"Answer":"In order to instantiate the server application with that debug feature in environment, the attacker would have to have the hand over your webserver, most probably with administrative privileges.\nFrom an outside process, an attacker cannot modify the environment of the running server, which is loaded into memory, without at least debug capabilities and a good payload for rewriting memory. It would be easier to just reload the server or try executing a script within it.\nI think you are safe the way you go. If you are paranoid, ensure to isolate (delete) the backdoor from the builds to production.","Q_Score":2,"Tags":"python,security,pyramid,environment,dev-to-production","A_Id":45113051,"CreationDate":"2017-07-14T23:42:00.000","Title":"Security implications of a pyramid\/wsgi os.environ backdoor?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is there anything specific that can be done to help make a Django Channels server less susceptible to light or accidental DDoS attack or general load increase from websocket\/HTTP clients? Since Channels is not truly asynchronous (still workers behind the scenes), I feel like it would be quite easy to take down a Channels-based website - even with fairly simple hardware. I'm currently building an application on Django Channels and will run some tests later to see how it holds up.\nIs there some form of throttling built in to Daphne? Should I implement some application-level throttling? This would still be slow since a worker still handles the throttled request, but the request can be much faster. Is there anything else I can do to attempt to thwart these attacks? \nOne thought I had was to always ensure there are workers designated for specific channels - that way, if the websocket channel gets overloaded, HTTP will still respond.\nEdit: I'm well aware that low-level DDoS protection is an ideal solution, and I understand how DDoS attacks work. What I'm looking for is a solution built in to channels that can help handle an increased load like that. Perhaps the ability for Daphne to scale up a channel and scale down another to compensate, or a throttling method that can reduce the weight per request after a certain point. \nI'm looking for a daphne\/channels specific answer - general answers about DDoS or general load handling are not what I'm looking for - there are lots of other questions on SO about that.\nI could also control throttling based on who's logged in and who is not - a throttle for users who are not logged in could help.\nEdit again: Please read the whole question! I am not looking for general DDoS mitigation advice or explanations of low-level approaches. I'm wondering if Daphne has support for something like:\n\nThrottling\nDynamic worker assignment based on queue size\nMiddleware to provide priority to authenticated requests\n\nOr something of that nature. I am also going to reach out to the Channels community directly on this as SO might not be the best place for this question.","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1825,"Q_Id":45122724,"Users Score":0,"Answer":"DDoS = Distributed Denial of Service\nThe 'Distributed' part is the key: you can't know you're being attacked by 'someone' in particular, because requests come from all over the place.\nYour server will only accept a certain number of connections. If the attacker manages to create so many connections that nobody else can connect, you're being DDoS'ed.\nSo, in essence you need to be able to detect that a connection is not legit, or you need to be able to scale up fast to compensate for the limit in number of connections. \nGood luck with that! \nDDoS protection should really be a service from your cloud provider, at the load balancer level.\nCompanies like OVH use sophisticated machine learning techniques to detect illegitimate traffic and ban the IPs acting out in quasi-real time. \nFor you to build such a detection machinery is a huge investment that is probably not worth your time (unless your web site is so critical and will lose millions of $$$ if it's down for a bit)","Q_Score":21,"Tags":"python,django,websocket,django-channels","A_Id":45270805,"CreationDate":"2017-07-15T21:05:00.000","Title":"Load spike protection for Django Channels","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is there anything specific that can be done to help make a Django Channels server less susceptible to light or accidental DDoS attack or general load increase from websocket\/HTTP clients? Since Channels is not truly asynchronous (still workers behind the scenes), I feel like it would be quite easy to take down a Channels-based website - even with fairly simple hardware. I'm currently building an application on Django Channels and will run some tests later to see how it holds up.\nIs there some form of throttling built in to Daphne? Should I implement some application-level throttling? This would still be slow since a worker still handles the throttled request, but the request can be much faster. Is there anything else I can do to attempt to thwart these attacks? \nOne thought I had was to always ensure there are workers designated for specific channels - that way, if the websocket channel gets overloaded, HTTP will still respond.\nEdit: I'm well aware that low-level DDoS protection is an ideal solution, and I understand how DDoS attacks work. What I'm looking for is a solution built in to channels that can help handle an increased load like that. Perhaps the ability for Daphne to scale up a channel and scale down another to compensate, or a throttling method that can reduce the weight per request after a certain point. \nI'm looking for a daphne\/channels specific answer - general answers about DDoS or general load handling are not what I'm looking for - there are lots of other questions on SO about that.\nI could also control throttling based on who's logged in and who is not - a throttle for users who are not logged in could help.\nEdit again: Please read the whole question! I am not looking for general DDoS mitigation advice or explanations of low-level approaches. I'm wondering if Daphne has support for something like:\n\nThrottling\nDynamic worker assignment based on queue size\nMiddleware to provide priority to authenticated requests\n\nOr something of that nature. I am also going to reach out to the Channels community directly on this as SO might not be the best place for this question.","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1825,"Q_Id":45122724,"Users Score":0,"Answer":"Theres a lot of things you cant to do about DDOS..however there are some neat 'tricks' depending on how much resources you have at your disposal, and how much somebody wants to take you offline.\nAre you offering a total public service that requires direct connection to the resource you are trying to protect?\nIf so, you just going to need to 'soak up' DDOS with the resources you have, by scaling up and out... or even elastic... either way it's going to cost you money!\nor make it harder for the attacker to consume your resources. There are number of methods to do this. \nIf you service requires some kind of authentication, then separate your authentication services from the resource you are trying to protect.\nMany applications, the authentication and 'service' run on the same hardware. thats a DOS waiting to happen.\nOnly let fully authenticated users access the resources you are trying to protect with dynamic firewall filtering rules. If your authenticated then gate to the resources opens (with a restricted QOS in place) ! If your a well known, long term trusted users, then access the resource at full bore.\nHave a way of auditing users resource behaviour (network,memory,cpu) , if you see particular accounts using bizarre amounts, ban them, or impose a limit, finally leading to a firewall drop policy of their traffic. \nWork with an ISP that can has systems in place that can drop traffic to your specification at the ISP border.... OVH are your best bet. an ISP that exposes filter and traffic dropping as an API, i wish they existed... basically moving you firewall filtering rules to the AS border... niiiiice! (fantasy)\nIt won't stop DDOS, but will give you a few tools to keep resources wasted a consumption by attackers to a manageable level. DDOS have to turn to your authentication servers... (possible), or compromise many user accounts.... at already authenticated users will still have access :-)\nIf your DDOS are consuming all your ISP bandwidth, thats a harder problem, move to a larger ISP! or move ISP's... :-). Hide you main resource, allow it to be move dynamically, keep on the move! :-). \nBreak the problem into pieces... apply DDOS controls on the smaller pieces. :-)\nI've tried a most general answer, but there are a lot a of depends, each DDOS mitigation requires a bit of Skin, not tin approach.. Really you need a anti-ddos ninja on your team. ;-)\nTake a look at distributed protocols.... DP's maybe the answer for DDOS. \nHave fun.","Q_Score":21,"Tags":"python,django,websocket,django-channels","A_Id":45345786,"CreationDate":"2017-07-15T21:05:00.000","Title":"Load spike protection for Django Channels","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is there anything specific that can be done to help make a Django Channels server less susceptible to light or accidental DDoS attack or general load increase from websocket\/HTTP clients? Since Channels is not truly asynchronous (still workers behind the scenes), I feel like it would be quite easy to take down a Channels-based website - even with fairly simple hardware. I'm currently building an application on Django Channels and will run some tests later to see how it holds up.\nIs there some form of throttling built in to Daphne? Should I implement some application-level throttling? This would still be slow since a worker still handles the throttled request, but the request can be much faster. Is there anything else I can do to attempt to thwart these attacks? \nOne thought I had was to always ensure there are workers designated for specific channels - that way, if the websocket channel gets overloaded, HTTP will still respond.\nEdit: I'm well aware that low-level DDoS protection is an ideal solution, and I understand how DDoS attacks work. What I'm looking for is a solution built in to channels that can help handle an increased load like that. Perhaps the ability for Daphne to scale up a channel and scale down another to compensate, or a throttling method that can reduce the weight per request after a certain point. \nI'm looking for a daphne\/channels specific answer - general answers about DDoS or general load handling are not what I'm looking for - there are lots of other questions on SO about that.\nI could also control throttling based on who's logged in and who is not - a throttle for users who are not logged in could help.\nEdit again: Please read the whole question! I am not looking for general DDoS mitigation advice or explanations of low-level approaches. I'm wondering if Daphne has support for something like:\n\nThrottling\nDynamic worker assignment based on queue size\nMiddleware to provide priority to authenticated requests\n\nOr something of that nature. I am also going to reach out to the Channels community directly on this as SO might not be the best place for this question.","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1825,"Q_Id":45122724,"Users Score":0,"Answer":"Let's apply some analysis to your question. A DDoS is like a DoS but with friends. If you want to avoid DDoS explotation you need minimize DoS possibilities. Thanks capitan obvious.\nFirst thing is to do is make a list with what happens in your system and wich resources are affected:\n\nA tcp handshake is performed (SYN_COOKIES are affected)\nA ssl handshake comes later (entropy, cpu)\nA connection is made to channel layer...\n\nThen monitorize each resource and try to implement a counter-measure:\n\nProtect to SYN_FLOOD configuring your kernel params and firewall\nUse entropy generators\nConfigure your firewall to limit open\/closed connection in short time (easy way to minimize ssl handshakes)\n...\n\nSeparate your big problem (DDoS) in many simple and easy to correct tasks. Hard part is get a detailed list of steps and resources.\nExcuse my poor english.","Q_Score":21,"Tags":"python,django,websocket,django-channels","A_Id":45558858,"CreationDate":"2017-07-15T21:05:00.000","Title":"Load spike protection for Django Channels","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am developing some scripts that I am planning to use in my LAB. Currently I installed Python and all the required modules only locally on the station that I am working with (the development station).\nI would like to be able to run the scripts that i develop through each of my LAB stations.\nWhat is the best practice to do that ?\nWill I need to Install the same environment, except for the IDE of course, in all my stations ? If yes, then what is the recommended way to do that ?\nBy the way, is it mostly recommended to run those scripts from the command line screen (Windows) or is there any other elegant way to do that ?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4897,"Q_Id":45129728,"Users Score":0,"Answer":"If you want to run a single script on multiple computers without installing Python everywhere you can \"compile\" the script to .exe using py2exe, cx_Freeze or PyInstall. The \"compilation\" actually packs Python and libraries into the generated .exe or accompanied files.\nBut if you plan to run many Python scripts you'd better install Python everywhere and distribute your scripts and libraries as Python packages (eggs or wheels).","Q_Score":4,"Tags":"python,python-3.x,automation","A_Id":45130847,"CreationDate":"2017-07-16T14:34:00.000","Title":"What is the best practice for running a python script?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"the question seems not to be concrete enough, so let me explain: I programmed an Webapplication to viszualize data of different sensors in a wireless network. The sensordata is stored in a SQLite-database, which is connected as client to a MQTT-Broker. The whole project is implemented on a RaspberryPi3, which is also the central node of the network.\nFor the whole project I used differnet softwares like apache2, mosquitto, sqlite3. Furthermore the RPi needs to be configurated, so external Hardwre can be connected to it (GPIO, I2C, UART and some modules). \nI wrote an installationguide with more then 60 commands.\nWhat is the most efficient way to write a tool, which installs an configurate the Raspberry with all needed components? (sh, bash, python ...)\nMaybe you can recommend me some guides which explains sh and bash.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":30,"Q_Id":45132753,"Users Score":1,"Answer":"I would configure one installation until you are satisfied and than use dd to clone your sd-card image. You can us dd again to perform the installation on another raspi.\nBest regards, Georg","Q_Score":0,"Tags":"python,bash,installation,sh,raspberry-pi3","A_Id":45138161,"CreationDate":"2017-07-16T19:53:00.000","Title":"How to program a tool which combines different components? (RPi)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I get the \u0398(1) part is the time that uses to calculate hash table, but I don't understand the \u0398(\u03b1) part. \nIn my view, the time complexity is \u0398(n). Assume \u03b1 is the expected length and the table has m slots. To ensure the key is not in the table, we need to search each slot, and each slot has \u03b1 excepted length, so the total time is \u03b1 times m, then it's \u0398(n). \nCould anyone tell me which part I didn't understand correctly?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1052,"Q_Id":45132902,"Users Score":2,"Answer":"Testing if a given key is in the hash table doesn't need to test all slots. You simply calculate the hash value for the given key (1). This hash value identifies which slot the key has to be in, if it is in the hash table. So, you simply need to compare all entries (\u03b1) in that slot with the given key, yielding \u0398(1+\u03b1). You don't need to look at the other slots because the key cannot be stored in any of the other slots.","Q_Score":0,"Tags":"python,algorithm,hash,hashmap,hashtable","A_Id":45133269,"CreationDate":"2017-07-16T20:12:00.000","Title":"Why has an unsuccessful search time for a hash table a time complexity \u0398(1+\u03b1)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"There have been many questions and answers about the relative benefits of static and dynamic typing. Each has their camp, and there are obviously good reasons for both. I'm wondering though, are there any specific features of Python that wouldn't be possible to implement or use in a statically-typed language?\nI would expect that some of the more functional parts would be challenging, but we obviously have Haskell and C++14 and onward.\nAgain, specific examples would be appreciated!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":67,"Q_Id":45146249,"Users Score":1,"Answer":"It is not possible to implement a list of heterogeneous types if you don't know all types you'll need at compile time.\nExample: you load with input() a user script that defines a new value of a new type defined there.\nThen you want to insert that value in a list in your program.\nI guess a lot of thing that come from interactions with input() are impossible to implement.","Q_Score":0,"Tags":"python,types,paradigms","A_Id":45202415,"CreationDate":"2017-07-17T13:57:00.000","Title":"What Python features wouldn't be possible with static typing?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way to determine which Redis Python modules are installed by default? I do not have a Redis installation, but would like to know for planning purposes.\nThank you.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":104,"Q_Id":45154390,"Users Score":0,"Answer":"None of the Redis client modules are part of the Python standard library. \nTo work with Redis, you will need to install a client module, I recommend redis-py, using your preferred package manager.","Q_Score":0,"Tags":"python,redis","A_Id":45154433,"CreationDate":"2017-07-17T22:05:00.000","Title":"Redis Python modules installed by default","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am coding Python3 in Vim and would like to enable autocompletion.\nI must use different computers without internet access. Every computer is running Linux with Vim preinstalled.\nI dont want to have something to install, I just want the simplest way to enable python3 completion (even if it is not the best completion), just something easy to enable from scratch on a new Linux computer.\nMany thanks","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2519,"Q_Id":45168222,"Users Score":0,"Answer":"by default, Ctrl-P in insert mode do an autocompletion with all the words already present in the file you're editing","Q_Score":4,"Tags":"python,linux,vim","A_Id":45168297,"CreationDate":"2017-07-18T13:29:00.000","Title":"Enable python autocompletion in Vim without any install","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am halfway in the development of a large Flask web application.\nBack in the beginning I chose not to use test-driven-development, for learning curve vs project deadline reasons.\nThus these last weeks I had the opportunity to learn more about it, and I am quite exited about starting to use it.\nHowever, regarding I didn't wrap my project with TDD from the start, is there any cons of starting to use it now ?\nI would not refactor my entire app, only the new features I am going to design in the near future.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":140,"Q_Id":45169563,"Users Score":0,"Answer":"Agree with the previous answer. Yes, you can start using TDD at every single point of development.\nWhen you try the 'red line' tests which should fall at the beginning there is no surprise for you that they show up lack of functionality. \nWhen you start implementing TDD on the big system with a huge amount of code already in you should check first for some functionality availability by also writing the test (or the group of tests). Then if it works well you carry on until the test start showing up the limits of code's potential.\nWould add that if you start now and decide to cover not only the new features (but the old ones as well as mentioned above) at this point you more likely will spend more time for the old features.\nAnd in that case it would not be called pure TDD (just saying) since some tests is going to be implemented after the code has been written but if it's suitable for the project that's also the option (definitely could worth it). And still it's most likely better to test something now than on the beta-testing stage. At least because it will be easier to come across the solution if you find something is going wrong with your old features. \nSo later you test so harder it's getting to solve the issues. It takes more time then. And if the people apply tests long time after the code has been written it comes to the double work since you need to rethink how your code works. That`s why in the TDD writing the tests goes almost along with writing the code. Even at this point it's probably easier for you to remember what you were coding at the beginning.","Q_Score":3,"Tags":"python,unit-testing,testing,tdd","A_Id":45198217,"CreationDate":"2017-07-18T14:24:00.000","Title":"Starting TDD halfway a project, good practice?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am halfway in the development of a large Flask web application.\nBack in the beginning I chose not to use test-driven-development, for learning curve vs project deadline reasons.\nThus these last weeks I had the opportunity to learn more about it, and I am quite exited about starting to use it.\nHowever, regarding I didn't wrap my project with TDD from the start, is there any cons of starting to use it now ?\nI would not refactor my entire app, only the new features I am going to design in the near future.","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":140,"Q_Id":45169563,"Users Score":3,"Answer":"TDD \"done right\" is always good practice - no matter at which point in time you start using it.\nBut in order to avoid getting to a situation where one part of the code base is nicely unit-tested and others are not: look for ways to not only cover new features. In other words: if time allows don't only test those parts of a file\/class that a new feature will go into - but instead try to get that whole unit into \"tests\". \nThe core aspect of unit tests is that they allow you to make changes to your code base without breaking things. Unit tests enable you to go with higher speed. Thus look for ways to ensure that you can go with \"high speed\" for the majority of your code base.","Q_Score":3,"Tags":"python,unit-testing,testing,tdd","A_Id":45183671,"CreationDate":"2017-07-18T14:24:00.000","Title":"Starting TDD halfway a project, good practice?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm afraid this issue might be too idiosyncratic but maybe someone can point me in the right direction via questions or hypotheses. \nI'm using psychoPy 1.84.2 which uses python 2.7. The computers I am hoping to use for my study are dells running windows 10 enterprise. \nThe issue is that ~80% of the time mouse clicks are completely missed and keyboard presses take 3-4 seconds to have an effect in my program. 20% of the time, there is no issue. While this is happening, I can still see the mouse cursor moving and I can open up programs and folders on the desktop and click around the psychoPy GUI without any lag. Additionally, videos played in the python window run fine.\nThese same files run perfectly well on two different macs but fail on the 10 dell desktops I was hoping to use for my study. Lastly, I did try using psychoPy 1.85.1 but had the same issues (plus a couple more). \nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":312,"Q_Id":45200604,"Users Score":0,"Answer":"Windows 10 enterprise can sometimes limit cpu bandwidth to certain programs at times.","Q_Score":0,"Tags":"python,python-2.7,psychopy","A_Id":45201798,"CreationDate":"2017-07-19T20:40:00.000","Title":"mouse and keyboard presses are missed or slow in python window","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm pretty new to programming and I've made a small Python application with tkinter and would like to host it on my GoDaddy website. I just can't seem to figure out how to connect the two.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1443,"Q_Id":45257330,"Users Score":0,"Answer":"You cannot run tkinter applications via a website.","Q_Score":2,"Tags":"wordpress,python-3.x,rest","A_Id":45266601,"CreationDate":"2017-07-22T17:23:00.000","Title":"How to get a Python script running on GoDaddy hosting?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm pretty new to programming and I've made a small Python application with tkinter and would like to host it on my GoDaddy website. I just can't seem to figure out how to connect the two.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1443,"Q_Id":45257330,"Users Score":1,"Answer":"If you have shared hosting account, Then you cannot use python scripts on go daddy. Because both cpanel and plesk shared hosting account does not support python. If you have deluxe or premium types hosting account then yes you can use python scripts. Even there also you can't use the modules which requires a compiler within virtual environment. \nYou have to enable SSH. For more you must contact their helping team..","Q_Score":2,"Tags":"wordpress,python-3.x,rest","A_Id":45258321,"CreationDate":"2017-07-22T17:23:00.000","Title":"How to get a Python script running on GoDaddy hosting?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just purchased a \"Kano\" (raspberry pi) for my daughter, and we're trying to create a python script using the terminal. I've been using the nano text editor, and so far it's been going well, but I know that there are better code editors for python.\nDoes anyone have a recommendation for a code editor for python that I can launch from the LXTerminal? For example, in a manner similar to how the nano editor is launched to edit a python script (\"nano mygame.py\")\nIdeally, I want something that comes re-installed with kano\/Debian that I can use out of the box, which is very user-friendly. I feel like always having to resort to ^O and ^X etc. to save and exit is really not user-friendly. Also, nano doesn't seem to have good syntax highlighting and indentation, etc. which would be nice for coding.\nI have the Pi 3 with all the latest software updates (as of the writing of this post)\nthanks, \nDarren","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":455,"Q_Id":45259272,"Users Score":1,"Answer":"For editing text using the terminal vim is an excellent choice (vim mygame.py). Initially it is going to be confusing, because it has two different modes and it is easy to forget which one you are in. But in the long term learning it will pay off, because it can do some incredible things for you. Once you get used to it, it will make nano look like a bad joke. And this is probably the best time for your daughter to learn it: later on it is only going to get more difficult to learn a more abstract, and more powerful editor.\nThe first thing to remember is that initially, after starting vim, you are in command mode so you cannot type text like you would expect. To change into editing mode, just press i (without a colon), then you can type text like in any other editor, until you press Esc, which goes back to command mode. Commands start with a colon. For example you can quit vim by typing :q (with the colon) and then pressing Enter. You write the file (i.e. save your changes) using :w. You can give it a filename too, which works exactly like \"Save as...\". To open another file for editing you can use :e otherfile.py.\nThese were the most essential things I could think of, but there are other modes for selecting lines, characters, rectangular blocks. For copy & pasting, and other things I would recommend going through a tutorial, or just searching for vim copy paste or whatever is needed. I cannot emphasize enough that it is worth learning these, because of the advanced features of the editor, especially if you are planning to use the editor for coding! As a quick example, you can completely reindent your whole code by typing gg=G in command mode.\nThe default settings of vim will give you a very basic look and feel, but you can download (and later customize) a .vimrc file which simply goes into your home directory, and from then on this will be used at every start. If you just Google vimrc, you will find a lots of good examples to start with, which will turn on syntax highlighting with pretty colours, and give you some more sensible settings in general. I would recommend downloading one or two versions of the .vimrc file early on, and trying out the difference it can make.\nAnother option would be emacs, which is equally powerful, and equally confusing for a beginner. If you want an editor that is intuitive using the terminal, nano is probably your best bet, from those that are installed by default. Yes, nano counts as intuitive. Anything else will be somewhat more difficult, and far more powerful.","Q_Score":0,"Tags":"python,raspberry-pi,debian,raspberry-pi3","A_Id":45259716,"CreationDate":"2017-07-22T21:11:00.000","Title":"user-friendly python code editor in debian (raspberry pi)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just purchased a \"Kano\" (raspberry pi) for my daughter, and we're trying to create a python script using the terminal. I've been using the nano text editor, and so far it's been going well, but I know that there are better code editors for python.\nDoes anyone have a recommendation for a code editor for python that I can launch from the LXTerminal? For example, in a manner similar to how the nano editor is launched to edit a python script (\"nano mygame.py\")\nIdeally, I want something that comes re-installed with kano\/Debian that I can use out of the box, which is very user-friendly. I feel like always having to resort to ^O and ^X etc. to save and exit is really not user-friendly. Also, nano doesn't seem to have good syntax highlighting and indentation, etc. which would be nice for coding.\nI have the Pi 3 with all the latest software updates (as of the writing of this post)\nthanks, \nDarren","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":455,"Q_Id":45259272,"Users Score":0,"Answer":"Geany is a nice little GUI editor in Raspbian. I use it over nano every time. No frills. but familiar menu commands and easy interface.","Q_Score":0,"Tags":"python,raspberry-pi,debian,raspberry-pi3","A_Id":45260780,"CreationDate":"2017-07-22T21:11:00.000","Title":"user-friendly python code editor in debian (raspberry pi)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed pygsheets module with this command: pip install https:\/\/github.com\/nithinmurali\/pygsheets\/archive\/master.zip\nWhen I tried to execute script, I got following error:\n\nTraceback (most recent call last): File\n \"\/usr\/local\/bin\/speedtest-to-google\", line 7, in \n import pygsheets ImportError: No module named 'pygsheets'\n\nI executed pip list and found: pygsheets (v1.1.2).","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":5115,"Q_Id":45263446,"Users Score":3,"Answer":"Use\npip3 install command to access it","Q_Score":1,"Tags":"python,pip,pygsheets","A_Id":46321626,"CreationDate":"2017-07-23T09:15:00.000","Title":"ImportError: No module named 'pygsheets'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed pygsheets module with this command: pip install https:\/\/github.com\/nithinmurali\/pygsheets\/archive\/master.zip\nWhen I tried to execute script, I got following error:\n\nTraceback (most recent call last): File\n \"\/usr\/local\/bin\/speedtest-to-google\", line 7, in \n import pygsheets ImportError: No module named 'pygsheets'\n\nI executed pip list and found: pygsheets (v1.1.2).","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":5115,"Q_Id":45263446,"Users Score":1,"Answer":"Script uses Python3 packages, so command pip3 install has to be used.","Q_Score":1,"Tags":"python,pip,pygsheets","A_Id":45689214,"CreationDate":"2017-07-23T09:15:00.000","Title":"ImportError: No module named 'pygsheets'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In the configuration for my Pyhon 3.6 AWS Lambda function I set the environment variable \"PYTHONVERBOSE\" with a setting of 1\nThen in the Cloudwatch logs for my function it shows lots of messages similar to:\ncould not create '\/var\/task\/pycache\/auth.cpython-36.pyc': OSError(30, 'Read-only file system')\nIs this important? Do I need to fix it?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":868,"Q_Id":45270330,"Users Score":1,"Answer":"I don't think you can write in the \/var\/task\/ folder. If you want to write something to disk inside of the lambda runtime try the \/tmp folder.","Q_Score":1,"Tags":"python-3.x,aws-lambda","A_Id":46840601,"CreationDate":"2017-07-23T22:10:00.000","Title":"AWS Lambda Python lots of \"could not create '\/var\/task\/__pycache__\/FILENAMEpyc'\" messages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"Iv written a script that uses the adafruit motor hat library to control motors when it recives 433MHz ex transmitted codes! Very short range at the moment however this is the best way for my project! \nThe problem is the 433MHz rx\/tx library is python3 and won't work on python2\nAnd the adafruit_motor_hat_library is pyrhon2 and wont work on pyrhon3?\nAs I need both of these to work in the same scrip how can I go about this?\nAlso if I try and run from command line it won't work, (if I python3.scrip.py it brings up error with adafruit motor hat, if I python.script.py it brings up error on 433MHz? \nIf anybody needs my full scrip I can copy and past it here but as the problem doesn't seem to be with the actual scrip it seemed pretty pointless! But if you need it I can provide it","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":293,"Q_Id":45310817,"Users Score":1,"Answer":"To save time, I would convert the smaller of the two libraries you mention to the other version. If they're about the same size, I'd convert the 2.x library to 3. The motor hat library is only ~350 lines of code, much of which will not change in conversion to 3.x. Would be a good self-teaching exercise...","Q_Score":2,"Tags":"python,python-2.7,python-3.x","A_Id":45310903,"CreationDate":"2017-07-25T18:14:00.000","Title":"Adafruit motor hat python3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have web application which made by symfony2(php framework)\nSo there is mysql database handled by doctrine2 php source code.\nNow I want to control this DB from python script.\nOf course I can access directly to DB from python.\nHowever, it is complex and might break the doctrine2 rule.\nIs there a good way to access database via php doctrine from python??","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":153,"Q_Id":45371167,"Users Score":0,"Answer":"You can try the Django ORM or SQL Alchemy but the configuration of the models have to be done very carefully. Maybe you can write a parser from Doctrine2 config files to Django models. If you do, open source it please.","Q_Score":0,"Tags":"php,python,symfony,frameworks","A_Id":45375722,"CreationDate":"2017-07-28T10:31:00.000","Title":"How to access doctrine database made by php from python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm a little confused as to how the PVM gets the cpu to carry out the bytecode instructions. I had read somewhere on StackOverflow that it doesn't convert byte-code to machine code, (alas, I can't find the thread now). \nDoes it already have tons of pre-compiled machine instructions hard-coded that it runs\/chooses one of those depending on the byte code?\nThank you.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2285,"Q_Id":45380268,"Users Score":2,"Answer":"If you mean Standard Python (CPython) by Python, then no! The byte-code (.pyc or .pyo files) are just a binary version of your code line by line, and is interpreted at run-time. But if you use pypy, yes! It has a JIT Compiler and it runs your byte-codeas like Java dn .NET (CLR).","Q_Score":6,"Tags":"python","A_Id":45380349,"CreationDate":"2017-07-28T18:36:00.000","Title":"Does the Python Virtual Machine (CPython) convert bytecode into machine language?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"With python social auth, when a user is logged in when he clicks 'Login with Facebook' or similar. \nThe request.user is not the newly logged in facebook user but the old logged in user. \n\nlog in with email test1@gmail.com\nlog in with facebook email test-facebook@gmail.com\n\nLogged in user (request.user) is still test1@gmail.com\nIs this intended behavior? \nIs there a way to fix this or should I not present log-in unless he's not logged out?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":49,"Q_Id":45412902,"Users Score":0,"Answer":"If there's a user already logged in in your app, then python-social-auth will associate the social account with that user, if it should be another user, then the first must be logged out. Basically python-social-auth will create new users if there's none logged in at the moment, otherwise it will associate the the social account.","Q_Score":0,"Tags":"django,python-social-auth","A_Id":45424674,"CreationDate":"2017-07-31T10:05:00.000","Title":"python social auth, log in without logging out","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I mean while you transfer python to executable, if the following python script has some modules imported, how will any other device will run the executable file if it doesn't have python installed without the modules?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":50,"Q_Id":45422064,"Users Score":0,"Answer":"The generated executable is essentially a packaged combination of the python interpreter and the compiled (.pyc) files, including any imported packages that might be necessary.","Q_Score":0,"Tags":"python,py2exe","A_Id":45422227,"CreationDate":"2017-07-31T17:35:00.000","Title":"Something that I don't understand about python to executable file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have successfully overridden the __getattr__ method in order to allow for complex behavior. However I still would like to allow some of the __builtin__ functions to be default. For example, I have used __getattr__ to handle __add__, __sub__, __mul__, etc. However, the __iadd__, __isub__, __imul__, etc. are trying to use the __getattr__ method and are throwing an error. I could just define their behaviors as well, but I think that allowing these methods to run as default would be better.\nBottom line: I would like to allow __getattr__ to filter which attributes it handles, and which it allows to run as default.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":136,"Q_Id":45443475,"Users Score":0,"Answer":"Answered my own question. I used if statements to handle groups of attributes, and then as a last resort, used return getattr(my_cls_name, attr) to allow any other builtin function to run normally. So now when it realizes there is no __iadd__ handler, it uses my __add__ instead. same with the other operators.","Q_Score":1,"Tags":"python,function,methods,getattr","A_Id":45451015,"CreationDate":"2017-08-01T16:47:00.000","Title":"python: selectively override __getattr__","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Following the guidelines to build Debian package from a Python files powered by Flassger.\nWhen running a build getting an error:\n\nImportError: No module named swagger_spec_validator.util\n\nWhich mean, that test.py doesn't see swagger_spec_validator.\nThere seem to be no Swagger related pakcages for Debian at all. Should the swagger_spec_validator be included somewhere in debian\/control file?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":164,"Q_Id":45467330,"Users Score":1,"Answer":"If swagger is the dependency of the software you package and it is not available in Debian, You'll need to package it before.\nIf swagger is a dependency for test suite only, you may consider modifying or disabling the test.py by creating a patch in d\/patches for example..","Q_Score":0,"Tags":"python,debian,packages,flasgger","A_Id":45478342,"CreationDate":"2017-08-02T17:24:00.000","Title":"Python into Debian package: No module named error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Newbie to linux, I thought that apt-get purge is usually used to remove a pkg totally, but today it neally crash my whold system. I want to remove a previously installed python 3.4 distribution, but I'm not sure which pkg it belongs, so I used find \/usr -type f -name \"python3.4\" to find it, the command returns several lines, the first one is \/usr\/bin\/python3.4, so then I typed dpkg -S \/usr\/bin\/python3.4 to determine which pkg python3.4 belongs, it returns python-minimal, so I typed sudo apt-get purge python-minimal, but then a lot of pkgs was removed, also some installed, I'm totally confused, and I saw even the app store disappeared, a lot of the system was removed... Can someone help me?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3227,"Q_Id":45473744,"Users Score":3,"Answer":"When you run apt purge or apt remove you are not only instructing apt to remove the named package, but any other package that depends on it. Of course apt doesn't perform that unexpected operation without first asking for your consent, so I imagine it showed the list of packages that it was going to remove, and when you pressed Y it removed all of them.\nSo, to undo the mess, if you still have the window where you run the purge then check which packages it told you it was going to remove, and manually apt install them. If you don't have the list around, then you need to manually install every package that is not working properly.\nIf it is the window manager that got damaged, try apt-get install ubuntu-gnome-desktop or the appropriate package for your distribution\/window manager.\nRule of thumb when deleting\/updating packages: always read the list of packages affected, sometimes there is unexpected stuff.","Q_Score":0,"Tags":"python,linux","A_Id":45473958,"CreationDate":"2017-08-03T02:18:00.000","Title":"What did apt-get purge do?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"If I pass text through python cyrillic text turns to \\u****\nThere are a lot of ways to handle it inside py-scripts but I also use python as handly json formatter (json.tool)\nI tried CMD.exe, powershell and MINGW bash","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1082,"Q_Id":45478674,"Users Score":2,"Answer":"This is not a problem. It is the correct encoding for non-ASCII text in JSON.","Q_Score":0,"Tags":"python,json,unicode","A_Id":45478864,"CreationDate":"2017-08-03T08:21:00.000","Title":"python json.tool and unicode escape","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Working with scientific data, specifically climate data, I am constantly hard-coding paths to data directories in my Python code. Even if I were to write the most extensible code in the world, the hard-coded file paths prevent it from ever being truly portable. I also feel like having information about the file system of your machine coded in your programs could be security issue.\nWhat solutions are out there for handling the configuration of paths in Python to avoid having to code them out explicitly?","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":6241,"Q_Id":45507805,"Users Score":1,"Answer":"I believe there are many ways around this, but here is what I would do:\n\nCreate a JSON config file with all the paths I need defined.\nFor even more portability, I'd have a default path where I look for this config file but also have a command line input to change it.","Q_Score":3,"Tags":"python","A_Id":45507877,"CreationDate":"2017-08-04T13:13:00.000","Title":"Methods to avoid hard-coding file paths in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am going through a book on Python which spends a decent time on module reloading, but does not explain well when it would be useful. \nHence, I am wondering, what are some real-life examples of when such technique becomes handy?\nThat is, I understand what reloading does. I am trying to understand how one would use it in real world.\nEdit:\nI am not suggesting that this technique is not useful. Instead, I am trying to learn more about its applications as it seems quite cool.\nAlso, I think people who marked this question as duplicate took no time to actually read the question and how it is different from the proposed duplicate. \nI am not asking HOW TO reload a module in Python. I already know how to do that. I am asking WHY one would want to reload a module in Python in real life. There is a huge difference in nature of these questions.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":92,"Q_Id":45513191,"Users Score":0,"Answer":"As an appendix to DYZ's answer, I use module reloading when analysing large data in interactive Python interpreter.\nLoading and preprocessing of the data takes some time and I prefer to keep them in the memory (in a module BTW) rather than restart the interpreter every time I change something in my modules.","Q_Score":4,"Tags":"python,python-3.x,module,reload","A_Id":47103371,"CreationDate":"2017-08-04T18:17:00.000","Title":"Real-life module reloading in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using ReportLab to create invoices. Since my customers can have various characters in their names (german, polish, russian letters), I want them displayed correctly in my PDFs.\nI know the key is to have a proper font style. Which font can handle all UTF-8 characters with no problems?\nIf there is no such font, how can I solve this?","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":831,"Q_Id":45521248,"Users Score":-1,"Answer":"I think you need to lower your sights a little. All UTF-8 characters is a really tall order. Do you really need Chinese, Japanese, Telugu, Hebrew, Arabic and emojis?\nYou have listed German, Polish and Russian. So you need a good coverage of Latin characters, plus Cyrillic. \nOn Windows, both Arial and Times New Roman will give you that. If you really do need Telugu and other East Asian writing systems then Arial Unicode MS has probably as much coverage as you are likely to want.","Q_Score":0,"Tags":"python,pdf,encoding,character-encoding,reportlab","A_Id":45521777,"CreationDate":"2017-08-05T11:12:00.000","Title":"UTF-8 font style for ReportLab","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm creating a Facebook Messenger Bot thats powered by a python backend.\nI'm promoting my bot via FB ads and am trying to figure out if theres any possible way to use Pixel's Conversion tracking to improve metrics (pretty sure facebook's ad placement trys to optimize based on conversion results)\nAnyone know if this is possible? Everything I'm finding so far is javascript code that you need to put on your website, and I don't have or need a website for my bot.\nThanks!","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":632,"Q_Id":45557554,"Users Score":0,"Answer":"Think I figured it out.. User clicks ad -> opens up a website to get the pixel conversion hit -> immediate re-direct back to messenger.","Q_Score":0,"Tags":"python,facebook,facebook-graph-api,bots,messenger","A_Id":45558293,"CreationDate":"2017-08-08T00:33:00.000","Title":"Facebook Ad Pixel Conversion tracking for Messenger Bot","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm creating a Facebook Messenger Bot thats powered by a python backend.\nI'm promoting my bot via FB ads and am trying to figure out if theres any possible way to use Pixel's Conversion tracking to improve metrics (pretty sure facebook's ad placement trys to optimize based on conversion results)\nAnyone know if this is possible? Everything I'm finding so far is javascript code that you need to put on your website, and I don't have or need a website for my bot.\nThanks!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":632,"Q_Id":45557554,"Users Score":0,"Answer":"\"User clicks ad \n-> opens up a website to get the pixel conversion hit \n-> immediate re-direct back to messenger\"\nI don't see how this is helping, as the pixel conversion hit happens before any action happens within the chat. \nIf you want to track a certain action within the chat, couldn't you redirect to a website and re-direct back to the chat from within the chat, say in the middle of the question flow?","Q_Score":0,"Tags":"python,facebook,facebook-graph-api,bots,messenger","A_Id":45763816,"CreationDate":"2017-08-08T00:33:00.000","Title":"Facebook Ad Pixel Conversion tracking for Messenger Bot","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working python 2.7 some codes which needs to import module from the other Github repository, any suggestions on what's the best way to import the module? I could git clone the other Github repository to local, but what if there is a change I am not aware of so I still need to sync. Or should I pull the code from Github directly? Thanks in advance.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":377,"Q_Id":45557791,"Users Score":1,"Answer":"Personally I would clone it to local and then reference the module from there. If a bug suddenly surfaces in the most recent commits from the module, it may impact your application right away. By keeping a stable version on your local, it would eliminate one more place to check during debugging of your application.\nOf course, if you pull the module from GitHub directly then you'll get all the latest updates and features, but I would do that if the module is thoroughly tested before it gets committed.\nThis is just my two cents. Hope that helps.","Q_Score":0,"Tags":"python,git,python-2.7,github","A_Id":45558306,"CreationDate":"2017-08-08T01:09:00.000","Title":"Suggestion on import python module from another github project","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to host a database on my raspberry pi to which I can access from any device. I would like to access the contents of the database using python. \nWhat I've done so far:\n\nI installed the necessary mysql packages, including apache 2. \nI created my first database which I named test.\nI wrote a simple php\n script that connects and displays all the contents of my simple\n database. The script is located on the raspberry pi at \/var\/www\/html\n and is executed when I enter the following from my laptop\n (192.168.3.14\/select.php)\n\nNow my goal is to be able to connect to the database using python from my laptop. But I seem to have an error connecting to it, this is what I wrote to connect to it.\ndb = MySQLdb.connect(\"192.168.3.14\",\"root\",\"12345\",\"test\" ) \nAny help or direction is appreciated.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":104,"Q_Id":45593608,"Users Score":1,"Answer":"on the terminal of your raspi use the following command:\nmysql -u -p -h --port\nwhere you switch out your hostname with your ip address. since currently you can only connect via local host","Q_Score":0,"Tags":"php,python,mysql","A_Id":45593914,"CreationDate":"2017-08-09T14:31:00.000","Title":"Raspberry Pi Database Server","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am capturing an image from PHP script from webcam and I want to send it to python script so that I can use OpenCV feature homography functions on it. How can I send an image using exec command in PHP and pass that image to cv2.imread() function in python? \nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":438,"Q_Id":45627467,"Users Score":0,"Answer":"Well, I believe that if you want to use cv2.imread you need to have a file, because one of the parameters is a file name and that is going to make everythins slower and resource consuming.\nI think that what you want to use is cv2.imdecode (similar to imread by in memory), in which case you only need to turn your image into the correct type of stream, a numpy array for example.\nI would also consider to process everything on python at once if you want to take in account performance.","Q_Score":1,"Tags":"php,python,opencv","A_Id":45742503,"CreationDate":"2017-08-11T05:18:00.000","Title":"How to send a image captured from webcam in PHP to Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I am working on a project that has a Raspberry Pi connected to a Serial Device via a USB to Serial Connector. I am trying to use PySerial to track the data being sent over the connected Serial device, however there is a problem.\nCurrently, I have my project set up so that every 5 seconds it calls a custom port.open() method I have created, which returns True if the port is actually open. This is so that I don't have to have the Serial Device plugged in when I initially go to start the program.\nHowever I'd also like to set it up so that the program can also detect when my serial device is disconnected, and then reconnected. But I am not sure how to accomplish this.\nIf I attempt to use the PySerial method isOpen() to check if the device is there, I am always having it return true as long as the USB to Serial connector is plugged in, even if I have no Serial device hooked up to the connector itself.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1786,"Q_Id":45634854,"Users Score":0,"Answer":"You might be able to tell whether the device is physically plugged in by checking the status of one of the RS232 control lines - CTS, DSR, RI, or CD (all of which are exposed as properties in PySerial). Not all USB-serial adapters support any of these.\nIf the only connection to the device is the TX\/RX lines, your choices are extremely limited:\n\nSend a command to the device and see if it responds. Hopefully its protocol includes a do-nothing command for this purpose.\nIf the device sends data periodically without needing an explicit command, save a timestamp whenever data is received, and return False if it's been significantly longer than the period since the last reception.","Q_Score":0,"Tags":"python,raspberry-pi,pyserial","A_Id":45635399,"CreationDate":"2017-08-11T12:07:00.000","Title":"PySerial, check if Serial is Connected","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Im using spidev on a raspberry pi 3 to communicate with 2 spi devices.\nOne on GPIO8 and one on GPIO16.\nSpidev requires a parameter for CS but GPIO16 is not a CS line. How do I fix this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":162,"Q_Id":45637732,"Users Score":0,"Answer":"I fixed it by connecting the spi devices to other pins.","Q_Score":0,"Tags":"python,raspberry-pi,gpio,spi","A_Id":45734337,"CreationDate":"2017-08-11T14:32:00.000","Title":"spidev software CS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"As a sys admin I am trying to simulate a user on a virtual machine for testing log file monitoring. \nThe simulated user will be automated to perform various tasks that should show up in bash history, \"ls\", \"cd\", \"touch\" etc. It is important that they show up in bash history because the bash history is logged. \nI have thought about writing directly to the bash history but would prefer to more accurately simulate a users behavior. The reason being that the bash history is not the only log file being watched and it would be better if logs for the same event remained synchronized. \nDetails\nI am working on CentOS Linux release 7.3.1611\nPython 2.7.5 is installed \nI have already tried to use pexpect.run('ls') or pexpect.spawn('ls'), 'ls' does not show up in the bash history with either command.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1718,"Q_Id":45646104,"Users Score":0,"Answer":"The short answer appears to be no you cannot do this with pexpect. \nAuditd is a possible alternative for tracking user input, but I have not figured out how to get it to record commands such as 'ls' and 'cd' because they do not call the system execve() command. The best work around I have found is to use the script command which opens another interactive terminal where every command entered in the prompt is recorded. You can use the file the script command outputs to (by default is typescript) to log all user commands.","Q_Score":0,"Tags":"python,linux,bash,shell,pexpect","A_Id":45718528,"CreationDate":"2017-08-12T03:05:00.000","Title":"Is it possible to use pexpect to generate bash shell commands that will show up in bash history?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am very new to Python and I saw many projects on Github using Mock to do their test but I don't understand why.\n When we use mock, we construct a Mock object with a specific return_value, I don't truely understand why we do this. I know sometimes it is difficult to build our needed resources but what is the point if we construct a object\/function with a certain return value ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":58,"Q_Id":45656981,"Users Score":0,"Answer":"Mock can help to write unit tests. \nIn unit tests, you want to test a small portion of your implementation. For example, as small as one function or one class. \nIn a moderately large software, these small parts depend on each other. Or sometimes there are external dependencies. You open files, do syscalls, or get external data in some other way. \nWhile writing a directed unit test for a small portion of your code, you do not want to spend time to set-up everything else around it. (The files, syscalls, external data). Mock comes to your help there. With mock, you can make the other dependencies of your code behave exactly as you like. This way you can focus on testing your intended implementation. \nComing to the mock with the return value: Say you want to test func_a. And func_a calls func_b. func_b does a lot of funky processing to calculate its return value. For example, talking to an external service, doing bunch of syscalls, or some other expensive operation. Since you are testing func_a, you only care about possible return values of func_b. (So that func_a can use them) In this scenario you would mock func_b and set the return values explicitly. This can really simplify your test complexity.","Q_Score":0,"Tags":"python,unit-testing","A_Id":45657800,"CreationDate":"2017-08-13T04:11:00.000","Title":"Python - Why we should use mock to do test?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"The prog asks me to check whether any special char like !@#... are present in the given string. How can I do this?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":355,"Q_Id":45657358,"Users Score":0,"Answer":"Try this any(x in string for x in '@#!')","Q_Score":0,"Tags":"python","A_Id":45657424,"CreationDate":"2017-08-13T05:20:00.000","Title":"How to check whether there is any special characters present in the given string using python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to use something like pytest for very basic testing using simple asserts. Is pytest the best choice for this or are there better recent alternatives?","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1708,"Q_Id":45678559,"Users Score":3,"Answer":"To the best of my knowledge, py.test is still the business!","Q_Score":2,"Tags":"python,pytest","A_Id":45678620,"CreationDate":"2017-08-14T16:03:00.000","Title":"Is there a recent pytest alternative with simple \"assert\"?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have added a git submodule in my project. Now all the imports in that submodule are broken because I have to use the full path of import. \nFor example, if the structure is like this: \nMyproject:\n- submodule_project:\n-- package1:\n--- code1.py\n-- package2:\n--- code2.py \nNow, in code1.py there is from package2 import code2. It tells me that package2 is unresolved reference. It is only resolved if I change it to from submodule_project.package2 import code2.\nI don't want this because I don't want to change anything in the submodule. I just added it to use some of its packages in my project and to get regularly updated whenever its developers update it.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":52,"Q_Id":45693078,"Users Score":0,"Answer":"If you want package2 to be a top-level importable package its parent directory (submodule_project in your case) has to be in sys.path. There are many way to do it: sys.path.append(), sys.path.insert(), PYTHONPATH environment variable.\nOr may be you don't want to have the code as a submodule at all. It doesn't make sense to have a submodule if the code in the submodule uses absolute import instead of relative (from ..package2 import code2). May be the package should be installed in site-packages (global or in a virtual environment) but not attached to the project as a submodule.","Q_Score":0,"Tags":"python,git,import,git-submodules","A_Id":45695609,"CreationDate":"2017-08-15T12:42:00.000","Title":"python importing level 2 packages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a listner which updates test result to test management tool at end_test. The problem is when run in dryrun mode it update every thing as Passed which is False result.\nIs there a way I can access ROBOT_OPTIONS in my listener because it will have all the command line options, OR is there an alternative way of checked if -dryrun is enabled in my listener library","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":464,"Q_Id":45697068,"Users Score":3,"Answer":"There's nothing that is officially supported. Though, a solution that might work for you is to import sys, and then scan sys.argv for the --dryrun option. This won't work if you have the dry run argument inside an argument file. \nAnother simple solution is for you to define a variable when you specify the dry run flag (eg: robot --dryrun --variable DRYRUN:True), and then your logic can use that variable.","Q_Score":4,"Tags":"python,robotframework","A_Id":45698543,"CreationDate":"2017-08-15T16:20:00.000","Title":"In my listener how to check if dryrun flag is set or not","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Raspberry Pi running a Python script posting data to a database on my server. So I would like to do the inverse of this. I need this raspberry pi to do some actions when they are called from the website.\nWhat would be the best approach?\nMaybe open some port and start listening for events there?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":33,"Q_Id":45697524,"Users Score":0,"Answer":"There are two simple ways to achieve this. You haven't described what sort of actions you are processing so the following is quite generic.\n\nPolling\n\nHave a master that all of the workers (pi) connect to and poll to get any work. The workers can do the work and send data back to the master.\n\nEvent driven\n\nRun an API on each pi that your master can call for each event. This is going to be the most performant but will probably require more work.","Q_Score":0,"Tags":"php,python,api,raspberry-pi","A_Id":45698143,"CreationDate":"2017-08-15T16:47:00.000","Title":"Communicate to a local device from website","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How to upload a zip folder in AWS lambda functions (python) without storing in S3. I need to upload the python code written by me normally including all python libraries in order to run the program.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3797,"Q_Id":45712240,"Users Score":0,"Answer":"select \"Upload a .ZIP file\" option from \"Code entry type\". then you need to change the Handler . for python code you will use \"main\/lambda_handler\".","Q_Score":3,"Tags":"python,amazon-web-services,aws-lambda","A_Id":54216242,"CreationDate":"2017-08-16T11:23:00.000","Title":"How to upload a zip folder in AWS lambda (python) without storing in S3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How to upload a zip folder in AWS lambda functions (python) without storing in S3. I need to upload the python code written by me normally including all python libraries in order to run the program.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":3797,"Q_Id":45712240,"Users Score":2,"Answer":"Do you want to do this from AWS Console?\nIf yes then you simply have to select \"Upload a .ZIP file\" option in the \"Code entry type\" dropdown while creating the Lambda\nThat dropdown has 3 options as follows\n\nEdit code inline\nUpload a .ZIP file\nUpload a file from Amazon S3","Q_Score":3,"Tags":"python,amazon-web-services,aws-lambda","A_Id":45712595,"CreationDate":"2017-08-16T11:23:00.000","Title":"How to upload a zip folder in AWS lambda (python) without storing in S3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using paramiko in Python in order to write files to linux servers. I seem to have errors when writing to a path which includes folders with Hebrew names. \nAfter initializing a ssh_client and sftp client on that session, i'm using chmod to get to the folder I want to write to. \nThen,\nI'm using the sftp.file method to get a file object to write some content to.\nIt works when I have paths in English.\nWhen I have a path that contains Hebrew the method fails.. \nIt fails at the point I'm initializing the file in the sftp session. \nThe error is\nUnknown type for u'\/root\/\\u05e9\/filename.json' type\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":278,"Q_Id":45723246,"Users Score":1,"Answer":"Judging from the error message \"Unknown type\", this error is not caused by initialization of the file object in your sftp session, but rather something afterwards has caused the error. It'll be clear if you can post the source code.","Q_Score":0,"Tags":"python,file,ssh,sftp,paramiko","A_Id":45726406,"CreationDate":"2017-08-16T21:25:00.000","Title":"Unknown type error trying to use the file method on sftp client from Paramiko in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"What I mean is, if my script is 1000 lines of code long, is it more likely to fail then if it was only a hundred lines long, with everything else being equal?\nIt seems like my tests are failing randomly just because my script is long","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":33,"Q_Id":45723500,"Users Score":2,"Answer":"The longer a script you write is, the more chances you have for making a mistake while you are writing it.\nThat said, it is not the case that\n\ntests are failing randomly just because my script is long\n\nYour tests are likely failing because there is an error somewhere, either in the tests or the logic in your script.","Q_Score":0,"Tags":"python,selenium,scripting,automation,appium","A_Id":45723536,"CreationDate":"2017-08-16T21:44:00.000","Title":"Does length of an automation script directly determine its likelihood of failing?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a bash script, in Python that runs on a Ubuntu server. Today, I mistakenly closed the Putty window after monitoring that the script ran correctly. \nThere is some usefull information that was printed during the scrip running and I would like to recover them. \nIs there a directory, like \/var\/log\/syslog for system logs, for Python logs? \n\nThis scripts takes 24 hours to run, on a very costly AWS EC2 instance, and running it again is not an option.\nYes, I should have printed usefull information to a log file myself, from the python script, but no, I did not do that.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":389,"Q_Id":45732437,"Users Score":1,"Answer":"Unless the script has an internal logging mechanism like e.g. using logging as mentioned in the comments, the output will have been written to \/dev\/stdout or \/dev\/stderr respectively, in which case, if you did not log the respective data streams to a file for persistent storage by using e.g. tee, your output is lost.","Q_Score":0,"Tags":"python,linux,bash,ubuntu,logging","A_Id":45801164,"CreationDate":"2017-08-17T10:17:00.000","Title":"Recover previous Python output to terminal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to write my own small mailserver application in python with aiosmtpd \na) for educational purpose to better understand mailservers\nb) to realize my own features \nSo my question is, what is missing (besides aiosmtpd) for an Mail-Transfer-Agent, that can send and receive emails to\/from other full MTAs (gmail.com, yahoo.com ...)?\nI'm guessing: \n1.) Of course a domain and static ip\n2.) Valid certificate for this domain\n...should be doable with Lets Encrypt\n3.) Encryption\n...should be doable with SSL\/Context\/Starttls... with aiosmtpd itself\n4.) Resolving MX DNS entries for outgoing emails!?\n...should be doable with python library dnspython\n5.) Error handling for SMTP communication errors, error replies from other MTAs, bouncing!?\n6.) Queue for handling inbound and pending outbund emails!? \nAre there any other \"essential\" features missing?\nOf course i know, there are a lot more \"advanced\" features for a mailserver like spam checking, malware checking, certificate validation, blacklisting, rules, mailboxes and more...\nThanks for all hints!\n\nEDIT: \nLet me clarify what is in my mind:\nI want to write a mailserver for a club. Its main purpose will be a mailing-list-server. There will be different lists for different groups of the club.\nLets say my domain is myclub.org then there will be for example youth@myclub.org, trainer@myclub.org and so on.\nOnly members will be allowed to use this mailserver and only the members will receive emails from this mailserver. No one else will be allowed to send emails to this mailserver nor will receive emails from it. The members email-addresses and their group(s) are stored in a database. \nIn the future i want to integrate some other useful features, for example: \n\nAuto-reminders \nA chatbot, where members can control services and request informations by email \n\nWhat i don't need: \n\nUser Mailboxes \nPOP\/IMAP access \nWebinterface \n\nOpen relay issue: \n\nI want to reject any [FROM] email address that is not in the members database during SMTP negotiation. \nI want to check the sending mailservers for a valid certificate. \nThe number of emails\/member\/day will be limited. \nI'm not sure, if i really need spam detection for the incoming emails? \n\nLosing emails issue: \nI think i will need a \"lightweight\" retry mechanism. However if an outgoing email can't be delivered after some retries, it will be dropped and only the administrator will be notified, not the sender. The members should not be bothered by email delivery issues. Is there any Python Library that can generate RFC3464 compliant error reply emails?\nReboot issue: \nI'm not sure if i really need persistent storage for emails, that are not yet sent? In my use case, all the outgoing emails should be delivered usually within a few seconds (if no delivery problem occurs). Before a (planned) reboot i can check for an empty send queue.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2053,"Q_Id":45734960,"Users Score":0,"Answer":"You may consider the following features:\n\nMessage threading \nSupport for Delivery status\nSupport for POP and IMAP protocols \nSupports for protocols such as RFC 2821 SMTP and RFC 2033 LMTP email message transport \nSupport Multiple message tagging \nSupport for PGP\/MIME (RFC2015)\nSupport list-reply\nLets each user manage their own mail lists Supports\nControl of message headers during composition \nSupport for address groups \nPrevention of mailing list loops \nJunk mail control","Q_Score":4,"Tags":"python,mail-server,aiosmtpd","A_Id":45750954,"CreationDate":"2017-08-17T12:19:00.000","Title":"Python aiosmtpd - what is missing for an Mail-Transfer-Agent (MTA)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm in IPython and want to run a simple python script that I've saved in a file called \"test.py\". \nI'd like to use the %run test.py command to execute it inside IPython, but I don't know to which folder I need to save my test.py. \nAlso, how can I change that default folder to something else, for example C:\\Users\\user\\foldername ? \nI tried with the .ipython folder (original installation folder) but that's not working.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":475,"Q_Id":45760932,"Users Score":0,"Answer":"%run myprogram works for Python scripts\/programs.\nTo run any arbitrary programs, use ! as a prefix, e.g. !myprogram.\nMany common shell commands\/programs (cd, ls, less, ...) are also registered as IPython magic commands (run via %cd, %ls, ...), and also have registered aliases, so you can directly run them without any prefix, just as cd, ls, less, ...","Q_Score":1,"Tags":"python,ipython","A_Id":60616311,"CreationDate":"2017-08-18T16:13:00.000","Title":"IPython - running a script with %run command - saved to which folder?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have written a Python script that iterates through rows of an Excel file and, for each row:\n\nGets an e-mail address, name, and name of attachment file to use\nComposes an e-mail\nSends out the e-mail\n\nI'm not sure if it's accurate to call this mass-emailing or if it is a candidate for being black-listed because it is sending out individualized e-mails. With a message submission rate of 5\/minute, I want to throttle it (or have the limit increased to 100).\nSo my question is: Is the sort of scenario, assuming the limit is increased to 100, prone to black-listing?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":86,"Q_Id":45763459,"Users Score":0,"Answer":"It depends on how well you know the people you're mailing.\nIf you know them pretty well, it should be fine. If they're total strangers, the recipients might think it's spam and start blocking you.\nI could help more if you told me how well you know the recipients.","Q_Score":0,"Tags":"python,email,exchange-server","A_Id":45763596,"CreationDate":"2017-08-18T19:01:00.000","Title":"Python Email via MS Exchange: Message Submission Rate Limit","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have written a Python script that iterates through rows of an Excel file and, for each row:\n\nGets an e-mail address, name, and name of attachment file to use\nComposes an e-mail\nSends out the e-mail\n\nI'm not sure if it's accurate to call this mass-emailing or if it is a candidate for being black-listed because it is sending out individualized e-mails. With a message submission rate of 5\/minute, I want to throttle it (or have the limit increased to 100).\nSo my question is: Is the sort of scenario, assuming the limit is increased to 100, prone to black-listing?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":86,"Q_Id":45763459,"Users Score":0,"Answer":"Its not easy to answer your question as it depends hardly on the remote email environment used here and what you understand with individualized emails (only a different \"Hello Mr. ZZ\" or \"Dear Ms. YY\" isn\u00b4t really an individualized email these days). To give you three possible examples:\nSituation 1:\nAll users are on the same email environment (e.g. Exchange Online \/ Office 365). Then the remote mail server might see here +100 similar emails and might mark them as spam. If all +100 users are on +100 different email servers that might be different however the following might be possible:\nSituation 2:\nOne user think that this email is spam and report that as spam. Depending on the AntiSpam engine used here a hash value from that email might be created and other email server using the same AntiSpam engine might therefore detect your email as spam as well.\nSituation 3:\nThe users are on different email environments but in front of them is an AntiSpam cloud solution. This solution will then see +100 similar emails from one eMail environment and might therefore clarify that as SPAM.\nOfftopic: You might consider using services like from MailChimp which use different email servers to spread out a similar email. This might help to prevent such issues as the mass emails aren\u00b4t send from only one server. On top of that you do not risk your own email server from being blacklisted which might have a very bad business impact on your company.","Q_Score":0,"Tags":"python,email,exchange-server","A_Id":45764959,"CreationDate":"2017-08-18T19:01:00.000","Title":"Python Email via MS Exchange: Message Submission Rate Limit","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"For a flood warning system, my Raspberry Pi rings the bells in near-real-time but uses a NAS drive as a postbox to output data files to a PC for slower-time graphing and reporting, and to receive various input data files back. Python on the Pi takes precisely 10 seconds to establish that the NAS drive right next to it is not currently available. I need that to happen in less than a second for each access attempt, otherwise the delays add up and the Pi fails to refresh the hardware watchdog in time. (The Pi performs tasks on a fixed cycle: every second, every 15 seconds (watchdog), every 75 seconds and every 10 minutes.) All disc access attempts are preceded by tests with try-except. But try-except doesn't help, as tests like os.path.exists() or with open() both take 10 seconds before raising the exception, even when the NAS drive is powered down. It's as though there's a 10-second timeout way down in the comms protocol rather than up in the software.\nIs there a way of telling try-except not to be so patient? If not, how can I get a more immediate indicator of whether the NAS drive is going to hold up the Pi at the next read\/write, so that the Pi can give up and wait till the next cycle? I've done all the file queueing for that, but it's wasted if every check takes 10 seconds.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":226,"Q_Id":45764187,"Users Score":0,"Answer":"Taking on MQTT at this stage would be a big change to this nearly-finished project. But your suggestion of decoupling the near-real-time Python from the NAS drive by using a second script is I think the way to go. If the Python disc interface commands wait 10 seconds for an answer, I can't help that. But I can stop it holding up the time-critical Python functions by keeping all time-critical file accesses local in Pi memory, and replicating whole files in both directions between the Pi and the NAS drive whenever they change. In fact I already have the opportunistic replicator code in Python - I just need to move it out of the main time-critical script into a separate script that will replicate the files. And the replicator Python script will do any waiting, rather than the time-critical Python script. The Pi scheduler will decouple the two scripts for me. Thanks for your help - I was beginning to despair!","Q_Score":0,"Tags":"python,exception-handling,timing,nas","A_Id":45768586,"CreationDate":"2017-08-18T19:55:00.000","Title":"How can Python test the availability of a NAS drive really quickly?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a web application that stores metadata about files in rocksdb, using their packed base64 MD5 hashes as a keys(Example: 7XDfSsHImTYaYDUIG8QfYg==) and allows end users to access it by providing same keys. Does rocksdb itself or its python-rocksdb API contain any vulnerability that would warrant sanitise those received key values before attempting to retrieve the data with them?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":252,"Q_Id":45776795,"Users Score":0,"Answer":"Does rocksdb itself or its python-rocksdb API contain any vulnerability that would warrant sanitise those received key values before attempting to retrieve the data with them?\n\nThere is no security risk in using rocksdb to store arbitrary data. The issues comes in when you are serializing \/ deserializing the value. You must use a known safe library.","Q_Score":1,"Tags":"python,rocksdb","A_Id":49740205,"CreationDate":"2017-08-19T22:23:00.000","Title":"Are there security security vulnerabilities in rocksdb or python-rocksd that warrant sanitizing keys received from external source?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a large manifest file containing about 460,000 entries (all S3 files) that I wish to load to Redshift. Due to issues beyond my control a few (maybe a dozen or more) of these entries contain bad JSON that will cause a COPY command to fail if I pass in the entire manifest at once. Using COPY with a key prefix will also fail in the same way.\nTo get around this I have written a Python script that will go through the manifest file one URL at a time and issue a COPY command for each one using psycopg2. The script will additionally catch and log any errors to ensure that the script runs even when it comes across a bad file, and allows us to locate and fix the bad files.\nThe script has been running for a little more than a week now on a spare EC2 instance and is only around 75% complete. I'd like to lower the run time, because this script will be used again. \nMy understanding of Redshift is that COPY commands are executed in parallel, and with that I had an idea - will splitting the manifest file into smaller chunks and then running the script each of those chunks reduce the time it takes to load all the files?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":792,"Q_Id":45785730,"Users Score":1,"Answer":"COPY command can load multiple files in parallel very fast and efficiently. So when you run one COPY command for each file in your python file, that's going to take a lot of time since you are not taking advantage of parallel loading.\nSo maybe you can write a script to find bad JSONs in your manifest and kick them out and run a single COPY with the new clean manifest? \nOr like you suggested, I would recommend splitting manifest file into small chunks so that COPY can run for multiple files at a time. (NOT a single COPY command for each file)","Q_Score":1,"Tags":"python,amazon-web-services,amazon-s3,amazon-redshift","A_Id":45787036,"CreationDate":"2017-08-20T18:49:00.000","Title":"Using multiple manifest files to load to Redshift from S3?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am running pytest on a Jenkins machine; although I am not sure which Python it is actually running.\nThe machine is running OSX; and I did install various libraries (like numpy and others), on top of another Python install via Brew, so I keep things separated.\nWhen I run the commands from console; I specify python2.6 -m pytest mytest.py, which works, but when I run the same via shell in Jenkins, it fail, because it can't find the right libraries (which are the extra libraries I did install, after installing Python via Brew).\nIs there a way to know what is Jenkins using, so I can force it to run the correct python binary, which has access to my extra libraries?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":171,"Q_Id":45806967,"Users Score":0,"Answer":"You can use which python to find which python Jenkins use.\nYou can use ABSPATH\/OF\/python to run your pytest","Q_Score":0,"Tags":"python,jenkins","A_Id":45807814,"CreationDate":"2017-08-21T23:45:00.000","Title":"how to find out which Python is called when I run pytest via Jenkins","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am writing a lambda function on Amazon AWS Lambda. It accesses the URL of an EC2 instance, on which I am running a web REST API. The lambda function is triggered by Alexa and is coded in the Python language (python3.x).\n\nCurrently, I have hard coded the URL of the EC2 instance in the lambda function and successfully ran the Alexa skill.\n\nI want the lambda function to automatically obtain the IP from the EC2 instance, which keeps changing whenever I start the instance. This would ensure that I don't have to go the code and hard code the URL each time I start the EC2 instance.\n\nI stumbled upon a similar question on SO, but it was unanswered. However, there was a reply which indicated updating IAM roles. I have already created IAM roles for other purposes before, but I am still not used to it.\nIs this possible? Will it require managing of security groups of the EC2 instance?\nDo I need to set some permissions\/configurations\/settings? How can the lambda code achieve this?\n\nAdditionally, I pip installed the requests library on my system, and I tried uploading a '.zip' file with the structure :\n\n\n\n REST.zip\/\n \n\n\n requests library folder\n \n\n index.py\n \n\n\n\nI am currently using the urllib library\n\nWhen I use zip files for my code upload (I currently edit code inline), it can't even accesse index.py file to run the code","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":613,"Q_Id":45854752,"Users Score":2,"Answer":"You could do it using boto3, but I would advise against that architecture. A better approach would be to use a load balancer (even if you only have one instance), and then use the CNAME record of the load balancer in your application (this will not change for as long as the LB exists).\nAn even better way, if you have access to your own domain name, would be to create a CNAME record and point it to the address of the load balancer. Then you can happily use the DNS name in your Lambda function without fear that it would ever change.","Q_Score":0,"Tags":"python,python-3.x,amazon-web-services,amazon-ec2,aws-lambda","A_Id":45856165,"CreationDate":"2017-08-24T06:49:00.000","Title":"Obtain EC2 instance IP from AWS lambda function and use requests library","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have built a photo booth on a raspberry pi. It works fantastic! But after some coding I now have a problem organizing my scripts. At the moment all scripts are launched via \"lxterminal -e\". So every script has it's own terminal window and everything runs simultaneously. I ask myself if this can be done in a more efficient way.\nThe basic function of the photo booth: People press a remote button, take a picture, picture is being shown on the built-in tft.\n\nstart.sh --> is being executed automatically after booting. It prepares the system, , sets up the camera and brings it in tethered mode. After all that it launches the other, following scripts:\nsystem-watchdog.sh --> checks continuously if one of the physical buttons on the photo booth is being pressed, to reboot or go into setup mode. It's an ever-lasting-while-loop.\nsync.sh --> syncs the captured photo to some folders, where they are modified for beeing printed. Also an ever-lasting-while-loop.\nbackup.sh --> copies all taken pictures to a usb device as a backup. This is a cronjob, every 5 minutes.\ntemp-logger.sh --> Logs the temperature of the CPU continuously, because I had heat-problems.\n\nThe cpu is running constantly at about 20-40%. Maybe with some optimization I could run on viewer scripts and less cpu usage.\nAny suggestions what I could use to organize the scripts in a better way?\nThanks for your suggestions!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":48,"Q_Id":45883224,"Users Score":1,"Answer":"sync.sh --> syncs the captured photo to some folders, where they are modified for 1. being shown on the second screen, 2. upload to\n dropbox and 3. being printed. Also an ever-lasting-while-loop.\nterminal-sync.sh --> copies the taken photos to the\n second-screen-terminal, where they are shown in a gallery. It's also\n an ever-lasting-while-loop.\n\nFor these, you can use inotifywait to wait for file availability before processing the file.\nYou should check using top, which script actually consuming CPU and why. Once you identify the script and why it consume CPU, then you can start finding optimized way to do the same job","Q_Score":0,"Tags":"python,linux,bash,scripting,organization","A_Id":45884636,"CreationDate":"2017-08-25T14:06:00.000","Title":"Bash \/ Python: Organization of several scripts","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"So I want to install opencv in my raspberry pi 3b. When I sudo update, upgrade and finally reboot my rasp pi, I noticed that my LCD touch is now disabled. Good thing I have a back-up of the OS to make the LCD touch enabled again. How will I avoid this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":36,"Q_Id":45913845,"Users Score":0,"Answer":"Before installing any new update in your Raspberry, check first provided drivers for your devices. Otherwise keep a copy of your drivers and reinstall them after update and upgrade.","Q_Score":0,"Tags":"python,raspberry-pi3","A_Id":45914010,"CreationDate":"2017-08-28T07:30:00.000","Title":"LCD not working after sudo update and upgrade","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"i am student and i am totally new to scraping etc, today my supervisor gave me task to get the list of followers of a user or page(celebrity etc)\nthe list should contain information about every user (i.e user name, screen name etc)\nAfter a long search i found that i can't get the age and gender of any user on twitter.\nsecondly i got help regarding getting list of my followers but i couldnt find help about \"how i can get user list of public account\"\nkindly suggest me that its possible or not, and if it is possible, what are the ways to get to my goals\nthank you in advance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":279,"Q_Id":45923490,"Users Score":0,"Answer":"Hardly so, and even if you manage to somehow do it, you'll most likely get blacklisted. Also, please read the community guidelines when it comes to posting questions.","Q_Score":0,"Tags":"python,twitter,web-scraping,text-mining,scrape","A_Id":45959340,"CreationDate":"2017-08-28T16:26:00.000","Title":"is it possible to scrape list of followers of a public twitter acount (page)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a bunch of Python scripts which are to be run by several different users. The scripts are placed in a Windows server environment. \nWhat I wish to achieve is to protect these scripts in such a way that standard users are allowed to run them but do not have the rights to read\/modify\/move them.\nIs this even possible and if so what is the optimal strategy?\nThanks in advance.","AnswerCount":3,"Available Count":2,"Score":-0.0665680765,"is_accepted":false,"ViewCount":381,"Q_Id":45931604,"Users Score":-1,"Answer":"There is no way to make them not readable but executable at the same time.","Q_Score":0,"Tags":"python,windows,security,server","A_Id":45931678,"CreationDate":"2017-08-29T05:55:00.000","Title":"Protect python script on Windows server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a bunch of Python scripts which are to be run by several different users. The scripts are placed in a Windows server environment. \nWhat I wish to achieve is to protect these scripts in such a way that standard users are allowed to run them but do not have the rights to read\/modify\/move them.\nIs this even possible and if so what is the optimal strategy?\nThanks in advance.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":381,"Q_Id":45931604,"Users Score":1,"Answer":"You can compile Python modules into native libraries with Cython and provide compiled files only; though it involves a lot of hassle and doesn't work in some cases. They still can be decompiled to C code but it will be mostly unreadable.\nPros: 1. compiled libraries can be imported as normal Python modules.\nCons: 1. requires additional setup; 2. doesn't work in some cases, e.g. celery tasks cannot reside in compiled modules because: 3. you lose introspection abilities; 4. tracebacks are basically unreadable.","Q_Score":0,"Tags":"python,windows,security,server","A_Id":45932177,"CreationDate":"2017-08-29T05:55:00.000","Title":"Protect python script on Windows server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"pyndri installed successfully, but when I am importing it, I get the following error:\n\nundefined symbol:_ZTVNSt7__cxx1119basic_istringstreamIcSt11char_traits....","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1106,"Q_Id":45933867,"Users Score":0,"Answer":"The problem comes from anaconda 4.2.0 environment libstdc++, run \nstrings ANACONDA_HOME\/bin\/..\/lib\/libstdc++.so.6 | grep GLIBCXX\nYou might see following output\nGLIBCXX_3.4\nGLIBCXX_3.4.1\nGLIBCXX_3.4.2\nGLIBCXX_3.4.3\nGLIBCXX_3.4.4\nGLIBCXX_3.4.5\nGLIBCXX_3.4.6\nGLIBCXX_3.4.7\nGLIBCXX_3.4.8\nGLIBCXX_3.4.9\nGLIBCXX_3.4.10\nGLIBCXX_3.4.11\nGLIBCXX_3.4.12\nGLIBCXX_3.4.13\nGLIBCXX_3.4.14\nGLIBCXX_3.4.15\nGLIBCXX_3.4.16\nGLIBCXX_3.4.17\nGLIBCXX_3.4.18\nGLIBCXX_3.4.19\nGLIBCXX_FORCE_NEW\nGLIBCXX_DEBUG_MESSAGE_LENGTH\nAs you see there is no GLIBCXX_3.4.20 in anaconda 4.2.0 libstdc++\nNow run the following commands to solve the problem:\ncd ANCONDA_HOME\/lib\n rm libstdc++.so.6.0.19\n ln -s \/usr\/lib\/x86_64-linux-gnu\/libstdc++.so.6 libstdc++.so.6.0.19\nHopefully this should solve the problem.","Q_Score":0,"Tags":"python,anaconda,libstdc++","A_Id":45933868,"CreationDate":"2017-08-29T08:08:00.000","Title":"undefined symbol: _ZTVNSt7__cxx1119basic_istringstreamIcSt11char_traitsIc.. while importing pyndri","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have got a Windows7 system, and I installed on it a Virtual Box 5.1.26.\nOn this virtual box, I installed a Debian64 - Linux server. (I think I configured it correctly, it is getting enough memory).\nWhen I want run a Python script on it (which is a web-scraping script, it process around 1000 pages and take it into database), i get always the same error message after a few minutes :\n\nUnable to allocate and lock memory. The virtual machine will be paused. Please close applications to free up memory or close the VM.\nOr something error message with : run out of time (when it want to load a website)\n\nIn the windows7 system my script is working without any problem, so I am a little bit confused now, what is the problem here?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":192,"Q_Id":45934277,"Users Score":0,"Answer":"First check the parameters of your virtual machine you might have given it much more RAM or processors than you have (or not enough).\nIf this is not the case close everything in the VM and only start the script.\nThese errors generally say that you don't have resources to perform the operation.\nCheck if your syntax is ok and if you are using the same version of python on both systems.\nNote that the VM is a guest system and can't have as much resources as your main OS because the main Os will die in some circumstances.","Q_Score":1,"Tags":"python,web-scraping,debian,virtualbox","A_Id":45934419,"CreationDate":"2017-08-29T08:31:00.000","Title":"How to run a python script successfully with a debian system on the VirtualBox?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"if you are using a custom python layer - and assuming you wrote the class correctly in python - let's say the name of the class is \"my_ugly_custom_layer\"; and you execute caffe in the linux command line interface, \nhow do you make sure that caffe knows how to find the file where you wrote the class for your layer? do you just place the .py file in the same directory as the train.prototxt?\nor\nif you wrote a custom class in python you need to use the python wrapper interface?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":263,"Q_Id":45942883,"Users Score":2,"Answer":"Your python layer has two parameters in the prototxt: layer: where you define the python class name implementing your layer, and moduule: where you define the .py file name where the layer class is implemented.\nWhen you run caffe (either from command line or via python interface) you need to make sure your module is in the PYTHONPATH","Q_Score":1,"Tags":"python,caffe,layer","A_Id":45944107,"CreationDate":"2017-08-29T15:22:00.000","Title":"Bekeley caffe command line interface","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"The Goal: Once a user has signed up they start a challenge. Once they've started the challenge I'd like to be able to send users weekly emails for 12 weeks (Or however long the challenge lasts for). Bearing in mind, one user may sign up today and one may sign up in three months time. Each week, the email will be different and be specific to that week. So I don't want the week one email being sent alongside week 2 for 12 weeks.\nShould I add 12 boolean fields inside the extended User model, then run checks against them and set the value to True once that week gas passed?\nAssuming this is the case. Would i then need to setup a cron task which runs every week, and compares the users sign up date to todays date and then checks off the week one boolean? Then use the post_save signal to run a check to see which week has been completed and send the 'week one' email?\nI hope that makes sense and i'm trying to get my head around the logic. I'm comfortable with sending email now. It's trying to put together an automated process as currently it's all manual.\nPlease let me know if I need to elaborate on anything. Any help would be much appreciated.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":752,"Q_Id":45955464,"Users Score":2,"Answer":"The easiest way would be something like this:\n\nMake a table e.g. challenge in database with following cols: challenge_name, week1, week2, ..., as much weeks as you need. Make them nullable, so if some challenge is shorter, the rest of weeks can be null.\nIn users table (or you can make new one) add two cols, one for active challenge, the other for day started.\nThen yes, you can run cron job daily, or maybe twice a day, in the morning and in the afternoon, that executes python function for sending mail. In that function you go through all users, check their current challenge, calculate the week they are in, query table challenge for mail content and then send.\n\nI think this is the best solution, certainly the most simple and solid one :)","Q_Score":1,"Tags":"python,django,email","A_Id":45955886,"CreationDate":"2017-08-30T08:24:00.000","Title":"Send weekly emails for a limited time after sign up in django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"While using gTTS google translator module in python 2.x, I am getting error- \n\nFile\n \"\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/lib\/python2.7\/site-packages\/gtts\/tts.py\",\n line 94, in init\n if self._len(text) <= self.MAX_CHARS: File \"\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/lib\/python2.7\/site-packages\/gtts\/tts.py\",\n line 154, in _len\n return len(unicode(text)) UnicodeDecodeError: 'ascii' codec can't decode byte 0xe0 in position 0: ordinal not in range(128)`.\n\nEven though I have included # -*- coding: utf-8 -*- in my python script, I am getting the error on using Non-ASCII characters. Tell me some other way to implement like I can write sentence in English and get translated in other language. But this is also not working as I am getting speech in English, only accent changed. \nI have searched a lot everywhere but can't find an answer. Please help!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":856,"Q_Id":45974121,"Users Score":1,"Answer":"I have tried writing a string in unicode format as-\nu'Qu'est-ce que tu fais? Gardez-le de c\u00f4t\u00e9.'.\nThe ASCII code characters are converted into unicode format and hence, resolve the error. So, the text you want to be converted into speech can even have utf-8 format characters and can be easily transformed.","Q_Score":3,"Tags":"text-to-speech,python-2.x,translate","A_Id":45987971,"CreationDate":"2017-08-31T05:49:00.000","Title":"getting Unicode decode error while using gTTS in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python wsgi app that is configured to be run with uwsgi which is installed in the app's virtual environment. The app's main functionality is to retrieve files from a database. I need to test this functionality while running the app with uwsgi. At the same time I need to mock the outputs of the function that connects to the database. When running uwsgi this proves to be a hard (impossible?) thing to do.\nThe main app is called app.py. In the same directory there's a tests module (dir with init.py) with tests. I try to patch the function's output with patch (form unittest.mock), then open the web-page with selenium in a test case, all while uwsgi is running. But uwsgi's ouput seems unaffected by the patching, uwsgi just uses the real function from app.py.\nWhat could I possibly do to achieve the required behaviour? I need to test how the app works with uwsgi, and at the same time can not use any database.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":367,"Q_Id":45997744,"Users Score":2,"Answer":"This seems like you're mixing up different levels of testing. Mocking\/patching is appropriate for a unit test, where you test a function in isolation. What you're describing is an integration test; here, rather than patching, you should set up your app to run with a test database.","Q_Score":2,"Tags":"python,unit-testing,selenium,uwsgi","A_Id":45997798,"CreationDate":"2017-09-01T10:00:00.000","Title":"Unittest + Mock + UWSGI","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"configured AWS Cli on Linux system.\nWhile running any command like \"aws ec2 describe-instances\" it is showing error \"Invalid IPv6 URL\"","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":6082,"Q_Id":45999285,"Users Score":6,"Answer":"Ran into the same error. \nRunning this command fixed the error for me:\nexport AWS_DEFAULT_REGION=us-east-1\nYou might also try specifying the region when running any command:\naws s3 ls --region us-east-1\nHope this helps!\nor run aws configure and enter valid region for default region name","Q_Score":0,"Tags":"python-2.7,amazon-ec2,aws-cli","A_Id":46288793,"CreationDate":"2017-09-01T11:27:00.000","Title":"Invalid IPv6 URL while running commands using AWS CLI","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"configured AWS Cli on Linux system.\nWhile running any command like \"aws ec2 describe-instances\" it is showing error \"Invalid IPv6 URL\"","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":6082,"Q_Id":45999285,"Users Score":1,"Answer":"I ran into this issue due to region being wrongly typed. When you run aws configure during initial setup, if you try to delete a mistaken entry, it will end up having invalid characters in the region name.\nHopefully, running aws configure again will resolve your issue.","Q_Score":0,"Tags":"python-2.7,amazon-ec2,aws-cli","A_Id":50748839,"CreationDate":"2017-09-01T11:27:00.000","Title":"Invalid IPv6 URL while running commands using AWS CLI","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I tried making a cronjob to run my script every second, i used *\/60 * * * * this a parameter to run every second but it didn't worked, pls suggest me how should i run my script every second ?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1441,"Q_Id":46024476,"Users Score":0,"Answer":"Well, no. Your argument - *\/60 * * * * - means \"run every 60 minutes\". And you can't specify a shorter interval than 1 minute, not in standard Unix cron anyway.","Q_Score":1,"Tags":"python,cron","A_Id":46024560,"CreationDate":"2017-09-03T14:34:00.000","Title":"I want to make a cronjob such that it runs a python script every second","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"In my test suite I have a file called \"utils.py\" in which I have assorted functions required by many of the tests. To accomplish this I created a \"Utils\" class and had all of the functions inside it.\nA colleague, with more Python experience, insisted that there should be no such class and instead all of these functions should be top-level. Thus \"Utils.get_feature_id()\" became \"get_feature_id()\".\nWould you concur with his assertion?\nRobert","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":71,"Q_Id":46060352,"Users Score":1,"Answer":"Yes. If a function doesn't access a self, it should most likely not be a method. You can use a full module if your goal was to arrange your functions in a distinct namespace. Python uses namespaces everywhere, so we need not shy away from global names like C++ tends to and Java enforces (effectively, because they're not that global after all).","Q_Score":0,"Tags":"python","A_Id":46060417,"CreationDate":"2017-09-05T17:23:00.000","Title":"Is it Pythonic to have global functions not part of a class?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying an application to write an application on which I have used a client\/server architecture. The client side is developed using .NET\\C# and the server side is developed on python. To communicate the both sides, I used first tcp\/ip socket; so i put my python's methods on a loop then I ask each time from my c# application to run an method. This idea is very bad as it require to cover all use cases that can be happening on network or something like that. After a work of search, I have found three technologies that can answer a client\/server architecture which are RPC, RMI and WCF. RMI a java oriented solution so it is rejected. So, my question here is: does RPC and WCF support multi programming languages (interoperability) especially betwenn C# and python?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":525,"Q_Id":46080092,"Users Score":1,"Answer":"I'm not sure I completely understand your use case, but I would suggest having a look at a REST API approach if you need to have .Net talk to Python, or vice versa.","Q_Score":0,"Tags":"c#,python,wcf,client-server,rpc","A_Id":46080832,"CreationDate":"2017-09-06T16:20:00.000","Title":"Client Server architecture using python and C#","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm Using python 3.5\nI have a couple of byte strings representing text that is encoded in various codecs so: b'mybytesstring' , now some are Utf8 encoded other are latin1 and so on. What I want to in the following order is:\n\ntransform the bytes string into an ascii like string.\ntransform the ascii like string back to a bytes string.\ndecode the bytes string with correct codec.\n\nThe problem is that I have to move the bytes string into something that does not accept bytes objects so I'm looking for a solution that lets me do bytes -> ascii -> bytes safely.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":13895,"Q_Id":46085215,"Users Score":0,"Answer":"You use the encode and decode methods for this, and supply the desired encoding to them. It's not clear to me if you know the encoding beforehand. If you don't know it you're in trouble. You may have to guess the encoding in some way, risking garbage output.","Q_Score":2,"Tags":"python,python-3.x,string","A_Id":46085264,"CreationDate":"2017-09-06T22:30:00.000","Title":"Convert bytes to ascii and back save in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am going to make a telegram bot in Python 3 which is a random chat bot. As I am new in telegram bots, I don't know how to join two different people in a chat bot. Is there a guide available for this?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2352,"Q_Id":46101394,"Users Score":0,"Answer":"I am not sure to understand your question, can you give us what you pretend to do more explained?\nYou have a few options, creating a group and adding the bot to it.\nIn private chat you only can talk with a single user at a time.","Q_Score":1,"Tags":"python,python-3.x,chat,bots,telegram","A_Id":46103183,"CreationDate":"2017-09-07T16:39:00.000","Title":"how can i join two users in a telegram chat bot?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am going to make a telegram bot in Python 3 which is a random chat bot. As I am new in telegram bots, I don't know how to join two different people in a chat bot. Is there a guide available for this?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2352,"Q_Id":46101394,"Users Score":0,"Answer":"You need to make a database with chatID as primary column. and another column as partner. which stores his\/her chat partner chatID.\nnow when a user sends a message to you bot you just need to check the database for that user and send the message to her chat partner.\nafter the chat is done you should empty partner fields of both users.\nAnd for the picking part. when a user wants to find a new partner, choose a random row from your database WHERE partnerChatID is Null and set them to first users ID and vise versa.","Q_Score":1,"Tags":"python,python-3.x,chat,bots,telegram","A_Id":46113831,"CreationDate":"2017-09-07T16:39:00.000","Title":"how can i join two users in a telegram chat bot?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"It seems to me python -m myscript and python myscript do the same thing: running a script.\nWhat is the purpose of using -m? Thanks.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":64,"Q_Id":46102627,"Users Score":3,"Answer":"In some cases, especially for very small projects, python script.py and python -m script will be pretty much the same.\nThe biggest difference is when your module lives in a package and has relative imports. If you have a script that import something like from .module import some_name, you will most likely get a ModuleNotFoundError when you run it with python package\/scripy.py. On the other hand, python -m package.script will produce whatever output you expected.","Q_Score":2,"Tags":"python,python-3.x","A_Id":46102720,"CreationDate":"2017-09-07T18:07:00.000","Title":"What is the purpose of using `-m`?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I run Gspread with Python3, I get this error:\n\nImportError: No module named 'gspread'\n\nWhen I run with just Python, I get no errors. I installed gspread with pip install gspread --user. I really need to use Python 3, and I expect I should be able to, but I just did something wrong.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2307,"Q_Id":46109131,"Users Score":0,"Answer":"Make sure you are using the correct interpreter.\nYou may have one or more python interpreters installed so it may be installing to a different one.","Q_Score":3,"Tags":"python,python-3.x,importerror,gspread","A_Id":63958311,"CreationDate":"2017-09-08T05:19:00.000","Title":"Python 3 and Gspread ImportError","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I run Gspread with Python3, I get this error:\n\nImportError: No module named 'gspread'\n\nWhen I run with just Python, I get no errors. I installed gspread with pip install gspread --user. I really need to use Python 3, and I expect I should be able to, but I just did something wrong.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2307,"Q_Id":46109131,"Users Score":0,"Answer":"You have to install pip for python3 using apt install python3-pip\nThen you can install using pip3 install gspread --user","Q_Score":3,"Tags":"python,python-3.x,importerror,gspread","A_Id":66132206,"CreationDate":"2017-09-08T05:19:00.000","Title":"Python 3 and Gspread ImportError","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a project where I will have several Raspberry Pi 3's set up, each having two barcode scanners, two passive buzzers, and two Adafruit NeoPixel Ring lights.\nEach time a barcode is scanned, an API request is sent to see if the barcode is valid or not. If the barcode is valid, the Adafruit NeoPixel Ring will be green and a success tone is played on the buzzer, and it the barcode is invalid, the light will be blue and a failure tone is played on the buzzer.\nMy question is: Is there a way in Python on the Raspberry Pi to detect which barcode scanner is sending the barcode? I realize that barcode scanners are HID devices and act like a keyboard, so I would like to know if there is a way in Python to treat the scanner different and not have an input() call to receive the scanner's input.\nIt is especially important to know which barcode scanner the incoming data came from so that I know which light to make green or blue and which buzzer to play the sound. In other words, if scanner 1 had a barcode that was valid and scanner 2 had a barcode that was invalid, I want NeoPixel Ring 1 to be green and NeoPixel Ring 2 to be blue.\nAs it stands now, I am considering using two Arduinos and hook up each scanner, buzzer, and NeoPixel Ring to them, and then use serial communication to communicate with the Raspberry Pi from each Arduino.\nWhat are your thoughts\/suggestions?\nThank you in advance!","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":624,"Q_Id":46136334,"Users Score":2,"Answer":"What I would do is set up the scanner in such a way that each one has a prefix, so whatever code is read, it will always have a prefix i.e. A000001, A000002, B00001, B00002, so all you'll have to do is use a string function to know that all codes that begin with \"A\" come from scanner A and all that begin with \"B\" come from scanner B. Regardless of what programming language you use. this works perfect with Motorola\/Zebra\/Honeywell scanners..","Q_Score":2,"Tags":"python,arduino,raspberry-pi,raspberry-pi3,serial-communication","A_Id":50027574,"CreationDate":"2017-09-10T00:45:00.000","Title":"Raspberry Pi: Detect Multiple Barcode Scanners in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to use Python to find a faster way to sift through a large directory(approx 1.1TB) containing around 9 other directories and finding files larger than, say, 200GB or something like that on multiple linux servers, and it has to be Python.\nI have tried many things like calling du -h with the script but du is just way too slow to go through a directory as large as 1TB. \nI've also tried the find command like find .\/ +200G but that is also going to take foreeeever.\nI have also tried os.walk() and doing .getsize() but it's the same problem- too slow.\nAll of these methods take hours and hours and I need help finding another solution if anyone is able to help me. Because not only do I have to do this search for large files on one server, but I will have to ssh through almost 300 servers and output a giant list of all the files > 200GB, and the three methods that i have tried will not be able to get that done. \nAny help is appreciated, thank you!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2409,"Q_Id":46144952,"Users Score":0,"Answer":"It is hard to imagine that you will find a significantly faster way to traverse a directory than os.walk() and du. Parallelizing the search might help a bit in some setups (e.g. SSD), but it won't make a dramatic difference.\nA simple approach to make things faster is by automatically running the script in the background every hour or so, and having your actual script just pick up the results. This won't help if the results need to be current, but might work for many monitoring setups.","Q_Score":0,"Tags":"python,linux","A_Id":46145014,"CreationDate":"2017-09-10T19:51:00.000","Title":"Faster way to find large files with Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am solving a large sparse quadratic problem. My objective function has only quadratic terms and the coefficients of all terms are the same and equal to 1 and it includes all of the variables. \nI use objective.set_quadratic_coefficients function in python to create my objective function. For small problems (10000 variables), the objective function is generated quickly but it gets much slower for larger problems (100000 variables) and does return anything for my main problem that has 1000000 variables. \nIs there an alternative to objective.set_quadratic_coefficients to speed up the creating the problem?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":119,"Q_Id":46147245,"Users Score":1,"Answer":"After asking my question in the IBM forum, I received and answer and it works. The fastest way to create the quadratic objective function is to use objective.set_quadratic() with only a list that contains the coefficient values (they can vary and don't need to be all equal to 1.0)","Q_Score":0,"Tags":"python,cplex,quadratic","A_Id":46158131,"CreationDate":"2017-09-11T01:58:00.000","Title":"Performance issue with setting quadratic objective in CPLEX","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been developing a web interface for a simple raspberry pi project. It's only turning lights on and off, but I've been trying to add a dimming feature with PWM.\nI'm using modWSGI with Apache, and RPi.GPIO for GPIO access. For my prototype I'm using (3) SN74HC595's in series for the LED outputs, and am trying to PWM the OE line to dim the lights.\nOperating the shift registers is easy, because they hold the outputs in between updates. However, for PWM to work the GPIO.PWM instance must stay active between WSGI sessions. This is what I'm having trouble with. I've been working on this for a few days, and saw a couple similar questions here. But nothing for active objects like PWM, only simple counters and such.\nMy two thoughts are:\n1) Use the global scope to hold the PWM object, and use PWM.ChangeDutyCycle() in the WSGI function to change brightness. This approach has worked before, but it seems like it might not here.\nOr 2) Create a system level daemon (or something) and make calls to that from within my WSGI function.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":130,"Q_Id":46157465,"Users Score":0,"Answer":"For anyone looking at this in 2020:\nI changed mod_wsgi to single thread mode. I'm not sure if it's related to Python, mod_wsgi, or bad juju, but it still would not last long term. After a few hours the PWM would stop at full off.\nI tried rolling my own PWM daemon, but ultimately went with the pigpio module (is Joan on SE?). It's been working perfect for me.","Q_Score":0,"Tags":"raspberry-pi,python-3.4,mod-wsgi","A_Id":47499801,"CreationDate":"2017-09-11T13:56:00.000","Title":"Object persistence in WSGI","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm looking for a work around to use numpy in AWS lambda. I am not using EC2 just lambda for this so if anyone has a suggestion that'd be appreciated. Currently getting the error:\ncannot import name 'multiarray'\nUsing grunt lambda to create the zip file and upload the function code. All the modules that I use are installed into a folder called python_modules inside the root of the lambda function which includes numpy using pip install and a requirements.txt file.","AnswerCount":6,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":8835,"Q_Id":46185297,"Users Score":0,"Answer":"1.) Do a Pip install of numpy to a folder on your local machine. \n2.) once complete, zip the entire folder and create a zip file.\n3.) Go to AWS lambda console, create a layer and upload zip file created in step 2 there and save the layer. \n4.) After you create your lambda function, click add layer and add the layer you created. That's it, import numpy will start working.","Q_Score":8,"Tags":"python,amazon-web-services,numpy,aws-lambda","A_Id":61375373,"CreationDate":"2017-09-12T21:05:00.000","Title":"Using numpy in AWS Lambda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm looking for a work around to use numpy in AWS lambda. I am not using EC2 just lambda for this so if anyone has a suggestion that'd be appreciated. Currently getting the error:\ncannot import name 'multiarray'\nUsing grunt lambda to create the zip file and upload the function code. All the modules that I use are installed into a folder called python_modules inside the root of the lambda function which includes numpy using pip install and a requirements.txt file.","AnswerCount":6,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":8835,"Q_Id":46185297,"Users Score":6,"Answer":"An easy way to make your lambda function support the numpy library for python 3.7:\n\nGo to your lambda function page\nFind the Layers section at the bottom of the page.\nClick on Add a layer.\nChoose AWS layers as layer source.\nSelect AWSLambda-Python37-Scipy1x as AWS layers.\nSelect 37 for version.\nAnd finally click on Add.\n\nNow your lambda function is ready to support numpy.","Q_Score":8,"Tags":"python,amazon-web-services,numpy,aws-lambda","A_Id":69191367,"CreationDate":"2017-09-12T21:05:00.000","Title":"Using numpy in AWS Lambda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to use module keyboard in Python 3.5.3. \npip, import and my program work fine on Windows. On my Raspberry pip install works and pip list shows keyboard. \nHowever when I try to run\nimport keyboard \nI get the error:\n \"ImportError: No module named 'keyboard'\" \nI even tried to use sudo import as the keyboard documentation suggests with the same result. \nWhat am I missing?","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":12939,"Q_Id":46219800,"Users Score":-1,"Answer":"I'm using Python 3.7.3 on Raspberry Pi, now the import keyboard is not longer required, just comment it or remove the line; all must works fine.","Q_Score":4,"Tags":"python,raspberry-pi","A_Id":61260234,"CreationDate":"2017-09-14T12:55:00.000","Title":"Python module \"keyboard\" works on Windows, not found on Raspberry","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Selenium IDE is a very useful tool to create Selenium tests quickly. Sadly, it has been unmaintained for a long time and now not compatible with new Firefox versions.\nHere is my work routine to create Selenium test without Selenium IDE:\n\nOpen the Inspector\nFind and right click on the element\nSelect Copy CSS Selector\nPaste to IDE\/Code editor\nType some code\nBack to step 2\n\nThat is a lot of manual work, switching back and for. How can I write Selenium tests faster?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":116,"Q_Id":46235088,"Users Score":0,"Answer":"The best way is to learn how your app is constructed, and to work with the developers to add an id element and\/or distinctive names and classes to the items you need to interact with. With that, you aren't dependent on using the fragile xpaths and css paths that the inspector returns and instead can create short, concise expressions that will hold up even when the underlying structure of the page changes.","Q_Score":0,"Tags":"python,selenium,automated-tests,selenium-ide,web-testing","A_Id":46241635,"CreationDate":"2017-09-15T08:30:00.000","Title":"Since Selenium IDE is unmaintained, how to write Selenium tests quickly?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to create a program\/script for the creation of a high numbers of random sequences (20 letter long sequence based on 4 different letters) with a minimum edit distance between all sequences. \"High\" would here be a minimum of 100k sequences, but if possible up to 1 million. \nI started with a naive approach of just generating random 20 letter sequences, and for each sequence, calculate the edit distance between the sequence and all other sequences already created and stored. If the new sequence pass my threshold value, store it, otherwise discard. \nAs you understand, this scales very badly for higher number of sequences. Up to 10k is reasonably fine, but trying to get 100k this starts to get troublesome. \nI really only need to create the sequences once and store the output, so I'm really not that fussy about speed, but making 1 million at this rate today is just no possible. \nBeen trying to think of alternatives to speed up the process, like building the sequences is \"blocks\" of minimal ED and then combining, but haven't come up with any solution. \nWondering, do anyone have any smart idea\/method that could be implemented to create such high number of sequences with minimal ED more time efficient? \nCheers,\nJB","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":79,"Q_Id":46235675,"Users Score":0,"Answer":"It seems, from wikipedia, that edit distance is one of three operations insertion, deletion, substitution; performed on a starting string. Why not systematically generate all strings up to N edits from a starting string then stop when you reach your limit?\nThere would be no need to check for the actual edit distance as they would be correct by generation. For randomness could you generate a number then shuffle them.","Q_Score":0,"Tags":"python,algorithm,performance,edit-distance","A_Id":46241767,"CreationDate":"2017-09-15T09:00:00.000","Title":"Create high nr of random sequences with min Edit Distance time efficient","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to measure the packet leaving and reaching time via scapy. Is it possible to measure the time when packet leaves the node? If so, How good scapy is in replaying exact those timestamps? Plus how to verify its credibility. Is it possible to compare scapy timestamps with wireshark's? If so then how?\nI know these are lots of questions. but I really need these answers. I thank in advance for your patience and effort.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":529,"Q_Id":46242451,"Users Score":0,"Answer":"Short answer: Scapy is not really good at replaying a PCAP file (if you want to be fast, I mean).\nIf you need better performances than what Scapy can offer, you should probably use tcpreplay; you can do that directly from Scapy, using the sendpfast() function.","Q_Score":0,"Tags":"python-2.7,timestamp,wireshark,scapy","A_Id":46265590,"CreationDate":"2017-09-15T14:55:00.000","Title":"How good scapy is in replaying a pcap file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to set up a gameshow type system where I have 5 stations each having a monitor and a button. The monitor will show a countdown timer and various animations. My plan is to program the timer, animations, and button control through pygame and put a pi at each station each running it's own pygame script, waiting for the start signal (can be keypress or gpio).\nI'm having trouble figuring out how to send that signal simultaneously to all stations. Additionally I need to be able to send a 'self destruct' signal to each station to stop the timer. I can ssh into each station but I don't know how to send keypress\/gpio signals through the command line to a running pygame script..\nI was thinking of putting a rf receiver on each pi, all at the same wavelength and using a common transmitter, but that seems very hacky and not necessarily so simultaneous.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":114,"Q_Id":46246197,"Users Score":0,"Answer":"This ought to work ... but it's purely hypothetical:\nUse a parallel circuit to set a pin \"high\" and \"low\" - \"high\" means start the timer; \"low\" means stop the timer. The next \"high\" resets and restarts the timer.\nYou could use two circuits. One for start\/stop and one for \"reset\". You'd probably need some code to not reset while running.\nThe parallel circuit can be controlled manually (for testing) or automatically (perhaps with a master program?).","Q_Score":0,"Tags":"python,raspberry-pi,pygame","A_Id":46246348,"CreationDate":"2017-09-15T19:17:00.000","Title":"Control Multiple Raspberry Pis Remotely \/ Gameshow Type System","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"from Crypto.Cipher import AES\nThis gives me following error when executed with python3. It works fine in python2.\n\n\nImportError: No module named 'Crypto'\n\n\nWhat is problem here?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":826,"Q_Id":46250806,"Users Score":2,"Answer":"I got the solution for this:\nThe pycrypto library has to be installed using pip3 instead of pip.\n\nsudo pip3 install crypto;\nsudo pip3 install pycrypto\n\nImport works fine afterwords.","Q_Score":0,"Tags":"python,cryptography","A_Id":46251597,"CreationDate":"2017-09-16T06:25:00.000","Title":"importing PyCrypto Library is not working in Python3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm built a telegram bot for the groups.When the bot is added to the group, it will delete messages containing ads.How can I change the bot to work for only 30 days in each group and then stop it?\nThat means, for example, today's bot is added to group 1 and the next week the bot is added to group 2; I need to change the bot to stop the 30 days in group 1 and stop it in group 2 for another 37 days.\nHow can I do that?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":174,"Q_Id":46253238,"Users Score":0,"Answer":"You can't know how long your bot had been added to group at this time. :(\nYou need to log it to your own database, and there is leaveChat method if you need it.","Q_Score":0,"Tags":"python,python-telegram-bot","A_Id":46253303,"CreationDate":"2017-09-16T11:11:00.000","Title":"How can a telegram bot change that works only for a specific time in a group?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm built a telegram bot for the groups.When the bot is added to the group, it will delete messages containing ads.How can I change the bot to work for only 30 days in each group and then stop it?\nThat means, for example, today's bot is added to group 1 and the next week the bot is added to group 2; I need to change the bot to stop the 30 days in group 1 and stop it in group 2 for another 37 days.\nHow can I do that?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":174,"Q_Id":46253238,"Users Score":0,"Answer":"Simply, all you need is a database at the back-end. Just store the group_id and join_date in each row. \nAt any time, you can query your database. If more than 30 days has passed join_date, stop the bot or leave the group.\nYou can also use any other storage rather than a database. A file, index, etc.","Q_Score":0,"Tags":"python,python-telegram-bot","A_Id":46253626,"CreationDate":"2017-09-16T11:11:00.000","Title":"How can a telegram bot change that works only for a specific time in a group?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a quick \"pythonic\" way to check if a file is in write mode, whether the mode is r+, w, w+, etc. I need to run a function when __exit__ is called, but only if the file is open in write mode and not just read-only mode. I am hoping some function exists to obtain this information but I can't seem to find anything.\nIs there a way to do this without having to build a separate function to interpret the list of mode types?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1269,"Q_Id":46261736,"Users Score":1,"Answer":"I use os.access('your_file_path', os.W_OK) to check write mode. \nfile.mode always returns 'r', while the file is actually in 'write' mode.","Q_Score":1,"Tags":"python-2.7,file,file-io","A_Id":59353987,"CreationDate":"2017-09-17T07:34:00.000","Title":"Python check if file object is in write mode","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is a programming language concept question, e.g. similar to the level of Programming Language Pragmatics, by Scott.\nIn Python, the classes of some kinds of objects are defined in terms of having some methods with special names, for example,\n\na descriptors' class is defined as a class which has a method named __get__, __set__, or __delete__().\nan iterators' class is defined as a class which has a method named __next__.\n\nQuestions:\n\nWhat is the language feature in Python called in programming language design? Is it duck typing?\nHow does the language feature work underneath?\nIn C++, C#, and Java, is it correct that a descriptor's class and an\niterator's class would have been defined as subclasses of some\nparticular classes? (similarly to C# interface IDisposable)\nIn Python, \n\nCan descriptors' classes be defined as subclasses of some particular class?\nCan iterators' classes be defined as subclasses of some particular class?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":63,"Q_Id":46263313,"Users Score":1,"Answer":"This is an aspect of duck typing.\nPython, as a dynamically-typed language, cares less about the actual types of objects than about their behaviour. As the saying goes, if it quacks like a duck, then it's probably a duck; in the case of your descriptor, Python just wants to know it defines the special methods, and if it does then it accepts that it is a descriptor.","Q_Score":0,"Tags":"python,programming-languages,computer-science,typing","A_Id":46263361,"CreationDate":"2017-09-17T10:58:00.000","Title":"What is the language feature that some kinds of classes are defined in terms of having some methods with special names?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is a programming language concept question, e.g. similar to the level of Programming Language Pragmatics, by Scott.\nIn Python, the classes of some kinds of objects are defined in terms of having some methods with special names, for example,\n\na descriptors' class is defined as a class which has a method named __get__, __set__, or __delete__().\nan iterators' class is defined as a class which has a method named __next__.\n\nQuestions:\n\nWhat is the language feature in Python called in programming language design? Is it duck typing?\nHow does the language feature work underneath?\nIn C++, C#, and Java, is it correct that a descriptor's class and an\niterator's class would have been defined as subclasses of some\nparticular classes? (similarly to C# interface IDisposable)\nIn Python, \n\nCan descriptors' classes be defined as subclasses of some particular class?\nCan iterators' classes be defined as subclasses of some particular class?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":63,"Q_Id":46263313,"Users Score":1,"Answer":"What is the language feature in Python called in programming language design? Is it duck typing?\n\n\"Any object with a member with a specific name (or signature), can work here\" is duck typing. I don't think there is a more specific term for \"any object with a member with a specific name (or signature), can work for this language feature\", if that's what you were asking.\n\nHow does the language feature work underneath?\n\nI don't understand the question. If a language feature means that it calls a method with a specific name, it calls a method with that name. That's it.\n\nIn C++, C#, and Java, is it correct that a descriptor's class and an iterator's class would have been defined as subclasses of some particular classes?\n\nI'm not aware of anything similar to descriptor in any of these languages and I don't think it makes sense to speculate on how it would look if it did exist.\nAs for iterators, each of these languages has a foreach loop, so you can look at that:\nIn C++, the range-based for loop works on any type that has instance members begin and end or for which the begin and end functions exist. The returned type has to support the ++, != and * operators.\nIn C#, the foreach loop works on any type that has instance method GetEnumerator(), which returns a type with a MoveNext() method and a Current property. There is also the IEnumerable interface, which describes the same shape. Enumerable types commonly implement this interface, but they're not required to do so.\nIn Java, the enhanced for loop works on any type that implements Iterable.\nSo, there are no subclasses anywhere (C# and Java differentiate between implementing an interface and deriving from a base class). Java requires you to implement an interface. C# uses duck typing, but also optionally allows you to implement an interface. C++ uses duck typing, there is no interface or base class at all.\nNote that, depending on the language, the decision whether to use duck typing for a certain language feature might be complicated. As an extreme example, one feature of C# (collection initializers) requires implementing of a specific interface (IEnumerable) and also the presence of a method with a specific name (Add). So this feature is partially duck typed.","Q_Score":0,"Tags":"python,programming-languages,computer-science,typing","A_Id":46263607,"CreationDate":"2017-09-17T10:58:00.000","Title":"What is the language feature that some kinds of classes are defined in terms of having some methods with special names?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In Python CGI, when I call name = os.popen('whoami').read(), the name will return as Apache. How can I get the original login name that was login to this machine? For example, in terminal windows, when I run whoami, the login name return as \"operator\". In Apache server, is there a way to get the login name as \"operator\"?\nThanks!\nTom Wang","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":183,"Q_Id":46289627,"Users Score":0,"Answer":"Python CGI script gets executed when APACHE gets a request. APACHE redirects the request to python. Since, user 'APACHE' would be running this script, you get that as the id. You can only get the id as operator if user 'operator' is running the script. Users connect to your script using a web browser which is intercepted by APACHE. There is no way to determine which user is making the request from web browser as they never login to the machine where APACHE is running. You can get their IP\/port using the requests library","Q_Score":0,"Tags":"python,apache","A_Id":46290001,"CreationDate":"2017-09-18T23:35:00.000","Title":"How to get original login name while in Python CGI Apache web server?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have the following problem.\nI need to replace a file with another one. As far as the new is transfered over the network, owner and group bits are lost. \nSo I have the following idea. To save current permissions and file owner bits and than after replacing the file restore them.\nCould you please suggest how to do this in Python or maybe you could propose a better way to achieve this.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":120,"Q_Id":46293283,"Users Score":0,"Answer":"You can use rsync facility to copy the file to remote location with same permissions. A simple os.system(rsync -av SRC :~\/location\/) call can do this. Another methods include using a subprocess.","Q_Score":0,"Tags":"python,python-2.7,file-permissions,file-ownership","A_Id":46293476,"CreationDate":"2017-09-19T06:23:00.000","Title":"Python save file permissions & owner\/group and restore later","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am playing around with a discord.py bot, I have pretty much everything working that I need (at this time), but I can't for the life of me figure out how to embed a YouTube video using Embed().\nI don't really have any code to post per-say, as none of it has worked correctly.\nNote: I've tried searching everywhere (here + web), I see plenty of info on embedding images which works great.\nI do see detail in the discord API for embedding video, as well as the API Documentation for discord.py; but no clear example of how to pull it off.\nI am using commands (the module I am working on as a cog) \nAny help would be greatly appreciated.\nEnvironment:\n\nDiscord.py Version: 0.16.11\nPython: 3.5.2\nPlatform: OS X\nVirtualEnv: Yes","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":7927,"Q_Id":46306032,"Users Score":1,"Answer":"Only form of media you can embed is images and gifs. It\u2019s not possible to embed a video","Q_Score":1,"Tags":"python,youtube,embed,discord.py","A_Id":50806683,"CreationDate":"2017-09-19T17:00:00.000","Title":"discord.py embed youtube video without just pasting link","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am playing around with a discord.py bot, I have pretty much everything working that I need (at this time), but I can't for the life of me figure out how to embed a YouTube video using Embed().\nI don't really have any code to post per-say, as none of it has worked correctly.\nNote: I've tried searching everywhere (here + web), I see plenty of info on embedding images which works great.\nI do see detail in the discord API for embedding video, as well as the API Documentation for discord.py; but no clear example of how to pull it off.\nI am using commands (the module I am working on as a cog) \nAny help would be greatly appreciated.\nEnvironment:\n\nDiscord.py Version: 0.16.11\nPython: 3.5.2\nPlatform: OS X\nVirtualEnv: Yes","AnswerCount":3,"Available Count":2,"Score":0.2605204458,"is_accepted":false,"ViewCount":7927,"Q_Id":46306032,"Users Score":4,"Answer":"What you are asking for is unfortunately impossible, since Discord API does not allow you to set custom videos in embeds.","Q_Score":1,"Tags":"python,youtube,embed,discord.py","A_Id":46324897,"CreationDate":"2017-09-19T17:00:00.000","Title":"discord.py embed youtube video without just pasting link","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am developing a program in python that can read emails, my program can now read emails from GMAIL even with attachment but my program can't read the email that was sent from Apple Mail. \nUnlike the email that I sent from GMAIL when I use Message.get_payload() in apple mail it does not have a value. I'm a newbie on python and this is my first project so please bear with me. Thank you in advance.\nNote: The email I sent from Apple has attachment on it.\nUpdate: I can now read the text inside the email my only problem now is how to get the attachment since when I loop all the payloads since it is multipart it only prints the text inside and this \n\"[, ]\"","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":471,"Q_Id":46314148,"Users Score":0,"Answer":"This is okay now It seems like the content type of the email i sent from Apple Mail was multipart which includes a \"text\/plain\" which contains the text inside my email and \"multipart\/related\" that contains the image i attached. So i just needed to check if the email is a multipart if so then loop it to print all payloads.","Q_Score":0,"Tags":"python,email,apple-mail","A_Id":46314807,"CreationDate":"2017-09-20T05:47:00.000","Title":"Python: Apple Email Content","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"i am new to serverless framework and aws, and i need to create a lambda function on python that will send email whenever an ec2 is shut down, but i really don't know how to do it using serverless. So please if any one could help me do that or at least give me some tracks to start with.","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":203,"Q_Id":46322899,"Users Score":3,"Answer":"You can use CloudWatch for this.\nYou can create a cloudwatch rule\n\nService Name - Ec2 \nEvent Type - EC2 Instance change notification\nSpecific state(s) - shutting-down\n\nThen use an SNS target to deliver email.","Q_Score":1,"Tags":"python,amazon-web-services,amazon-ec2,aws-lambda,serverless-framework","A_Id":46323508,"CreationDate":"2017-09-20T13:05:00.000","Title":"send email whenever ec2 is shut down using serverless","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'd designed a python software that required to start right after boot into system. I'd use sudo nano \/home\/pi\/.config\/lxsession\/LXDE-pi\/autostart to add in @python3 \/home\/pi\/X\/exe.py\nBefore I'd include serial communication into the apps, everything works fine.\nBut after I'd add in serial, the autostart had failed.\nSo, how to autostart on boot a PyQt5 based serial comn.-able apps in Raspbian Jessie?\nI'd been suspecting that this weird behavior is due to serial communication that I'd added, that will be used before Pi logon.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":61,"Q_Id":46345699,"Users Score":0,"Answer":"I'd decided to reflash the image and my problem is solved.","Q_Score":1,"Tags":"python-3.x,serial-port,pyqt5,raspbian","A_Id":46519334,"CreationDate":"2017-09-21T13:47:00.000","Title":"Raspbian autostarting a PyQT5 UI that has Serial communication","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using xmlrunner in combination with unittest in python for testing purposes by running \nxmlrunner.XMLTestRunner(outsuffix=\"\",).run(suite)\nwhere suite is standard unittest.suite.TestSuite\nWhen I run the tests on my windows machine I get an output by using the standard print() function in my tests. Unfortunately I don't get any output to my terminal when running the tests on my fedora machine. The output is correctly logged to an XML file but I would like to have the output directly to stdout \/ terminal.\nDid I miss something that explains this behaviour?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":249,"Q_Id":46346745,"Users Score":0,"Answer":"OK, I found the reason. On my Fedora 24 machine an old version of xmlrunner (1.14.0 - something) was installed. I used pip to install the lates xmlrunner (1.7.7) for python3 and now I do get the output directly on the terminal.","Q_Score":0,"Tags":"python,linux,unit-testing","A_Id":46359839,"CreationDate":"2017-09-21T14:34:00.000","Title":"No print to stdout when running xmlrunner in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a test case where I am iterating using a FOR loop, where the variable in the loop is \"j\". \nI am then using this \"j\" in a user-defined keyword, but the test case fails and the error is \"Variable j not found\".\nThis exact same test case works on another machine without any error, and I'm not sure why. In my machine where it fails, there is no problem with libraries or the setup, and this variable is not being saved anywhere.\nCould someone please suggest why this could happen?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1010,"Q_Id":46350778,"Users Score":2,"Answer":"You can give variable \"j\" with symbol @","Q_Score":0,"Tags":"python-2.7,testing,automation,automated-tests,robotframework","A_Id":72298130,"CreationDate":"2017-09-21T18:21:00.000","Title":"Variable not found in Robot Framework-RIDE","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"My team uses .rst\/sphinx for tech doc. We've decided to do tables in csv files, using the .. csv-table:: directive. We are beginning to using sphinx-intl module for translation. Everything seems to work fine, except that I don't see any our tables int he extracted .po files. Has anyone had this experience? What are best practices for doing csv tables and using sphinx-intl?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":89,"Q_Id":46351068,"Users Score":1,"Answer":"We tested and verified that the csv content is automatically extracted into PO files, and building a localized version places the translated strings in MO files back into the table.","Q_Score":0,"Tags":"internationalization,python-sphinx,restructuredtext","A_Id":46535864,"CreationDate":"2017-09-21T18:40:00.000","Title":"How do I use sphinx-intl if I am using the .. csv-table:: directives for my tables?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to simulate a file download via http(s) from within a Python script. The script is used to test a router\/modem appliance in my local LAN. \nCurrently, I have a virtual machine's network configured to use the appliance as default gateway and DNS. The python script on my test machine sshs into the VM using the Phython's paramiko library. From within the python script using this ssh connection I run wget https:\/\/some.websi.te\/some_file.zip. That seems like overkill but I don't want to reconfigure the network on my machine running the test script.\nIs there a way to eliminate the extra VM (the one that runs wget via ssh) and still simulate the download? Of course that should run within my python test script on my local machine? \nIn other words can I get python to use another gateway than the system default from within a script?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":431,"Q_Id":46362927,"Users Score":2,"Answer":"I can provide 2 ways to do want you want: a bad way, and a clean way.\nLet's talk about the bad way:\nIf your script is using \"the default gateway\" of the system, may be, by setting up a dedicated route for your destination used by your script into your system to avoid your script to use the default gateway, may be enough to solve your problem. This is a bad way because not only your script will be impacted, all the traffic generated from your host to that destination will be impacted.\nLet's talk about the clean way. I suppose your are running Linux, but I think you may be able to do the same in all OS that are supporting multi-routing tables feature into their kernel.\nHere is the summary of the steps you need to do:\n\nto prepare the second (or third ...) routing table using the ip command and the 'table table_name' option\nto create a rule traffic selector using ip rule using the uidrange option. This option allows you to select the traffic based on the UID of the user.\n\nWhen you have done these steps, you can test your setup by creating a user account within the range of UID selected into ip-rule command and test your routing setup.\nThe last step, is to modify your python script by switching your uid to the uid selected in ip-rule, and existing from it when you have finish to generate your traffic.\nTo summarize the clean way, it is to do the same as the bad way, but just for a limited number of users uid of your Linux system by using the multi-routing tables kernel feature, and to switch to the selected user into your script to use the special routing setup.\nThe multi-routing tables feature of kernel is the only feature I think that is able to merge 2 different systems, as you requested it, your host and its VM, without the need of VM. And you can activate the feature by switching from one user to another one into your script of any language.","Q_Score":1,"Tags":"python,networking,python-requests","A_Id":46373450,"CreationDate":"2017-09-22T10:48:00.000","Title":"Is there a way to make a http request in python using another gateway than the system default?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I tried installing z3 theorem prover.\nI am using Ubuntu 16.04.\nAnd I am using Python 2.7.12\nI did the installation in two ways:\n\nI used sudo apt-get install z3\nBut when I tried to import z3 by opening python from terminal using from z3 import * and also using import z3 as z I got an error saying No Module named z3\nI used\npython scripts\/mk_make.py\ncd build\nmake\nsudo make install\n\nand also added build\/python to PYTHONPATH and build to LD_LIBRARY_PATH but I got the same problem when i tried to import z3 using the same way.\nNow I tried running examples.py\nwhich is the folder build\/python\nAnd lo!!! No Error!!!\nI also tried running other example files and I didn't get any error for them too.\nCan anybody help me with the problem why I cannot import z3 when I open Python from terminal or any other folder outside of build\/python?\nEDIT:\nI found out that I have to do adding the folders to the path every time I open a terminal outside of build\/python","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1158,"Q_Id":46369458,"Users Score":1,"Answer":"I found out that I have to add the paths everytime I open a new terminal window. Then only z3 can be imported from anywhere.","Q_Score":1,"Tags":"python,python-2.7,z3,z3py","A_Id":47165922,"CreationDate":"2017-09-22T16:38:00.000","Title":"Cannot import z3 in python-2.7.12 in ubuntu even after installation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am working on an extendscript code (Adobe After Effects - but it is basically just javascript) which needs to iterate over tens of thousands of file names on a server. This is extremely slow in extendscript but I can accomplish what I need to in just a few seconds with python, which is my preferred language anyway. So I would like to run a python file and return an array back into extendscript. I'm able to run my python file and pass an argument (the root folder) by creating and executing a batch file, but how would pass the result (an array) back into extendscript? I suppose I could write out a .csv and read this back in but that seems a bit \"hacky\".","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":656,"Q_Id":46375886,"Users Score":5,"Answer":"In After Effects you can use the \"system\" object's callSystem() method. This gives you access to the system's shell so you can run any script from the code. So, you can write your python script that echos or prints the array and that is essentially what is returned by the system.callSystem() method. It's a synchronous call, so it has to complete before the next line in ExtendScript executes.\nThe actual code might by something like:\nvar stdOut = system.callSystem(\"python my-python-script.py\")","Q_Score":1,"Tags":"python,batch-file,extendscript","A_Id":46386083,"CreationDate":"2017-09-23T03:58:00.000","Title":"extendscript return argument from python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm pretty new to Python. However, I am writing a script that loads some data from a file and generates another file. My script has several functions and it also needs two user inputs (paths) to work.\nNow, I am wondering, if there is a way to test each function individually. Since there are no classes, I don't think I can do it with Unit tests, do I?\nWhat is the common way to test a script, if I don't want to run the whole script all the time? Someone else has to maintain the script later. Therefore, something similar to unit tests would be awesome.\nThanks for your inputs!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":293,"Q_Id":46386122,"Users Score":2,"Answer":"If you write your code in the form of functions that operate on file objects (streams) or, if the data is small enough, that accept and return strings, you can easily write tests that feed the appropriate data and check the results. If the real data is large enough to need streams, but the test data is not, use the StringIO function in the test code to adapt.\nThen use the __name__==\"__main__\" trick to allow your unit test driver to import the file without running the user-facing script.","Q_Score":0,"Tags":"python,unit-testing,testing,procedural-programming","A_Id":46386323,"CreationDate":"2017-09-24T02:53:00.000","Title":"How can I test a procedural python script properly","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is the explicit and clear disadvantages of using ASGI instead of WSGI for HTTP request handling in Django in general?\nI know ASGI is for asynchronous tasks, but it can also handle synchronous HTTP requests via http.* channels. Is it slower than normal WSGI or is there any unsupported features comparing to WSGI?\nOne more, to provide both REST API and websocket handling in same project, which way do you prefer and why?\n\nWSGI for REST + ASGI for websocket in different server instances\nWSGI for REST + ASGI for websocket in same machine\nASGI for both","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":26075,"Q_Id":46386596,"Users Score":18,"Answer":"I think the one major downside you will find is that the ASGI servers are newer and therefore tested less, may have less features, fewer in number, and probably have a smaller community behind them. However, I use an ASGI server (Daphne) for everything and feel that websockets offer so much in terms of user experience that everything will eventually shift to ASGI.\nBeing able to use asyncio in your code is a major benefit for web programming. Instead of running 10 queries one after the other and waiting for each one to come back, you can run 10 queries at the same time, while hitting your cache and making a HTTP request simultaneously on a single thread.","Q_Score":30,"Tags":"python,django,django-channels","A_Id":53784973,"CreationDate":"2017-09-24T04:28:00.000","Title":"Disadvantages of using ASGI instead of WSGI","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"What is the explicit and clear disadvantages of using ASGI instead of WSGI for HTTP request handling in Django in general?\nI know ASGI is for asynchronous tasks, but it can also handle synchronous HTTP requests via http.* channels. Is it slower than normal WSGI or is there any unsupported features comparing to WSGI?\nOne more, to provide both REST API and websocket handling in same project, which way do you prefer and why?\n\nWSGI for REST + ASGI for websocket in different server instances\nWSGI for REST + ASGI for websocket in same machine\nASGI for both","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":26075,"Q_Id":46386596,"Users Score":9,"Answer":"I didn't do any benchmarking but use both WSGI and ASGI in several project and didn't see any sufficient differences between their performance, so if the Django WSGI performance is acceptable for you then ASGI will work too.\nFor the REST + websockets API I used ASGI for both. There is no reason to use WSGI if you have ASGI enabled in your project (WSGI works over ASGI).","Q_Score":30,"Tags":"python,django,django-channels","A_Id":49812130,"CreationDate":"2017-09-24T04:28:00.000","Title":"Disadvantages of using ASGI instead of WSGI","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am looking for python library to find out a key and tempo of the song recorded in MP3 format. I've found the music21 lib that allows doing that. But it seems like it works only with midi files. \nDoes somebody know how to parse MP3 files using music21 and get the required sound characteristics? If it is impossible, please suggest another library.","AnswerCount":3,"Available Count":3,"Score":0.1973753202,"is_accepted":false,"ViewCount":995,"Q_Id":46394954,"Users Score":3,"Answer":"There are ways of doing this in music21 (audioSearch module) but it's more of a proof of concept and not for production work. There are much better software packages for analyzing audio (try sonic visualizer or jMIR or a commercial package). Music21's strength is in working with scores.","Q_Score":3,"Tags":"python,mp3,music21","A_Id":46396673,"CreationDate":"2017-09-24T21:16:00.000","Title":"Is it possible to analyze mp3 file using music21?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am looking for python library to find out a key and tempo of the song recorded in MP3 format. I've found the music21 lib that allows doing that. But it seems like it works only with midi files. \nDoes somebody know how to parse MP3 files using music21 and get the required sound characteristics? If it is impossible, please suggest another library.","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":995,"Q_Id":46394954,"Users Score":4,"Answer":"No, this is not possible. Music21 can only process data stored in musical notation data formats, like MIDI, MusicXML, and ABC.\nConverting a MP3 audio file to notation is a complex task, and isn't something that software can reliably accomplish at this point.","Q_Score":3,"Tags":"python,mp3,music21","A_Id":46395044,"CreationDate":"2017-09-24T21:16:00.000","Title":"Is it possible to analyze mp3 file using music21?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am looking for python library to find out a key and tempo of the song recorded in MP3 format. I've found the music21 lib that allows doing that. But it seems like it works only with midi files. \nDoes somebody know how to parse MP3 files using music21 and get the required sound characteristics? If it is impossible, please suggest another library.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":995,"Q_Id":46394954,"Users Score":1,"Answer":"Check out librosa. It can read mp3s and give some basic info such as tempo.","Q_Score":3,"Tags":"python,mp3,music21","A_Id":46417595,"CreationDate":"2017-09-24T21:16:00.000","Title":"Is it possible to analyze mp3 file using music21?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way to check the complexity or performance (i.e. Big O notation) of python data structure's methods offline?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":58,"Q_Id":46395323,"Users Score":0,"Answer":"If you understood what Big O notation means, you should be able to \"measure the running times\" of increasingly longer input.\nTry with input size 10, 100, 1000, 10000, ... and plot the result. This is a fine approximation of the behaviour of your function.\nYOu should make friend with pytho's time module :)","Q_Score":1,"Tags":"python","A_Id":46398934,"CreationDate":"2017-09-24T22:06:00.000","Title":"Python data structure's complexity\/performance check","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a client application with python. GUI is created with PyQt.\nBasically, the application connects to the server via ssh and retrieves information thereby reading files generated by the server software. I am using paramko module.\nMy question is:\nShould I open an ssh connectivity right when the client application is started and keep until it quits? Or I should create a new ssh connectivity whenever a button in client app triggers information retrieval?\nHow would it affect the performance?\nAny suggestion and reference would be highly appreciated.","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":64,"Q_Id":46398738,"Users Score":-1,"Answer":"Whenever you have ssh to server 1 port is block from both the side, if you have connection when client starts then it will block that port and no one could communicate to server , also you increasing server load just keeping the connection open. \nSo, my advice is to start ssh whenever the need is and stop once task is completed.","Q_Score":1,"Tags":"python,ssh,paramiko","A_Id":46398816,"CreationDate":"2017-09-25T06:19:00.000","Title":"Client application's connectivity with server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to do a script that would be able to read the taps from another keyboard. That script would run at the start, then I couldn't use raw_input at its own.\nThank you in advance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":28,"Q_Id":46410780,"Users Score":0,"Answer":"The only way i know to do this is to from turtle import *, which will import the turtle graphics module, which will allow you to use listen(), onkey(), and more... the syntax for onkey is onkey(\"FUNCTION\", \"KEY\")","Q_Score":0,"Tags":"python,python-2.7,raspberry-pi,raspberry-pi3","A_Id":46410824,"CreationDate":"2017-09-25T17:20:00.000","Title":"How to do a script to read keyboard taps","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have recently made a game with python that makes the user decipher an anagram and based on difficulty it increases their score. Is there any way to implement a high score into this without the use of a text file?\nThe overall goal is for the program to compare the users score to the high score and if the score is greater it would edit the high score to the score gained. This would need to stay like that for the next run through of the program after I close it.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":52,"Q_Id":46420245,"Users Score":3,"Answer":"At the end of the day, you need to store the score in one type of database or the other, whether it's a file-based database or relational or any other. For one execution of your code, you can certainly keep it in the RAM, but for persistence, there's no way around it. If your use case is simple, you may consider sqlite instead of explicit file-based storage.","Q_Score":1,"Tags":"python","A_Id":46420296,"CreationDate":"2017-09-26T07:29:00.000","Title":"Python: is it possible to set a high score without a text file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have recently made a game with python that makes the user decipher an anagram and based on difficulty it increases their score. Is there any way to implement a high score into this without the use of a text file?\nThe overall goal is for the program to compare the users score to the high score and if the score is greater it would edit the high score to the score gained. This would need to stay like that for the next run through of the program after I close it.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":52,"Q_Id":46420245,"Users Score":0,"Answer":"Don't forget: there's always HKCU and winreg module from stdlib. It can be useful. It's well documented.","Q_Score":1,"Tags":"python","A_Id":46421366,"CreationDate":"2017-09-26T07:29:00.000","Title":"Python: is it possible to set a high score without a text file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a bunch of 32-bit floating point values in a Python script, need to store them to disc and load them in a C++ tool.\nCurrently they are written in human-readable format. However the loss of precision is too big for my (numeric) application.\nHow do I best store (and load) them without loss?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":393,"Q_Id":46422692,"Users Score":2,"Answer":"You can use float.hex in python to get the hexadecimal representation of your number, then read it using the std::hexfloat stream manipulator in C++.","Q_Score":1,"Tags":"python,c++,json,serialization,floating-point","A_Id":46424992,"CreationDate":"2017-09-26T09:29:00.000","Title":"serializing float32 values in python and deserializing them in C++","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to write output files containing tabular datas (float values in lines and columns) from a C++ program.\nI need to open those files later on with other languages\/softwares (here python and paraview, but might change).\nWhat would be the most efficient output format for tabular files (efficient for files memory sizes efficiency) that would be compatible with other languages ?\nE.g., txt files, csv, xml, binarized or not ?\nThanks for advices","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":408,"Q_Id":46468549,"Users Score":0,"Answer":"First of all the efficiency of i\/o operations is limited by the buffer size. So if you want to achieve higher throughput you might have to play with the input output buffers. And regarding your doubt of what way to output into the files is dependent on your data and what delimiters you want to use to separate the data in the files.","Q_Score":1,"Tags":"python,c++,io","A_Id":46468692,"CreationDate":"2017-09-28T11:57:00.000","Title":"Which data files output format from C++ to be read in python (or other) is more size efficient?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to write output files containing tabular datas (float values in lines and columns) from a C++ program.\nI need to open those files later on with other languages\/softwares (here python and paraview, but might change).\nWhat would be the most efficient output format for tabular files (efficient for files memory sizes efficiency) that would be compatible with other languages ?\nE.g., txt files, csv, xml, binarized or not ?\nThanks for advices","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":408,"Q_Id":46468549,"Users Score":2,"Answer":"1- Your output files contain tabular data (float values in lines and columns), in other words, a kind of matrix.\n2- You need to open those files later on with other languages\/softwares\n3- You want to have files memory sizes efficiency\nThat's said, you have to consider one of the two formats below:\n\nCSV: if your data are very simple (a matrix of float without particualr structure)\nJSON if you need a minimum structure for your files\n\nThese two formats are standard, supported by almost all the known languages and maintained softwares.\nLast, if your data have a great complexity structure, prefer to look at a format like XML but the price to pay is then in the size of your files!\nHope this helps!","Q_Score":1,"Tags":"python,c++,io","A_Id":46473158,"CreationDate":"2017-09-28T11:57:00.000","Title":"Which data files output format from C++ to be read in python (or other) is more size efficient?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to hide a InlineKeyboardMarkup if no answer is provided. I'm using Python and python-telegram-bot. Is this possible?\nThank you.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":545,"Q_Id":46492279,"Users Score":0,"Answer":"Just edit the message sent without providing a reply_markup.","Q_Score":0,"Tags":"python,telegram-bot,python-telegram-bot","A_Id":46501988,"CreationDate":"2017-09-29T15:33:00.000","Title":"Hide InlineKeyboardMarkup in no answer provided","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm integrating MicroPython into a microcontroller and I want to add a debug step-by-step execution mode to my product (via a connection to a PC).\nThankfully, MicroPython includes a REPL aka Python shell functionality: I can feed it one line at a time and execute.\nI want to use this feature to single-step on the PC-side and send in the lines in the Python script one-by-one. \nIs there ANY difference, besides possibly timing, between running a Python script one line at a time vs python my_script.py?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1057,"Q_Id":46495647,"Users Score":1,"Answer":"I don't know whether MicroPython has compile() and exec() built-in.\nBut when embeded Python has them and when MCU has enough RAM, then I do the following:\n\nSend a line to embeded shell to start a creation of variable with multiline string.\n'_code = \"\"\"\\'\nSend the code I wish executed (line by line or however)\nClose the multiline string with \"\"\"\nSend exec command to run the transfered code stored in the variable on MCU and pick up the output.\n\nIf your RAM is small and you cannot transfer whole code at once, you should transfer it in blocks that would be executed. Like functions, loops, etc.\nIf you can compile bytecode for MicroPython on a PC, then you should be able to transfer it and prepare it for execution. This would use a lot less of RAM.\nBut whether you can inject the raw bytecode into shell and run it depends on how much MicroPython resembles CPython.\nAnd yep, there are differences. As explained in another answer line by line execution can be tricky. So blocks of code is your best bet.","Q_Score":1,"Tags":"python,micropython","A_Id":46496039,"CreationDate":"2017-09-29T19:22:00.000","Title":"Run Python script line-by-line in shell vs atomically","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to write an app that has the ability to call a script of some language from an IOS app at runtime. From what I have found so far this is not possible unless I do something like embedding Python in the app.\nBasically I want to have the ability to add an object with some properties and functions to a database online. The user will then be able to download the object to their IOS device and the object and its functionality will be added to the app. There might be hundreds of these scripts available so hard-coding them in Swift seems impractical.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":90,"Q_Id":46531585,"Users Score":0,"Answer":"You can't do that. Apple does not allow it.","Q_Score":0,"Tags":"python,ios,swift","A_Id":46531927,"CreationDate":"2017-10-02T18:34:00.000","Title":"Calling a script (some language) from a Swift app at Runtime","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to write an app that has the ability to call a script of some language from an IOS app at runtime. From what I have found so far this is not possible unless I do something like embedding Python in the app.\nBasically I want to have the ability to add an object with some properties and functions to a database online. The user will then be able to download the object to their IOS device and the object and its functionality will be added to the app. There might be hundreds of these scripts available so hard-coding them in Swift seems impractical.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":90,"Q_Id":46531585,"Users Score":0,"Answer":"It seems obvious, but you can probably run scripts as JS and catch the result from them - like put your JS to some endpoint and execute it.\nBut for your purpose I can't think about this solution as a good idea.","Q_Score":0,"Tags":"python,ios,swift","A_Id":46532638,"CreationDate":"2017-10-02T18:34:00.000","Title":"Calling a script (some language) from a Swift app at Runtime","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"\/lib64\/libc.so.6: version `GLIBC_2.22' not found (required by \/var\/task\/pyhull\/_pyhull.so).\nNot able to fix this error on Aws Lambda any help please ?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3248,"Q_Id":46568074,"Users Score":0,"Answer":"It was related to Lambda Server lib problem.Solved by making zip in aws ec2 server by installing all python libraries there in ec2","Q_Score":0,"Tags":"python,amazon-web-services,lambda,glibc","A_Id":49010419,"CreationDate":"2017-10-04T14:59:00.000","Title":"\/lib64\/libc.so.6: version `GLIBC_2.22' not found in Aws Lambda Server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"\/lib64\/libc.so.6: version `GLIBC_2.22' not found (required by \/var\/task\/pyhull\/_pyhull.so).\nNot able to fix this error on Aws Lambda any help please ?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3248,"Q_Id":46568074,"Users Score":0,"Answer":"The \/var\/task\/pyhull\/_pyhull.so was linked against GLIBC-2.22 or later.\nYou are running on a system with GLIBC-2.21 or earlier.\nYou must either upgrade your AWS system, or get a different _pyhull.so build.","Q_Score":0,"Tags":"python,amazon-web-services,lambda,glibc","A_Id":46575657,"CreationDate":"2017-10-04T14:59:00.000","Title":"\/lib64\/libc.so.6: version `GLIBC_2.22' not found in Aws Lambda Server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm using the Django test runner to run my unit tests. Some of these tests use factories which create TONS of files on my local system. They all have a detectable name, and can be removed reasonably easily.\nI'm trying to avoid having to either\n\nKeep a file-deleting cron job running\nChange my custom image model's code to delete the file if it detects that we're testing. Instead, I'd like to have a command run once (and only once) at the end of the test run to clean up all files that the tests have generated.\n\nI wrote a small management command that deletes the files that match the intended convention. Is there a way to have the test runner run call_command on that upon completion of the entire test suite (and not just in the tearDown or tearDownClass methods of a particular test)?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1122,"Q_Id":46571485,"Users Score":1,"Answer":"If you create a services.py file in the same folder as models.py, you can put the cleanup code in there and then call it from the management command and from the test tearDown while keeping it DRY.","Q_Score":2,"Tags":"python,django,unit-testing,python-unittest,factory-boy","A_Id":46572485,"CreationDate":"2017-10-04T18:11:00.000","Title":"Django\/unittest run command at the end of the test runner","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I don't understand the following from pep-0404\nIn Python 3, implicit relative imports within packages are no longer available - only absolute imports and explicit relative imports are supported. In addition, star imports (e.g. from x import *) are only permitted in module level code.\nWhat is a relative import?\nI have lines that import like this\nFrom . Import \" something\"\nWhy is it just a dot?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":65,"Q_Id":46586465,"Users Score":1,"Answer":"According to the documentation, I need to add the package name in front of the (.). So an (import .module) should be (import filename.module). Statements like (from . import something) can change to (import filename.module.something as something)","Q_Score":0,"Tags":"python,python-3.x,python-import,relative-path","A_Id":46771938,"CreationDate":"2017-10-05T13:09:00.000","Title":"Relative vs explicit import upgrading from python 2","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a class that includes some auxiliary functions that do not operate on object data. Ordinarily I would leave these methods private, but I am in Python so there is no such thing. In testing, I am finding it slightly goofy to have to instantiate an instance of my class in order to be able to call these methods. Is there a solid theoretical reason to choose to keep these methods non-static or to make them static?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":66,"Q_Id":46649482,"Users Score":2,"Answer":"If a method does not need access to the current instance, you may want to make it either a classmethod, a staticmethod or a plain function.\nA classmethod will get the current class as first param. This enable it to access the class attributes including other classmethods or staticmethods. This is the right choice if your method needs to call other classmethods or staticmethods.\nA staticmethod only gets it's explicit argument - actually it nothing but a function that can be resolved on the class or instance. The main points of staticmethods are specialization - you can override a staticmethod in a child class and have a method (classmethod or instancemethod) of the base class call the overridden version of the staticmethod - and eventually ease of use - you don't need to import the function apart from the class (at this point it's bordering on lazyness but I've had a couple cases with dynamic imports etc where it happened to be handy).\nA plain function is, well, just a plain function - no class-based dispatch, no inheritance, no fancy stuff. But if it's only a helper function used internally by a couple classes in the same module and not part of the classes nor module API, it's possibly just what you're looking for.\nAs a last note: you can have \"some kind of\" privacy in Python. Mostly, prefixing a name (whether an attribute \/ method \/ class or plain function) with a single leading underscore means \"this is an implementation detail, it's NOT part of the API, you're not even supposed to know it exists, it might change or disappear without notice, so if you use it and your code breaks then it's your problem\".","Q_Score":1,"Tags":"python,static","A_Id":46649763,"CreationDate":"2017-10-09T15:00:00.000","Title":"Should methods that do not act on object data be made static?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was able to get the callback with the redirect_uri and auth code and I was able to authorize the user and redirect him but I am not getting the account_linking in the request object after successful login ie.., I want to check whether the user is logged in or not for every message he sends.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":125,"Q_Id":46667754,"Users Score":0,"Answer":"The account linking feature does not support this type of token validation. You would need to send a request to your auth server to check if the person is still logged in.","Q_Score":0,"Tags":"python,bots,facebook-messenger,messenger,facebook-messenger-bot","A_Id":46671593,"CreationDate":"2017-10-10T13:16:00.000","Title":"Facebook messenger account linking","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"i have had a rough time getting my scripts to work on my raspberry pi zero w and the last program i need installed requires selenium. This script was designed for windows 10 + python 2.7 because i make my scripts in this environment. \nI was wondering if it is possible to use selenium on a raspberry pi zero w and preferably headless if possible.\nI can't find any info, help or guidelines online anywhere and have no idea how to use pip in raspbian (if it even has pip).","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":757,"Q_Id":46675769,"Users Score":0,"Answer":"I don't see why you couldn't. You can install pip with apt install python-pip, you'll probably need to sudo that command unless you login as root.\nThen you can just open a terminal and use the pip install command to get selenium. If that doesn't work you can try running python -m pip install instead.","Q_Score":0,"Tags":"python-2.7,selenium","A_Id":46677415,"CreationDate":"2017-10-10T20:49:00.000","Title":"Selenium (Maybe headless) on raspberry pi zero w","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"What are the differences between interactive debugging (python -m pdb foo.py) and hard-coded breakpoint (import pdb; pdb.set_trace()).\nMost tutorials on dubuggers only focuse on the use of specific commands, but it would be interesting to understand:\n\nWhat is the best practice in choosing debugging modes?\nDo they have different performance in terms of computational time?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":208,"Q_Id":46678503,"Users Score":4,"Answer":"python -m pdb foo.py will pop you into the debugger at the very beginning of the program. This is likely to be useful in very small programs which you want to analyse as a whole.\nIn larger and more complex programs, where the situation you want to investigate arises after significant computiation at the top of a tall function call stack, this sort of usage is very impractical.\nIn such a case it is usually easier to set a hard breakpoint with import pdb; pdb.set_trace() at the point in your source code where the interesting situation arises. Then you launch the program normally, it executes normally, perhaps taking a significant time to perform many computations without your intervention, until it reaches the point you care about. Only when you reach the point of interest does the debugger ask you to intervene.\nAs for performance: In the first case, you will have to step through each and every statement in order advance; in the second, the debugger is not invoked until you reach the point of interest.\nIn the firt case, the CPU spends nearly all of its time waiting for the human to respond; in the second it spends most of its time on executing the program, until the point of interest is reached.","Q_Score":3,"Tags":"python,debugging,pdb","A_Id":46681066,"CreationDate":"2017-10-11T01:49:00.000","Title":"Python debugger: interactive debugging vs. hard-coded breakpoint","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using APScheduler for my project. I went through APScheduler documentation. But I am not able to understand what is actual difference between 'Interval' and 'cron' triggers. Following definition was given in docs: \ninterval: use when you want to run the job at fixed intervals of time\ncron: use when you want to run the job periodically at certain time(s) of day","AnswerCount":1,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":1834,"Q_Id":46683129,"Users Score":7,"Answer":"With interval, you can specify that the job should run say every 15 minutes. A fixed amount of time between each run and that's it.\nWith cron, you can tell it to run on every second tuesday at 9am, or every day at noon, or on every 1st of January at 7pm. In cron, you define the minute, hour, day of month, month, day of week (eg. Monday) and year where it should run, and you can assign periodicity to any of those (ie. every Monday, or every fifth minute).\nAnything you can achieve with interval can also be achieved with cron I think, but not the other way around.","Q_Score":4,"Tags":"python-2.7,apscheduler","A_Id":46683202,"CreationDate":"2017-10-11T08:14:00.000","Title":"What is the difference between 'Interval' and 'Cron' triggers in APScheduler?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using BOT API for telegram,\nthrough setGameScore i tried to set game score of user with _user_id_ and score but its not working ...\nused bot.setGameScore (user_id = 56443156,score=65)\nIam not using game to set only for inlinequery\ni received a caused error : \"Message to set game score not found\"","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":489,"Q_Id":46685936,"Users Score":0,"Answer":"Used :\nbot.setGameScore (user_id = 5432131, score=76,inline_message_id=uygrtfghfxGKJB)\nI received these two(user_id,inline_message_id) parameters from update.callback_query","Q_Score":0,"Tags":"python,python-telegram-bot","A_Id":46703372,"CreationDate":"2017-10-11T10:30:00.000","Title":"How to set game score using setGameScore in python telegram bot","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have been using remote interpreter all the times before, but suddenly it shows failed error message: can't run python interpreter: error connecting to remote host: \nI am using SFTP, and I have tried \"Test SFTP connection\", got success message with the same host.\nI am wondering how do I see verbose message in the remote debugging connection. \nI am using PyCharm 2017.2 professional.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1301,"Q_Id":46696267,"Users Score":4,"Answer":"Solve the problem. There are two places to edit the same remote interpreter. One is from Default Setting-> Project Interpreter -> Setting Icon -> More -> edit icon, another is from Tools -> Deployment -> Configuration. The settings in both places need to be correct for the same remote interpreter.\nFor some reason, the password in my first location was cleared.","Q_Score":1,"Tags":"python,pycharm,remote-debugging","A_Id":46715433,"CreationDate":"2017-10-11T19:41:00.000","Title":"Pycharm stopped working in remote interpreter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I can see that we can create account on PyPI using OpenID as well. Can we also upload python packages to PyPI server using OpenID? Something like generic upload procedure by creating .pypirc file and using PyPI username and password.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":111,"Q_Id":46702163,"Users Score":1,"Answer":"I don't think it's possible. Setup username and password at PyPI and use them in your .pypirc.","Q_Score":1,"Tags":"python,pip,pypi,python-wheel,twine","A_Id":46708728,"CreationDate":"2017-10-12T05:38:00.000","Title":"Is it possible to upload python package on PyPI using OpenID?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a game where I have to get data from the server (through REST WebService with JSON) but the problem is I don't know when the data will be available on the server. So, I decided to use such a method that hit Server after specific time or on request on every frame of the game. But certainly this is not the right, scale able and efficient approach. Obviously, hammering is not the right choice. \nNow my question is that how do I know that data has arrived at server so that I can use this data to run my game. Or how should I direct the back-end team to design the server in an efficient way that it responds efficiently. \nRemember at server side I have Python while client side is C# with unity game-engine.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":46,"Q_Id":46708236,"Users Score":0,"Answer":"It is clearly difficult to provide an answer with little details. TL;DR is that it depends on what game you are developing. However, polling is very inefficient for at least three reasons:\n\nThe former, as you have already pointed out, it is inefficient because you generate additional workload when there is no need\nThe latter, because it requires TCP - server-generated updates can be sent using UDP instead, with some pros and cons (like potential loss of packets due to lack of ACK)\nYou may get the updates too late, particularly in the case of multiplayer games. Imagine that the last update happened right after the previous poll, and your poll is each 5 seconds. The status could be already stale.\n\nThe long and the short of it is that if you are developing a turn-based game, poll could be alright. If you are developing (as the use of Unity3D would suggest) a real-time game, then server-generated updates, ideally using UDP, are in my opinion the way to go.\nHope that helps and good luck with your project.","Q_Score":0,"Tags":"c#,python,json,rest,web-services","A_Id":46719477,"CreationDate":"2017-10-12T11:16:00.000","Title":"Check the data has updated at server without requesting every frame of the game","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to web scrape some Tweets from this url using Python 3.5\nurl = \"https:\/\/twitter.com\/search?l=en&q=ecb%20draghi%20since%3A2012-09-01%20until%3A2012-09-02&src=typd\"\nMy problem is that %20d %20s %20u are already encoded in Python 3.5, so my code does not run on this url. Is there a way to solve this issue?\nThanks in advance,\nBest","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":622,"Q_Id":46709569,"Users Score":0,"Answer":"%20 is the URL encoding for space (0x20 being space's ASCII code). Just replace all those %20 by spaces and everything will likely work.","Q_Score":0,"Tags":"python,hyperlink,web-scraping,percentage","A_Id":46709727,"CreationDate":"2017-10-12T12:25:00.000","Title":"%20d %20s %20u in link Python 3.5","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've constructed a python script python_script.py in Linux. Is there a way to do a cron job which will be compatible with Linux and Windows. In fact, even tough I have implemented this script in Linux, it will be run under a cron job in Windows.\nOtherwise, assume the script works well on Linux and Windows. How could we create an automatic task on Windows (similar to a cron job on Linux)?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":400,"Q_Id":46721382,"Users Score":0,"Answer":"Create an automatic task using scheduler in windows.create a bat file to run the Python script and schedule that ask from the windows scheduler.hope this helps","Q_Score":0,"Tags":"python,excel","A_Id":46721674,"CreationDate":"2017-10-13T02:00:00.000","Title":"Cron job which will work under Linux and Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a .py file containing some functions. One of the functions requires Python's csv module. Lets call it foo.\nHere is the thing: if I enter the python shell, import the csv module, write the defitinion of foo and use it, everything runs fine.\nThe problem comes when I try to import foo from a custom module. If I enter the python shell, import the csv module, import the module where foo is located and try to use it, it will returns an error stating that 'csv' has not been defined (it behaves as if the csv module had not been imported).\nI'm wondering if I'm missing some kind of scope behaviour related to imports. \nHow can I enable foo to use the csv module or any other module it requires?\nThank you in advance","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":42,"Q_Id":46746542,"Users Score":0,"Answer":"By importing it in the file that defines the foo function. \nThe foo function doesn't know to look in the dictionary containing the globals you use in the REPL (where you have imported csv). It looks in the globals of it's module (there's other steps here of course), if it doesn't find it there you'll get a NameError.","Q_Score":0,"Tags":"python,python-3.x,csv","A_Id":46746600,"CreationDate":"2017-10-14T16:03:00.000","Title":"Using a module inside another module","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know in pytest-timeout I can specify timeout for each testcase but single failure terminates whole test run instead failing the slacking off testcase.\nAm I forced to make my own solution of this or there are ready-to-use tools which provide that?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3317,"Q_Id":46766899,"Users Score":0,"Answer":"This has been fully supported by pytest-timeout right from the beginning, you want to use the signal method as described in the readme of pytest-timeout. Please do read the readme carefully as it comes with some caveats. And indeed it is implemented using SIGALRM as the other answer also suggests, but it already exists so no need to re-do this.","Q_Score":4,"Tags":"python,testing,timeout,pytest","A_Id":58541728,"CreationDate":"2017-10-16T09:22:00.000","Title":"pytest-timeout - fail test instead killing whole test run","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed pyaudio (latest as of today Oct 16, 2017) in my Raspberry PI 3 with \"sudo pip3 install pyaudio\". I am running \"python3\" for the code below:\n\nimport pyaudio\n\np = pyaudio.PyAudio()\nprint(\"Number of devices={}\".format(p.get_device_count()))\n\n\nThis prints Number of devices=0\nDoes anyone have the same problem? Need help to resolve this issue.\nAdditional info: \"lsusb\" prints all the devices. \nI am able to see the device in alsamixer. I am able to test that device works. Looks like pyaudio & python3 may have something to do.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":53,"Q_Id":46774670,"Users Score":0,"Answer":"The above issue was happening with Raspberry NOOBS image.\nI ended up downloading the RASPBIAN image and finally it is working though pyaudio is printing too many warning messages.","Q_Score":1,"Tags":"python-3.x,pyaudio","A_Id":46991552,"CreationDate":"2017-10-16T16:13:00.000","Title":"Raspberry Pi 3 pyaduio does not detect any devices","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to build a chatbot in FB messenger.\nI could SEND typing indicator with sender action API.\nHowever, I can't find information about receiving it.\nIs there any way to do that or is it unavailable??\nThank you!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":162,"Q_Id":46783029,"Users Score":0,"Answer":"Nope, there is no way to detect the indicator programmatically.","Q_Score":0,"Tags":"python,facebook,chatbot,messenger","A_Id":46815095,"CreationDate":"2017-10-17T05:26:00.000","Title":"how to receive typing indicator from user in facebook messenger","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to create a simple python script which will directly transfer objects from blender to Maya. I created a python script which exports the object from blender to a temp folder. now I want to import that object into Maya without actually going to Maya>file>import. I searched for the solution for a while and found out that I can create a standalone instance of Maya with mayapy.exe and work in non-GUI instance of Maya. but what I want to do is import the object into an already running instance of Maya(GUI version) as soon as the exporting script is done running.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":249,"Q_Id":46783775,"Users Score":0,"Answer":"as suggested by Andrea, I opened the commandPort of maya and connected to it using socket in python script. now i can send commands to maya using that python script as long as the maya commandPort is open.","Q_Score":1,"Tags":"python,maya","A_Id":46792329,"CreationDate":"2017-10-17T06:26:00.000","Title":"how to give commands to the running instance of maya with mayapy.exe?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using python kubernetes 3.0.0 library and kubernetes 1.6.6 on AWS.\nI have pods that can disappear quickly. Sometimes when I try to exec to them I get ApiException Handshake status 500 error status.\nThis is happening with in cluster configuration as well as kube config.\nWhen pod\/container doesn't exist I get 404 error which is reasonable but 500 is Internal Server Error. I don't get any 500 errors in kube-apiserver.log where I do find 404 ones.\nWhat does it mean and can someone point me in the right direction.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1730,"Q_Id":46789946,"Users Score":0,"Answer":"For me, The reason for 500 was basically pod unable to pull the image from GCR","Q_Score":2,"Tags":"python,kubernetes","A_Id":69754077,"CreationDate":"2017-10-17T12:16:00.000","Title":"kubectl exec returning `Handshake status 500`","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm using python kubernetes 3.0.0 library and kubernetes 1.6.6 on AWS.\nI have pods that can disappear quickly. Sometimes when I try to exec to them I get ApiException Handshake status 500 error status.\nThis is happening with in cluster configuration as well as kube config.\nWhen pod\/container doesn't exist I get 404 error which is reasonable but 500 is Internal Server Error. I don't get any 500 errors in kube-apiserver.log where I do find 404 ones.\nWhat does it mean and can someone point me in the right direction.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1730,"Q_Id":46789946,"Users Score":0,"Answer":"For me the reason was,\nI had two pods, with same label attached, 1 pod was in Evicted state and other was running , i deleted that pod, which was Evicted and issue was fixed","Q_Score":2,"Tags":"python,kubernetes","A_Id":70119831,"CreationDate":"2017-10-17T12:16:00.000","Title":"kubectl exec returning `Handshake status 500`","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a file foo.py. I have made some changes to the working directory, but not staged or commited any changes yet. I know i can use git checkout foo.py to get rid of these changes. I also read about using git reset --hard HEADwhich essentially resets your working directory, staging area and commit history to match the latest commit.\nIs there any reason to prefer using one over the other in my case, where my changes are still in working directory?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2533,"Q_Id":46800824,"Users Score":0,"Answer":"Under your constraints, there's no difference. If there ARE staged changes, there is, though:\nreset reverts staged changes.\ncheckout does not ...","Q_Score":7,"Tags":"python,git","A_Id":46801007,"CreationDate":"2017-10-17T23:50:00.000","Title":"git reset --hard HEAD vs git checkout","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a file foo.py. I have made some changes to the working directory, but not staged or commited any changes yet. I know i can use git checkout foo.py to get rid of these changes. I also read about using git reset --hard HEADwhich essentially resets your working directory, staging area and commit history to match the latest commit.\nIs there any reason to prefer using one over the other in my case, where my changes are still in working directory?","AnswerCount":3,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":2533,"Q_Id":46800824,"Users Score":6,"Answer":"Is there any reason to prefer using one over the other in my case, where my changes are still in working directory?\n\nNo, since they will accomplish the same thing.\n\nIs there any reason to prefer using [git checkout -- path\/to\/file] over [git reset --hard] in [general but not in my specific case]?\n\nYes: this will affect only the one file. If your habit is git reset --hard to undo changes to one file, and you have work-tree and\/or staged changes to other files too, and you git reset --hard, you may be out of luck getting those changes back without reconstructing them by hand.\nNote that there is a third construct: git checkout HEAD path\/to\/file. The difference between this and the one without HEAD (with -- instead1) is that the one with HEAD means copy the version of the file that is in a permanent, unchangeable commit into the index \/ staging-area first, and then into the work-tree. The one with -- means copy the version of the file that is in the index \/ staging-area into the work-tree.\n\n1The reason to use -- is to make sure Git never confuses a file name with anything else, like a branch name. For instance, suppose you name a file master, just to be obstinate. What, then, does git checkout master mean? Is it supposed to check out branch master, or extract file master? The -- in git checkout -- master makes it clear to Git\u2014and to humans\u2014that this means \"extract file master\".\n\nSummary, or, things to keep in mind\nThere are, at all times, three active copies of each file:\n\none in HEAD;\none in the index \/ staging-area;\none in the work-tree.\n\nThe git status command looks at all three, comparing HEAD-vs-index first\u2014this gives Git the list of \"changes to be committed\"\u2014and then index-vs-work-tree second. The second one gives Git the list of \"changes not staged for commit\".\nThe git add command copies from the work-tree, into the index.\nThe git checkout command copies either from HEAD to the index and then the work-tree, or just from the index to the work-tree. So it's a bit complicated, with multiple modes of operation:\n\ngit checkout -- path\/to\/file: copies from index to work-tree. What's in HEAD does not matter here. The -- is usually optional, unless the file name looks like a branch name (e.g., a file named master) or an option (e.g., a file named -f).\n\ngit checkout HEAD -- path\/to\/file: copies from HEAD commit, to index, then to work-tree. What's in HEAD overwrites what's in the index, which then overwrites what's in the work-tree. The -- is usually optional, unless the file name looks like an option (e.g., -f).\nIt's wise to use the -- always, just as a good habit.\n\n\nThe git reset command is complicated (it has many modes of operation).\n(This is not to say that git checkout is simple: it, too, has many modes of operation, probably too many. But I think git reset is at least a little bit worse.)","Q_Score":7,"Tags":"python,git","A_Id":46800935,"CreationDate":"2017-10-17T23:50:00.000","Title":"git reset --hard HEAD vs git checkout","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I can run the code but trying to use the Hydrogen package in Atom I have problems importing some (not all) modules and I do not why. I do use Hydrogen with Python3.6 and i did install all needed modules with pip3.\nImportErrorTraceback (most recent call last)\n in ()\n----> 1 import sklearn\nImportError: No module named sklearn","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":2045,"Q_Id":46864270,"Users Score":4,"Answer":"I don't have high enough reputation to comment, so my barebones answer will have to be put here. I think your problem is to do with where the kernel is starting. In the Hydrogen settings, look for the option 'Directory to start kernel in'. The default is to always start in the directory in which Hydrogen was first invoked. If you have installed modules in a different working directory, then they will not be found, unless you change this option to 'current directory of the file' (restart required)\nYou can check your sys.path() to see where the kernel is looking for modules. If all else fails, you can manually move the installed packages to the 'site-packages' folder, whose location is revealed by sys.path()\nI thought pip would put the packages in the right place by default, but maybe not - especially if you have virtual environments set up. \nYou can use the command pip show to get the path to which pip has installed the package in question.","Q_Score":1,"Tags":"python,python-3.x,scikit-learn,atom-editor,hydrogen","A_Id":48893827,"CreationDate":"2017-10-21T14:24:00.000","Title":"Importing Modules with Hydrogen in Atom","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have worked with Python for about 4 years and have recently started learning C++. In C++ you create a constructor method for each class I I was wondering if it is correct to think that this is equivalent to the __init__(self) function in Python? Are there any notable differences? Same question for a C++ destructor method vs. Python _exit__(self)","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1097,"Q_Id":46864368,"Users Score":1,"Answer":"Yes, Python's __init__ is analogous to C++'s constructor. Both are typically where non-static data members are initialized. In both languages, these functions take the in-creation object as the first argument, explicit and by convention named self in Python and implicit and by language named this in C++. In both languages, these functions can return nothing. One notable difference between the languages is that in Python base-class __init__ must be called explicitly from an inherited class __init__ and in C++ it is implicit and automatic. C++ also has ways to declare data member initializers outside the body of the constructor, both by member initializer lists and non-static data member initializers. C++ will also generate a default constructor for you in some circumstances.\nPython's __new__ is analogous to C++'s class-level operator new. Both are static class functions which must return a value for the creation to proceed. In C++, that something is a pointer to memory and in Python it is an uninitialized value of the class type being created.\nPython's __del__ has no direct analogue in C++. It is an object finalizer, which exist also in other garbage collected languages like Java. It is not called at a lexically predetermined time, but the runtime calls it when it is time to deallocate the object.\n__exit__ plays a role similar to C++'s destructor, in that it can provide for deterministic cleanup and a lexically predetermined point. In C++, this tends to be done through the C++ destructor of an RAII type. In Python, the same object can have __enter__ and __exit__ called multiple times. In C++, that would be accomplished with the constructor and destructor of a separate RAII resource holding type. For example, in Python given an instance lock of a mutual exclusion lock type, one can say with lock: to introduce a critical section. In C++, we create an instance of a different type taking the lock as a parameter std::lock_guard g{lock} to accomplish the same thing. The Python __enter__ and __exit__ calls map to the constructor and destructor of the C++ RAII type.","Q_Score":1,"Tags":"python,c++,constructor","A_Id":46864702,"CreationDate":"2017-10-21T14:34:00.000","Title":"Python __init__ Compared to C++ Constructor","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have worked with Python for about 4 years and have recently started learning C++. In C++ you create a constructor method for each class I I was wondering if it is correct to think that this is equivalent to the __init__(self) function in Python? Are there any notable differences? Same question for a C++ destructor method vs. Python _exit__(self)","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":1097,"Q_Id":46864368,"Users Score":1,"Answer":"The best you can say is that __init__ and a C++ constructor are called at roughly the same point in the lifetime of a new object, and that __del__ and a C++ destructor are also called near the end of the lifetime of an object. The semantics, however, are markedly different, and the execution model of each language makes further comparison more difficult.\nSuffice it to say that __init__ is used to initialize an object after it has been created. __del__ is like a destructor that may be called at some unspecified point in time after the last reference to an object goes away, and __exit__ is more like a callback invoked at the end of a with statement, whether or not the object's reference count reaches zero.","Q_Score":1,"Tags":"python,c++,constructor","A_Id":46864771,"CreationDate":"2017-10-21T14:34:00.000","Title":"Python __init__ Compared to C++ Constructor","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Could someone with Pika experience give me a quick yes\/no response as to whether the following functionality is possible, or whether my thinking that it is indicates a lack of conceptual understanding of Pika.\nMy desired functionality:\nPython service (single threaded script) has one connection to my RabbitMQ broker using the SelectConnection adapter. \nThat connection has two channels.\nUsing one channel, A, the service declares a queue and binds to some exchange E1. \nThe other channel, B, is used to declares some other exchange, E2.\nThe service consumes messages from the queue via A.\nIt does some small processing of those messages, [possibly carries out CRUD operates through its connection to a MongoDB instance,] then publishes a message to exchange E2 via B.\nI have read the Pika docs thoroughly, and have not found enough information to understand whether this is doable. \nTo put it simply - can a single python script both publish and consume via one selectconnection adapter connection?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1125,"Q_Id":46871609,"Users Score":2,"Answer":"Yes of course. You can achieve that in many ways (via the same connection, different connection, same channel, different channel etc.)\nWhat I do when I have implemented this in the past is, I create my connection, get the channel and setup my consumer with it's delegate (function). When my consume message function is called I get the channel parameter that comes with it, which I sub-sequentially use to publish the next message to a different queue. If you don't want to use the same channel, you can simply setup another then.","Q_Score":3,"Tags":"rabbitmq,messaging,microservices,pika,python-pika","A_Id":56149895,"CreationDate":"2017-10-22T07:34:00.000","Title":"Can a Pika RabbitMQ client service both consume and publish messages?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have some sensor nodes. they are connected to a Raspberry Pi 2 and send data on it. the data on Raspberry Pi is sending the data to Thingspeak.com and it shows the data from sensor nodes. \nnow I am developing a Kaa server and wanna see my data (from Raspberry Pi) on Kaa. is there any chance to connect the current programmed Raspberry Pi(in Python) to Kaa? \nMany thanks, \nShid","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":495,"Q_Id":46871792,"Users Score":0,"Answer":"Mashid. From what I know, to use a KAA server, you should utilize the SDK obtained when you create a new application on the KAA server. This SDK also functions as an API key that will connect the device with a KAA server (on a KAA server named with Application Token). The platforms provided for using this SDK are C, C ++, Java, Android, and Objective C. There is currently no SDK for the Python platform.","Q_Score":0,"Tags":"python,raspberry-pi,sandbox,iot,kaa","A_Id":48001019,"CreationDate":"2017-10-22T07:59:00.000","Title":"how to connect a programmed raspberry pi to a Kaa platform?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Dev C++. Include Python.h doesnt work, and IDE states it cant find the file or directory. I can pull up the Python.h C file, so I know I have it. How do I connect two-and-two? I imagine I have to tell my IDE where the file path is, but how would I do that?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1269,"Q_Id":46878736,"Users Score":1,"Answer":"check that in dev-C++ tools > compiler options > directories > c includes and c++ includes have the path to where your Python.h is.","Q_Score":1,"Tags":"python,c++,ide","A_Id":46878851,"CreationDate":"2017-10-22T20:16:00.000","Title":"How to get Dev C++ to find Python.h","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working my way through Google Foobar and I'm very confused about \"Free the Bunny Prisoners\". I'm not looking for code, but I could use some insight from anyone that's completed it. First, the problem:\n\nFree the Bunny Prisoners\nYou need to free the bunny prisoners before Commander Lambda's space\n station explodes! Unfortunately, the commander was very careful with\n her highest-value prisoners - they're all held in separate,\n maximum-security cells. The cells are opened by putting keys into each\n console, then pressing the open button on each console simultaneously.\n When the open button is pressed, each key opens its corresponding lock\n on the cell. So, the union of the keys in all of the consoles must be\n all of the keys. The scheme may require multiple copies of one key\n given to different minions.\nThe consoles are far enough apart that a separate minion is needed for\n each one. Fortunately, you have already freed some bunnies to aid you\n - and even better, you were able to steal the keys while you were working as Commander Lambda's assistant. The problem is, you don't\n know which keys to use at which consoles. The consoles are programmed\n to know which keys each minion had, to prevent someone from just\n stealing all of the keys and using them blindly. There are signs by\n the consoles saying how many minions had some keys for the set of\n consoles. You suspect that Commander Lambda has a systematic way to\n decide which keys to give to each minion such that they could use the\n consoles.\nYou need to figure out the scheme that Commander Lambda used to\n distribute the keys. You know how many minions had keys, and how many\n consoles are by each cell. You know that Command Lambda wouldn't\n issue more keys than necessary (beyond what the key distribution\n scheme requires), and that you need as many bunnies with keys as there\n are consoles to open the cell.\nGiven the number of bunnies available and the number of locks required\n to open a cell, write a function answer(num_buns, num_required) which\n returns a specification of how to distribute the keys such that any\n num_required bunnies can open the locks, but no group of (num_required\n - 1) bunnies can.\nEach lock is numbered starting from 0. The keys are numbered the same\n as the lock they open (so for a duplicate key, the number will repeat,\n since it opens the same lock). For a given bunny, the keys they get is\n represented as a sorted list of the numbers for the keys. To cover all\n of the bunnies, the final answer is represented by a sorted list of\n each individual bunny's list of keys. Find the lexicographically\n least such key distribution - that is, the first bunny should have\n keys sequentially starting from 0.\nnum_buns will always be between 1 and 9, and num_required will always\n be between 0 and 9 (both inclusive). For example, if you had 3\n bunnies and required only 1 of them to open the cell, you would give\n each bunny the same key such that any of the 3 of them would be able\n to open it, like so: [ [0], [0], [0], ] If you had 2 bunnies and\n required both of them to open the cell, they would receive different\n keys (otherwise they wouldn't both actually be required), and your\n answer would be as follows: [ [0], [1], ] Finally, if you had 3\n bunnies and required 2 of them to open the cell, then any 2 of the 3\n bunnies should have all of the keys necessary to open the cell, but no\n single bunny would be able to do it. Thus, the answer would be: [\n [0, 1], [0, 2], [1, 2], ]\nLanguages\nTo provide a Python solution, edit solution.py To provide a Java\n solution, edit solution.java\nTest cases\nInputs:\n (int) num_buns = 2\n (int) num_required = 1 Output:\n (int) [[0], [0]]\nInputs:\n (int) num_buns = 5\n (int) num_required = 3 Output:\n (int) [[0, 1, 2, 3, 4, 5], [0, 1, 2, 6, 7, 8], [0, 3, 4, 6, 7, 9], [1, 3, 5, 6, 8, 9], [2, 4, 5, 7, 8, 9]]\nInputs:\n (int) num_buns = 4\n (int) num_required = 4 Output:\n (int) [[0], [1], [2], [3]]\n\nI can't figure out why answer(5, 3) = [[0, 1, 2, 3, 4, 5], [0, 1, 2, 6, 7, 8], [0, 3, 4, 6, 7, 9], [1, 3, 5, 6, 8, 9], [2, 4, 5, 7, 8, 9]]. It seems to me that [[0], [0, 1, 2], [0, 1, 2], [1], [2]] completely satisfies the requirements laid out in the description. I don't know why you'd ever have keys with a value greater than num_required-1.\nOne possibility I thought of was that there are unwritten rules that say all of the minions\/bunnies need to have the same number of keys, and you can only have num_required of each key. However, if that's the case, then [[0, 1, 2], [0, 1, 2], [0, 3, 4], [1, 3, 4], [2, 3, 4]] would be okay.\nNext I thought that maybe the rule about needing to be able to use all num_required keys at once extended beyond 0, 1, and 2, regardless of how many consoles there are. That is, you should be able to make [6, 7, 8] as well as [0, 1, 2]. However, that requirement would be broken because the first bunny doesn't have any of those numbers.\nI'm stuck. Any hints would be greatly appreciated!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4292,"Q_Id":46898131,"Users Score":4,"Answer":"I think you missed the part where it says \nbut no group of (num_required - 1) bunnies can.\nI can explain my solution further, but I will ruin the fun. (I'm the owner of that repo).\nLet's try it with your answer.\n[[0], [0, 1, 2], [0, 1, 2], [1], [2]]\nYour consoles are 3. Bunny 2 can open it on its own, Bunny 3 can open it also on his own -> it does NOT satisfy the rule.","Q_Score":3,"Tags":"java,python","A_Id":46918732,"CreationDate":"2017-10-23T20:40:00.000","Title":"Google Foobar: Free the Bunny Prisoners clarification","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Today I messed up the versions of Python on my CentOS machine. Even yum cannot work properly. I made the mistake that I removed the default \/usr\/bin\/python which led to this situation. How could I get back a clear Python environment? I thought remove them totally and reinstall Python may work, but do not know how to do it. Wish somebody could help!","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":19404,"Q_Id":46915455,"Users Score":-1,"Answer":"To install Python on CentOS: sudo yum install python2\/3 (select the version as per requirement)\nTo uninstall Python on CentOS: sudo yum remove python2\/3 (select the version as per your requirement)\nTo check version for python3(which you installed): python3 --version\nTo check version for python2 (which you installed): python2 --version","Q_Score":3,"Tags":"python,centos,rpm,yum","A_Id":63481093,"CreationDate":"2017-10-24T16:20:00.000","Title":"Remove clearly and reinstall python on CentOS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am writing a tool for internal use at work. A user enters a router or switch IP address, username and password into a web form. The app then uses pexpect to SSH into the device, downloads a configuration and tests that the configuration complies with various standards by running true\/false tests (e.g. hostname is set). Leaving aside whether this is a good idea or not, my problem is that when I run the program under the Flask development program it works fine. When I set it up to run under WSGI it fails at the SSH portion with the error:\npexpect.exceptions.ExceptionPexpect: The command was not found or was not executable: ssh.\nI tried uWSGI and Unicorn and played with the number of workers etc. to no avail.\nI suspect this is a setuid root thing. Google searches do not point to a solution. Can anyone lead me to a fix? If pexpect will not work, I may give up and require the user to upload a config file they save themselves but I am frustrated that this works on the flask development server but not a production server.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":256,"Q_Id":46919968,"Users Score":0,"Answer":"You probably just need to replace ssh with its full path, e.g. \/usr\/bin\/ssh.\nYou can find the full path with which ssh.","Q_Score":1,"Tags":"python,flask,pexpect","A_Id":62195793,"CreationDate":"2017-10-24T21:03:00.000","Title":"Using python flask and pexpect works on flask development server fails with WSGI","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am running a uwsgi application on my linux mint. it has does work with a database and shows it on my localhost. i run it on 127.0.0.1 IP and 8080 port. after that i want to test its performance by ab(apache benchmark).\nwhen i run the app by command uwsgi --socket 0.0.0.0:8080 --protocol=http -w wsgi and get test of it, it works correctly but slowly.\nso i want to run the app with more than one thread to speed up. so i use --threads option and command is uwsgi --socket 0.0.0.0:8080 --protocol=http -w wsgi --threads 8 for example. \nbut when i run ab to test it, after 2 or 3 request, my application stops with some errors and i don't know how to fix it. every time i run it, type of errors are different. some of errors are like these:\n\n(Traceback (most recent call last): 2014, 'Command Out of Sync')\n\nor \n\n(Traceback (most recent call last): File \".\/wsgi.py\", line 13, in\n application\n return show_description(id) File \".\/wsgi.py\", line 53, in show_description\n cursor.execute(\"select * from info where id = %s;\" %id) File \"\/home\/mohammadhossein\/myFirstApp\/myappenv\/local\/lib\/python2.7\/site-packages\/pymysql\/cursors.py\",\n line 166, in execute\n result = self._query(query) File \"\/home\/mohammadhossein\/myFirstApp\/myappenv\/local\/lib\/python2.7\/site-packages\/pymysql\/cursors.py\",\n line 322, in _query\n conn.query(q) File \"\/home\/mohammadhossein\/myFirstApp\/myappenv\/local\/lib\/python2.7\/site-packages\/pymysql\/connections.py\",\n line 856, in query\n self._affected_rows = self._read_query_result(unbuffered=unbuffered) 'Packet sequence number\n wrong - got 1 expected 2',) File\n \"\/home\/mohammadhossein\/myFirstApp\/myappenv\/local\/lib\/python2.7\/site-packages\/pymysql\/connections.py\",\n line 1057, in _read_query_result\n\nor \n\n('Packet sequence number wrong - got 1 expected 2',) Traceback (most\n recent call last):\n\nor \n\n('Packet sequence number wrong - got 1 expected 2',) Traceback (most\n recent call last): File \".\/wsgi.py\", line 13, in application\n return show_description(id) File \".\/wsgi.py\", line 52, in show_description\n cursor.execute('UPDATE info SET views = views+1 WHERE id = %s;', id) File\n \"\/home\/mohammadhossein\/myFirstApp\/myappenv\/local\/lib\/python2.7\/site-packages\/pymysql\/cursors.py\",\n line 166, in execute\n result = self._query(query)\n\nPlease help me how to run my uwsgi application wiht more than one thread safety. any help will be welcome","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":238,"Q_Id":46927517,"Users Score":0,"Answer":"it has solved.\nthe point is that you should create separate connection for each completely separate query to avoid missing data during each query execution","Q_Score":0,"Tags":"python,multithreading,server,uwsgi","A_Id":47568008,"CreationDate":"2017-10-25T08:26:00.000","Title":"uwsgi application stops with error when running it with multi thread","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"Okay i can send audio with some url in inline mode. But how can i send the local audio from the directory? Telegram Bot API return me this:\n\nA request to the Telegram API was unsuccessful. The server returned\n HTTP 400 Bad Request. Response body:\n [b'{\"ok\":false,\"error_code\":400,\"description\":\"Bad Request:\n CONTENT_URL_INVALID\"}']","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":505,"Q_Id":46940780,"Users Score":0,"Answer":"InlineQueryResultAudio only accepts links while InlineQueryResultCachedAudio only accepts file_id. What you can do is post the files to your own server or upload it elsewhere to use the former one, or use SendAudio to get the file_id of it and use the latter one.","Q_Score":0,"Tags":"python,telegram-bot,python-telegram-bot","A_Id":46947479,"CreationDate":"2017-10-25T19:37:00.000","Title":"Telegram Bot API InlineQueryResultAudio","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How to open my .py script from anywhere on my pc directly into python idle form command prompt?\nIs there any way so that i can typeidle test.py on cmd so that it opens the test.py file in the current directory and if test.py is not available creates a new file and opens it into idle","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2809,"Q_Id":47001108,"Users Score":3,"Answer":"You can do that by adding the directory where you have installed the idle editor the PATH environment variable.\nHow to do that depends on your operating system: just search the Internet for add directory to path plus your operating system: e.g. Windows\/Ubuntu, etc.\nAfter changing the environment variable it may be a good idea to restart your PC (to make sure that all programs use the updated version)","Q_Score":3,"Tags":"python,windows,python-idle","A_Id":47001239,"CreationDate":"2017-10-29T14:07:00.000","Title":"Python IDLE from cmd","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a Raspberry Pi running Linux. My plan is that I can plug in a USB in the robot and have and it will run the python files. the reason I chose this method is that it allows for easy editing and debugging of the scripts.\nIs there a way to execute my files when the USB is inserted?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2024,"Q_Id":47005067,"Users Score":1,"Answer":"Try to use os.path.exists to detect whether the pendrive is there in an infinite loop and when detected execute code on pendrive using os.system and break out of loop .","Q_Score":0,"Tags":"python,usb,autorun","A_Id":58617987,"CreationDate":"2017-10-29T20:44:00.000","Title":"Auto run python file when usb inserted","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a GSM Modem SIM 900D. I am using it with my server and Python code to send and receive messages. I want to know how many Text SMS I could send and receive through this GSM modem per minute.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":377,"Q_Id":47030098,"Users Score":0,"Answer":"If you consider all protocols involved, including radio part, 300+ messages across a good dozen of protocols would have to be sent in order to deliver outgoing SMS to SMSC, and a great deal of waiting and synchronization will have to be involved. This (high overhead) will be your limiting factor and you would probably get 10-15 SMS per minute or so. \nReducing overhead is only possible with a different connectivity methods, mostly to eliminate radio part and mobility management protocols. Usual methods are: connecting to a dedicated SMS gateway provider via whatever protocol they fancy, or acting as SMSC yourself and connecting to SS7 network directly.","Q_Score":0,"Tags":"python,sms,gsm,sms-gateway","A_Id":47046290,"CreationDate":"2017-10-31T07:37:00.000","Title":"GSM 900D Module Limit for Text Messages Sending & Receiving","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Every AWS Account has an email associated to it. \nHow can I change that email address for that account using boto3?","AnswerCount":2,"Available Count":2,"Score":0.3799489623,"is_accepted":false,"ViewCount":494,"Q_Id":47063752,"Users Score":4,"Answer":"It is not possible to change an account's email address (Root) programmatically. You must log in to the console using Root credentials and update the email address.","Q_Score":0,"Tags":"python,amazon-web-services,email,boto3,amazon-iam","A_Id":47064014,"CreationDate":"2017-11-01T21:13:00.000","Title":"How can I change the AWS Account Email with boto3?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Every AWS Account has an email associated to it. \nHow can I change that email address for that account using boto3?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":494,"Q_Id":47063752,"Users Score":0,"Answer":"No as of Oct 2019 you can't update account information(including email) using boto or any other AWS provided SDKs.","Q_Score":0,"Tags":"python,amazon-web-services,email,boto3,amazon-iam","A_Id":58530022,"CreationDate":"2017-11-01T21:13:00.000","Title":"How can I change the AWS Account Email with boto3?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to write the telegram bot, and i need help here \nbot.deleteMessage(chat_id=chatId, message_id=mId)\nThis code returns the following error: 400 Bad Request: message can't be deleted \nBot has all rights needed for deleting messages.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2259,"Q_Id":47064078,"Users Score":0,"Answer":"A bot can delete messages:\n1. in groups:\nOnly his own messages if he is not admin, otherwise also messages from other users.\n2. in private:\nonly his own messages\n\nin both the cases only if the message is not older than 48h.\nProbably, since you said in comments messages aren't older than 48h, you can doing it wrong because of the first 2 points","Q_Score":1,"Tags":"python,telegram,telegram-bot,python-telegram-bot","A_Id":47100798,"CreationDate":"2017-11-01T21:36:00.000","Title":"Telegram Bot deleteMessage function returns 400 Bad Request Error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Using dockerbuild file, how can I do there something like:\nexport PYTHONPATH=\/:$PYTHONPATH\nusing RUN directive or other option","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2449,"Q_Id":47079459,"Users Score":7,"Answer":"In your Dockerfile, either of these should work:\n\nUse the ENV instruction (ENV PYTHONPATH=\"\/:$PYTHONPATH\")\nUse a prefix during the RUN instruction (RUN export PYTHONPATH=\/:$PYTHONPATH && )\n\nThe former will persist the changes across layers. The latter will take effect in that layer\/RUN command","Q_Score":2,"Tags":"python,docker","A_Id":47079624,"CreationDate":"2017-11-02T15:50:00.000","Title":"Adding path to pythonpath in dockerbuild file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm building an experiment in Psychopy in which, depending on the participants response, I append an element to a list. I'd need to remove\/pop\/del it after a specific amount of time has passed after it was appended (e.g. 10 seconds). I was considering creating a clock to each element added, but as I need to give a name to each clock and the number of elements created is unpredictable (dependent on the participants responses), I think I'd have to create names to each of the clocks created on the go. However, I don't know how to do that and, on my searches about this, people usually say this isn't a good idea. \nWould anyone see a solution to the issue: remove\/pop\/del after a specific time has passed after appending the element?\nBest,\nFelipe","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":95,"Q_Id":47080385,"Users Score":3,"Answer":"I would take a slightly different approach: I would wrap the items you're inserting into the list with a thin object that has a timestamp field.\nThen I'd just leave it there, and when you iterate the list to find an object to pop - check the timestamp first and if it's bigger than 10 seconds, discard it. Do it iteratively until you find the next element that is younger than 10 seconds and use it for your needs.\nImplementing this approach should be considerably simpler than triggering events based on time and making sure they run accurately and etc.","Q_Score":1,"Tags":"python,list,append,psychopy,del","A_Id":47080508,"CreationDate":"2017-11-02T16:39:00.000","Title":"Append an element to a list and del\/pop\/remove it after a a specific amount of time has passed since it was appended","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is the difference between \"AWS Command Line Interface\" and \"AWS Elastic Beanstalk Command Line Interface\"? \nDo I need both to deploy a Django project through AWS Elastic Beanstalk?\nThank you!","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1072,"Q_Id":47106848,"Users Score":2,"Answer":"You should start with the EBCLI and then involve the AWSCLI where the EBCLI falls short.\nThe AWSCLI (aws) allows you to run commands from a bunch of different services, whereas, the EBCLI (eb) is specific to Elastic Beanstalk. The EBCLI makes a lot of tedious tasks easier because it is less hands on than the AWS CLI. I have observed, for most of my tasks, the EBCLI is sufficient; I use the AWS CLI and the AWS SDKs otherwise.\nConsider deploying your Django app.\n\nYou could start off by performing eb init, which would take you through an interactive set of menus, from which you would choose your region, and solution stack (Python).\nNext, you would perform eb create, which creates an application version and subsequently an Elastic Beanstalk environment for you.\n\nThe above two EBCLI steps translate to half a dozen or more AWSCLI steps. Furthermore, a lot of the processes that the EBCLI hides from you involve multiple AWS services, which can make the task of replicating the EBCLI through the AWS CLI all the more tedious and error-prone.","Q_Score":3,"Tags":"python,django,amazon-web-services,aws-cli,amazon-elastic-beanstalk","A_Id":47276695,"CreationDate":"2017-11-04T02:40:00.000","Title":"What is the difference between AWSCLI and AWSEBCLI?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"What is the difference between \"AWS Command Line Interface\" and \"AWS Elastic Beanstalk Command Line Interface\"? \nDo I need both to deploy a Django project through AWS Elastic Beanstalk?\nThank you!","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1072,"Q_Id":47106848,"Users Score":0,"Answer":"You only need eb to deploy and control Elastic Beanstalk. You can use aws to control any other resource in AWS. You can also use aws for lower-level control of Elastic Beanstalk.","Q_Score":3,"Tags":"python,django,amazon-web-services,aws-cli,amazon-elastic-beanstalk","A_Id":47106874,"CreationDate":"2017-11-04T02:40:00.000","Title":"What is the difference between AWSCLI and AWSEBCLI?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I've been looking around for a solution to this and I'm completely stuck.\nThe icecast\/shoutcast libs all seem to be Python 2.7 which is an issue as I'm using 3.6\nAny ideas for where to start with broadcasting and authenticating would be very useful. I'm looking to stream mp3 files.\nTIA.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2107,"Q_Id":47121053,"Users Score":0,"Answer":"Use liquidsoap to generate your audio stream(s) and output them to shoutcast and\/or icecast2 servers. I currently have liquidsoap, shoutcast, icecast2 and apache2 all running on the same Ubuntu 18.04 server. liquidsoap generates the audio stream and outputs it to both shoutcast and icecast2. Listeners can use their browser to access either the shoutcast stream at port 8000 or the icecast2 stream at port 8010. It works very well 24 x 7.\nYou can have multiple streams and liquidsoap has many features including playlists and time-based (clock) actions. See the liquidsoap documentation for examples to create audio streams from your mp3 or other format audio files. Best of all liquidsoap is free.","Q_Score":1,"Tags":"python,python-3.x,streaming,audio-streaming,shoutcast","A_Id":61761330,"CreationDate":"2017-11-05T11:31:00.000","Title":"Python broadcast to shoutcast (DNAS) or icecast","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am looking for some help knowing what to research\/look into for connecting an AWS Lambda function to a homemade server. \nI am building an Amazon Echo skill that uses AWS Lambda. The end goal is to have the Echo skill get information from my server and contribute to a database sitting on the server. I am using Nginx and Gunicorn to help serve my Flask application.\nAre there any tools or concepts I can look into to make this work? Currently, I am kind of lost and am seeing AWS Lambda and my server as two unique, silo-ed entities. But surely this isn't the case!\nThank you for your help!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":54,"Q_Id":47126418,"Users Score":3,"Answer":"You need to build an API on your server. Probably a REST API, or at least some HTTP endpoints on your Flask server that will accept some JSON data in the request. Then your Lambda function will make HTTP requests to your server to interact with it.","Q_Score":0,"Tags":"python,amazon-web-services,nginx,flask,aws-lambda","A_Id":47126544,"CreationDate":"2017-11-05T20:42:00.000","Title":"How do I connect AWS Lambda to homemade server?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Suppose I have a python script that uses many uncommon modules. I want to deploy this script to sites which are unlikely to have these uncommon modules. What are some convenient way to install and deploy this python script without having to run \"pip\" at all the sites?\nI am using python v3.x","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":164,"Q_Id":47149250,"Users Score":0,"Answer":"You can create a python package with all the uncommon modules in your project and upload to a feed, could be public feed like www.pypi.org where all the pip installs are downloaded from or it could be your organizations azure devops artifacts.\nAfter uploading your package, you only need to pip install from the feed that you have chosen.","Q_Score":3,"Tags":"python,python-3.x,deployment,pyinstaller","A_Id":61566212,"CreationDate":"2017-11-07T02:55:00.000","Title":"Deploying python script that uses uncommon modules","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I use Komodo-edit to edit usually python files, and so far the syntax highlighting works fine. \nBut currently I have created two files in the same(!) session which are in different tabs: test2.py and test3.py. In one case the code is syntax highlighted, for the other code it is not. Everything is just in black font colour. \nWhat is going on? How to have syntax highlighting for this tab?\nWhen I right-click in a tab I can select Properties and Settings which opens a new window. In this window, I select File Preferences -> Languages -> Syntax Checking. In there the selected language is text and I cannot change it. The section is called Language-specific syntax checking properties.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":85,"Q_Id":47183145,"Users Score":0,"Answer":"In the Properties and Settings just go to File Preferences. Here you can change the language setting.","Q_Score":0,"Tags":"python,komodo","A_Id":47184856,"CreationDate":"2017-11-08T15:10:00.000","Title":"Why do I have partly no code syntax highlighting in Komodo-edit?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wanted to know whether win32com.client package be used in an python app if I want to run that application in the Unix server. My goal is to set a cron in the unix server to automate some mail related task using win32com.client. All I want to know is that will this whole win32com will work smoothly in the Unix server.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":624,"Q_Id":47194826,"Users Score":0,"Answer":"No. win32com can only be installed and used on a Windows OS.","Q_Score":0,"Tags":"python,unix,win32com","A_Id":47194889,"CreationDate":"2017-11-09T05:56:00.000","Title":"Small query regarding win32com.client","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I wrote a Python script for mass commenting on a certain website.It works perfectly on my computer but when my friend tried running it on his then a Captcha would appear on the login page where as on running it on my machine no captcha appears.I tried resetting the caches,cookies but still no captcha. Tried resetting the browser settings but still no luck and on the other system the captcha always appears.If you could list down the reasons of why this happening that would be great.Thanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":40,"Q_Id":47215370,"Users Score":0,"Answer":"His IP is probably flagged. Also recaptcha will automatically throw a captcha if an outdated or odd user agent is detected.","Q_Score":0,"Tags":"python,python-2.7,python-3.x,recaptcha,captcha","A_Id":47215397,"CreationDate":"2017-11-10T03:47:00.000","Title":"Captcha not Appearing or Malfunctioning on one system and working on the other","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I developed automation soft on python 3.6.2 and used pywinauto module for that. I shared this soft with python 3.6.3 user. When tried to ran my app on 3.6.3 it crashed. The crash was on \"from pywinauto.application import Application\" line. It pointed on lack of some attributes in \"comtype\". I solved it simply by copy-paste all related files of \"comtype\" from my 3.6.2 to 3.6.3 version of user. Then it worked perfect. My question is: Is there any conventional way to solve this issue?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":341,"Q_Id":47219769,"Users Score":1,"Answer":"Solved conventionally by manual installation\/update of \"comtypes\" modules.","Q_Score":0,"Tags":"python,pywinauto","A_Id":47247409,"CreationDate":"2017-11-10T09:42:00.000","Title":"comtype error on python 3.6.3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've had a dispute with some colleges on should I take a syntax check after every code modification as a distinct step or I'd better rely on unit tests to catch possible syntax breakage ... ( of course unit tests do that ). \nThis is not a question whether to use or not tests for your code ( of course yes, but see below )\nMy use case is pretty simple, I am newbie in Python and try to play with some web application (MVC) by modifying model file. The changes are quite simple, indeed a couple or so lines at once, however as I am pretty unfamiliar with Python syntax, some stupid errors ( like wrong indentation, so on ) easily creep into. \nThe real hurdle is that I deploy an application via Google Cloud Platform ( as app engine ), so it takes a while for application comes up with new version and I can hit an endpoint and finally look into its error logs to understand what's happening. So I'd like to get a shorter and simple way - at least for these types of errors - just running syntax check before deploy. \nThe central part of the dispute was that I hadn't been advised to take a syntax check explicitly, but better relying on higher level tests for this ( units tests for example ), on what I say that:\n1) And don't have unit tests yet ( and even if I had them I'd treat them as a next step in my test chain ).\n2) I only edit a certain file ( one and only one ), with a minimum modifications, and MOSTLY the types of errors I have ( as I told as I am newbie in Python ) is syntax errors, not logic or semantic ones, so as I assume I am safe to have just syntax checking and then give it a deploy. And even though I hit a semantic\/logic problems with my code later ( even syntax check pass ) this is a undoubtedly question for high level tests ( unit \/ acceptance so on) - but for now I'm just playing with a code written in a language I am not feel quite at home.\n3) I don't commit my changes outside and don't trouble anyone. \n4) the last argument is controversial, because it's a bit of the scope, however I'd like to leave it here - in some cases even lightweight unit tests might be overkill if ALL you need is to get a syntax check in a single file. Consider this example. One just edits the code in place, deployed at server trying to fix immediate issues, so no unit or other tests exists and you want to be sure that your modification won't break the code syntactically.","AnswerCount":3,"Available Count":3,"Score":-0.0665680765,"is_accepted":false,"ViewCount":300,"Q_Id":47262474,"Users Score":-1,"Answer":"By default, Python completes a syntax check on the functions within your code. Additionally, this syntax check will look for any open brackets or unfinished lines of code to make sure the code will work properly. However, the syntax checker does not always highlight the problem directly. To fix this you will just have to look at the code yourself.\nIf you need to spell check things like variable names or strings I would advise copying the code into a spell checking program like Microsoft Word or Grammarly.\nI hope this helps.","Q_Score":2,"Tags":"python,unit-testing,testing,syntax-checking","A_Id":47262706,"CreationDate":"2017-11-13T10:44:00.000","Title":"Could syntax check for your code be taken as distinct step?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've had a dispute with some colleges on should I take a syntax check after every code modification as a distinct step or I'd better rely on unit tests to catch possible syntax breakage ... ( of course unit tests do that ). \nThis is not a question whether to use or not tests for your code ( of course yes, but see below )\nMy use case is pretty simple, I am newbie in Python and try to play with some web application (MVC) by modifying model file. The changes are quite simple, indeed a couple or so lines at once, however as I am pretty unfamiliar with Python syntax, some stupid errors ( like wrong indentation, so on ) easily creep into. \nThe real hurdle is that I deploy an application via Google Cloud Platform ( as app engine ), so it takes a while for application comes up with new version and I can hit an endpoint and finally look into its error logs to understand what's happening. So I'd like to get a shorter and simple way - at least for these types of errors - just running syntax check before deploy. \nThe central part of the dispute was that I hadn't been advised to take a syntax check explicitly, but better relying on higher level tests for this ( units tests for example ), on what I say that:\n1) And don't have unit tests yet ( and even if I had them I'd treat them as a next step in my test chain ).\n2) I only edit a certain file ( one and only one ), with a minimum modifications, and MOSTLY the types of errors I have ( as I told as I am newbie in Python ) is syntax errors, not logic or semantic ones, so as I assume I am safe to have just syntax checking and then give it a deploy. And even though I hit a semantic\/logic problems with my code later ( even syntax check pass ) this is a undoubtedly question for high level tests ( unit \/ acceptance so on) - but for now I'm just playing with a code written in a language I am not feel quite at home.\n3) I don't commit my changes outside and don't trouble anyone. \n4) the last argument is controversial, because it's a bit of the scope, however I'd like to leave it here - in some cases even lightweight unit tests might be overkill if ALL you need is to get a syntax check in a single file. Consider this example. One just edits the code in place, deployed at server trying to fix immediate issues, so no unit or other tests exists and you want to be sure that your modification won't break the code syntactically.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":300,"Q_Id":47262474,"Users Score":0,"Answer":"Personally speaking, if you drill into your head the PEP8 than most of the time syntax will come naturally i.e. like touch typing. However, most of you know multiple languages so I can imagine it get hard remembering all :)","Q_Score":2,"Tags":"python,unit-testing,testing,syntax-checking","A_Id":47296655,"CreationDate":"2017-11-13T10:44:00.000","Title":"Could syntax check for your code be taken as distinct step?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've had a dispute with some colleges on should I take a syntax check after every code modification as a distinct step or I'd better rely on unit tests to catch possible syntax breakage ... ( of course unit tests do that ). \nThis is not a question whether to use or not tests for your code ( of course yes, but see below )\nMy use case is pretty simple, I am newbie in Python and try to play with some web application (MVC) by modifying model file. The changes are quite simple, indeed a couple or so lines at once, however as I am pretty unfamiliar with Python syntax, some stupid errors ( like wrong indentation, so on ) easily creep into. \nThe real hurdle is that I deploy an application via Google Cloud Platform ( as app engine ), so it takes a while for application comes up with new version and I can hit an endpoint and finally look into its error logs to understand what's happening. So I'd like to get a shorter and simple way - at least for these types of errors - just running syntax check before deploy. \nThe central part of the dispute was that I hadn't been advised to take a syntax check explicitly, but better relying on higher level tests for this ( units tests for example ), on what I say that:\n1) And don't have unit tests yet ( and even if I had them I'd treat them as a next step in my test chain ).\n2) I only edit a certain file ( one and only one ), with a minimum modifications, and MOSTLY the types of errors I have ( as I told as I am newbie in Python ) is syntax errors, not logic or semantic ones, so as I assume I am safe to have just syntax checking and then give it a deploy. And even though I hit a semantic\/logic problems with my code later ( even syntax check pass ) this is a undoubtedly question for high level tests ( unit \/ acceptance so on) - but for now I'm just playing with a code written in a language I am not feel quite at home.\n3) I don't commit my changes outside and don't trouble anyone. \n4) the last argument is controversial, because it's a bit of the scope, however I'd like to leave it here - in some cases even lightweight unit tests might be overkill if ALL you need is to get a syntax check in a single file. Consider this example. One just edits the code in place, deployed at server trying to fix immediate issues, so no unit or other tests exists and you want to be sure that your modification won't break the code syntactically.","AnswerCount":3,"Available Count":3,"Score":0.1973753202,"is_accepted":false,"ViewCount":300,"Q_Id":47262474,"Users Score":3,"Answer":"If syntax problems are causing you problems and the costs and delay to find those problems are annoying enough, check the syntax first. This isn't just about syntax checks. Anything that causes an annoying enough problem deserves some sort of mitigation. Computers are really handy for boring, repetitive tasks. I wouldn't not do this because some language community thought solving problems was stupid or weird (though every community seems to have some version of it except for the Smalltalkers ;)\nOther people might think it's bad practice because their cost of doing it explicitly doesn't offset the cost of finding out later. I rarely do a syntax check explicitly but then I have unit tests and run those frequently.\nPerhaps your solution is to automate your deployment and throw a syntax check in there. If that fails the deployment stops. You don't have an additional step because it's already baked into the step you're doing now.","Q_Score":2,"Tags":"python,unit-testing,testing,syntax-checking","A_Id":47421593,"CreationDate":"2017-11-13T10:44:00.000","Title":"Could syntax check for your code be taken as distinct step?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am interested in making a website that activates a python script. I am most familiar with c# but I have a python scraping script I would like to use that currently runs well on my raspberry pi.\nMy question is:\nHow do I make a C# asp.net website that activates the python script? what is the best approach? should i just forget c# all together and use something like django to host the site?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":28,"Q_Id":47270103,"Users Score":0,"Answer":"Considering how easy that is with something like django, I would go that route. Unless you're a C# wizard (I am most certainly not) or need it for something else.","Q_Score":0,"Tags":"c#,python,asp.net,django,raspberry-pi3","A_Id":47270170,"CreationDate":"2017-11-13T17:26:00.000","Title":"website to activate my python scraper using c# and possibly a raspberry pi","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I wanted to run a discord bot from my raspberry pi so I could have it always running, so I transferred over the bot file. BTW this bot was made in python. I get an error saying no module named discord. This is because I don't have discord installed. Whenever I try to use pip3 install discord I get a message saying that it was successful, but was installed under Python 3.4. I need it to be installed under Python 3.5 so that my bot's code will run properly. If I try to use python3 -m pip install discord I get the error \/usr\/local\/bin\/python3: No module named pip. When I run pip -V I get 3.4. I want to make the version 3.5 instead of 3.4, but even after running the get-pip.py file I still am on pip 3.4. Any help?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1062,"Q_Id":47278382,"Users Score":1,"Answer":"I had a similar problem on a different machine. what I did to have the python 3.6 interpreter as the default one for the python 3 command was this:\nFirst, edit your .bashrc file to include the following line export PATH=\/path\/to\/python\/bin:$PATH(in this case, I will be using \/home\/pi\/python). Then, download the python 3.6 usingwget https:\/\/www.python.org\/ftp\/python\/3.6.3\/Python-3.6.3.tgz. Unarchive it using tar -zxvf Python-3.6.3.tgz, and cding into the directory. Then, configure it by doing .\/configure --prefix=$HOME\/python(Or to the path you had used in .bashrc), and make it using make, and sudo make install. Afterwards, reboot the raspberry pi, and you should now be able to use python 3.6 with the python3 command","Q_Score":0,"Tags":"python,pip,discord.py","A_Id":47361577,"CreationDate":"2017-11-14T05:36:00.000","Title":"Pip Not Working On Raspberry Pi For Discord Bot","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to run my code written in Python 3 with pypy, but I got an error : \n\nImportError: No module named 'osgeo'\n\nbut running it with python3 test.py works (but slow) .\nMy installed version of python is 3.5.2 \npypy comes with it's python version 3.5.3 \nIs there anyway you could tell pypy to use my own version of python, and will it resolve the problem?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":526,"Q_Id":47327413,"Users Score":0,"Answer":"Are you using PyPy3?\nIf you use PyPy it will execute your code with a Python 2.7 interpreter. And if you install a library for python3 it does not mean that the library is installed for python2 too. You need to specify for wich interpreter are you installing the library ( like using pip or pip3 )","Q_Score":0,"Tags":"python,python-3.x,pypy","A_Id":47327550,"CreationDate":"2017-11-16T10:36:00.000","Title":"How to run pypy with an existing installation of Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running Python 3.6.1 on a Windows 7 machine. I have some scripts in H:\\Myname\\Python\\myscripts.\nI have created the user variable PYTHONPATH and set it to the folder above. I do not have admin rights so I can create a user variable only.\nIn that folder, I have a myscripts.py file with some functions.\nIf I try to access it running import myscripts from a file stored elsewhere, it doesn't work: I get a ModuleNotFoundError\nIf I print sys.path, the folder I have set in PYTHONPATH is not there.\nWhy? What am I doing wrong? Isn't sys.path supposed to show PYTHONPATH?\nDoes the fact that H is a network drive have anything to do with it?\nI can't seem to find anything on the web for this problem in relation to Windows (but lots for Unix systems).","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2246,"Q_Id":47335080,"Users Score":1,"Answer":"A common way to fix this quickly is to use\nsys.path.append(\"path\/to\/module\")\nBe careful with '\\\\' if you are using Windows.\nNot exactly answering your question but this could fix the problem.","Q_Score":1,"Tags":"python,windows,python-import","A_Id":47335172,"CreationDate":"2017-11-16T16:47:00.000","Title":"Cannot import module - why does sys.path not find PYTHONPATH?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to release the code for an application I made in Python to the public, just as a pastebin link. However, the app needs a client ID, secret and user agent to access the API (for reddit in this case).\nHow can I store the key strings in the python code without giving everyone free reign on my api access? Maybe a hashing function or similar?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":51,"Q_Id":47337762,"Users Score":4,"Answer":"You probably don't want to provide the actual keys and other private information at all, hashed or otherwise. Besides being a security issue, it probably violates all sorts of agreements you implicitly made with the provider.\nAnyone using the application should be able to get their own key in the same manner you did. You can (and should) provide instructions for how to do this.\nYour application should expect the key information in a well documented format, usually a configuration file, that the user must provide once they have obtained the keys in question. You should document the exact format you expect to read the key in as well.\nYour documentation could also include a dummy file with empty or obvious placeholder values for the user to fill in. It may be overkill, but I would recommend making sure that any placeholders you use are guaranteed not to be valid keys. This will go a long way to avoiding any accidents with the agreements you could violate otherwise.","Q_Score":4,"Tags":"python,python-3.x,hash","A_Id":47337902,"CreationDate":"2017-11-16T19:37:00.000","Title":"How to release a Python application that uses API keys to the public?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm creating a Reddit bot with praw, and I want to have the bot do things based on private messages sent to it. I searched the documentation for a bit, but couldn't find anything on reading private messages, only sending them. I want to get both the title and the content of the message. So how can I do this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":527,"Q_Id":47340391,"Users Score":2,"Answer":"Didn't find it in the docs, but a friend who knows a bit of raw helped me out.\nUse for message in r.inbox.messages() (where r is an instance of reddit) to get the messages.\nUse message.text to get the content, and message.subject to get the title.","Q_Score":1,"Tags":"python,praw","A_Id":47340599,"CreationDate":"2017-11-16T22:45:00.000","Title":"How to read private messages with PRAW?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a writing a program that embeds data in a photo (steganography). This worked completely fine when I was using png lossless compression however I would like this to work in JPEG file format. Previously I would read in my image file and replace the last two bits in every color channel with a part of my message. Then I would compress it and output it. With lossy compression however I am assuming I cannot embed a message pre compression because without a doubt, the message would be unreadable.\nMy question is, do I need to embed the message post compression\/encoding somewhere in the SOS YCbCr data? If not there then where must I store the message? Thank you in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":704,"Q_Id":47345119,"Users Score":1,"Answer":"The best place to hide a message in JPEG is in the blocks that extend beyond the edge of the image (unless the image dimensions are multiples of 8).","Q_Score":0,"Tags":"python-3.x,jpeg,steganography","A_Id":47356538,"CreationDate":"2017-11-17T07:08:00.000","Title":"Hiding a message in a JPEG image","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to fit a generalized ordered logit model to some data I have. I first tried to use the ordered logit model using the MASS package from R, but it seems that the proportional odds assumption is violated by the data. Indeed, not all independent variables do exert the same effect across all categories of the dependent variable. Hence I am a bit blocked. I say that I could use the generalized ordered logit model instead, but could not find how to use it. Indeed, I can not find any package on either R or python that coud help me on that. \nIf someone has any hints on packages I could use, it would be of great help!\nThank you very much!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1939,"Q_Id":47346321,"Users Score":0,"Answer":"Try the 'VGAM' package. There is a function called vglm.\nexample: vglm(Var2~factor(Var1),cumulative(parallel = F),data) generalized order model\ncumulative(parallel=T) will perform a proportional odds model.\nparallel=F is the default.","Q_Score":3,"Tags":"python,r,logistic-regression","A_Id":59307014,"CreationDate":"2017-11-17T08:33:00.000","Title":"generalized ordered logit in R or python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I run my compiled program (cx_Freeze) it says __init__line 31. no module named codecs.\nI have Python 3.6, does anybody know why it says that, and how to maybe fix it?\nI have seen the other questions here on StackOverflow, but they don't seem to solve the problem for me and possibly other too.\nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":541,"Q_Id":47359677,"Users Score":1,"Answer":"If you are using cx_Freeze 5.1, there was a bug that resulted in this error. It has been corrected in the source so if you checkout the latest source and compile it yourself it should work for you. If not, let me know!","Q_Score":1,"Tags":"python,python-3.x,cx-freeze","A_Id":47395605,"CreationDate":"2017-11-17T21:38:00.000","Title":"Python cx_Freeze __init__ \"no module named codecs\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm writing a Python script that is only meant to be run from the console. e.g.: $> myscript.\nI'm wondering what is the leading conventions in Python for scripts of this sort. Should I call it myscript, or myscript.py?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":612,"Q_Id":47360213,"Users Score":2,"Answer":"Yes\nWhy? \nPortability\nPython scripts in Linux environments are recognized as such, but NT is... special. If there's ever a need to move it to anything made by microsoft, you need the extension. \nReadability\nAppending a filename extension to it will make it obvious what kind of file it is, for when others look in your directories. \nUseability\nIf ever you need to call it into python as a module, you NEED the .py extension.\nConvention\nIt is the standard for all python scripts to have the .py or .pyc extension on them.","Q_Score":2,"Tags":"python","A_Id":47360365,"CreationDate":"2017-11-17T22:28:00.000","Title":"Should executable Python script be named with .py?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm looking for a way to get the battery level in EV using OBD2 dongle,\nI manage to get the fuel level in Toyota and Ford but I need to get data from the battery management systems (BMS) on EV.\nI'm using python obd libraries and I have both comma.ai panda and OBDLink-LX dongles.\nthanks,\nAvi","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1579,"Q_Id":47377617,"Users Score":3,"Answer":"Some cars will report battery level on PID 0x5B of mode 1.","Q_Score":1,"Tags":"python,obd-ii","A_Id":47616373,"CreationDate":"2017-11-19T13:50:00.000","Title":"obd2 battery level on electric vehicle","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I understand from previous questions that access to Google Translate API may have recently changed.\nMy goal is to translate individual tweets in a dataframe from X Language to English.\nI tried to setup the Google Cloud Translate API with no success\nI have setup gcloud sdk, enabled the billing and looks like the certification is ok. But, still no success.\nHas anyone else had any recent experience with it using R and\/or Python?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":200,"Q_Id":47378315,"Users Score":0,"Answer":"Just as an update, for anyone seeking to translate dataframes\/variables\ntranslateR doesnt seem to accept the Google API key \nHowever, everything works very smoothly using the \"googleLangaugeR\" package","Q_Score":2,"Tags":"r,python-3.x,google-translate","A_Id":47410428,"CreationDate":"2017-11-19T15:03:00.000","Title":"Google Cloud Translate API : challenge setup (R and\/or Python)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Python Telethon\nI need to receive messages from the channel\nError:\n\n>>> client.get_message_history(-1001143136828)\n\nTraceback (most recent call last):\nFile \"messages.py\", line 23, in \n total, messages, senders = client.get_message_history(-1001143136828)\nFile \"\/Users\/kosyachniy\/anaconda\/lib\/python3.5\/site-packages\/telethon\/telegram_client.py\", line 548, in get_message_history\n add_mark=True\nKeyError: 1143136828","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2377,"Q_Id":47380618,"Users Score":0,"Answer":"Error in library\nNeed to update: pip install telethon --upgrade","Q_Score":2,"Tags":"python,api,telegram,telethon","A_Id":47380957,"CreationDate":"2017-11-19T18:43:00.000","Title":"Telethon How do I get channel messages?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to change the default python version I use, without affecting any other defaults. Appending the python path to the $PATH environment variable only accomplishes that as long as there is only the python executable at that given location, which is not the case if I want to use the \/usr\/bin version (export PATH=\\usr\\bin:$PATH). \nI know I could theoretically create a symbolic link in some other folder of my choosing, but this is not very elegant.\nIs there any other way of changing the default python (like a nice environment variable that python uses which takes precedence over the $PATH environment variable)?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":637,"Q_Id":47391785,"Users Score":1,"Answer":"In general, Python itself does not provide any way to do this. Once Python starts up, there is already one particular version running, and it can't change to a different version on the fly.\nYour operating system may provide some way of choosing which version of Python is the default (e.g. eselect python on Gentoo Linux), but it's impossible to say whether that's the case for you without knowing what OS you're using. If your OS doesn't provide something like this, it is possible to make your own scripts to set and change a default Python version.","Q_Score":1,"Tags":"python","A_Id":47391863,"CreationDate":"2017-11-20T12:13:00.000","Title":"Changing the default python without changing the $PATH variable?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"How can I get the information on what's key bound for a specific function such as copying, for example in Windows it is Ctrl + C. How can I get that information with script?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":19,"Q_Id":47395189,"Users Score":1,"Answer":"You can't, every system has its global shortcuts and only in some of them they are partially listed somewhere.","Q_Score":0,"Tags":"python,cross-platform,keyboard-shortcuts","A_Id":52665948,"CreationDate":"2017-11-20T15:13:00.000","Title":"How can I get platform specific keybind information?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I'm trying to get a working code in Python that will eject\/unmount all USB flash drives attached to the Pi (Running Raspbian) - so that they can be removed safely. The final code will be run from within the python program. \nAdditionally, I'd like to eject\/unmount the USB flash drive even if it's in use. \nI've looked around and can't see how to do this. Thanks. \n\nudisks --detach \/media\/pi\/DOCS\/ - 'Blocked device... Resource temporarily available'... \nudisks --detach \/media\/pi\/ - 'Blocked device...Resource temporarily available'... \nudisks --detach \/media\/ - 'Blocked device...Resource temporarily available'... \nsudo udisks --detach \/media\/pi\/DOCS\/ - still blocked...\nsudo umount \/path\/to\/devicename - command not found...\neject \/media\/pi\/DOCS\/ - Unable to open '\/dev\/sda'\n(DOCS is the name if my USB flash drive. - though I want to eject all USB flash drives - not just my one)\n\nSo I'm going to ask the user in Python to select their USB flash drive from a list, which is pretty easy (just read in the folder) - so I will have the pathway to the USB. I'm still not sure which code can safely disconnect the USB flash drive - Maybe more research is the answer. Thanks for your help so far.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":6438,"Q_Id":47418025,"Users Score":2,"Answer":"For udisks --detach the parameter should be the device, not the mounting point.\nFor example, if the USB Disk is \/dev\/sdb the command would be udisks --detach \/dev\/sdb\nIf the command still doesn't work you could try udiskctl power-off -b which should also work.","Q_Score":2,"Tags":"bash,python-3.x,raspberry-pi,raspbian","A_Id":47431418,"CreationDate":"2017-11-21T16:30:00.000","Title":"Ejecting\/unmounting random USB flash drive in Raspberry pi \/ Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am currently running Simulations written in C later analyzing the results using Python scripts.\nATM the C Programm is writing the results (lots of double values) in a text file which is slowly but surely eating a lot of disc space. \nIs there a file format which is more space efficient to store lots of numeric values?\nAt best but not necessarily it should fulfill the following requirements\n\nValues can be appended continuously such that not all values have to be in memory at once.\nThe file is more or less easily readable using Python.\n\nI feel like this should be a really common question, but looking for an answer I only found descriptions of various data types within C.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":201,"Q_Id":47460240,"Users Score":2,"Answer":"Binary file, but please, be careful with the format of data that you are saving. If possible, reduce the width of each variable that you are using. For example, do you need to save decimal or float, or you can have just 16 or 32 bit integer?\nFurther, yes, you may apply some of the compression scheme to compress the data before saving, and decompress it after reading, but that requires much more work, and it is probably an overkill for what you are doing.","Q_Score":2,"Tags":"python,c,numerical-methods","A_Id":47460725,"CreationDate":"2017-11-23T16:51:00.000","Title":"Space efficient file type to store double precision floats","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a open() command in my Python script which opens the file data.json in my Apache serve running on Raspberry Pi in w mode. This script in turn is run by PHP using the shell_exec command. When the script is run alone, the Python code works. However, it does not function when run by PHP. Does anyone have any idea why this is happening, or is more information needed? Thank you in advance for your help!","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":165,"Q_Id":47463593,"Users Score":0,"Answer":"Thank you to user2693053 for solving this problem:\n\nSounds like a privilege issue, although I am not experienced enough\n with calling Python from php to know whether that could be an issue\n here.\n\nand yes, it is a privilege issue! I fixed the problem by doing the sudo chmod 777 * command in the \/var\/www\/html directory.","Q_Score":0,"Tags":"php,python,json,apache,file-io","A_Id":47467584,"CreationDate":"2017-11-23T21:44:00.000","Title":"Python open() function not working when script executed by shell_exec() in PHP","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a open() command in my Python script which opens the file data.json in my Apache serve running on Raspberry Pi in w mode. This script in turn is run by PHP using the shell_exec command. When the script is run alone, the Python code works. However, it does not function when run by PHP. Does anyone have any idea why this is happening, or is more information needed? Thank you in advance for your help!","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":165,"Q_Id":47463593,"Users Score":1,"Answer":"Did you use the relative or absolute path?\nTry to use the absolute path and check what's your working directory.\nI think you are starting the python script not in the directory you think you are. :)","Q_Score":0,"Tags":"php,python,json,apache,file-io","A_Id":47464087,"CreationDate":"2017-11-23T21:44:00.000","Title":"Python open() function not working when script executed by shell_exec() in PHP","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"i've been working with the python project before and never submitted a pyc file. Not sure as to why.\nI am using intellij, maybe it automatically ignores those files and doesn't display them?\nmaybe I am not using CPython? python --version spits out to me\nPython 3.6.1 :: Continuum Analytics, Inc.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":30,"Q_Id":47466982,"Users Score":0,"Answer":"The issue I had was that I never had the issue of committing a pyc file. Now I added it to gitignore and what not, but why did I never commit it before?\nturns out... intellij idea does completely ignore pyc files... I cannot even create a pyc file in the project manually. So maybe that is why.","Q_Score":0,"Tags":"python,git,intellij-idea","A_Id":47467268,"CreationDate":"2017-11-24T05:40:00.000","Title":"pyc got checked into my git project by coworker, how comes?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a .py file and I want to make it so I can type it's name in another .py file and have it run all the code from the first file.\nRemember, this is in Python 2.7 on a Raspberry Pi 3.\nThank you!","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":156,"Q_Id":47487749,"Users Score":1,"Answer":"Calling os.system(\"second.py\") or using subprocess.Popen from you first script should work for you.","Q_Score":1,"Tags":"python,python-2.7","A_Id":47487805,"CreationDate":"2017-11-25T15:48:00.000","Title":"Python 2.7 Running External .py Files in Program","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a .py file and I want to make it so I can type it's name in another .py file and have it run all the code from the first file.\nRemember, this is in Python 2.7 on a Raspberry Pi 3.\nThank you!","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":156,"Q_Id":47487749,"Users Score":2,"Answer":"Well you can use execfile() or os.system() to solve your problem. But I think, the correct way to tackle your problem is to import the file in your current script and call the imported file's functions or main function directly from your script.","Q_Score":1,"Tags":"python,python-2.7","A_Id":47487886,"CreationDate":"2017-11-25T15:48:00.000","Title":"Python 2.7 Running External .py Files in Program","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using python pytest to run my unit tests.\nMy project folders are:\nMain - contains data file: A.txt\nMain\\Tests - the folder from which I run pytest\nMain\\Tests\\A_test - folder that contains a test file\nThe test in A_test folder uses the file A.txt (that is in Main folder).\nMy problem is that when I run py.test the test fails because it can't find A.txt.\nI found out that it is because pytest uses the path Main\\Test when running the test instead of changing the path to Main\\Tests\\A_test (I'm using relative path when opening A.txt inside the test file)\nMy question: is there a way to make pytest change directory to the folder of the test it executes for each test? so that relative paths inside the tests will still work? \nIs there some other generic way to solve it? (I don't want to change everything to absolute paths or something like this, also this is an example, in real life I have several hundreds tests).\nThank you,\nNoam","AnswerCount":5,"Available Count":1,"Score":0.1586485043,"is_accepted":false,"ViewCount":21673,"Q_Id":47498390,"Users Score":4,"Answer":"Adding __init__.py to the package of the tests worked for me. All test are executed afterwards.","Q_Score":17,"Tags":"python,unit-testing,pytest","A_Id":61614421,"CreationDate":"2017-11-26T16:30:00.000","Title":"Using pytest where test in subfolder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"[text element].font.size returns None if the element has inherited its size from a parent text style.\nThe documentation refers to a style hierarchy but doesn't appear to include documentation about it. Does anyone know how you traverse this hierarchy to determine the actual size of a font element if it has inherited its size from somewhere else?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":322,"Q_Id":47530337,"Users Score":1,"Answer":"The hierarchy governing the inheritance of font style is knowledge that belongs to the ill-documented black arts of PowerPoint. I don't know of a place where it's clearly described.\nIf I needed to learn it, I would start with a Google search on \"powerpoint style hierarchy\" to gather candidate participants and then settle in for a long period of experimentation.\nThe candidates I can think of are, roughly in order of precedence:\n\nformatting directly applied at the run level\ndefault run formatting applied at the paragraph level (this doesn't always take effect)\nformatting inherited from a placeholder, if the shape was originally a placeholder.\nA theme related to the slide, its slide layout, or its slide master.\nA table style\nPresentation-default formatting.\n\nI would devote a generous period to getting anything I could from Google, form a set of hypotheses, then set up experiments to prove or disprove those hypotheses.\nNote the challenge is made more complex by the conditions involved, such as \"is in a table\" and \"is a placeholder\", etc.","Q_Score":3,"Tags":"python-pptx","A_Id":47537303,"CreationDate":"2017-11-28T11:22:00.000","Title":"python-pptx font size from hierarchy \/ template \/ master","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a api made based on thrift TCompactProtocol.\nIs there a quick way to convert it into TBinaryProtocolTransport?\nIs there a tool for conversion?\nFYI. My api is Line Api bases api Python.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":159,"Q_Id":47560349,"Users Score":0,"Answer":"There is no tool needed. Since yyou did not elaborate on your actual use case too much, I can only give a generic answer.\nYou control both RPC server & client + we do NOT talk about stored data\nIn that case you need only to replace the transports on both ends and you're pretty much done.\nAll other cases\nYou will need two pieces\n\na piece of code that deserializes old data stored with \"compact\"\na piece of code that deserializes these data using \"binary\"\n\nBoth cases are not really hard to implement technically.","Q_Score":0,"Tags":"python,api,line,thrift","A_Id":47595331,"CreationDate":"2017-11-29T19:28:00.000","Title":"how to convert thrift TCompactProtocol to TBinaryProtocolTransport","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My general question is how does \"dig any\" work?\nIn particular, I would like to compare the use of dig to naive sending of multiple equivalent requests (a, txt, mx, ...).\nDoes a single DNS query is sent? Is the use of dig more efficient?\nIs it guaranteed to get the same results as sending multiple equivalent requests (a, txt, mx, ...)?\nIf they are not equivalent, when should I use each of the methods?\nAnd finally, if somebody has Python (prefered Python3) implementation of dig (not by running it using subprocess etc.) - I will be glad to get a reference.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1027,"Q_Id":47590504,"Users Score":1,"Answer":"An ANY query is a perfectly ordinary query that asks for the record type with number 255, which is usually referred to as the ANY type, for fairly obvious reasons. It doesn't matter which tool sends the query (the program dig, or code you write, or something else), it's the same query anyway.\nThere is no guarantee that an ANY query will give the same results as multiple queries for many different types, it's entirely up to the server that generates the responses.\nOther than for debugging and diagnostics, there is hardly ever a reason to send an ANY query.\nThere are loads of DNS libs for Python. I'm sure someone else can tell you which one is the preferred one these days.","Q_Score":1,"Tags":"dns,resolver,dig,dnspython","A_Id":47598958,"CreationDate":"2017-12-01T09:40:00.000","Title":"How does dig any work?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a series of tests that are quite complicated. Unfortunately, the builtin Pycharm Debugger is waaay too slow to handle them. I tried making it faster, but any attempts failed, so I have to resort to using pdb. \nMy problem is that the command line that appears if I run my tests with pycharm and come across a pdb breakpoint is quite annoying:\n\nIt does not support code completion (of course I googled it, but my attempts failed). \nI can't even press 'up' to get the last command again\nMost annoyingly: When I already wrote some code in the command line and jump to the beginning of the line to edit it, the cursor automatically jumps to the end of the line.\n\nI noticed that it is not the iPython console which I get when I go into pdb debug mode when I don't use pytest.\nDo you have any idea on how to solve any of these issues? Ideally on how to speed up the Pycharm debugger, or how to get the iPython console also in pytest? \nHelp is much appreciated. Thanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":560,"Q_Id":47590564,"Users Score":0,"Answer":"A few things that might help you with debugging speed are: \n\nusing Python 3.5\/3.6. \nIf you're running in linux\/macos install the cython extension (you get prompted) \nUse the latest Pycharm, 2017.3 at this moment. \nTry to simplify tests. If not possible, just run those you need for the debugging process by creating a special runner in Pycharm and using the -k 'pattern' argument for pytest.\n\nMoreover, I don't understand why you're invoking pdb if you're using the Pycharm debugger.","Q_Score":0,"Tags":"python,debugging,pycharm,pytest","A_Id":47594318,"CreationDate":"2017-12-01T09:43:00.000","Title":"Debugging pytests in Pycharm with pdb shows annoying console","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I tried to run \"from dash_table_component import Table\" and it said it had no module named dash_table_component. I tried to pip install dash-table-experiments but it still showed no module for dash_table_component. I would like to ask that what Python package I should install to get this module?\nThank you!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":953,"Q_Id":47597320,"Users Score":0,"Answer":"from dash_table_experiments import DataTable","Q_Score":0,"Tags":"python","A_Id":50000236,"CreationDate":"2017-12-01T16:16:00.000","Title":"Package for dash_table_component","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"ng serve command runs a server instance on a localhost. I would like to use some server-side scripts on the same localhost and communicate between angular app and the http server.\nI have some issue by not knowing in which directory I should place Python scripts. So that I can run extend the functionality of Angular app, to gather data from localhost server?\nEDIT:\nI am visiting http:\/\/localhost:4200\/data.php in a browser, but I am always getting a 304 redirect. I figure this could be due to incorrect placing of php files. I've put it in src, ..src and app folder, but nothing seem to work.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":629,"Q_Id":47606914,"Users Score":0,"Answer":"Root directory if it is one or two files - like configs etc. \nIf you actually need a server side app maybe it's better to make that the root project and have angular in a view folder.","Q_Score":0,"Tags":"python,angular","A_Id":47606964,"CreationDate":"2017-12-02T10:30:00.000","Title":"Angular project and server files on localhost","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a more open-ended design oriented question for you here. I have background in Python but not in web nor async programming. I am writing an app to save data collect from websockets 24\/24, 7\/7 with the aim to minmise data loss. \nMy initial thoughts is to use Python 3.6 with asyncio, aiohttp and aiofiles.\nI don't know whether to use one co-routine per websocket connection or one thread per websocket connection. Performance may not an issue as much as good connection error handling.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":574,"Q_Id":47611139,"Users Score":1,"Answer":"To answer your actual question, threads and coroutines will be equally reliable but coroutines are much easier to reason with and much of the modern existing code you'll find to read or copy will use them. \nIf you want to benefit from multiple cores, much better to use multiprocessing than threads to avoid the trickiness of the GIL.","Q_Score":2,"Tags":"python,websocket,cloud,aiohttp,python-aiofiles","A_Id":47617568,"CreationDate":"2017-12-02T18:29:00.000","Title":"websocket data collection design","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The primary problem I'm trying to solve is how to detect all the subclasses of a particular class. The reason I'm unable to use __subclasses__ is that the child classes aren't yet accessible in the context from which I'm attempting to access them.\nThe folder structure I'm working with looks like this:\n\n main.py\n projects\/\n __init__.py\n project.py\n some_project_child.py\n\nWhat I'd like to do is get a list of all subclasses of Project (defined in project.py) from main.py. \nI'm able to do this by doing:\nfrom projects.project import Project\nfrom projects.some_project_child import SomeProjectChild\nProject.__subclasses__\nThe aspect of this approach I'd like to avoid is having to add an import line every time I add a new project file\/class. I realize I can do this by iterating over the files in the directory and import each one's contents but is there a cleaner more pythonic manner of handling this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":19,"Q_Id":47622391,"Users Score":1,"Answer":"It is the nature of a non-compiled language like Python that it is impossible to do anything like this without importing. There is simply no way for Python to know what subclasses any class has without executing the files they are defined in.","Q_Score":0,"Tags":"python,inheritance","A_Id":47622552,"CreationDate":"2017-12-03T19:31:00.000","Title":"Fetching subclasses that are not present in current context","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently using the exchangelib library in python. I would like to compare the mail of the account connected to exchangelib and the mail of a meeting organizer. I can have the account mail by typing \"account.primary_smtp_address\" but I don't know how I could get the meeting organizer mail.\nFor now i can only get the organizer's name by typing \"item.subject\" where \"item\" is my meeting.\nConversely, is it possible to get the account's name (the complete name: \"Michael JORDAN\" for example) which I could compare with the meeting organizer's name.\nThank you !","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":134,"Q_Id":47656709,"Users Score":0,"Answer":"The meeting organizer is available on CalendarItem objects as item.organizer.","Q_Score":1,"Tags":"python,email,organizer,exchangelib","A_Id":47670437,"CreationDate":"2017-12-05T15:03:00.000","Title":"Exchangelib - Get meeting organizer mail","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have subscribed to multiple (around 4) topics using paho.mqtt. \nOn receiving message from each topic, I want to buffer the message until it reaches some threshold and then later insert bulk messages into MySQL database.I want to gather some 1000 messages and check if the threshold is greater than 1000 and then finally insert into database on certain time interval (for every 1 minute). \nFor each topic, there is corresponding table in the database. Which callback function Should I use on_message() callback or message_callback_add()? Which is better in such scenario?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1202,"Q_Id":47714544,"Users Score":2,"Answer":"What does \"is better\" mean for you?\nThe callback registered with on_message() will get all messages for all your subscriptions, whereas with message_callback_add you can have different callbacks for each topic that you subscribe to.\nDo you need your callbacks to do different things based on the topic name? If not, you use on_message, else you use message_callback_add.","Q_Score":0,"Tags":"python,callback,mqtt,paho","A_Id":47719711,"CreationDate":"2017-12-08T12:34:00.000","Title":"Paho mqtt callbacks on multiple subscription","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently working on a project, which will dynamically fetch some informations of my job and display them in a html page. To accomplish this i wrote a python script, which will be invoked using a PHP webservice. The script needs to edit some files in order to work.\nBasically PHP executes the script using \n $output = shell_exec('python script.py'); \nThe problem is, that if the webservice is called, the script does not have the needed permissions to edit the files.\nSo the webserver should call the script using something like $output = shell_exec('sudo python script.py'); \nI may need to change the permissions to the project folder but i don't know how.\nSome additional informations:\nI'm using a raspberry pi 3 with LAMP installation on raspian as webserver\nThe folder structure is the following:\n\nprojectfolder \n| \n- style (containing css)\n-script.py\n-script2.py\n-filetoedit1.txt\n-filetoedit2.html\nAny help is appreciated!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":25,"Q_Id":47720160,"Users Score":0,"Answer":"As suggested by @wpercy you have figure out which user is executing the file. Usually that user is called www-data !\nTo find out which user is calling the service use\n ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\\ -f1 \nAfter you figured out the user you have to change the permission for the folder. That command schould be something like chown -R www-data:www-data \/var\/www\/html\/Projectfolder \nSpecial thanks to wpercy!","Q_Score":0,"Tags":"php,python,linux,webserver,file-permissions","A_Id":47720634,"CreationDate":"2017-12-08T18:23:00.000","Title":"Linux editing privilege over webservice","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am trying to use Allure report with Python3, although the libraries used for Python Pytest are not supported, from what I can see.\nThe documentation say that Allure plugin for pytest support the previous version of allure only.\nIs there a workaround to use pytest on python3, and get the Allure reports created?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":614,"Q_Id":47725736,"Users Score":0,"Answer":"Found the solution.\nFirst of all, you need to remove ALL the old libraries and packages, since it may cause problems.\nThen you need to install the Allure command line via Brew.\nThat will allow you to generate reports from the output of your tests.\nThen what is left is to install via Pip the package for Python, which is called Allure-pytest.\nI did notice that some imports are different from the previous version of Allure; not sure what is the problem though, since importing Allure works fine in Python, but when I generate reports, I get errors because Objevt of type bytearray is not JSON serializable. \nWas working with the previous version of Allure API on Python 2.7, so I am not sure what is wrong, but most likely it is user error.","Q_Score":0,"Tags":"python,pytest,allure","A_Id":47764766,"CreationDate":"2017-12-09T05:48:00.000","Title":"Use Allure report V2 via pytest on Python3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have implemented a lambda project which has 4 modules\/project inside it. Each module\/project has python(s) files which implement module functionality.\nI have to write the test cases for each module so that it goes through CircleCI and execute on themselves:\n\nThat the module is starting and stopping a stepfunction.\nmodule is calling Rest service.\nIt is writing\/reading files from S3 Bucket.\n\nEverywhere, it is like a test driven development to write unit test, but now I have completed project implementation, how do I write automated test cases for my module ?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1070,"Q_Id":47758329,"Users Score":1,"Answer":"When it comes to unit testing, there's nothing special you have to do about AWS Lambda projects.\nYou Lambda handler is a Python function. Therefore, you can import it on your tests, call it with some input, and assert the output. Just like a normal Python function.","Q_Score":1,"Tags":"python,automated-tests,aws-lambda","A_Id":47763008,"CreationDate":"2017-12-11T17:36:00.000","Title":"How do I write test cases for my AWS Python-based lambda project?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any real documentation for the Python Azure IoTHub SDK? I have found a few code samples but nothing comprehensive. It's also hard to correlate with the documentation for other language SDK's as they all seem slightly different. Even the source code is not good documentation as it's actually a wrapper over C++.\nI'd like to be able to take advantage of all the features, but I can't. For instance in the code samples we see send_confirmation_callback, receive_message_callback, device_twin_callback, device_method_callback, and blob_upload_conf_callback, and it's not clear to me what these all do, or what other kinds of callbacks there might be.\nAm I missing it or does it not exist?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":271,"Q_Id":47763078,"Users Score":1,"Answer":"This is really disappointing that as of July 2019, no documentation\/API reference is available for Azure IOT suite's python SDK. What we have is a git repository with uncommented C-code or some sample programs.\nTo answer your question, No, there is no documentation as of now. I personally had to add dotnet in my stack only to get it working. Though working with python SDK would make life marginally better if there WAS a python SDK. The current one is simply a wrapper on created with BOOST. However, you can look into the API references for dotnet SDK and then moving back to the so-called Python SDK get's relatively easier. \n-Cheers (:","Q_Score":0,"Tags":"python,azure,azure-iot-hub,azure-iot-sdk","A_Id":57144824,"CreationDate":"2017-12-11T23:25:00.000","Title":"Documentation for Python Azure IoTHub SDK","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to monitor a file and if there is a change file I need to execute a script but the catch is cron job is not allowed, also this will be executed on AIX system.\nCan somebody help me here on how to proceed.Thank You","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":73,"Q_Id":47764837,"Users Score":0,"Answer":"One way I can think of is to write a daemon (another script perhaps) and keep checking the file for changes.\nIt is possible to write a script with infinite loop and the loop can contain the file check logic.","Q_Score":0,"Tags":"python,shell,cron,scheduled-tasks,aix","A_Id":47767204,"CreationDate":"2017-12-12T03:19:00.000","Title":"how to monitor changes in file without cron job in AIX","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am using mod_wsgi with pyramid and have different wsgi files per environment\/server like the pyramid-test.wsgi and pyramid-prod.wsgi\nThese files contains code to set environment variables that are different per environment. Example:\n\nos.environ['SQLALCHEMY_URL'] = 'TODO'\n\nI try to move this code to a file called settings.py that will be called in the .wsgi file. These settings files will be hold next to the .wsgi file or preferable in a secure sub dir, such that others can't read the settings (like db password), but can however deploy a new version and overwrite the .wsgi file such that the app is automatically reloaded by Apache.\nHow can I call the python code in the settings.py file from the .wsgi file?\nWhen I try to do that, it can't find it, as it's not part of the app module.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":443,"Q_Id":47814599,"Users Score":1,"Answer":"Presuming you are using recommended separate mod_wsgi daemon process group for each application instance, set the python-path option of the WSGIDaemonProcess directive for each to include the directory where your instance specific settings module is. A normal import should then work.","Q_Score":0,"Tags":"python,mod-wsgi,pyramid","A_Id":47821932,"CreationDate":"2017-12-14T13:32:00.000","Title":"How to call a function in another python file in my wsgi file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've added an exploit from www.exploit-db.com to \/.msf4\/modules\/exploit\/windows\/remote\/41987.py following the naming convention. I updated the database with the command updatedb and rebooted. \nMetasploit does not detect the newly added exploit. However, if i add 41891.rb, it detects it no problem. Why does Metasploit not see the python files?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2281,"Q_Id":47820287,"Users Score":0,"Answer":"Because metasploit is purely written in Ruby.","Q_Score":1,"Tags":"python,exploit,metasploit","A_Id":47822711,"CreationDate":"2017-12-14T18:54:00.000","Title":"Metasploit does't detect added exploit from exploit-db","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've added an exploit from www.exploit-db.com to \/.msf4\/modules\/exploit\/windows\/remote\/41987.py following the naming convention. I updated the database with the command updatedb and rebooted. \nMetasploit does not detect the newly added exploit. However, if i add 41891.rb, it detects it no problem. Why does Metasploit not see the python files?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2281,"Q_Id":47820287,"Users Score":0,"Answer":"DO as follow to add python extension (if you havent done yet):\n- meterpreter > use python\n- try python_import to import your python code module","Q_Score":1,"Tags":"python,exploit,metasploit","A_Id":47952094,"CreationDate":"2017-12-14T18:54:00.000","Title":"Metasploit does't detect added exploit from exploit-db","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a python project working fine in Aptana.\nI then started to use pipenv for the project's environment management and now I can't get Aptana to use that environment.\nI also set up a new project then added it to Aptana and Aptana uses a 3.7 version of python instead of the pipenv python 2.7.\nAny suggestions on where to start looking?","AnswerCount":1,"Available Count":1,"Score":0.761594156,"is_accepted":false,"ViewCount":1372,"Q_Id":47827106,"Users Score":5,"Answer":"Pipenv and python folders\nGet the location where pipenv is storing the virtual environment with:\npipenv --venv\nIt will return a folder: [environment_folder]\nAlso, get at hand the location of the original python executable, the one used by pipenv: [python_folder]\nEclipse configuration\nGo to the existing project where you want to use pipenv or create a new python project.\nGo to Eclipse menu: Project > Properties\nChoose: PyDev - Interpreter\nClick: \"Click here to configure an interpreter not listed\"\nChoose \"New\" from python interpreter\nUse the environment_folder output of pipenv --venv\nSet Interpreter Executable to: [environment_folder]\\Scripts\\python.exe\nWhen propmted, select folders to add to system PYTHONPATH:\n\n[python_folder]\\Lib\n[python_folder]\\DLLs\n[environment_folder]\\\n[environment_folder]\\lib [environment_folder]\\Scripts\n[environment_folder]\\lib\\site-packages\n\nAdd those folders.\nAccept and apply.\nAnd everything should be ready.","Q_Score":5,"Tags":"python,aptana,aptana3,pipenv","A_Id":53565839,"CreationDate":"2017-12-15T06:41:00.000","Title":"How do I configure Aptana IDE (Eclipse) to work with pipenv?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm using Python to get texts of tweets from twitter using tweepy and is it possible to get ID and password from user, pass it to twitter api, and access to the tweets and get json data. \nI read \"User timelines belonging to protected users may only be requested when the authenticated user either \u201cowns\u201d the timeline or is an approved follower of the owner.\" but not sure whether it means the programmer must be accessible to the protected account or the api can access to protected account by receiving ID and password.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1041,"Q_Id":47861097,"Users Score":2,"Answer":"The User Credentials is what determines permissions. With OAuth a user gives your app permission to act on their behalf.","Q_Score":1,"Tags":"python,api,twitter","A_Id":47863424,"CreationDate":"2017-12-18T01:34:00.000","Title":"Is it able to view protected accounts using twitter api?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm performing different sentiment analysis techniques for a set of Twitter data I have acquired. They are lexicon based (Vader Sentiment and SentiWordNet) and as such require no pre-labeled data. \nI was wondering if there was a method (like F-Score, ROC\/AUC) to calculate the accuracy of the classifier. Most of the methods I know require a target to compare the result to.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1755,"Q_Id":47865082,"Users Score":1,"Answer":"What I did for my research is take a small random sample of those tweets and manually label them as either positive or negative. You can then calculate the normalized scores using VADER or SentiWordNet and compute the confusion matrix for each which will give you your F-score etc.\nAlthough this may not be a particularly good test, as it depends on the sample of tweets you use. For example you may find that SentiWordNet classes more things as negative than VADER and thus appears to have the higher accuracy if your random sample are mostly negative.","Q_Score":1,"Tags":"python,nltk,sentiment-analysis,senti-wordnet,vader","A_Id":49966573,"CreationDate":"2017-12-18T09:06:00.000","Title":"Accuracy of lexicon-based sentiment analysis","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm performing different sentiment analysis techniques for a set of Twitter data I have acquired. They are lexicon based (Vader Sentiment and SentiWordNet) and as such require no pre-labeled data. \nI was wondering if there was a method (like F-Score, ROC\/AUC) to calculate the accuracy of the classifier. Most of the methods I know require a target to compare the result to.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1755,"Q_Id":47865082,"Users Score":0,"Answer":"The short answer is no, I don't think so. (So, I'd be very interested if someone else posts a method.)\nWith some unsupervised machine learning techniques you can get some measurement of error. E.g. an autoencoder gives you an MSE (representing how accurately the lower-dimensional representation can be reconstructed back to the original higher-dimensional form).\nBut for sentiment analysis all I can think of is to use multiple algorithms and measure agreement between them on the same data. Where they all agree on a particular sentiment you mark it as more reliable prediction, where they all disagree you mark it as unreliable prediction. (This relies on none of the algorithms have the same biases, which is probably unlikely.)\nThe usual approach is to label some percentage of your data, and assume\/hope it is representative of the whole data.","Q_Score":1,"Tags":"python,nltk,sentiment-analysis,senti-wordnet,vader","A_Id":47885084,"CreationDate":"2017-12-18T09:06:00.000","Title":"Accuracy of lexicon-based sentiment analysis","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to export my color scheme, so I can import back and forth on other computers and Anaconda envs? I can't seem to find a practical way of doing it.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1031,"Q_Id":47892039,"Users Score":2,"Answer":"(Spyder maintainer here) Sorry, Spyder doesn't have this functionality at the moment (February 2020).","Q_Score":4,"Tags":"python,anaconda,spyder","A_Id":47895902,"CreationDate":"2017-12-19T17:13:00.000","Title":"How to import\/export syntax coloring scheme","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have downloaded python 3.6.3 & installed wmi extension, wmi module. I'm getting error like \"AttributeError: module wmi has no attribute WMI\". Please help.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":723,"Q_Id":47901878,"Users Score":0,"Answer":"if your file name is wmi.py:\n rename it","Q_Score":0,"Tags":"python,wmi","A_Id":59811597,"CreationDate":"2017-12-20T08:41:00.000","Title":"Python wmi module attribute error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm writing Python script cron-job, which is periodically get updates from RabbitMQ and process them. Every time I process them I need only to get current snapshot of RMQ queue. I use queue_declare to get number of messages in it.\nI know how to get messages one by one with basic_get. Also, I can use basic_consume\/start_consuming and get messages in background, store them in some list and periodically get from that list, but what if script will fail with some error? I will lost all read messages in list. Also, I can use few consumers (pool of connections to RMQ) and get messages one by one. Maybe there is some other approach to do it?\nSo, my question is - what is the best (i.e. secure and fast) way to get current messages from RabbiMQ queue?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":517,"Q_Id":47925668,"Users Score":3,"Answer":"The best way to consume the messages is using basic_consume.\nbasic_get is slow","Q_Score":0,"Tags":"python,rabbitmq","A_Id":47937389,"CreationDate":"2017-12-21T13:06:00.000","Title":"The best way to read a lot of messages from RabbitMQ queue?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Ok, so python3 and unicode. I know that all python3 strings are actually unicode strings and all python3 code is stored as utf-8. But how does python3 reads text files? Does it assume that they are encoded in utf-8? Do I need to call decode('utf-8') when reading a text file? What about pandas read_csv() and to_csv()?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":11947,"Q_Id":47948518,"Users Score":0,"Answer":"Do I need to call decode('utf-8') when reading a text file?\n\nYou need to try-read a text file to make sure it's utf-8 encoding in the file.","Q_Score":8,"Tags":"python-3.x,unicode,utf-8","A_Id":57127693,"CreationDate":"2017-12-22T23:39:00.000","Title":"Reading UTF-8 Encoded Files and Text Files in Python3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to create a telegram bot which would immediately forward message from another bot, that regularly posts some info. I've tried to find some ready templates, but alas... I would be grateful for any useful info. Thanks!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":497,"Q_Id":47952659,"Users Score":1,"Answer":"I don't think this is possible. As far as I know, bots can't communicate with other bots.\nBut you can add bots to groups","Q_Score":0,"Tags":"python,telegram-bot","A_Id":47952757,"CreationDate":"2017-12-23T12:52:00.000","Title":"Is it possible to create a telegram bot which forwards messages from another bot to telegram group or channel?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to generate all possible sequence of alternative digit and numbers. For example \n5j1c6l2d4p9a9h9q\n6d5m7w4c8h7z4s0i\n3z0v5w1f3r6b2b1z\nNumberSmallletterNumberSmallletter\nNumberSmallletterNumberSmallletter\nNumberSmallletterNumberSmallletter\nNumberSmallletterNumberSmallletter\nI can do it by using 16 loop But it will take 30+ hours (rough idea). Is there any efficient way. I hope there will be in python.","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":264,"Q_Id":47954890,"Users Score":2,"Answer":"There is no \"efficient\" way to do this. There are 2.8242954e+19 different possible combonations, or 28,242,954,000,000,000,000. If each combination is 16 characters long, storing this all in a raw text file would take up 451,887,264,000 gigabytes, 441,296,156.25 terabytes, 430,953.2775878906 petabytes, or 420.8528101444 exabytes. The largest hard drive available to the average consumer is 16TB (Samsung PM1633a). They cost 12 thousand US dollars. This puts the total cost of storing all of this data to 330,972,117,600 US dollars (3677.46797 times Bill Gates' net worth). Even ignoring the amount of space all of these drives would take up, and ignoring the cost of the hardware you would need to connect them to, and assuming that they could all be running at highest performance all together in a lossless RAID array, this would make the write speed 330,972,118 gigabytes a second. Sounds like a lot, doesn't it? Even with that write speed, the file would take 22 minutes to write, assuming that there were no bottlenecks from CPU power, RAM speed, or the RAID controller itself. \nSources - a calculator.","Q_Score":1,"Tags":"python,algorithm,numpy,combinations,permutation","A_Id":47955527,"CreationDate":"2017-12-23T18:20:00.000","Title":"Generate all possible sequence of altrenate digits and alphabets","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So, my project does a lot of mathematics for the user. It lets them enter equations and then solves them with some fairly complicated items like eigenvalues. I do some of this is javascript, but I have also written a python script utilizing numpy. I would like the user to be able to have the option of having the script on their local machine and then solving the mathematics there instead of on my server.\nSo, the user would enter an equation and hit enter. The javascript would then call a python script running on the users local machine. The equation is solved there with my code and the result is returned to the web page.\nI thought that this would be possible with CGI, but I cannot seem to find clear documentation on how this would be accomplished. Is there a better way?\nI do not want to run third party software and I do not want to run the python code in the browser.\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":399,"Q_Id":47956052,"Users Score":0,"Answer":"Short answer is: no, this isn't possible.\nSure, they can download your script and run it themselves if they have a compatible version of Python installed, but you won't be able to run it from the browser (that would be a severe security problem!)\nYour options are either to write it in JS, or create an API on your server, or find and use an existing API.","Q_Score":0,"Tags":"python,cgi","A_Id":47956075,"CreationDate":"2017-12-23T21:12:00.000","Title":"Call python script from web page and get results","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"My bot is admin in a channel and I want to read channel's recent actions(like who joined the channel and etc) using python-telegram-bot. How can I achive this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":967,"Q_Id":47962314,"Users Score":1,"Answer":"There have no method to get recently actions by bot. And bots won't get notified when users joined channel.\nIf you want to know whether user in your channel, there have getChatMember method.","Q_Score":0,"Tags":"python,telegram,telegram-bot,python-telegram-bot","A_Id":47962389,"CreationDate":"2017-12-24T16:34:00.000","Title":"Read channel recent actions with telegram bot","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am collecting some data from my android application. How to run a python script in my android application that uses the collected data as input and generates some output?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":4957,"Q_Id":47968040,"Users Score":2,"Answer":"Consider Jython, Jython is an implementation of the high-level, dynamic, object-oriented language Python seamlessly integrated with the Java platform. The predecessor to Jython, JPython, is certified as 100% Pure Java.\n\nmbedded scripting - Java programmers can add the Jython libraries to\ntheir system to allow end users to write simple or complicated\nscripts that add functionality to the application.\nInteractive experimentation - Jython provides an interactive\ninterpreter that can be used to interact with Java packages or with\nrunning Java applications. This allows programmers to experiment and\ndebug any Java system using Jython.\nRapid application development - Python programs are typically 2-10X\nshorter than the equivalent Java program. This translates directly\nto increased programmer productivity. The seamless interaction\nbetween Python and Java allows developers to freely mix the two\nlanguages both during development and in shipping products.\n\n\nThe awesome features of Jython are as follows,\n\n\nDynamic compilation to Java bytecodes - leads to highest possible\nperformance without sacrificing interactivity.\nAbility to extend existing Java classes in Jython - allows effective\nuse of abstract classes.\n\nJython doesn't compile to \"pure java\", it compiles to java bytecode subsequently to class files. To develop for Android, one compile java bytecode to Dalvik bytecode. To be honest, this path of development is not official , thus you will run into lots of problem with compatibility of course.","Q_Score":16,"Tags":"android,python,android-activity","A_Id":48065914,"CreationDate":"2017-12-25T11:09:00.000","Title":"Running Python Script from Android Activity","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Python and currently I have a Python project under VS2017 solution along with a C# project. I know the question has been asked before and the steps involved creating a process in C# and calling the Python.exe and pass in the *.pr file. However, with VS2017 and the integrated Python environment, I want to know if the process of invoking\/calling Python functions has been changed\/improved? Does it still require me to have Python installed on the server and physically point the location of the Python.exe?\nI cannot and will not use IronPython as it is running the dead 2.7 base and I want to use Python 3.6 going forward. \nThank you for any pointers!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":48,"Q_Id":47984024,"Users Score":0,"Answer":"No, it's still the same. Starting a process is a feature of the .NET language (code) and has nothing to do with Visual Studio.","Q_Score":0,"Tags":"c#,python,python-3.x,visual-studio","A_Id":47984044,"CreationDate":"2017-12-26T21:46:00.000","Title":"Invoke Python functions from C# in VS2017","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to implement a transparent IMAPS (SSL\/TLS) proxy from zero using python (pySocks and imaplib).\nThe user and the proxy are in the same network and the mail server is outside (example: gmail servers). All the traffic on port 993 is redirected to the proxy. The user should retrieve his emails using his favorite email application (example: thunderbird). The proxy should receive the commands and transmit it to the user\/server and should be able to read the content of the retrieved emails.\nHowever, as the traffic is encrypted, I don't know how to get the account and the password of the user (without using a database) OR how to read the content of the emails without knowing the account and the password of the user.\nAfter few days looking for a solution, I still don't have any track. Maybe it is not possible ? If you have any track, I would be happy to read it.\nThank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":221,"Q_Id":47988332,"Users Score":0,"Answer":"You must implement your proxy as a Man In The Middle attack. That means that there are two different SSL\/TLS encrypted communication channels: one between the client and the proxy, one between the the proxy and the server. That means that either:\n\nthe client explicitely sets the proxy as its mail server (if only few servers are to be used with one name\/address per actual server)\nthe proxy has a certificate for the real mail server that will be trusted by the client. A common way is to use a dummy CA: the proxy has a private certificate trusted by the client that can be used to sign certificates for any domains like antivirus softwares do.\n\nOnce this is set up, the proxy has just to pass all commands and responses, and process the received mails on the fly.\nI acknowledge that this is not a full answer, but a full answer would be far beyond the scope of SO and I hope it could a path to it. Feel free to ask more precise questions here if you are later stuck in actual implementation.","Q_Score":0,"Tags":"python,imap","A_Id":47988655,"CreationDate":"2017-12-27T07:48:00.000","Title":"Transparent IMAPs proxy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using discord.py to create my bot and I was wondering how to create roles\/permissions specific to the bot? \nWhat that means is when the bot enters the server for the first time, it has predefined permissions and role set in place so the admin of the server doesn't need to set a role and permissions for the bot.\nI have been trying to look up a reference implementation of this but no luck. If someone can point me at example of how to get a simple permission\/role for a bot that will be great!","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":7000,"Q_Id":47999716,"Users Score":1,"Answer":"you want to do this through oath2 using the url parameters","Q_Score":0,"Tags":"python,bots,discord","A_Id":48163714,"CreationDate":"2017-12-27T23:15:00.000","Title":"How to create a role for a Discord Bot","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed the google assistant SDK on a raspberry pi 3 and have so far managed to get Spotify working, and managed to get IFTTT to run for lights. What I really want to know is whether it is possible to have google assistant run and interact with python scripts on the pi. By which I mean I have a script called sound_the_alarm.py which pulls news from different sources, gives updates on bitcoin etc, and then plays a random song from my library, and turns on a light via gpio. I would like to be able to say \u201cok google sound the alarm at 7:00 tomorrow and have it update the crib tab with an instance of the alarm. Is this possible? I have found nothing online suggesting so! \nThanks\nWill","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1796,"Q_Id":48000835,"Users Score":0,"Answer":"It is possible, but not directly, as I know.\nI use IFTTT for that (check on youtube how easy it is).\nThe easiest way is to have public IP with your raspberry, but it is dangerous (see below for solution).\n\nLog into ifttt.com and make an applet: Google Assistant Command to Webhook. It is a piece of cake. You will learn it in minutes (use youtube for tutorial).\nYou type as a webhook public IP of your raspberry with a link to PHP app.\nYour PHP app fetches the info about command from Google Assistant and exec(\"Your command here\");\n\nAdditional info:\n\nIt is probably possible to make fetching app in Python instead of PHP, but I am not a Python programmer, so I cannot help with it. I use PHP for that.\nIt is MUUUCH SAFER to make additional \"Gate Server\". Take the cheapest hosting provider. Make an APP on this server (probably in PHP :P). Your IFTTT sends a request to the Gate (instead of raspberry directly). And your raspberry pi contacts the gate checking if there are no any orders for it. If there is any, it follows the order. Because of that nobody knows your raspberry IP address. You can hide it behind the router so it is more less safe.\n\nI hope my solution is understandable :).\nK.","Q_Score":2,"Tags":"python,cron,raspberry-pi3,google-assistant-sdk","A_Id":50710220,"CreationDate":"2017-12-28T02:12:00.000","Title":"Google assistant to run python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I've gone through about 20 threads but don't seem to be able to find an answer to what I hoped was a simple question!\nI have a unicode-encoded byte \"\\xbf\" which translates to a \"\u00bf\" character.\nIf I encode the character as follows: u\"\u00bf\".encode(\"cp1252\") it outputs \"\\xbf\". How can I return this back to a \"\u00bf\" character for display on screen?\nNo matter what I attempt, I seem to get an ordinal not in range(128) error.\nEDIT: A further example of this is simply using chr(191), which also gives the result \"\\xbf\". How can I make this print the ASCII character?\nAny and all help appreciated!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":232,"Q_Id":48003638,"Users Score":0,"Answer":"So after much experimentation and for reasons I don't fully understand, the following code works:\nprint \"%s\" %(\"\\xbf\").decode(\"cp1252\")\nIt's a workable solution so I'll call this one solved!","Q_Score":0,"Tags":"python,unicode","A_Id":48004364,"CreationDate":"2017-12-28T07:48:00.000","Title":"Unable to convert unicode byte to ASCII","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've script in python that takes photos from raspberry camera and send mail with this photos. From command line everything works OK, script start do the jobs and finishes without errors. \nI setup cron to execute script every 1 hour. \nEvery hour I get mail but without attachments.\nWhere or how can I check why script executed from cron don't send attachments?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":668,"Q_Id":48006244,"Users Score":0,"Answer":"While running cron job check any relative paths is given in your code, then either change it to absolute path or change the directory inside the script. Then only the cron job will take the attachment or anything that need to include into your script.","Q_Score":1,"Tags":"python-3.x,cron,raspberry-pi","A_Id":48019881,"CreationDate":"2017-12-28T10:59:00.000","Title":"execute python script from cron don't send mail","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"For a specific program I'm working in, we need to evaluate some code, then run a unittest, and then depending on whether or not the test failed, do A or B.\nBut the usual self.assertEqual(...) seems to display the results (fail, errors, success) instead of saving them somewhere, so I can't access that result.\nI have been checking the modules of unittest for days but I can't figure out where does the magic happen or if there is somewhere a variable I can call to know the result of the test without having to read the screen (making the program read and try to find the words \"error\" or \"failed\" doesn't sound like a good solution).","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":978,"Q_Id":48007839,"Users Score":0,"Answer":"You can use pdb to debug this issue, in the test simply add these two lines to halt execution and begin debugging.\nimport pdb\n pdb.settrace()\nNow for good testing practice you want deterministic test results, a test that fails only sometimes is not a good test. I recommend mocking the random function and using data sets that capture the errors you find.","Q_Score":1,"Tags":"python,unit-testing,python-unittest","A_Id":48013158,"CreationDate":"2017-12-28T12:49:00.000","Title":"Python: How to access test result variables from unittest module","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have imported \"smtplib\" in the code, and I doubt that the server won't have this installed. Is there a CDN for modules in python ?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":30,"Q_Id":48010487,"Users Score":1,"Answer":"You should save your dependencies in a requirements.txt file and use pip to install the requirements as part of your Django app's deployment process.\nEdit: smtplib is part of the standard lib, so it should be available out of the box.","Q_Score":0,"Tags":"python,django","A_Id":48010534,"CreationDate":"2017-12-28T15:54:00.000","Title":"What if the hosting Django server don't have the module I imported?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I recently made a music bot in my discord server but the problem I have is that I have to turn on the bot manually etc. and it goes offline when I turn off my computer. How can I make the bot stay online at all times, even when I'm offline?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":4654,"Q_Id":48014892,"Users Score":1,"Answer":"Use a Raspberry Pi with an internet connection. Install all necessary components and then run the script in its terminal. Then, you can switch off the monitor and the bot will continue running. I recommend that solution to run the bot 24\/7. If you don't have a Raspberry Pi, buy one (they're quite cheap), or buy a server to run the code on.","Q_Score":0,"Tags":"python,discord.py","A_Id":51890116,"CreationDate":"2017-12-28T21:59:00.000","Title":"How do I make my discord bot stay online","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently made a music bot in my discord server but the problem I have is that I have to turn on the bot manually etc. and it goes offline when I turn off my computer. How can I make the bot stay online at all times, even when I'm offline?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4654,"Q_Id":48014892,"Users Score":0,"Answer":"You need to run the python script on a server, e.g. an EWS linux instance. \nTo do that you would need to install python on the server and place the script in the home directory and just run it via a screen.","Q_Score":0,"Tags":"python,discord.py","A_Id":48034102,"CreationDate":"2017-12-28T21:59:00.000","Title":"How do I make my discord bot stay online","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to build a AWS Lambda function using APi Gateway which utlizes pyodbc python package. I have followed the steps as mentioned in the documentation. I keep getting the following error Unable to import module 'app': libodbc.so.2: cannot open shared object file: No such file or directory when I test run the Lambda function. \nAny help appreciated. I am getting the same error when I deployed my package using Chalice. It seems it could be that I need to install unixodbc-dev. Any idea how to do that through AWS Lambda?","AnswerCount":6,"Available Count":1,"Score":0.0333209931,"is_accepted":false,"ViewCount":6014,"Q_Id":48016091,"Users Score":1,"Answer":"Fisrt, install unixODBC and unixODBC-devel packages using yum install unixODBC unixODBC-devel. This step will install everything required for pyodbc module. \nThe library you're missing is located in \/usr\/lib64 folder on you Amazon Linux instance.\nCopy the library to your python project's root folder (libodbc.so.2 is just a symbolic link, make sure you copy symbolic link and library itself as listed): libodbc.so, libodbc.so.2 and libodbc.so.2.0.0","Q_Score":3,"Tags":"python,amazon-web-services,aws-lambda,chalice","A_Id":50925535,"CreationDate":"2017-12-29T00:40:00.000","Title":"Unable to use pyodbc with aws lambda and API Gateway","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am looking for a way to automatically check contacts in Dynamics 365 CRM and sync them to mailcontacts in Exchange online distribution lists.\nDoes anyone have suggestions on where to start with this?\nI was thinking of trying to use python scripts with the exchangelib library to connect to the CRM via API, check the CRM contacts, then connect to Exchange online with API to update the mailcontacts in specific distribution lists if needed.\nDoes this sound plausible?\nAre their more efficient ways of accomplishing this?\nAny suggestions are greatly appreciated, thanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":76,"Q_Id":48025594,"Users Score":0,"Answer":"How about using MS Flow? I have done similar thing before using MS Flow to transfer emails from CRM to an online email processing service and retrieving emails back to CRM.","Q_Score":0,"Tags":"python,api,dynamics-crm,exchange-server,exchangelib","A_Id":48050166,"CreationDate":"2017-12-29T16:36:00.000","Title":"Syncing Dynamics CRM contacts to Exchange mailcontacts distribution lists","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am submitting a python script to condor. When condor runs it it gets\nan import error. Condor runs it as\n\/var\/lib\/condor\/execute\/dir_170475\/condor_exec.exe. If I manually copy\nthe python script to the execute machine and put it in the same place\nand run it, it does not get an import error. I am wondering how to\ndebug this.\nHow can I see the command line condor uses to run it? Can the file\ncopied to \/var\/lib\/condor\/execute\/dir_170475\/condor_exec.exe be\nretained after the failure so I can see it? Any other suggestions on\nhow to debug this?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":289,"Q_Id":48031855,"Users Score":1,"Answer":"You can simply run an interactive job (basically just a job with sleep or cat as command) and do ssh_to_job to run it.\nGenerally you need to set-up your python environment on the compute node, it is best to have a venv and activate it inside your start script.","Q_Score":1,"Tags":"python,condor","A_Id":61310906,"CreationDate":"2017-12-30T07:18:00.000","Title":"Debugging htcondor issue running python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I've created a simple script that executes a \"moving mouse and keyboard\" sequence. Although currently to get this to work I use a Shell (Idle) to run and that is to slow with boot up time and such.\nIs there a way to have this python file on desktop och with a hotkey swiftly run the code? I tried doing it through terminal but it doesn't like my module.\nSome info:\nThis is for both mac and windows.\nThe module I imported is pyautogui from PyPi and it works in the shell.\nThank you in advance!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5035,"Q_Id":48042158,"Users Score":0,"Answer":"Some things to consider when trying to setup a hotkey to successfully execute any kind of command:\nEach Operating System has its own ways to setup hotkeys and sometimes this may differ between distributions as well as between desktop managers. \nMany of the relevant how-to-descriptions are easily found via regular search machines as Google. \nIf you would in fact like your script to set-up its own hotkeys you would have to re-write it in such a manner that it can detect the current operating system\/distribution\/desktop manager by itself and execute the commands relevant to that particular set-up.","Q_Score":2,"Tags":"python,hotkeys","A_Id":48042519,"CreationDate":"2017-12-31T11:44:00.000","Title":"Run Python script quickly via HotKey","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Slack API provides you two options: use app as a bot and as a logged in user itself. I want to create App that will be working as a user and run channel commands. How can I do with discord.py?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":8029,"Q_Id":48043363,"Users Score":0,"Answer":"As Wright has commented, this is against discord's ToS. If you get caught using a selfbot, your account will be banned. However, if you still REALLY want to do this, what you need to do is add\/replace bot.run('email', 'password') to the bottom of your bot, or client.run('email', 'password') to the bottom depending on how your bot is programmed.","Q_Score":2,"Tags":"python,discord,discord.py","A_Id":48051694,"CreationDate":"2017-12-31T14:43:00.000","Title":"How to login as user rather bot in discord server and run commands?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently using PyCUDD, which is a SWIG-generated Python wrapper for the C package CUDD. I'm currently trying to get CUDD to print some debug information from inside the C code, but any printfs inside the C code don't seem to be producing any output - putting them in the .i files for SWIG produces output, putting them in the C code does not. I'm not sure if this is some property of SWIG specifically or of compiling the C code to a shared object library.\n(Particularly frustrating is that I know that I have had this problem and gotten it working before, but I can't seem to find anything searching for the problem now, and I apparently forgot to leave notes on that one thing.)","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":861,"Q_Id":48064686,"Users Score":0,"Answer":"I still forget what my problem was before. However, I have found that what was causing my problem here was a linker issue - the linker was looking at an old version of the library, which did not have my changes.","Q_Score":0,"Tags":"python,c,swig,cudd","A_Id":48671922,"CreationDate":"2018-01-02T16:41:00.000","Title":"Make printf appear in stdout from shared object library","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is the most dense way (fewest characters) that I can store a complete SHA-256 hash?","AnswerCount":2,"Available Count":1,"Score":0.4621171573,"is_accepted":false,"ViewCount":1624,"Q_Id":48081688,"Users Score":5,"Answer":"Calling .digest() on a hashlib.sha256 object will return a 32-byte string -- the shortest possible way (with 8-bit bytes as the relevant unit) to store 256 bits of data which is effectively random for compressibility purposes.\nSince 8 * 32 == 256, this provably has no wastage -- every bit is used.","Q_Score":2,"Tags":"python,hash,sha","A_Id":48081802,"CreationDate":"2018-01-03T16:50:00.000","Title":"In Python, represent a SHA-256 hash using the fewest characters possible","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Here I am trying to import 'libEpsonFiscalDriver.so' file in raspberry pi using python 2.7. Here are my steps in python\n\n>>>import ctypes\n>>>ctypes.cdll.LoadLibrary('\/home\/pi\/odoo\/my_module\/escpos\/lib\/libEpsonFiscalDriver.so')\n\n\n Traceback (most recent call last):\n File \"\", line 1, in \n File \"\/usr\/lib\/python2.7\/ctypes\/__init__.py\", line 443, in LoadLibrary\n return self._dlltype(name)\n File \"\/usr\/lib\/python2.7\/ctypes\/__init__.py\", line 365, in __init__\n self._handle = _dlopen(self._name, mode)\n OSError: \/home\/pi\/odoo\/my_module\/escpos\/lib\/libEpsonFiscalDriver.so: cannot open shared object file: No such file or directory\n\nSo here I am getting this error.\nExtra Information: Header Information of libEpsonFiscalDriver.so file.\nreadelf -h libEpsonFiscalDriver.so\n\nELF Header:\n Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 \n Class: ELF32\n Data: 2's complement, little endian\n Version: 1 (current)\n OS\/ABI: UNIX - System V\n ABI Version: 0\n Type: DYN (Shared object file)\n Machine: Intel 80386\n Version: 0x1\n Entry point address: 0x5de0\n Start of program headers: 52 (bytes into file)\n Start of section headers: 125176 (bytes into file)\n Flags: 0x0\n Size of this header: 52 (bytes)\n Size of program headers: 32 (bytes)\n Number of program headers: 7\n Size of section headers: 40 (bytes)\n Number of section headers: 29\n Section header string table index: 26\n\nFor more, I have tested this same code with my other system with Ubuntu installed having Intel Processor and it works fine there. As, lib header listed Machine as Intel 80386. I dought that this lib will only work with Intel Architecture. Is it the thing or am I missing something?\nAny help will be more than appreciated! Thank you.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1606,"Q_Id":48111026,"Users Score":0,"Answer":"The lib is not compatible with Raspberry Pi as the architectures are different. You need to find an ARM based version of that driver if you want to use it on the Pi.","Q_Score":1,"Tags":"python,python-2.7,raspberry-pi","A_Id":49945959,"CreationDate":"2018-01-05T09:51:00.000","Title":"cannot open shared object file: No such file or directory in raspberry pi with python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Right now I'm running Python in Atom with Platformio as my terminal. First off, what's the keyboard shortcut to run the file? Secondly, is there a better terminal package out there? I'd like more features such as right clicking and selecting run the file or something that makes running the file easier (maybe a run button). I switch between files quite frequently so I'd like an alternative other than using the up arrow to run previous command.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":685,"Q_Id":48119447,"Users Score":0,"Answer":"I use Atom for python. The best terminal plugin I have found is Platformio. I have a plugin named script that allows me to run python scripts from the editor window. The command also has a shortcut to speed up the process. Load script and it will appear under the packages menu. It also defines the shortcut for 'run script' as the command-I keys.\nLately I've been running python script using the Hydrogen plugin. This allows in-line plotting along with running your script. Answers and plots appear in the editor pane. Its very nice if you have to plot.","Q_Score":0,"Tags":"python,atom-editor","A_Id":48119925,"CreationDate":"2018-01-05T18:38:00.000","Title":"Python- Alternative terminal in Atom text editor","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm running ipython through an ssh terminal. %load in ipython prints the code to the screen. Is there a way of loading a script while surpressing the verbosity (preferably with few keystrokes)?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":616,"Q_Id":48139998,"Users Score":1,"Answer":"Do not use %load, instead type %run. From their docstrings:\n%load Load code into the current frontend.\n%run Run the named file inside IPython as a program.","Q_Score":2,"Tags":"python,ipython","A_Id":48140853,"CreationDate":"2018-01-07T17:57:00.000","Title":"How to %load a script in ipython without printing code to the screen?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Python 2.7 (that means that there is no base64.decodebytes())\nI need to convert my base64 string, for example aW0ganVzdCBhIGJhc2UgNjQgZmlsZQ== into binary (i.e string of 1's and 0's).\nI thought to try and write the base 64 string to a file in mode wb and then read it back with rb but even when used wb to write - I still see the original base 64 string when opening the file..\nWhat am I missing?\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1624,"Q_Id":48152403,"Users Score":1,"Answer":"That's right. You can see the readable characters even if you save them into binary file. Because they are ASCII characters.\nActually, you are not going to save file with binary format, because you can't get the binary string by save it with 'wb'.\nWhat you should do is to get the ASCII value of every character, and convert it to binary number.","Q_Score":3,"Tags":"python,python-2.7,base64","A_Id":48152634,"CreationDate":"2018-01-08T14:32:00.000","Title":"Python 2.7 - convert base 64 to binary string","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've written a 40k line program in python3. Now I need to use a module throughout my program that is called pytan which will impart a functionality addition. The problem is that pytan is written in python2.\nSo is it possible to switch the interpreter to python 2.7 inside one script that is called by another running in python 3?\nWhat's the best way to handle this situation.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":122,"Q_Id":48152513,"Users Score":6,"Answer":"You cannot \"switch the interpreter to python 2.7\". You're either using one or the other. Your choices are effectively:\n\nCome up with an alternative that doesn't require the pytan module.\nModify the pytan module so that it runs under Python 3.\nModify your code so that it runs under Python 2.\nIsolate the code that requires pytan such that you can run it as a subprocess under the python 2 interpreter. There are a number of problems with this solution:\n\nIt requires people to have two versions of Python installed.\nIt will complicate things like syntax highlighting in your editor.\nIt will complicate testing.\nIt may require some form of IPC (pipes, sockets, files, etc...) between your main code and your python 2 subprocess (this isn't terrible, but it's a chunk of additional complexity that wouldn't be necessary if you could make one of the other options work).","Q_Score":3,"Tags":"python,python-3.x,python-2.7","A_Id":48152682,"CreationDate":"2018-01-08T14:40:00.000","Title":"How do you use a python2 module inside a python3 program","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm running apache2 web server on raspberry pi3 model B. I'm setting up smart home running with Pi's and Uno's. I have a php scrypt that executes python program>index.php. It has rwxrwxrwx >I'll change that late becouse i don't fully need it.\n And i want to real-time display print from python script.\n exec('sudo python3 piUno.py') Let's say that output is \"Hello w\"\nHow can i import\/get printed data from .py?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2682,"Q_Id":48174011,"Users Score":0,"Answer":"First make sure you have permissions to write read execute for web user.\nYou can you user sudo sudo chmod 777 \/path\/to\/your\/directory\/file.xyz\nFor php file and file you want to run. $output = exec('sudo pytho3 piUno'); echo $output;\nCredits ---> Ralph Thomas Hopper","Q_Score":0,"Tags":"php,python,python-3.x,raspberry-pi3","A_Id":48174819,"CreationDate":"2018-01-09T17:50:00.000","Title":"get python to print\/return value on your website with php","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"py on a raspberry pi with python 2.7.9 and pip 1.5.6. I installed and uninstalled pyvisa and pyvisa-py several times, but the problems stay. I connected the KEITHLEY Multimeter 2000 per R232 to USB with the Raspberry.\nWhen I run the basic Code:\n\nimport visa\nrm = visa.ResourceManager('@py')\na=rm.list_resources()\nprint(a)\n\nI receive:\n\nTraceback (most recent call last):\n File \"pyvisa.py\", line 1, in \n import visa\n File \"\/usr\/local\/lib\/python2.7\/dist-packages\/visa.py\", line 16, in \n from pyvisa import logger, __version__, log_to_screen, constants\n File \"\/home\/pi\/pyvisa.py\", line 2, in \n rm = visa.ResourceManager('@py')\nAttributeError: 'module' object has no attribute 'ResourceManager'\n\nas well when I try\npython -m visa info\n\nTraceback (most recent call last):\n File \"\/usr\/lib\/python2.7\/runpy.py\", line 162, in _run_module_as_main\n \"__main__\", fname, loader, pkg_name)\n File \"\/usr\/lib\/python2.7\/runpy.py\", line 72, in _run_code\n exec code in run_globals\n File \"\/usr\/local\/lib\/python2.7\/dist-packages\/visa.py\", line 16, in \n from pyvisa import logger, __version__, log_to_screen, constants\n File \"pyvisa.py\", line 1, in \n import visa\n File \"\/usr\/local\/lib\/python2.7\/dist-packages\/visa.py\", line 16, in \n from pyvisa import logger, __version__, log_to_screen, constants\nImportError: cannot import name logger\n\nOn the other hand i can't upgrade, because the requirements are already up-to-date.\n\npip install pyvisa-py --upgrade\nRequirement already up-to-date: pyvisa-py in \/usr\/local\/lib\/python2.7\/dist-packages\nRequirement already up-to-date: pyvisa>=1.8 in \/usr\/local\/lib\/python2.7\/dist-packages (from pyvisa-py)\nRequirement already up-to-date: enum34 in \/usr\/local\/lib\/python2.7\/dist-packages (from pyvisa>=1.8->pyvisa-py)\n\nI would be very thankfull if somebody could help me with this issue.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1834,"Q_Id":48196521,"Users Score":0,"Answer":"\"In python 2.7, the import system will always use files in the working directory over the one in site-packages and as your file is named pyvisa.py when importing visa.py it picks your own module instead of the 'real' pyvisa module.\"MatthieuDartiailh from github","Q_Score":0,"Tags":"python,python-2.7,raspberry-pi3,pyvisa","A_Id":48204460,"CreationDate":"2018-01-10T21:40:00.000","Title":"pyvisa-py on raspberry pi AttributeError: 'module' object has no attribute 'ResourceManager'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hi I am trying to connect to the outlook server to sending the email with smtplib in python. \nTrying this code smtplib.SMTP('smtp-mail.outlook.com') does not print out anything and also does not return an error. \nCan somebody tell me what might be the problem and how to fix it. \nThank you a lots.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1765,"Q_Id":48204680,"Users Score":0,"Answer":"thank you for all your answer, the problem is actually caused because of some restriction in my work network. I have talked with them and the problem is solved.","Q_Score":0,"Tags":"python,smtplib","A_Id":51780455,"CreationDate":"2018-01-11T10:20:00.000","Title":"Python SMTPLIB does not connect","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a script that runs git remote commands and require user\/password credential, because the script runs by teamcity I was wondering if there is a way for teamcity to pass these credential to my script?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4184,"Q_Id":48214572,"Users Score":0,"Answer":"By design, TeamCity resists making usernames\/passwords available to build steps. This is not to say that you couldn't make it work that way, but be aware of the reason it does it. If anyone should be able to configure build jobs but shouldn't be able to see the password in question, you'd have a security problem.\nThe best solution in my opinion is to use SSH when possible. TeamCity will be happy to run an ssh-agent while your build steps execute, configured with the private key (hence, the identity) of your choosing. Just being able to configure a build does not give a user the ability to see the private key (or any other sensitive credential) in this scenario, even if they code cleverly and maliciously.\nOf course this isn't always an option. But for basic git access it usually is, and you may want to consider it.","Q_Score":1,"Tags":"python,git,teamcity","A_Id":48214746,"CreationDate":"2018-01-11T19:33:00.000","Title":"run a script using teamcity that require credentials","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am doing an example of a Simple Linear Regression in Python and I want to make use of Lambda functions to make it work on AWS so that I could interface it with Alexa. The problem is my Python package is 114 MB. I have tried to separate the package and the code so that I have two lambda functions but to no avail. I have tried every possible way on the internet. \nIs there any way I could upload the packages on S3 and read it from there like how we read csv's from S3 using boto3 client?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":946,"Q_Id":48241838,"Users Score":0,"Answer":"There are certain limitations when using AWS lambda.\n1) The total size of your uncompressed code and dependencies should be less than 250MB.\n2) The size of your zipped code and dependencies should be less than 75MB.\n3) The total fixed size of all function packages in a region should not exceed 75GB.\nIf you are exceeding the limit, try finding smaller libraries with less dependencies or breaking your functionality in to multiple micro services rather than building code which does all the work for you. This way you don't have to include every library in each function. Hope this helps.","Q_Score":1,"Tags":"python,amazon-web-services,amazon-s3,aws-lambda","A_Id":50647228,"CreationDate":"2018-01-13T16:28:00.000","Title":"Working around AWS Lambda space limitations","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"On my Discord server, I have a #selfies channel where people share photos and chat about them. Every now and then, I would like to somehow prune all messages that do not contain files\/images. I have tried checking the documentation, but I could see not see any way of doing this. Is it not possible?","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":10898,"Q_Id":48255732,"Users Score":3,"Answer":"You can iterate through every message and do: \nif not message.attachments:\n ...\nmessage.attachments returns a list and you can check if it is empty using if not","Q_Score":5,"Tags":"python,python-3.x,discord,discord.py","A_Id":48287783,"CreationDate":"2018-01-15T00:59:00.000","Title":"Is there a way to check if message.content on Discord contains a file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a flow sensor that I have to read with c because python isn't fast enough but the rest of my code is python. What I want to do is have the c code running in the background and just have the python request a value from it every now and then. I know that popen is probably the easiest way to do this but I don't fully understand how to use it. I don't want completed code I just want a way to send text\/numbers back and forth between a python and a c code. I am running raspbian on a raspberry pi zero w. Any help would be appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":215,"Q_Id":48265821,"Users Score":0,"Answer":"Probably not a full answer, but I expect it gives some hints and it is far too long for a comment. You should think twice about your requirements, because it will probably not be that easy depending on your proficiency in C and what OS you are using. \nIf I have correctly understood, you have a sensor that sends data (which is already weird unless the sensor is an intelligent one). You want to write a C program that will read that data and either buffer it, and retain only last (you did not say...) and at the same time will wait for requests from a Python script to give it back what it has received (and kept) from the sensor. That probably means a dual thread program with quite a bit of synchronization.\nYou will also need to specify the communication way between C and Python. You can certainly use the subprocess module, but do not forget to use unbuffered output in C. But you could also imagine an independant program that uses a FIFO or a named piped with a well defined protocol for external requests, in order to completely separate both problems.\nSo my opinion is that this is currently too broad for a single SO question...","Q_Score":0,"Tags":"python,c,popen","A_Id":48266333,"CreationDate":"2018-01-15T15:18:00.000","Title":"How to read a sensor in c but then use that input in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How does the quality of my code gets affected if I don't use __init__ method in python? A simple example would be appreciated.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":486,"Q_Id":48279419,"Users Score":1,"Answer":"Its not a matter of quality here, in Object-oriented-design which python supports, __init__ is way to supply data when an object is created first. In OOPS, this is called a constructor. In other words A constructor is a method which prepares a valid object.\nThere are design patters on large projects are build that rely on the constructor feature provided by python. Without this they will not function, \nfor e.g.\n\nYou want to keep track of every object that is created for a class, now you need a method which is executed every time a object is created, hence the constructor. \nOther useful example for a constructor is lets say you want to create a customer object for a Bank. Now a customer for a bank will must have an account number, so basically you have to set a rule for a valid customer object for a Bank hence the constructor.","Q_Score":2,"Tags":"python,class","A_Id":48279639,"CreationDate":"2018-01-16T10:46:00.000","Title":"What happens when your class does not explicitly define an __init__ method?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Edited Question:\nI guess I worded my previous question improperly, I actually want to get away from \"unit tests\" and create automated, modular system tests that build off of each other to test the application as whole. Many parts are dependent upon the previous pages and subsequent pages cannot be reached without first performing the necessary steps on the previous pages. \nFor example (and I am sorry I cannot give the actual code), I want to sign into an app, then insert some data, then show that the data was sent successfully. It is more involved than that, however, I would like to make the web driver portion, 'Module 1.x'. Then the sign in portion, 'Module 2.x'. The data portion, 'Module 3.x'. Finally, success portion, 'Module 4.x'. I was hoping to achieve this so that I could eventually say, \"ok, for this test, I need it to be a bit more complicated so let's do, IE (ie. Module 1.4), sign in (ie. Module 2.1), add a name (ie Module 3.1), add an address (ie. Module 3.2), add a phone number (ie Module 3.3), then check for success (ie Module 4.1). So, I need all of these strung together. (This is extremely simplified and just an example of what I need to occur. Even in the case of the unit tests, I am unable to simply skip to a page to check that the elements are present without completing the required prerequisite information.) The issue that I am running into with the lengthy tests that I have created is that each one requires multiple edits when something is changed and then multiplied by the number of drivers, in this case Chrome, IE, Edge and Firefox (a factor of 4). Maybe my approach is totally wrong but this is new ground for me, so any advice is much appreciated. Thank you again for your help!\nPrevious Question:\nI have found many answers for creating unit tests, however, I am unable to find any advice on how to make said tests sequential. \nI really want to make modular tests that can be reused when the same action is being performed repeatedly. I have tried various ways to achieve this but I have been unsuccessful. Currently I have several lengthy tests that reuse much of the same code in each test, but I have to adjust each one individually with any new changes. \nSo, I really would like to have .py files that only contain a few lines of code for the specific task that I am trying to complete, while re-using the same browser instance that is already open and on the page where the previous portion of the test left off. Hoping to achieve this by 'calling' the smaller\/modular test files. \nAny help and\/or examples are greatly appreciated. Thank you for your time and assistance with this issue.\nRespectfully, \nBilliamaire","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":150,"Q_Id":48309776,"Users Score":0,"Answer":"You don't really want your tests to be sequential. That breaks one of the core rules of unit tests where they should be able to be run in any order.\nYou haven't posted any code so it's hard to know what to suggest but if you aren't using the page object model, I would suggest that you start. There are a lot of resources on the web for this but the basics are that you create a single class per page or widget. That class would hold all the code and locators that pertains to that page. This will help with the modular aspect of what you are seeking because in your script you just instantiate the page object and then consume the API. The details of interacting with the page, the logic, etc. all lives in the page object is exposed via the API it provides.\nChanges\/updates are easy. If the login page changes, you edit the page object for the login page and you're done. If the page objects are properly implemented and the changes to the page aren't severe, many times you won't need to change the scripts at all.\nA simple example would be the login page. In the login class for that page, you would have a login() method that takes username and password. The login() method would handle entering the username and password into the appropriate fields and clicking the sign in button, etc.","Q_Score":0,"Tags":"python,selenium,automated-tests,modular","A_Id":48311473,"CreationDate":"2018-01-17T20:50:00.000","Title":"Is it possible to make sequential tests in Python-Selenium tests?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have made a web form which, upon submit, starts a large process of operations that could result in a large batch of notifications being sent to a number of other users.\nIn order to avoid an end-user mass-submitting many times during a short time span, I would like to queue up these operations in a queue (or what?) and after a certain delay, only actually submit the latest entry.\nI am currently working on AWS and experimenting with various solutions using SQS. Unfortunately I have not been able to find a good solution.\nCurrent solution\nRight now, I am doing the following, but I am assuming I am using the wrong tool for the job:\nFirst time the user submits:\n\nBackend receives request, looks if a temporary queue exists in amazon\ncalled something like temp_queue_[user's id] \nIf true, delete this queue, then create a new queue, with a\ndelivery delay of 10 minutes, enqueue the message in this one \nIf false, the same as above, just without deleting a queue first\n\nI then have a separate process which reloads a list of queues every 10-some minutes and actually commits any message they find.\n\nI have played around with other approaches such as trying different delivery delays, various MessageGroupIds and so forth, but I end up with the same problem which is, that one consumer will not be guaranteed to get all messages, and in flight, delayed and invisible messages are not able to be dequeued. \nFurthermore, I cannot \"filter\" messages from a queue, such as to only receive messages related to only a specific user. So I am definitely starting to think that a queue is the wrong tool. Problem is, I don't know what is.\nBest regards,","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":35,"Q_Id":48310756,"Users Score":0,"Answer":"Hard to understand what exactly you're trying to accomplish, but I think you should let the user submit through the web server to a database, and then have your timed process query that database for 'valid' submissions to process every so many minutes. Timestamp, max() and a user\/sessionId within SQL should be the only necessary elements.\nMight give one of the managed database offerings on AWS, IBM Cloud, etc. a go if you don't want to sink in the time to running your own database server.\nBest of luck.","Q_Score":0,"Tags":"python,amazon-web-services,concurrency,queue,amazon-sqs","A_Id":48311147,"CreationDate":"2018-01-17T22:03:00.000","Title":"Delay form submission and commit only the latest","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Situation: I need to find the top level [root] directory of any operating system using the most Pythonic way possible, without system calls.\nProblem: While I can check for the operating system using things like if \"Windows\" in platform.system(), I cannot be too sure if the drive letter is always C:\\ or \/ (the latter being unlikely). I also cannot possibly be sure that there are only Windows and *NIXes that needs to be catalog.\nQuestion: Is there a way to get the top level directory of any operating system? Preferably using the os module since I am already using it.","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":5801,"Q_Id":48333999,"Users Score":6,"Answer":"I believe os.path.abspath(os.sep) is close to what you are asking for.","Q_Score":5,"Tags":"python,python-2.7,python-os","A_Id":48334082,"CreationDate":"2018-01-19T04:10:00.000","Title":"How to get the filesystem's root directory in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have been using Django Postman for a few weeks now, and in order to limit the number of messages sent by each user, I have been wondering what would be the best way to limit the number of messages a user can send a day, a week... using Django-postman? \nI have been browsing dedicated documentation for weeks too in order to find an answer for the how, but I think this is not a usecase for now, and I do not really know how to manage that. \nOf course I am not looking for a well cooked answer, but I would like to avoid writing labyrinthine code, so maybe just a few ideas about it could help me to see clear through that problematic.\nMany thanks for your help on that topic!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":427,"Q_Id":48370499,"Users Score":0,"Answer":"as a simple idea the inserting of new msg in database should be with a condition to limit their numbers (the count of the previous msg isn't > max )\n another method : you will show the input of the msg jsut when (selet * form table where userid=sesion and count(usermsg)< max )","Q_Score":3,"Tags":"python,django,django-apps","A_Id":48372180,"CreationDate":"2018-01-21T18:54:00.000","Title":"Is it possible to limit the number of messages a user can send a day with Django postman?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have added my bot to a group chat, now for few commands I need to give access only to the group admin, so is it possible to identify if the message sender is admin of the group?\nI am using python-telegram-bot library","AnswerCount":3,"Available Count":1,"Score":-0.0665680765,"is_accepted":false,"ViewCount":6220,"Q_Id":48387330,"Users Score":-1,"Answer":"No. You need to hardcode user id in your source and compare if user id in admin-ids array.","Q_Score":3,"Tags":"telegram-bot,python-telegram-bot","A_Id":48407514,"CreationDate":"2018-01-22T17:41:00.000","Title":"Telegram Bot: Can we identify if message is from group admin?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My telegram bot needs to send a message to all the users at the same time. However, Telegram claims a max of 30 calls\/sec so it gets really slow. I am sure that there is a telegram bot which sends over 30 calls\/sec. Is there a paid plan for this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1442,"Q_Id":48397015,"Users Score":2,"Answer":"Telegram don't provide paid plan at this time.\nFor sending massive amount of message, it is better to use channel, and ask users to join.\nIf you really want to send via PM, you can send 1,800 messages per minute, I think this limit is enough for most use case.","Q_Score":1,"Tags":"telegram,telegram-bot,python-telegram-bot,php-telegram-bot,telegram-webhook","A_Id":48397565,"CreationDate":"2018-01-23T08:18:00.000","Title":"API call limitation on my telegram bot","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been using atom code editor to write C code and run it using a gcc compiler, recently I started out on python code and have been trying to run python script using atom code editor but i keep on getting errors, is there a way to fix this?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1966,"Q_Id":48429246,"Users Score":1,"Answer":"Having run C on atom should not interfere with you running python. Make sure you've installed the python extension and you name your file with the py extension. Also, install the 'script' extension. Enter your script and hit command-I. The script extension should then run your script. Command-I is just a shortcut to run script. You can install these extensions (add-ons) by going to Preferences under the Atom menu item. This opens a window in Atom and you can install from a list of available extensions.","Q_Score":0,"Tags":"python,atom-editor","A_Id":48435723,"CreationDate":"2018-01-24T18:25:00.000","Title":"How to run python script using atom?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm using a cron task to schedule many jobs every 2 min.\nSince there are no higher resolution for less than a minute in cron, I make the python code call a randomised sleep command (between 0-60) so it will spread the execution time across a minute.\nThis works out fine for me.\nI'm just wondering that if I have a process which sleep for 50 seconds, does it keep hold of the memory during these 50 seconds? Can it cause performance problems?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":664,"Q_Id":48441559,"Users Score":2,"Answer":"Undoubtedly, whatever memory is consumed by Python and the startup of your script will stay in memory for the duration of the sleep, but since you have written the code you can organise things to minimise the memory usage until the sleep is over.\nAs to cpu performance, I'm sure that you will incur no overhead for the duration of the sleep.","Q_Score":2,"Tags":"python,linux,cron,sleep","A_Id":48441730,"CreationDate":"2018-01-25T11:14:00.000","Title":"Does sleep command slow the performance?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a web application that I developed for use on a Raspberry Pi written in Python and hosted on nginx. It's a bit slow to serve new pages, even when there is very little to no logic being processed for the page that's loading (4-5 seconds+). \nI know that's a common problem as Pi's aren't exactly equipped to handle the load required to deliver web pages super quickly, but I was wondering if anyone had any experience with this and if it would be worthwhile to recreate the app in some other environment? I was wondering if perhaps a nodejs server would be significantly (a few seconds) quicker in general, or building a single page application using react would be worthwhile? Or if there is some other solution that would be even faster?\nEDIT:\nmore info: raspberry pi 3, json for storing\/reading data (very small amounts of data), running chrome, only one user interacting directly with the app, and on the device itself (not from the internet or another network)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":99,"Q_Id":48446691,"Users Score":3,"Answer":"If the frontend will run on a browser executed on a laptop o desktop it will run fine, but if the interface will run on a browser executed on the Pi maybe it will be too expensive in terms of GPU\/CPU usage and it will require fine tuning in order to avoid unnecessary re-renders.\nSo if the browser is on a remote machine ok, if not think about a something like TkInter for UI.","Q_Score":0,"Tags":"javascript,python,nginx,web,raspberry-pi","A_Id":48447114,"CreationDate":"2018-01-25T15:41:00.000","Title":"Web Interface on the Raspberry Pi","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is there a way to easily run a currently active python file in Visual Studio? I'm used to Notepad++ in which I had customized it to run an active python file in cmd on ctrl+r which made testing code very easy and fast. If there was something similar I could do for Visual Studio, that would be wonderful. \nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1054,"Q_Id":48455275,"Users Score":1,"Answer":"Download the extension 'Code Runner'. You may need to restart visual studio code after loading. Open your script in an editor window. Hit the keys 'control-alt-n' and your script should run. I just checked it on my mac and it ran fine.","Q_Score":0,"Tags":"python,visual-studio,keyboard-shortcuts","A_Id":48455444,"CreationDate":"2018-01-26T03:11:00.000","Title":"How to easily run a python script from Visual Studio","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Aws Lex for constructing chatbots. I had a scenario where I need to have welcome message initially without user input so that I can give a direction to the user in my chatbot.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4953,"Q_Id":48476742,"Users Score":0,"Answer":"If you are using your own website or an app for integrating the chatbot, then you can send some unique welcome text from that website\/app when it loads for the first time i.e on load method to the amazon lex. And in amazon lex you can create a welcome intent and put exact same text as utterance.\nThis way, when the website\/app loads, it will send text to amazon lex and lex can fire the welcome intent and reply to it.","Q_Score":2,"Tags":"python,amazon-web-services,amazon-lex","A_Id":48495195,"CreationDate":"2018-01-27T14:24:00.000","Title":"How to get welcome messages in AWS Lex (lambda in Python)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Aws Lex for constructing chatbots. I had a scenario where I need to have welcome message initially without user input so that I can give a direction to the user in my chatbot.","AnswerCount":2,"Available Count":2,"Score":0.4621171573,"is_accepted":false,"ViewCount":4953,"Q_Id":48476742,"Users Score":5,"Answer":"You need to work that scenario using API call to start a context with your user.\nYou can follow these steps:\n\nYou need to create an Intent called AutoWelcomeMessage.\nCreate a Slot type with only one value i.e: HelloMe.\nCreate an Utterances HelloMessage.\nCreate a Slot as follow: Required, name: answer, Slot Type: HelloMe, Prompt: 'AutoWelcomePrompt'.\nPick Amazon Lambda for your Fulfillment that will send a response to your user. I.e:\n\nHello user, may I help? (Here the user will enter another Intent and your Bot will respond).\nNow, start a conversation with your User, just call via API your Lex Bot and send an intention with Intent AutoWelcomeMessage, that call starts a context with your Lex Bot and the fulfillment will execute your Lambda.","Q_Score":2,"Tags":"python,amazon-web-services,amazon-lex","A_Id":48477745,"CreationDate":"2018-01-27T14:24:00.000","Title":"How to get welcome messages in AWS Lex (lambda in Python)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"TL;DR : Is passing auth data to a boto3 script in a csv file named as an argument (and not checked in) less secure than a plaintext shared credentials file (the default answer in docs) for any reason? \nI want to write a boto3 script intended to run from my laptop that uses an IAM key. The main accepted way to initialize your session is to include the API key, the secret, the region, and (if applicable) your session key in a shared credentials file identified by AWS_SHARED_CREDENTIALS_FILE, or to have the key and secret be environment variables themselves (AWS_ACCESS_KEY_ID, etc.) What I would like to do is load these values in a dictionary auth from a csv or similar file, and then use the keys and values of this dictionary to initialize my boto3.Session. This is easy to do; but, because a utility to load auth data from csv is so obvious and because so few modules provide this utility, I assume there is some security problem with it that I don't know. \nIs there a reason the shared credentials file is safer than a csv file with the auth data passed as an argument to the boto3 script? I understand that running this from an EC2 instance with a role assignment is best, but I'm looking for a way to test libraries locally before adding them to one run through role security.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":931,"Q_Id":48477832,"Users Score":2,"Answer":"There is nothing special or secure with a csv file. Its security risks are same as credentials file since both are text files. If you are worried about security and prefer a file option, one alternative I can think of:\n\nEncrypt the credentials and store them as binary data in a file\nIn your Boto3 script, read the file, decrypt the data and supply the credentials to Boto3\nYou can use simple symmetric keys to encrypt the creds","Q_Score":1,"Tags":"python,amazon-web-services,security,boto3","A_Id":48478740,"CreationDate":"2018-01-27T16:23:00.000","Title":"AWS BOTO3 : Handling API keys","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have downloaded Anaconda on my computer however Anaconda is installed for all users on my mac therefore when I try and access python2.7 by typing in the path: \/anaconda3\/envs\/py27\/bin:\/anaconda3\/bin:\/usr\/local\/bin:\/usr\/bin:\/bin:\/usr\/sbin:\/sbin\nEven if I open from terminal the path above is not in the current directory since:\nmachintoshHD\/anaconda3\/....\nmachintoshHD\/Users\/adam\/desktop....\nhow can i redirect the configure script feature in the atom package script so that i can run python 2?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":423,"Q_Id":48481203,"Users Score":0,"Answer":"Only way I can change Atom python is to run it from a directory that has a different default python version. if I type python from a terminal window, whichever version of python that opens is the version Atom uses. I use virtual environments so I can run python 2.7.13 or python 3.6. If I want Atom to run python 3, I activate my python 3 environment and then run atom.\nThere may be a way to do this from within Atom but I haven't found it yet.","Q_Score":0,"Tags":"python,atom-editor","A_Id":48512683,"CreationDate":"2018-01-27T22:28:00.000","Title":"Atom script configure script run python 2.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Is there any way that can handle deleted message by user in one-to-one chat or groups that bot is member of it ?\nthere is method for edited message update but not for deleted message .","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1993,"Q_Id":48484272,"Users Score":0,"Answer":"The pyrogram have DeletedMessagesHandler \/ @Client.on_deleted_messages(). If used as Userbot, It handles in all chat groups channels. I failed to filter. Maybe it will work in a bot","Q_Score":8,"Tags":"telegram-bot,python-telegram-bot","A_Id":72498718,"CreationDate":"2018-01-28T07:49:00.000","Title":"handle deleted message by user in telegram bot","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any way that can handle deleted message by user in one-to-one chat or groups that bot is member of it ?\nthere is method for edited message update but not for deleted message .","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1993,"Q_Id":48484272,"Users Score":9,"Answer":"No. There is no way to track whether messages have been deleted or not.","Q_Score":8,"Tags":"telegram-bot,python-telegram-bot","A_Id":48485447,"CreationDate":"2018-01-28T07:49:00.000","Title":"handle deleted message by user in telegram bot","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to keep files in my git master, which should not be downloaded when the git is cloned. Only running an additional script should download these optional files (some trained models).\nIs there any git way (e.g. a special command)\/pythonic way to do this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":17,"Q_Id":48503493,"Users Score":1,"Answer":"I want to keep files in my git master, which should not be downloaded when the git is cloned.\n\nImpossible. Either store the files in a different branch or in an entirely different repository from where a script will clone them.","Q_Score":0,"Tags":"python,git,gitignore","A_Id":48503972,"CreationDate":"2018-01-29T14:25:00.000","Title":"How to clone\/load special data mentioned in gitignore from master","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have searched StackOverflow and haven't found an answer to my problem.\nI run a Python script on Task Scheduler that runs a few times per day and it sends out an email to various people. It ran well for the past year but over the past week it sometimes started getting stuck half way through and so it did send out the email to everyone. I'm trying to figure out what is causing the error and what it is getting stuck on, but I can't find any way to save or output the Python console log with error messages while running in Task Scheduler. How do I see what is causing the error? \nThanks for your help.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":998,"Q_Id":48508135,"Users Score":0,"Answer":"please select the task from the task scheduler library and click history. from there select \"Action completed\" task category and right click.. then select event properties.. you will find the resulting code.. if this shows 0 that is okay if there is something else you need to look for that code!\nthis applies for Windows 2012 R2 servers","Q_Score":1,"Tags":"python,scheduled-tasks","A_Id":62406225,"CreationDate":"2018-01-29T18:56:00.000","Title":"Logging Python console errors in Task Scheduler","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to deploy a simple python bot on Heroku but I get the error\ncouldn't find that process type \nWhen I try to scale the dynos. I already made a procfile and it looks like this:\nweb: gunicorn dep:app, where \"dep\" is the name of my python code \nWhat could be the reason?","AnswerCount":6,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":49734,"Q_Id":48512013,"Users Score":7,"Answer":"Make Sure Procfile should not have any extension like .txt\notherwise this will be the error\nremote: -----> Discovering process types\n remote: Procfile declares types -> (none)\nTo create file without extension type following in cmd \n notepad Procfile.\n\nNow add web: gunicorn dep:app and save\nNow when you will git push heroku master the above lines will be like\nremote: -----> Discovering process types\n remote: Procfile declares types -> web\nAnd the error is gone when you will run\nC:\\Users\\Super-Singh\\PycharmProjects\\URLShortener>heroku ps:scale web=1\nScaling dynos... done, now running web at 1:Free","Q_Score":22,"Tags":"python,heroku","A_Id":50388192,"CreationDate":"2018-01-30T00:10:00.000","Title":"Couldn't find that process type, Heroku","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I'm trying to deploy a simple python bot on Heroku but I get the error\ncouldn't find that process type \nWhen I try to scale the dynos. I already made a procfile and it looks like this:\nweb: gunicorn dep:app, where \"dep\" is the name of my python code \nWhat could be the reason?","AnswerCount":6,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":49734,"Q_Id":48512013,"Users Score":0,"Answer":"While it's not Python, in my case, I had heroku\/java followed by heroku\/pgbouncer. In Heroku's Settings, I switched them so heroku\/pgbouncer was on top. This fixed the issue. Perhaps your buildpacks need to be ordered differently if you are using multiple.","Q_Score":22,"Tags":"python,heroku","A_Id":71761780,"CreationDate":"2018-01-30T00:10:00.000","Title":"Couldn't find that process type, Heroku","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I'm trying to deploy a simple python bot on Heroku but I get the error\ncouldn't find that process type \nWhen I try to scale the dynos. I already made a procfile and it looks like this:\nweb: gunicorn dep:app, where \"dep\" is the name of my python code \nWhat could be the reason?","AnswerCount":6,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":49734,"Q_Id":48512013,"Users Score":56,"Answer":"This may happen if your procfile is misspelt, such as \"procfile\" or \"ProcFile\" etc. The file name should be \"Procfile\" (with a capital P).\nsometimes changing the file name is not anough, because git wouldn't spot the change. I had to delete the Procfile completely, then commit the change, than add it again with the right name, and then commit that again:\n\nremove your procfile\ngit commit\nadd a new procfile with the exact name \"Procfile\"\ncommit again\ngit push heroku master (or main - new heroku projects now uses main)\n\nshould work!","Q_Score":22,"Tags":"python,heroku","A_Id":53184918,"CreationDate":"2018-01-30T00:10:00.000","Title":"Couldn't find that process type, Heroku","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I have automation scripts where the implicitly_wait is parametrized so that the user will be able to set it. I have a default value of 20 seconds which I am aware of but there is a chance that the user has set it with a different value.\nIn one of my methods I would like to change the implicitly_wait (to lower it as much as possible) and return it to the value before the method was called. In order to do so I would like to save the implicitly_wait value before I change it. This is why I am looking for a way to reach to it.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":31,"Q_Id":48542904,"Users Score":0,"Answer":"After reading through the Selenium code and playing in the interpreter, it appears there is no way to retrieve the current implicit_wait value. This is a great opportunity to add a wrapper to your framework. The wrapper should be used any time a user wants to change the implicit wait value. The wrapper would store the current value and provide a 'getter' to retrieve the current value. Otherwise, you can submit a request to the Selenium development team...","Q_Score":0,"Tags":"python,python-3.x,selenium","A_Id":48543491,"CreationDate":"2018-01-31T13:04:00.000","Title":"How can I view the implicitly_wait that the webdriver was set with?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to model the spread of information on Twitter, so I need the number of tweets with specific hashtags and the time each tweet was posted. If possible I would also like to restrict the time period for which I am searching. So if I were examining tweets with the hashtag #ABC, I would like to know that there were 1,400 tweets from 01\/01\/2015 - 01\/08\/2015, and then the specific time for each tweet. I don't the actual tweet itself though. From what I've read so far, it looks like the Twitter API restricts the total number of tweets you can pull and limits how far back I can search. Anyone know if there's a way for me to get this data?","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":1686,"Q_Id":48549453,"Users Score":-1,"Answer":"Twitter api provides historical data for a hashtag only up to past 10 days. There is no limit on number of tweets but they have put limitation on time.\nThere is no way to get historical data related to a hashtag past 10 days except:\n\nYou have access to their premium api (Twitter has recently launched its premium api where you get access only if you qualify their criteria. Till date they have provided access to very limited users)\nYou can purchase the data from data providers like Gnip\nYou have internal contacts in Twitter ;)","Q_Score":1,"Tags":"python,r,twitter,tweepy,twython","A_Id":48580106,"CreationDate":"2018-01-31T18:51:00.000","Title":"How can I get the number of tweets associated with a certain hashtag, and the timestamp of those tweets?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to write a Python-script for parsing .pst-files from Outlook using pypff. I've successfully extracted all the information I need, except from the message type. This is important, as I want to be able to distinguish between ordinary e-mails, meeting invitations and other items in the file. \nDistinguishing between object types seems to be possible in the libpff (ITEM_TYPE), but this functionality does not seem to be implemented in pypff. \nDoes anybody have an idea how to extract this information from a .pst-file, either using pypff or some other handy Python package?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":792,"Q_Id":48583906,"Users Score":1,"Answer":"All messages are grouped into folders (default and user-defined) in the pst file. Default folders like Inbox, Outbox, Sent Items, Deleted Items, Drafts, Tasks, Contacts can be used to differentiate pypff message objects.","Q_Score":0,"Tags":"python,parsing,outlook,pst","A_Id":52829980,"CreationDate":"2018-02-02T13:38:00.000","Title":"Identifying message type when parsing Outlook .pst file using pypff","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm coming from NetBeans and evaluating others and more flexible IDEs supporting more languages (i.e. Python) than just php and related.\nI kept an eye on Eclipse that seems to be the best choice; at the time I was not able to find an easy solution to keep the original project on my machine and automatically send \/ syncronize the files on the remove server via sftp.\nAll solutions seems to be outdated or stupid (like mounting a smb partition or manually send the file via an ftp client!\nI'm not going to believe that an IDE like Eclipse doesn't have a smart solution of what I consider a basic feature of an IDE, so I think I missed something... On Eclipse forums I've seen the same question asked lots of time but without any answer!\nSome suggestions about is strongly apreciated otherwise I think the only solution is stick on one IDE each language I use that seem to be incredible on 2018.\nI'm developing on MacOS and the most interesting solution (kDevelop) fails on building with MacPorts.\nThank you very much.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1140,"Q_Id":48599891,"Users Score":2,"Answer":"RSE is a very poor solution, as you noted it's a one-shot sync and is useless if you want to develop locally and only deploy occasionally. For many years I used the Aptana Studio suite of plugins which included excellent upload\/sync tools for individual files or whole projects, let you diff everything against a remote file structure over SFTP when you wanted and exclude whatever you wanted.\nUnfortunately, Aptana is no longer supported and causes some major problems in Eclipse Neon and later. Specifically, its editors are completely broken, and they override the native Eclipse editors, opening new windows that are blank with no title. However, it is still by far the best solution for casual SFTP deployment...there is literally nothing else even close. With some work it is possible to install Aptana and get use of its publishing tools while preventing it from destroying the rest of your workspace.\n\nInstall Aptana from the marketplace.\nGo to Window > Preferences > Install\/Update, then click \"Uninstall or update\".\nUninstall everything to do with Aptana except for Aptana Studio 3 Core and the Aptana SecureFTP Library inside that.\n\nThis gets rid of most, but not all of Aptana's editors, and the worst one is the HTML editor which creates a second HTML content type in Eclipse that cannot be removed and causes all kinds of chaos. But there is a workaround. \n\nExit Eclipse. Go into the eclipse\/plugins\/ directory and remove all plugins beginning with com.aptana.editor.* EXCEPT FOR THE FOLLOWING which seem to be required:\ncom.aptana.editor.common.override_1.0.0.1351531287.jar\ncom.aptana.editor.common_3.0.3.1400201987.jar\ncom.aptana.editor.diff_3.0.0.1365788962.jar\ncom.aptana.editor.dtd_3.0.0.1354746625.jar\ncom.aptana.editor.epl_3.0.0.1398883419.jar\ncom.aptana.editor.erb_3.0.3.1380237252.jar\ncom.aptana.editor.findbar_3.0.0.jar\ncom.aptana.editor.idl_3.0.0.1365788962.jar\ncom.aptana.editor.text_3.0.0.1339173764.jar\nGo back into Eclipse. Right-clicking a project folder should now expose a 'Publish' option that lets you run Aptana's deployment wizard and sync to a remote filesystem over SFTP.\n\nHope this helps...took me hours of trial and error, but finally everything works. For the record I am using Neon, not Oxygen, so I can't say definitively whether it will work in later versions.","Q_Score":1,"Tags":"java,php,python,eclipse","A_Id":48876177,"CreationDate":"2018-02-03T17:13:00.000","Title":"Eclipse Oxygen: How to automatically upload php files on remote server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created simple test cases using selenium web driver in python. I want to log the execution of the test cases at different levels. How do I do it? Thanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1240,"Q_Id":48617220,"Users Score":0,"Answer":"I created library in python for logging info messages and screenshots in HTML file called selenium-logging\nThere is also video explanation of package on youtube (25s) called \"Python HTML logging\"","Q_Score":1,"Tags":"python,selenium-webdriver","A_Id":69818465,"CreationDate":"2018-02-05T06:53:00.000","Title":"Logging in selenium python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have numerous audio wav files.\nEvery audio files have 2 channels and each channel contains voices of 2 different persons so I want to get the channel where the activity is more or we can say the channel where the speaker is saying more and I have to delete the other channel.\nAs of now I am doing this with audacity but can i do it via python or any terminal command in ubuntu?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":825,"Q_Id":48637985,"Users Score":1,"Answer":"Best Idea is to separate both the channels and then get the size of both, cause in wav files size is directly proportional to activity in that channel.","Q_Score":2,"Tags":"python,audio,wav","A_Id":51028661,"CreationDate":"2018-02-06T07:52:00.000","Title":"Identify channels in a wav file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way in python to get the path to the in-memory file, so it'll behave as a normal file for methods which needs file path?\nMy objective is to protect the file, so avoiding dumping into \/tmp.\nTrying to read an encrypted file -> decrypt a file into memory -> use its path for other interfaces. \nmmap does not provide path or filename. \nOr any alternative solution for this problem ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3170,"Q_Id":48641625,"Users Score":0,"Answer":"Can you elaborate a bit more what the \"other interfaces\" require? If the other interfaces just need a file-like object (read, write, etc), then you can use io.StringIO or io.BytesIO from the standard library.","Q_Score":11,"Tags":"python,encryption,mmap,in-memory,data-protection","A_Id":72453786,"CreationDate":"2018-02-06T11:09:00.000","Title":"Path to in-memory-file without dumping in tmp","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am solving a minimization linear program using COIN-OR's CLP solver with PULP in Python.\nThe variables that are included in the problem are a subset of the total number of possible variables and sometimes my pricing heuristic will pick a subset of variables that result in an infeasible solution. After which I use shadow prices to price new variables in.\nMy question is, if the problem is infeasible, I still get values from calling prob.constraints[c].pi, but those values don't always seem to be \"valid\" or \"good\" per se.\nNow, a solver like Gurobi won't even let me call the shadow prices after an infeasible solve.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":214,"Q_Id":48648927,"Users Score":0,"Answer":"Actually Stu, this might work! - the \"dummy var\" in my case could be the source\/sink node, which I can loosen the flow constraints on, allowing infinite flow in\/out but with a large cost. This makes the solution feasible with a very bad high optimal cost; then the pricing of the new variables should work and show me which variables to add to the problem on the next iteration. I'll give it a try and report back. My only concern is that the bigM cost coefficient on the source\/sink node may skew the pricing of the variables making all of them look relatively attractive. This would be counter productive bc adding most of the variables back into the problem will defeat the purpose of my column generation in the first place. I'll test it...","Q_Score":0,"Tags":"python,pulp,coin-or-cbc","A_Id":48711131,"CreationDate":"2018-02-06T17:42:00.000","Title":"Are shadow prices valid after an infeasible solve from COIN using PULP","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to run my program if I type a specific command.\nMy Python program should take the test file as a command line argument. For example in the command prompt or the terminal, my program should run if you type \u201cpython my_program.py test.txt\u201d.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":69,"Q_Id":48654048,"Users Score":1,"Answer":"Open command prompt, make sure you are in the right directory. If you are on windows you can simply hold shift and right click the folder and open command line here. If not you can just manually navigate to the directory by using the cd (change directory) command.\nType python my_program.py test.txt and it will work.","Q_Score":0,"Tags":"python,terminal","A_Id":48654132,"CreationDate":"2018-02-07T00:17:00.000","Title":"How to run a program by typing a specific command","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to run my program if I type a specific command.\nMy Python program should take the test file as a command line argument. For example in the command prompt or the terminal, my program should run if you type \u201cpython my_program.py test.txt\u201d.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":69,"Q_Id":48654048,"Users Score":1,"Answer":"use the execfile built-in function from python, you can google it, there are many answers as well on this site with this info. Make research before asking.","Q_Score":0,"Tags":"python,terminal","A_Id":48654102,"CreationDate":"2018-02-07T00:17:00.000","Title":"How to run a program by typing a specific command","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm building a project that does a giveaway every Monday. There are three prizes, the basic prize, the \"lucky\" prize, and the jackpot prize. The basic prize is given out 70% of the time, the lucky prize gets given out 25% of the time and the jackpot prize gets rewarded the final 5% of the time.\nThere are multiple people that get prizes each Monday. Each person in the giveaway gets at least the basic prize.\nRight now I'm just generating a random number and then assigning the prizes to each participant on my local computer. This works, but the participants have to trust that I'm not rigging the giveaway.\nI want to improve this giveaway by using the blockchain to be the random number generator. The problem is that I don't know how to do this technically.\nHere is my start to figuring out how to do it: When the giveaway is created, a block height is defined as being the source of randomness. Each participant has a userID. When the specific block number is found, the block hash is catenated to the userID and then hashed. The resulting hash is then \"ranged\" across the odds defined in the giveaway.\nThe part I can't figure out is how to do the \"ranging\". I think it might involve the modulo operator, but I'm not sure. If the resulting hash falls into the 5% range, then that user gets the jackpot prize. If the hash falls into the 70% range, then he gets the basic prize, etc.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":27,"Q_Id":48656958,"Users Score":0,"Answer":"I figured this out, the solution is below:\nint(hashlib.sha256(block_header + userID).hexdigest(), 16) \/ float(2**256)\nYou conver the hash into an integer, then divide that integer by 2**256. This gives you a decimal from 0 to 1 that can be compared to a random.random() to get the prize.","Q_Score":0,"Tags":"python,probability,blockchain","A_Id":48712283,"CreationDate":"2018-02-07T06:00:00.000","Title":"Assigning giveaways based on cryptocurrency block header","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to find a new method to cluster sequence data. I implemented my method and got an accuracy rate for it. Now I should compare it with available methods to see whether it works as I expected or not. \nIs it possible to tell me what are the most famous methods in bioinformatics domain and what are the packages corresponded to those methods in Python? I am an engineer and have no idea about the most accurate methods in this field that I should compare my method to them.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1216,"Q_Id":48666310,"Users Score":1,"Answer":"It also depends on the question for which tool you need(data reduction, otu clustering, making a tree, etc..). These days you see a shift in cluster tools that uses a more dynamic approach instead of a fixed similarity cutoff.\nExample:\n\nDADA2 \nUNOISE\nSeekdeep\n\nFixed clustering:\n\nCD-HIT \nuclust\nvsearch","Q_Score":1,"Tags":"python,cluster-analysis,sequence,bioinformatics","A_Id":50987919,"CreationDate":"2018-02-07T14:31:00.000","Title":"bioinformatics sequence clustering in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a C# (Mono) app that gets data from a sensor and passes it to a Python script for processing. It runs on a Raspberry Pi\/Raspbian. The script is started at program initialization and is running in background waiting for data to be passed to it.\nThe data consists of 1000 samples, 32 bit double (in total, 32 kbits). Currently I write the data in a file and pass the file path to the script. \nI was thinking of speeding up processing time by passing the data directly to the script, avoiding writing the file. However, I see that the number of characters of command line arguments is a limited.\nIs there a solution to pass the data to the Python script by avoiding file writing\/reading? I've read something about memory mapping, but I do not know if it's a solution.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":309,"Q_Id":48680155,"Users Score":0,"Answer":"Is there a solution to pass the data to the Python script by avoiding\n file writing\/reading?\n\nI can only think of two approaches:\n\nYou could open a socket for communication between both programs through localhost. The C# program would send data to that socket, and the Python program would read it.\nWrite both programs in Python or C#. The single program would capture\ndata and process it.\n\n\nI've read something about memory mapping, but I do not know if it's a\n solution.\n\nMemory mapping is about loading a file in memory, and once the work on it is finished, write it back at once. Since you have two different processes, I don't think it is applyable here.\nHope this helps.","Q_Score":0,"Tags":"c#,python,mono","A_Id":48683700,"CreationDate":"2018-02-08T07:45:00.000","Title":"How to pass large data to Python script?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have packages stored in s3 bucket. I need to read metadata file of each package and pass the metadata to program. I used boto3.resource('s3') to read these files in python. The code took few minutes to run. While if I use aws cli sync, it downloads these metafiles much faster than boto. My guess was that if I do not download and just read the meta files, it should be faster. But it isn't the case. Is it safe to say that aws cli is faster than using boto?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4228,"Q_Id":48692483,"Users Score":0,"Answer":"It's true that the AWS CLI uses boto, but the cli is not a thin wrapper, as you might expect. When it comes to copying a tree of S3 data (which includes the multipart chunks behind a single large file), it is quite a lot of logic to make a wrapper that is as thorough and fast, and that does things like seamlessly pick up where a partial download has left off, or efficiently sync down only the changed data on the server.\nThe implementation in the awscli code is more thorough than anything in the Python or Java SDKs, as far as I have seen. I've seen several developers who were too proud to call the CLI from their code, but zero thus far all such attempts I have seen have failed to measure up. Love to see a counter example, though.","Q_Score":3,"Tags":"python,amazon-s3,boto,boto3","A_Id":63806918,"CreationDate":"2018-02-08T18:32:00.000","Title":"Is aws CLI faster than using boto3?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"tryton V3.8 on MAC. I have a database \"steve\" with trytond running TCP\/IP. When doing database connect in tryton client, I get the following result as the last line in the error window: \"IOError: File not found : \/site-packages\/trytond\/modules\/product\/tryton.cfg\" \nIn ~\/.bash_profile, I have: \n export PYTHONPATH=~\/bryants:$PYTHONPATH \nwhere ~\/bryants has a init.py file, and all modules are beneath it. \nThere is a tryton.cfg file in the ~\/bryants\/product directory. Why isn't it looking in the ~\/bryants directory? Why isn't it being found?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":96,"Q_Id":48696759,"Users Score":1,"Answer":"Tryton search modules only in the subdirectory modules from its installation path or for the entry points trytond.modules But it does not use the PYTHONPATH to detect modules.\nSo you must move the modules under the \"modules\" directory or you must install the modules with python setup.py install (or python setup.py develop).","Q_Score":0,"Tags":"python-2.7,tryton","A_Id":48704012,"CreationDate":"2018-02-09T00:01:00.000","Title":"tryton file not found when opening database - looking in site-packages rather than directory in PYTHONPATH","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Is it possible to trigger a custom device action from another device that is attached to the same account?\ne.g.:\n\nTrigger a custom device action registered to one PI from a second PI that doesn't have any custom device actions.\nTrigger a custom device action registered to one PI from an Android phone attached to the same email address.\n\nBasically I'm trying to figure out if you have to speak directly to the device that has the custom device action.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":95,"Q_Id":48697423,"Users Score":1,"Answer":"Yes, you cannot do remote execution of device actions.","Q_Score":0,"Tags":"python-3.x,raspberry-pi,google-assistant-sdk","A_Id":48698224,"CreationDate":"2018-02-09T01:28:00.000","Title":"Trigger a device action from another device on the same account","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm working with splinter and Python and I'm trying to setup some automation and log into Twitter.com\nHaving trouble though...\nFor example the password field's \"name=session[password]\" on Twitter.com\/login\nand the username is similar. I'm not exactly sure of the syntax or what this means, something with a cookie...\nBut I'm trying to fill in this field with splinters:\nbrowser.fill('exampleName','exampleValue')\nIt isn't working... Just curious if there is a work around, or a way to fill in this form?\nThanks for any help!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":59,"Q_Id":48709350,"Users Score":0,"Answer":"What's the purpose of doing this rather than using the official API?\nScripted logins to Twitter.com are against the Terms of Service, and Twitter employs multiple techniques to detect and disallow them. Accounts showing signs of automated login of this kind are liable to suspension or requests for security re-verification.","Q_Score":0,"Tags":"python,python-3.x,twitter,login,splinter","A_Id":48716354,"CreationDate":"2018-02-09T15:43:00.000","Title":"How to log into Twitter with Splinter Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm seeing a hard to track down error with Google Cloud IoT. I have 2 projects set up with IoT API enabled. I'm using the same \"quickstart\" instructions to test, by setting up \"my-registry\" and \"my-device\". Let's call them projects A and B. I then run both the python and node examples pulled straight from git. The node example runs fine for both projects A and B, validated by pulling using gcloud. However, the python example works for project A, but with project b gets a \"on disconnect. 1. out of memory\" error. There is never a \"connection accepted\" message for B, but yes for A. \"Out of memory\" seems to be a generic error, not really the issue. It could represent a variety of issues in connectivity. Nothing on the server side Anyone encountered this one before? I appreciate any help in resolving or at least trace the eror.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":1506,"Q_Id":48713679,"Users Score":3,"Answer":"Turns out it's the python version. It was just about impossible to debug. I ended trying on many different devices\/os to slowly isolate the issue. Looks like newly created projects rely on newer versions of google cloud sdk and python. Must have python 2.7.14.","Q_Score":3,"Tags":"python,google-cloud-platform,iot,paho","A_Id":48819342,"CreationDate":"2018-02-09T20:33:00.000","Title":"Google Cloud IoT Python MQTT \"out of memory\" error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to develop two packages A and B in parallel, and B depends on A. I need to import something from A when running my unit tests for B.\nSo how can I configure things in setup.py so that when I run the unit tests for B, the local directory (in parallel to the one for B) gets added to the modules path and A can be imported?\nI do not constantly want to install A so that B can depend on it like on an installed package.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":23,"Q_Id":48720266,"Users Score":1,"Answer":"OK, I think this is actually quite easy and I was thinking to complicated: I made it work by just setting PYTHONPATH to the relative path to the directory containing package A.","Q_Score":0,"Tags":"python,python-3.x,unit-testing,dependencies,setuptools","A_Id":48720426,"CreationDate":"2018-02-10T11:29:00.000","Title":"How to depend on local directory for setuptools unit tests?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm going to have to run the same python script multiple of times (>500) at the same time using cron, I'm looking for ways to best handle this to avoid problems in future and if there is any better way that I can use for reporting and logging to alert me if one script is down , please advise me with it. \nPlan so far, is to make a copy of the same scripts (folder) a couple of times while renaming each to unique name to distinguish later, then run it using cron scheduler.\nadvise please.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":101,"Q_Id":48727820,"Users Score":0,"Answer":"Use multiprocessing if you do not want the data between the processes to be shared. You can give a name to your processes.","Q_Score":0,"Tags":"python,multithreading,logging,cron,bots","A_Id":48728192,"CreationDate":"2018-02-11T02:51:00.000","Title":"Running the same script multiple times , easier way to manage and report","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to find a way to execute test-cases with help of Graphical user interface in Pytest. \nI found few plugins like Pytest-sugar which displays failed\/passed status only. But I actually need to select the test-cases that I want to run in GUI display.\nIs there a way to achieve this ?\nThanks in advance !!","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":1806,"Q_Id":48733840,"Users Score":-1,"Answer":"So far I have not found any GUI to see the status of the tests. In fact I am working on developing one with Qt5","Q_Score":0,"Tags":"python,user-interface,pytest","A_Id":70441874,"CreationDate":"2018-02-11T16:42:00.000","Title":"How execute pytest-test cases with GUI","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have accomplished running a js file with the following python script:\nimport subprocess\nsubprocess.check_call('npm run test')\nThe file test.js reads sensor data and is only written in javascript because the only available library for this sensor is a NodeJS library. Now, I want the test.js to return those values everytime it is executed within my python script. How do I do that?\nAnd it is not possible via this method, are there others? I cannot write this js script in python as the library uses NodeJS. \nI want to thank everone that tries to help me in advance and if you need more info, simply contact me!","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":779,"Q_Id":48734600,"Users Score":2,"Answer":"For anyone who might ever find himself in the same situation, I have found a workaround that works for me and might even work for you!\nSo, this is actually quite simple, but only works for a specific application. Here, I have a sensor which is read by a javascript script, but I want a python script to handle the sensor's output value. What I did was:\nimport subprocess\nimport os \ndeadly_string = subprocess.getoutput('npm run test')\nnot_so_deadly_string = deadly_string[-6:]\nprint (\"value: \", not_so_deadly_string)\nI captured the output of the terminal with \"subprocess.getoutput\". The output of the terminal looks something like this:\nnodejs-qmc5883l@....\n.....\nDeclination angle correction: 1\n.\n.\n.\nAzimuth= 300.00\nThe value \"300.00\" is what I want, so I cut the last 5 characters of the string and that's it....","Q_Score":1,"Tags":"javascript,python,node.js","A_Id":48735967,"CreationDate":"2018-02-11T17:56:00.000","Title":"Running a javascript script through python using the subprocess library on a raspberry pi and returning values from it","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to calculate something like this: a^b mod c, where all three numbers are large.\nThings I've tried:\n\nPython's pow() function is taking hours and has yet to produce a result. (if someone could tell me how it's implemented that would be very helpful!)\nA right-to-left binary method that I implemented, with O(log e) time, would take about 30~40 hours (don't wanna wait that long).\nVarious recursion methods are producing segmentation faults (after I changed the recursion limits)\n\nAny optimizations I could make?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1213,"Q_Id":48738650,"Users Score":2,"Answer":"It sounds like you are trying to evaluate pow(a, b) % c. You should be using the 3-argument form, pow(a, b, c), which takes advantage of the fact that a * b mod c == a mod c * b mod c, which means you can reduce subproducts as they are computed while computing a ^ b, rather than having to do all the multiplications first.","Q_Score":1,"Tags":"python,algorithm,pow,modular-arithmetic,cryptanalysis","A_Id":48738710,"CreationDate":"2018-02-12T02:10:00.000","Title":"How to implement modular exponentiation?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python program that imports other files which potentially import other files, as is normal with python development\nThe problem is, when I measure coverage with coverage.py, some files which are imported but not used, get coverage \"hits\" on the def and import statements.\nMy question is: is there are way to avoid those hits? For my particular application these hits are considered noise.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1816,"Q_Id":48776116,"Users Score":0,"Answer":"Since coverage.py does not provide this feature, my solution was to write a small ast based function that calculate ghost hit points and remove them from the the coverage.py results","Q_Score":0,"Tags":"python,coverage.py","A_Id":48830576,"CreationDate":"2018-02-13T21:41:00.000","Title":"With coverage.py, how to skip coverage of import and def statements","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to take input from usb barcode scanner in python (Raspberry pi).\nBarcode scanner works as keyboard so i need to press enter key after scanning .I dont want to press enterkey after scanning the data, the data\n(barcode) should be directly stored in to variable. How to do it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2635,"Q_Id":48784009,"Users Score":0,"Answer":"At last the problem is solved, in barcode scanner there is a mode where automatic enter key pressing is done.Just have to scan the enterkey barcode from the barcoe scanner manual.","Q_Score":0,"Tags":"python-2.7,raspberry-pi,raspberry-pi3,barcode-scanner,raw-input","A_Id":48805544,"CreationDate":"2018-02-14T09:46:00.000","Title":"How to use usb barcode scanner with python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I accidentally removed my Python's site-packages which means I got no any modules. Unfortunately, I noticed too late that the Yum uses a module named yum which is installed in the Python's site-packages where is located in \/usr\/local\/lib\/python2.7\/site-packages.\nI was trying to reinstall yum but no yum module was installed.\nHope to find an answer,\nthanks!","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1086,"Q_Id":48825025,"Users Score":1,"Answer":"I fixed this issue by installing CentOS on a VM and then scp the python2.7 directory to the server.","Q_Score":1,"Tags":"python,centos,centos7,yum","A_Id":48830296,"CreationDate":"2018-02-16T10:43:00.000","Title":"Centos 7 - No module named yum - Accidentally removed Python site-packages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I accidentally removed my Python's site-packages which means I got no any modules. Unfortunately, I noticed too late that the Yum uses a module named yum which is installed in the Python's site-packages where is located in \/usr\/local\/lib\/python2.7\/site-packages.\nI was trying to reinstall yum but no yum module was installed.\nHope to find an answer,\nthanks!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1086,"Q_Id":48825025,"Users Score":0,"Answer":"Try rpm -V yum which checks for issues with yum","Q_Score":1,"Tags":"python,centos,centos7,yum","A_Id":48825047,"CreationDate":"2018-02-16T10:43:00.000","Title":"Centos 7 - No module named yum - Accidentally removed Python site-packages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Raspberry Pi connected to a Seagate Backup Plus 3T external hard drive.\nI've written a Python script to make backup copies of files from my Windows File Server onto the external hard drive.\nEverything SEEMS to be running fine. But when I copy a file from the external hard drive back to the Windows File Server, I have random bit errors... specifically the high order bit of random bytes will be a '1' in the copied file (i.e. 0x31 ==> 0xB1, 0x2B ==> 0xAB, 0x71 ==> 0xF1).\nIn a 9MB .MOV file, I've got 13 of these random bit errors.\nIn the python application, I've used both shutil.copy2 function to copy the files, and I've written a subroutine to open files for binary read\/write and copy 1MB at a time.\nWhen I connected the external hard drive to a Windows 10 machine and tried to copy files from File Server to external hard drive and back, I didn't get any errors.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":74,"Q_Id":48859707,"Users Score":0,"Answer":"Finally got it figured out. After additional trial and error, I figured out that there is something wrong with the wired network port on the Pi. Everything works fine if I swap out my Pi3 with my Pi1, and the Pi3 works if I use the WiFi (been using wired port for speed).","Q_Score":0,"Tags":"python,raspberry-pi,usb-drive","A_Id":48959545,"CreationDate":"2018-02-19T04:53:00.000","Title":"Raspberry Pi: File copy to Seagate Backup Plus Bit Errors","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Say I have a python function called sample(). It takes no arguments. It returns a dictionary in the end though. How can I perform unit testing for such a function ? Can I test it with status code like 200 ? How can i test if the function is written correctly ?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1043,"Q_Id":48861309,"Users Score":0,"Answer":"A plain python function has no status code. Status codes are a part protocols like of HTTP.\nYour test can call the function and check if the result is a dictionary. Without knowing anything more about your function this is the only thing I can suggest.","Q_Score":0,"Tags":"python,python-unittest","A_Id":48861482,"CreationDate":"2018-02-19T07:28:00.000","Title":"How to unittest a python function that takes no arguments?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Below are a list of recurring monthly bills. The first number is the day of the month the bill arrives (first chance to pay it) and the second number is the due day of the month (last chance to pay it).\n\n16, 1\n2, 16\n10, 25\n31, 26\n15, 31\n\nThe difference between the arrival and due date is always less than a month. I'm looking for an algorithm that, for any number of bills with any reception dates and any due dates, will:\n\nproduce a list of fewest possible login dates to the online bank where the bills are paid.\nguarantee that no due dates are missed.\n\nMy idea so far is to look for a single date (or date range) on which as many as possible bills are between arrival and due date, and then repeat this process until the list is empty.\nIs this the best approach? Is there an existing algorithm for this problem? What is it called? Code examples, if any, would be preferred in Python, PHP or just pseudo-code.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":127,"Q_Id":48865959,"Users Score":1,"Answer":"Actually, Your solution is not correct and here is why:\nSuppose you have many days where the same amount of ranges intersect, and this amount is the maximum among all others. For example:\n\n1 -> 3\n3 -> 6\n6 -> 9\n9 -> 10\n\nFrom what I see you you have the following days (3, 6, 9) where all of them have two bills to be paid, and no other day contains more bills to be paid. Now since you can't possibly determine which day to start with, you could for example choose day 6 and pay the bills (2, 3). Next, you have no other option but to choose days 3 and 9 to pay bills 1 and 4 correspondingly. You used 3 days, while the answer is 2 choosing the first day to be 3 paying both bills 1 and 2, then choosing day 9 paying bills 3 and 4.\nAnyways, I'm pretty sure I have an almost linear time solution for you.\nFirst, let's make your input a little bit more clear, and add 30 (or 31 in case of 31 days month) to the second number if it is in fact smaller than the first one. Your example would look like this:\n\n16 -> 31\n2 -> 16\n10 -> 25\n31 -> 56\n15 -> 31\n\nMy idea is based on the following 2 facts: \n\nWhenever a login is made, it is always better to pay all the bills which are available, and haven't been paid yet.\nWhen traversing the time line of the month from the beginning (day 1) to the end (day 60) it is always better to try and delay the logging process if possible; meaning that if the delay won't cause any due date to be missed.\n\nIn order to do so let's first assign a unique ID to each entry:\n\n16 -> 31\n2 -> 16\n10 -> 25\n31 -> 56\n15 -> 31\n\nLet's use sweep line algorithm which generally solves interval related problems. Create a vector called Sweep where each element of this vector contains the following information:\n\nID: The ID of the corresponding entry.\nTimer: Indicating either the first or the last day to pay a bill.\nType: Just a flag. 0 means that Timer contains the first day to pay the bill number ID (first number), whereas 1 means that Timer contains the last day to pay the bill number ID (second number).\n\nFor each entry insert 2 elements to Sweep vector:\n\nID = ID of the entry, Timer = First number, Type = 0.\nID = ID of the entry, Timer = Second number, Type = 1.\n\nAfter inserting all these elements to Sweep vector it will have a size equals to 2 x number of entries. Sort this vector increasingly based on the value of Timer, in case of a tie then increasingly based on the value of Type (In order to first check the start of an entry before its end).\nTraverse Sweep vector while keeping a set containing the IDs of all the unpaid bills so far, let's call this set Ready. In each step you might deal with one the following elements (based on the Type we added):\n\nType = 0. In this case it means that you have reached the day of first being able to pay the bill number ID. Don't pay this bill yet. Instead insert its ID to our Ready set (idea 2).\nType = 1. In this case check to see whether the corresponding ID is inside Ready set. If it is not just continue to the next element. If it is in fact inside Ready set this means that you have reached the last day for paying a previously unpaid bill. You have no other option but to pay this bill, alongside with all the other bills inside Ready set at this day (idea 1). By paying the bill I mean to increase the variable containing your answer by one, and if it's important to you traverse Ready set and store somewhere that all these IDs must be paid at the current day. After doing so you have paid all the ready bills, just clear Ready set (erase all the elements inside it).\n\nEvery entry causes 2 elements to be inserted into the Sweep vector, and every entry will be inserted exactly once into Ready set, and deleted once as well. The cost for checking an ID inside Ready set is O(Log N) and it's done for every entry exactly once. The sorting operation is O(N Log N). Thus, your total complexity would be: O(N Log N) where N is the total number of entries you have.\nPython is not really my strongest programming language, so I will leave the mission of coding the mentioned algorithm up to you (in C++ for example it's not that hard to implement). Hope it helps!\n\nEDIT (thanks to @Jeff's comment)\nYou can make your solution to be even O(N) using the following approach:\nInstead of iterating over the events, you could iterate over the days from 1 to 60, and keep the same handling method as I mentioned. This way we eliminated the sort operation.\nTo remove the O(Log N) factor from the inserting and checking operation we could use a hash table as mentioned by @Jeff's comment, or instead of a hash table you could use a boolean array Visited, with a vector Ready. you will insert Ready bills to the vector. When you need to pay bills you will simply iterate over the Ready vector and mark the bills inside it as visited in their corresponding indexes inside the Visited array. Checking if I bill has been paid can be simply done by accessing the corresponding index inside the Visited array.\nThe funny thing is that after writing my answer I came up with almost the exact same optimization as mentioned by @Jeff's comment. However, seeing that number of days is really small, I decided not to make my answer any more complex, and keep it easier to understand. Now that @Jeff mentioned the optimization I decided to add it to my answer as well. However, please note that with this optimization the overall complexity now equals to O(N + D), where N is the total number of bills, and D is the total number of days. So, if D is quite large you will actually need to stick with the first solution.","Q_Score":1,"Tags":"python,algorithm","A_Id":48868888,"CreationDate":"2018-02-19T12:11:00.000","Title":"Algorithm for fewest logins to online bank","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is the error I get when I try to invoke my lambda function as a ZIP file. \n\n\"The file lambda_function.py could not be found. Make sure your\n handler upholds the format: file-name.method.\"\n\nWhat am I doing wrong?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1338,"Q_Id":48865970,"Users Score":0,"Answer":"Just to clarify: If I want to invoke Keras all I have to do is download the Keras directories and put my lambda code and Keras directories as a zip folder and upload it directly from my desktop right? \nJust wanted to know if this is the right method to invoke Keras.","Q_Score":2,"Tags":"python,amazon-web-services,aws-lambda,alexa,alexa-skills-kit","A_Id":48887689,"CreationDate":"2018-02-19T12:11:00.000","Title":"Error when invoking lambda function as a ZIP file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Right now, I am generating the Allure Report through the terminal by running the command: allure serve {folder that contains the json files}, but with this way the HTML report will only be available to my local because\n\n\nThe json files that generated the report are in my computer\nI ran the command through the terminal (if i kill the terminal, the report is gone) \n\n\nI have tried: Saving the Allure Report as Webpage, Complete, but the results did not reflect to the page, all i was seeing was blank fields. \nSo, what im trying to to do is after I execute the command to generate the report, I want to have an html file of the report that i can store, save to my computer or send through email, so i do not have to execute the command to see the previous reports. (as much as possible into 1 html file)","AnswerCount":6,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":10030,"Q_Id":48914528,"Users Score":5,"Answer":"It's doesn't work because allure report as you seen is not a simple Webpage, you could not save it and send as file to you team. It's a local Jetty server instance, serves generated report and then you can open it in the browser.\nHere for your needs some solutions:\n\nOne server(your local PC, remote or some CI environment), where you can generate report and share this for you team. (server should be running alltime)\nShare allure report folder as files({folder that contains the json files}) to teammates, setup them allure tool, and run command allure server on them local(which one).\n\nHope, it helps.","Q_Score":7,"Tags":"python,automation,frameworks,allure","A_Id":48926889,"CreationDate":"2018-02-21T20:04:00.000","Title":"Is there a way to export Allure Report to a single html file? To share with the team","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Right now, I am generating the Allure Report through the terminal by running the command: allure serve {folder that contains the json files}, but with this way the HTML report will only be available to my local because\n\n\nThe json files that generated the report are in my computer\nI ran the command through the terminal (if i kill the terminal, the report is gone) \n\n\nI have tried: Saving the Allure Report as Webpage, Complete, but the results did not reflect to the page, all i was seeing was blank fields. \nSo, what im trying to to do is after I execute the command to generate the report, I want to have an html file of the report that i can store, save to my computer or send through email, so i do not have to execute the command to see the previous reports. (as much as possible into 1 html file)","AnswerCount":6,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":10030,"Q_Id":48914528,"Users Score":0,"Answer":"Allure report generates html in temp folder after execution and you can upload it to one of the server like netlify and it will generate an url to share.","Q_Score":7,"Tags":"python,automation,frameworks,allure","A_Id":63722118,"CreationDate":"2018-02-21T20:04:00.000","Title":"Is there a way to export Allure Report to a single html file? To share with the team","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a lambda I'm writing that will send SNS based on non-whitelisted accounts doing disallowed functions in IAM. The cloudtrail event contains a JSON policyDocument with ARNs like so:\n \\\"AWS\\\": [\\r\\n \\\"arn:aws:iam::999900000000:root\\\",\\r\\n \\\"arn:aws:iam::777700000000:root\\\"\\r\\n ]\\r\\n },\\r\\n \\\"Action\\\": \\\"sts:AssumeRole\\\",\\r\\n \\\"Condition\\\": {}\\r\\n }\\r\\n ]\\r\\n}\nI will create a whitelist in python with just the account numbers:\naccountWhitelist = [\"999900000000\",\"1234567891011\"]\nWith this event I need to do something like an if str(policyDocAwsAcctArn) contains accountWhitelist account number do nothing else send SNS. Will I need to use something like regex on the arn to remove the arn:aws:iam:: :root after the account number? I need to be sure to have the account numbers parsed out individually as there might be 2+ arns in the AWS json. Thanks for any ideas.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":95,"Q_Id":48950193,"Users Score":0,"Answer":"I used this regex:\nregex = r'arn:(?P[^:\\n]):(?P[^:\\n]):(?P[^:\\n]):(?P[^:\\n]):(?P(?P[^:\/\\n]*)[:\/])?(?P.[^\\s|\\,]+)'\nand pulled the account number \n for item in awsAccountIdList:\n awsRegexAccountIds = re.search(regex, item).group(\"AccountID\")\ncompared the list to the whitelist:\nnonWhitelistedList = [item for item in listOfAccountIds if item not in accountWhitelist]\nThen if the list contained a value sent the SNS with the value:\n if len(nonWhitelistedList) == 0:\n SendSNS(Value)","Q_Score":0,"Tags":"python-3.x,aws-lambda","A_Id":49135142,"CreationDate":"2018-02-23T14:35:00.000","Title":"Python lambda in AWS if str in list contains","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've created a script for my school project that works with data. I'm quite new to working remotely on a server, so this might seem like a dumb question, but how do I execute my script named \n\nstats.py\n\nso that it continues executing even after I log off PuTTy? The script file is located on the server. It has to work with a lot of data, so I don't want to just try something and then few days later find out that it has exited right after I logged off.\nThank you for any help!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1277,"Q_Id":48977688,"Users Score":1,"Answer":"There are many ways you can run a python program after you disconnect from an SSH session.\n1) Tmux or Screen\nTmux is a \"terminal multiplexer\" which enables a number of terminals to be accessed by a single one.\nYou start by sshing as you do, run it by typing tmux and executing it. Once you are done you can disconnect from putty and when you login back you can relog to the tmux session you left\nScreen also does that you just type screen instead of tmux\n2) nohup\n\"nohup is a POSIX command to ignore the HUP signal. The HUP signal is, by convention, the way a terminal warns dependent processes of logout.\"\nYou can run it by typing nohup &","Q_Score":0,"Tags":"python,server,putty","A_Id":48977787,"CreationDate":"2018-02-25T19:43:00.000","Title":"How to run a python script on a remote server that it doesn't quit after I log off?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python script that connects to an IMAP server. The script downloads the mails from the server in a certain format. The second time the script is run, rather than downloading all the mails, it should download new mails (synchronize) to avoid time overhead.\nI have an issue. How to detect if a certain mail has been dragged from one directory to another directory (or mailbox). E.g. if I move a mail from mailbox A to mailbox B, is there any such flag like 'MOVED' to identify such mails.\nSo the next time the script runs I am able to fetch RECENT or UNSEEN mails but not the one whose path on the server has been changed.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":41,"Q_Id":48992383,"Users Score":0,"Answer":"No. There's not. IMAP considers a moved message to be deleted from one folder and created in a new folder. There is no continuity between folders in general.","Q_Score":0,"Tags":"python,email,imaplib","A_Id":49032647,"CreationDate":"2018-02-26T16:01:00.000","Title":"IMAPLIB: Is there any MOVED flag to identify mails moved between mailboxes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Given a string of upper case alphabets and we have to compress the string using Run length Encoding.\nInput = \"AABBBACCDA\"\noutput = 2A3B1A2C1D1A","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":58,"Q_Id":49014634,"Users Score":0,"Answer":"Since it's your homework I'm not going to solve it for you. The pythonic way would be to use some \"magic\" function that will solve your problem.\nHowever you're here to learn programming in general, so implement this:\nCount the characters until the next character is different from the current one.\nAppend to your output string the number the current character showed up and the current character.\nPrint.","Q_Score":0,"Tags":"python-3.x","A_Id":49014837,"CreationDate":"2018-02-27T17:30:00.000","Title":"Run length Encoding for a given String","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm starting using Allure with Python Behave for high-level BDD testing of a medium size C++ ecosystem of services. \nWhat I get is a web page inside Jenkins with pretty and clear reports, thanks to the Allure-Jenkins plugin.\nI have also some unit tests made with TAP, shown in Jenkins with another plugin. \nWhat I would like to get is the integration of the unit test reports inside the same Allure page\nUnfortunately, I was not able to find a C++ Unit Testing Framework directly supporting Allure reports: does any exist?\nOtherwise, I could I get this integration?\nThank you!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":435,"Q_Id":49051248,"Users Score":1,"Answer":"As far as I know there is no Allure integrations for C++ test frameworks exist yet. But Allure supports JUnit-style XML report format that is de facto standard format for reporting test results. So if your framework can generate results in such format you can generate Allure report for it.","Q_Score":1,"Tags":"c++,jenkins,tap,allure,python-behave","A_Id":49302946,"CreationDate":"2018-03-01T13:56:00.000","Title":"C++ Unit Test Framework with Allure Report","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"So I'm a new intern at a company and they gave me practically a blank computer. I needed to install some programs from their Git to run python and the only available python editors are Idle and Atom. I personally prefer atom, so I installed with the package \"script\" that should run python scripts. However I can't run python 3.4 and I get this error \n\" 'python' is not recognized as an internal or external command,\noperable program or batch file.\"\nWhich I get since on cmd typing 'python' does not launch the python only typing 'py'. Since I am an intern I have no control over the Environmental variables so I can't change py command to python. How can I change atom script package to use \"py\" command instead of \"python\".","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":246,"Q_Id":49067976,"Users Score":0,"Answer":"I solved it by going inscript 3.17.3 code:\nscript --> lib --> grammars --> python.coffee\nIn there I changed \"command: 'python'\" to \"command: 'py'\" for lines 3 and 7.\nThis should work for whatever command your windows batch uses to run python.","Q_Score":0,"Tags":"python-3.x,package,atom-editor","A_Id":49252287,"CreationDate":"2018-03-02T11:13:00.000","Title":"running Python commands on Atom","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to install the mod_wsgi module in apache in my Ubuntu server but I need it to be specifically for version 2.7.13 in Python.For whatever reason every time I run sudo apt-get install libapache2-mod-wsgi it installs the mod_wsgi module for Python 2.7.12.I'm doing all of this because I'm running into a weird python version issue.When I run one of my python Scripts in my server terminal it works perfectly with version 2.7.13.In Apache however the script doesn't work.I managed to figure out that my Apache is running version 2.7.12 and I think this is the issue.Still can't figure out how to change that apache python version yet though.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":623,"Q_Id":49074360,"Users Score":1,"Answer":"Eventually Figured it out.The problem was that I had 2 versions of Python 2.7 installed in my server(2.7.12 and 2.7.13) so the definitions of one were conflicting with the other.Solved it when I completely removed Python 2.7.13 from the server.","Q_Score":0,"Tags":"python,ubuntu,server,mod-wsgi","A_Id":49112016,"CreationDate":"2018-03-02T17:30:00.000","Title":"How to install mod_wsgi to specific python version in Ubuntu?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"We are trying to convert a gRPC protobuf message to finally be a json format object for processing in python. \nThe data sent across from server in serialized format is around 35MB and there is around 15K records. But when we convert protobuf message into string (using MessageToString) it is around 135 MB and when we convert protobuf message into a JSON string (using MessageToJson) it is around 140MB. But the time taken for conversion is around 5 minutes for each. It does not add any value wherein we take so much time to convert data on the client side. \nAny thoughts or suggestion or caveats that we are missing would be helpful. Thanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1175,"Q_Id":49091459,"Users Score":0,"Answer":"Fixed the issue by only picking the fields that is needed when deserializing the data, rather than deserialize all the data returned from the server.","Q_Score":0,"Tags":"python,json,protocol-buffers,grpc","A_Id":50177889,"CreationDate":"2018-03-04T02:49:00.000","Title":"Converting gRPC protobuf message to json runs for long","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to set up Whoosh search in a serverless environment (aws lambda hosted api) and having trouble with Whoosh since it hosts the index on the local filesystem. That becomes an issue with containers that aren't able to update and reference a single index. \nDoes anyone know if there is a solution to this problem. I am able to select the location that the directory is hosted but it has to be on the local filesystem. Is there a way to represent an s3 file as a local file? \nI'm currently having to reindex every time the app is initialized and while it works it's clearly an expensive and terrible workaround.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":266,"Q_Id":49101093,"Users Score":0,"Answer":"The answer seems to be no. Serverless environments by default are ephemeral and don't support persistent data storage which is needed for something like storing an index that Whoosh generates.","Q_Score":2,"Tags":"python,api,amazon-web-services,lambda,whoosh","A_Id":53909533,"CreationDate":"2018-03-04T22:17:00.000","Title":"Is it possible to use Whoosh search in a serverless environment?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently reading binary files that are 150,000 kb each. They contain roughly 3,000 structured binary messages and I'm trying to figure out the quickest way to process them. Out of each message, I only need to actually read about 30 lines of data. These messages have headers that allow me to jump to specific portions of the message and find the data I need.\nI'm trying to figure out whether it's more efficient to unpack the entire message (50 kb each) and pull my data from the resulting tuple that includes a lot of data I don't actually need, or would it cost less to use seek to go to each line of data I need for every message and unpack each of those 30 lines? Alternatively, is this something better suited to mmap?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":218,"Q_Id":49118216,"Users Score":1,"Answer":"Seeking, possibly several times, within just 50\u00a0kB is probably not worthwhile: system calls are expensive. Instead, read each message into one bytes and use slicing to \u201cseek\u201d to the offsets you need and get the right amount of data.\nIt may be beneficial to wrap the bytes in a memoryview to avoid copying, but for small individual reads it probably doesn\u2019t matter much. If you can use a memoryview, definitely try using mmap, which exposes a similar interface over the whole file. If you\u2019re using struct, its unpack_from can already seek within a bytes or an mmap without wrapping or copying.","Q_Score":3,"Tags":"python,python-3.x,binary-data","A_Id":52750509,"CreationDate":"2018-03-05T19:40:00.000","Title":"Efficiently processing large binary files in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Python 2.6\nLinux (CentOS)\nI using shutil.copyfile() function to copy file. I write an exception message in the log file if file is doesn't exist. So, i get message with wrong symbols, because my file path contains russian characters. For example:\norigin file path - \"\/PNG\/401\/405\/018_\/01200\u0413\/osv_1.JPG\" ('\u0413' it is russian symbol)\nfile path in message - \"\/PNG\/401\/405\/018_\/01200\\xd0\\x93\/osv_1.JPG\"\nI'm tried to use this code print(str(error).decode('utf-8')) but it's doesn't work. But this code\nprint(os.listdir(r'\/PNG\/401\/405\/018_\/')[0].decode('utf-8')) work pretty well. Any ideas?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":84,"Q_Id":49150948,"Users Score":0,"Answer":"Well the output is perfectly correct. '\u0413' is the unicode character U+0413 (CYRILLIC CAPITAL LETTER GHE) and its UTF-8 encoding is the 2 characters '\\xd0' and '\\x93'. You simply have to read the log file with an utf8 enabled text editor (gvim or notepad++ are), or if you have to process it in Python make sure to read it as an utf8 encoded file.","Q_Score":0,"Tags":"python,encoding,exception-handling,python-2.6,shutil","A_Id":49153288,"CreationDate":"2018-03-07T11:36:00.000","Title":"IOError return message with broken encoding","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Python 2.6\nLinux (CentOS)\nI using shutil.copyfile() function to copy file. I write an exception message in the log file if file is doesn't exist. So, i get message with wrong symbols, because my file path contains russian characters. For example:\norigin file path - \"\/PNG\/401\/405\/018_\/01200\u0413\/osv_1.JPG\" ('\u0413' it is russian symbol)\nfile path in message - \"\/PNG\/401\/405\/018_\/01200\\xd0\\x93\/osv_1.JPG\"\nI'm tried to use this code print(str(error).decode('utf-8')) but it's doesn't work. But this code\nprint(os.listdir(r'\/PNG\/401\/405\/018_\/')[0].decode('utf-8')) work pretty well. Any ideas?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":84,"Q_Id":49150948,"Users Score":0,"Answer":"print(str(error).decode('string-escape')) - works for me","Q_Score":0,"Tags":"python,encoding,exception-handling,python-2.6,shutil","A_Id":49230851,"CreationDate":"2018-03-07T11:36:00.000","Title":"IOError return message with broken encoding","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm starting with Python 3, using Raspbian (from Debian), and using virtualenv. I understand how to create\/use a virtualenv to \"sandbox\" different Python project, HOWEVER I'm a bit unclear on whether one should be setting up a different linux user for each project (assuming that the project\/virtualenv will be used to create & then run a daemon process on the linux box). \nSo when creating separate python environments the question I think is should I be:\n\ncreating a new linux user account for each deamon\/acript I'm working on, so that both the python virtual environment, and the python project code area can live under directories owned by this user?\nperhaps just create one new non-administrator account at the beginning, and then just use this account for each project\/virtual environmnet\ncreate everything under the initial admin user I first log with for raspbian (e.g. \"pi\" user) - Assume NO for this option, but putting it in for completeness.","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":124,"Q_Id":49228214,"Users Score":4,"Answer":"TL;DR: 1. no 2. yes 3. no\n\n\ncreating a new linux user account for each deamon\/script I'm working on, so that both the python virtual environment, and the python project code area can live under directories owned by this user?\n\n\nNo. Unnecessary complexity and no real benefit to create many user accounts for this. Note that one user can be logged in multiple sessions and running multiple processes.\n\n\nperhaps just create one new non-administrator account at the beginning, and then just use this account for each project\/virtual environment\n\n\nYes, and use sudo from the non-admin account if\/when you need to escalate privilege.\n\n\ncreate everything under the initial admin user I first log with for raspbian (e.g. \"pi\" user) - Assume NO for this option, but putting it in for completeness.\n\n\nNo. Better to create a regular user, not run everything as root. Using a non-root administrator account would be OK, though.","Q_Score":2,"Tags":"python,linux,python-3.x,virtualenv,virtualenvwrapper","A_Id":49228268,"CreationDate":"2018-03-12T04:33:00.000","Title":"should new python virtualenv's be created with new linux user accounts?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm starting with Python 3, using Raspbian (from Debian), and using virtualenv. I understand how to create\/use a virtualenv to \"sandbox\" different Python project, HOWEVER I'm a bit unclear on whether one should be setting up a different linux user for each project (assuming that the project\/virtualenv will be used to create & then run a daemon process on the linux box). \nSo when creating separate python environments the question I think is should I be:\n\ncreating a new linux user account for each deamon\/acript I'm working on, so that both the python virtual environment, and the python project code area can live under directories owned by this user?\nperhaps just create one new non-administrator account at the beginning, and then just use this account for each project\/virtual environmnet\ncreate everything under the initial admin user I first log with for raspbian (e.g. \"pi\" user) - Assume NO for this option, but putting it in for completeness.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":124,"Q_Id":49228214,"Users Score":1,"Answer":"In the general case, there is no need to create a separate account just for a virtualenv.\nThere can be reasons to create a separate account, but they are distinct from, and to some extent anathema to, virtual environments. (If you have a dedicated account for a service, there is no need really to put it in a virtualenv -- you might want to if it has dependencies you want to be able to upgrade easily etc, but the account already provides a level of isolation similar to what a virtualenv provides within an account.)\nReasons to use a virtual environment:\n\nMake it easy to run things with different requirements under the same account.\nMake it easy to install things for yourself without any privileges.\n\nReasons to use a separate account:\n\nFine-grained access control to privileged resources.\nProperly isolating the private resources of the account.","Q_Score":2,"Tags":"python,linux,python-3.x,virtualenv,virtualenvwrapper","A_Id":49228732,"CreationDate":"2018-03-12T04:33:00.000","Title":"should new python virtualenv's be created with new linux user accounts?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm starting with Python 3, using Raspbian (from Debian), and using virtualenv. I understand how to create\/use a virtualenv to \"sandbox\" different Python project, HOWEVER I'm a bit unclear on whether one should be setting up a different linux user for each project (assuming that the project\/virtualenv will be used to create & then run a daemon process on the linux box). \nSo when creating separate python environments the question I think is should I be:\n\ncreating a new linux user account for each deamon\/acript I'm working on, so that both the python virtual environment, and the python project code area can live under directories owned by this user?\nperhaps just create one new non-administrator account at the beginning, and then just use this account for each project\/virtual environmnet\ncreate everything under the initial admin user I first log with for raspbian (e.g. \"pi\" user) - Assume NO for this option, but putting it in for completeness.","AnswerCount":3,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":124,"Q_Id":49228214,"Users Score":2,"Answer":"It depends on what you're trying to achieve. From virtualenv's perspective you could do any of those.\n#1 makes sense to me if you have multiple services that are publicly accessible and want to isolate them.\nIf you're running trusted code on an internal network, but don't want the dependencies clashing then #2 sounds reasonable.\nGiven that the Pi is often used for a specific purpose (not a general purpose desktop say) and the default account goes largely unused, using that account would be fine. Make sure to change the default password.","Q_Score":2,"Tags":"python,linux,python-3.x,virtualenv,virtualenvwrapper","A_Id":49228490,"CreationDate":"2018-03-12T04:33:00.000","Title":"should new python virtualenv's be created with new linux user accounts?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have required to send POS Receipt to customer while validating POS order, the challenge is ticket is defined in point_of_sale\/xml\/pos.xml \nreceipt name is \nhow can i send this via email to customer.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":205,"Q_Id":49235894,"Users Score":0,"Answer":"You can create a wizard at the time of validation of POS order which popup after validating order. In that popup enter mail id of customer and by submit that receipt is directly forwarded to that customer.","Q_Score":0,"Tags":"python-3.x,odoo,point-of-sale,odoo-11","A_Id":52870087,"CreationDate":"2018-03-12T12:59:00.000","Title":"Send POS Receipt Email to Customer While Validating POS Order","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm running into an error where when I try \nfrom PIL import Image, ImageFilter\nin a Python file I get an error stating ModuleNotFoundError: No module named 'PIL'.\nSo far I've tried uninstalling\/reinstalling both PIL and Pillow, along with just doing import Image, but the error keeps on occurring and I have no idea why. All the solutions I've found so far have had no effect on my issue. \nI'm running Python 3.5 on Ubuntu 16.04","AnswerCount":6,"Available Count":3,"Score":0.0333209931,"is_accepted":false,"ViewCount":24852,"Q_Id":49247310,"Users Score":1,"Answer":"I solved the issue with the command python3 -m pip install Pillow.","Q_Score":11,"Tags":"python,python-3.x,ubuntu,python-imaging-library,pillow","A_Id":67286251,"CreationDate":"2018-03-13T02:19:00.000","Title":"No module named 'PIL'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm running into an error where when I try \nfrom PIL import Image, ImageFilter\nin a Python file I get an error stating ModuleNotFoundError: No module named 'PIL'.\nSo far I've tried uninstalling\/reinstalling both PIL and Pillow, along with just doing import Image, but the error keeps on occurring and I have no idea why. All the solutions I've found so far have had no effect on my issue. \nI'm running Python 3.5 on Ubuntu 16.04","AnswerCount":6,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":24852,"Q_Id":49247310,"Users Score":5,"Answer":"Alright, I found a fix \nTo fix the issue, I uninstalled PIL and Pillow through sudo pip3 uninstall pillow and sudo apt-get purge python3-pil. I then restarted and then used sudo -H pip3 install pillow to reinstall Pillow \nThe only step I was missing before was rebooting, and not reinstalling PIL afterwards. \nIt seems to have worked without any issues so far.","Q_Score":11,"Tags":"python,python-3.x,ubuntu,python-imaging-library,pillow","A_Id":49247556,"CreationDate":"2018-03-13T02:19:00.000","Title":"No module named 'PIL'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm running into an error where when I try \nfrom PIL import Image, ImageFilter\nin a Python file I get an error stating ModuleNotFoundError: No module named 'PIL'.\nSo far I've tried uninstalling\/reinstalling both PIL and Pillow, along with just doing import Image, but the error keeps on occurring and I have no idea why. All the solutions I've found so far have had no effect on my issue. \nI'm running Python 3.5 on Ubuntu 16.04","AnswerCount":6,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":24852,"Q_Id":49247310,"Users Score":2,"Answer":"In my case the problem had to do with virtual environments. \nThe python program ran in a virtual environment, but I called pip install Pillow from a normal command prompt. When I ran the program in a non-virtual environment, from PIL import Image worked. \nIt also worked when I called venv\/scripts\/activate before calling pip install Pillow. So apparently PIL is not found when installed in the python root but the program runs in a virtual environment.","Q_Score":11,"Tags":"python,python-3.x,ubuntu,python-imaging-library,pillow","A_Id":52448736,"CreationDate":"2018-03-13T02:19:00.000","Title":"No module named 'PIL'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I tried to install MATLAB R2017b runtime Python 3.6 on to my ubuntu 16.4. As per the instruction that given in matlab community python installer (setup.py) should be in ..\/..\/v93\/extern\/engines\/python location. \nWhen I go there Icouldnt see that setup.py file in the location. I have tried so many time re installing the MATLAB R2017b runtime. \nBut I couldn't find that python setup.py on the location. \ncould you please send me instruction how to install this MATLAB R2017b runtime on ubuntu 16.4 where I can access my matlab libries from python3.6","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":88,"Q_Id":49270176,"Users Score":1,"Answer":"The python installer should be in \/{matlab_root}\/extern\/engines\/python.\nThen python setup.py install\nHope it helps","Q_Score":1,"Tags":"python,matlab,computer-vision,ubuntu-16.04","A_Id":49274707,"CreationDate":"2018-03-14T05:14:00.000","Title":"In Matlab Runtime Python3.6 installer not found in order to install matlab python suport for ubunut 16.4","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a remote cron job that scrapes data using selenium every 30 minutes. Roughly 1 in 10 times the selenium script fails. When the script fails, I get an error output instead (various selenium error messages). Does this cause the cron job to stop? Shouldn't crontab try to run the script again in 30 minutes?\nAfter a failed attempt, when I type crontab -l, it still shows my cron job. \nHow do I ensure that the crontab tries again in 30 minutes?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":306,"Q_Id":49283567,"Users Score":0,"Answer":"ANSWER: The website I was scraping was sophisticated enough to find out I was using selenium because cron was running the job every 30 minutes on the dot. So they flagged my VM's IP address after the 4-5th attempt. \nMy solution was simple: add randomness to the interval with which I scrapped the website using random.uniform and time.sleep - now I have no issues scraping.","Q_Score":0,"Tags":"python-3.x,selenium,cron","A_Id":49321214,"CreationDate":"2018-03-14T16:56:00.000","Title":"Does cron job persist\/run again if the python script fails?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a remote cron job that scrapes data using selenium every 30 minutes. Roughly 1 in 10 times the selenium script fails. When the script fails, I get an error output instead (various selenium error messages). Does this cause the cron job to stop? Shouldn't crontab try to run the script again in 30 minutes?\nAfter a failed attempt, when I type crontab -l, it still shows my cron job. \nHow do I ensure that the crontab tries again in 30 minutes?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":306,"Q_Id":49283567,"Users Score":0,"Answer":"Who is sending the error output? If it's the cron daemon, then your job should be dead; if the selenium process itself is sending the mail, then it may still be running, and stuck.","Q_Score":0,"Tags":"python-3.x,selenium,cron","A_Id":49287487,"CreationDate":"2018-03-14T16:56:00.000","Title":"Does cron job persist\/run again if the python script fails?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"A collaborator of mine wrote a software package in Python 2.7, took advantage of it to run some tests and obtain some scientific results. We wrote together a paper about the methods he developed and the results he obtained.\nEverything worked out well so he recently put this package publically available on his GitHub webpage.\nThen I thought it would have been useful to have a Python 3.5 version of that package. Therefore I downloaded the original software and made the proper changes to have it working on Python 3.5.\nNow I don't know how to properly release this Python 3.5 package.\nI envision three possibilities:\n\nShould I put it on his original GitHub project repository? This option would lead to some confusion, because people would have to download both the Python 2.7 and the Python 3.5 code.\nShould I create a new repository only for my Python 3.5 package, in addition to the Python 2.7 one released by my collaborator? This option would lead to the existence of two running code repositories, and to some confusion as well, because people might not know which is the \"official one\" to use.\nShould I create a new repository only for my Python 3.5 package, and ask my collaborator to delete his Python 2.7 repository? This option would make our paper inconsistent, because it states that tests were done with Python 2.7.\n\nDo you envision any other option I did not include?\nDo you have any suggestion?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":44,"Q_Id":49326559,"Users Score":1,"Answer":"I think number 1. and 2. should both work as long as you provide enough details in the README.md file in the repository. \nIn case of option 1, you should ask your collaborator to add you as a collaborator to the repository.\nIn case of number 2, you should definitely cross-link each other's repositories in your README-files respectively. \nI'd definitely add a requirements.txt file for each python version so that the users can conveniently install your dependencies with pip install -r requirements.txt or pip3 install -r requirements.txt.","Q_Score":0,"Tags":"python,python-3.x,python-2.7,github,version","A_Id":49326823,"CreationDate":"2018-03-16T17:36:00.000","Title":"What's the best way to release two versions of the same software package on GitHub?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I get an error when I execute python2 -m pip freeze this command. \nThe error message is as below:\n\/usr\/bin\/python: cannot import name HashMissing; 'pip' is a package and cannot be directly executed\nI had used apt-get remove --purge python python-pip fo removing the python2. \nThen, I do these path checking for knowing pip and python command path. \n\n john@mymachine:~$ whereis python\n python: \/usr\/bin\/python \/usr\/bin\/python3.4m \/usr\/bin\/python3.4 \/usr\/bin\/python2.7 \/usr\/bin\/python2.7-config \/usr\/lib\/python3.4 \/usr\/lib\/python2.7 \/etc\/python3.4 \/etc\/python2.7 \/usr\/local\/lib\/python3.4 \/usr\/local\/lib\/python2.7 \/usr\/include\/python2.7 \/usr\/share\/python \/usr\/share\/man\/man1\/python.1.gz\n john@mymachine:~$ which -a pip\n \/usr\/local\/bin\/pip\n jonh@mymachine:~$ whereis pip\n pip: \/usr\/local\/bin\/pip \/usr\/local\/bin\/pip3.5 \/usr\/local\/bin\/pip2.7 \/usr\/local\/bin\/pip3.4\n john@mymachine:~$ which -a python\n \/usr\/bin\/python\n\nWish some help.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":202,"Q_Id":49335903,"Users Score":0,"Answer":"Don't know the reason. But, I install the pip again.\nwget https:\/\/bootstrap.pypa.io\/get-pip.py\nand\npython get-pip.py\nThe problem is resolved.","Q_Score":0,"Tags":"python,pip","A_Id":49356101,"CreationDate":"2018-03-17T12:17:00.000","Title":"python2 -m pip freeze showing an error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have some python code which is heavily dependent on greenlets. I can use either gevent or eventlet.\nI have packaged some sections of the code in a C-extension but these calls do not yield to other greenlets. Is it possible to write my extension such that it will yield control to other python threads while it does not require the GIL?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":174,"Q_Id":49358984,"Users Score":0,"Answer":"You can use normal PyObject_CallFunction(eventlet\/greenlet.sleep) to yield control to other green threads. It must be run with GIL locked, like any other Python code.\nYou can not run Python code without GIL. (you can but it will quickly go sideways and corrupt memory).","Q_Score":1,"Tags":"python,gevent,eventlet,python-extensions,greenlets","A_Id":49380361,"CreationDate":"2018-03-19T08:56:00.000","Title":"Make C-Extension calls \"green\" in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying test my python script using jenkins.Issue I am facing is with the test report generation\nI have created a folder 'test_reports' in my jenkins workspace.\nC:\\Program Files (x86)\\Jenkins\\jobs\\PythonTest\\test_reports\nBut then when I run the script from jenkins I get the error as,\nERROR: Step \u2018Publish JUnit test result report\u2019 failed: No test report files were found. Configuration error?\nHow do I actually configure the test report? Is the xml file generated automatically?\nAny help would be greatly appreciated","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":648,"Q_Id":49361114,"Users Score":0,"Answer":"This was an expected result because,The script file I wrote was not a unit-test module.It was just a normal python file(It wasn't supposed to create any XML results).\nOnce I created the script using unit-test framework and import the xml runner,I was able to generate the xml files of the result.","Q_Score":0,"Tags":"python,testing,jenkins,report","A_Id":49377372,"CreationDate":"2018-03-19T10:49:00.000","Title":"How to configure xml Report in jenkins","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"What are the advantages of saving file in .pkl format over .txt or .csv format in Python?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":4316,"Q_Id":49370591,"Users Score":1,"Answer":".pkl can serialize a very wide range of objects, not just text data.","Q_Score":3,"Tags":"python,pickle","A_Id":49370614,"CreationDate":"2018-03-19T19:06:00.000","Title":"What are the advantages of .pkl file over .txt or csv file in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a box where we are running a internal web page build on perl-cgi. My knowledge is little limited about coding. but I want to run some pages built on python cgi. Technically is it possible to run both perl+python cgi on same server without doing much configuration change","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":95,"Q_Id":49386143,"Users Score":3,"Answer":"Yes. It's actually very easy. Because cgi doesn't care what language it's written it - it's just a script that the web server runs on demand, and passes parameters. \nYou can even use compiled C as your cgi language if you want. \nAll you need to do is be able to read the local environment (and pretty much every language can) and read STDIN - and pretty much every language can. \nYou can comfortably run perl and python scripts along side each other - the server simply doesn't care. \nTo get more complicated, you might want to preload\/prefork your cgi scripts, and then it starts to be a little more complicated to use arbitrary languages. \nBut for a basic run-on-demand cgi script, anything will suffice.","Q_Score":1,"Tags":"python,perl,cgi","A_Id":49386283,"CreationDate":"2018-03-20T13:54:00.000","Title":"Can we run perl and python cgi web portal from same server\/box","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python code which is quite heavy, my computer cant run it efficiently, therefore i want to run the python code on cloud.\nPlease tell me how to do it ? any step by step tutorial available\nthanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3979,"Q_Id":49386402,"Users Score":0,"Answer":"You can try Heroku. It's free and they got their own tutorials. But it's good enough only if you will use it for studying. AWS, Azure or google cloud are much better for production.","Q_Score":3,"Tags":"python,cloud","A_Id":49386557,"CreationDate":"2018-03-20T14:04:00.000","Title":"How to run python code on cloud","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to automate a Python script on a Google Cloud VM using Crontab.\nWhen I run python Daily_visits.py my code runs as expected and generates a table in BigQuery.\nMy Crontab job is as follows: *\/2 * * * * \/usr\/bin\/python Daily_visits.py but generates no output.\nI've run which python and I get \/usr\/bin\/python back, and I have run chmod +x Daily_visits.sh on my file, what else am I missing?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":842,"Q_Id":49386938,"Users Score":4,"Answer":"You should write absolute path for Daily_visits.py file. Go to Daily_visits.py file's directory and run command:\npwd\nYou take output like it:\n\/var\/www\/Daily_visits.py\nCopy and paste it change into crontab.\n*\/2 * * * * \/usr\/bin\/python \/var\/www\/Daily_visits.py","Q_Score":0,"Tags":"python,linux,google-cloud-platform","A_Id":49387025,"CreationDate":"2018-03-20T14:28:00.000","Title":"Automating a Python script with Crontab","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I gave a requirement involving SMS and AWS platform, the requirement is - users can send SMS to a mobile number and I need to store the SMS and it's metadata into AWS RDS or DynamoDB or any AWS compatible storage. These SMS will be used to populate a realtime dashboard.\nAnyone here came across such a scenario? or any tools or technologies I could use to resolve it?\nThanks a ton for your replies,\nArun","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1531,"Q_Id":49399530,"Users Score":0,"Answer":"As far as I know, receiving international SMS is free and without hassle on the receiver's side. Unlike sending SMS which AWS SNS provide\nSo that separate the SMS receiving business and the storage business. To receive SMS you can look at Nexmo or Twilio.\nPlease note that SMS fails regularly and the sender is charged for international SMS most of the time","Q_Score":2,"Tags":"python,amazon-web-services,mobile,sms,amazon-sns","A_Id":49400763,"CreationDate":"2018-03-21T06:20:00.000","Title":"Receive SMS from users and store in AWS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I use Eclipse for Python development and depend on the F2 function key to send lines of code to the console. Recently, F2 has stopped working in my installation of Eclipse Neon. I have tried everything I can think of to get it to work again:\n\nclose and reopen the python module\nclose and reopen Eclipse (as recommended on Stackoverflow)\ncheck the key bindings to make sure F2 is properly bound, unbind it, rebind it, reset to default key bindings\nreboot my computer\ninstall new version of Eclipse, Oxygen, twice..\n\nIn one of the newly installed Oxygens, at least the first time I press F2, it does open the pop-up asking what console to start with, but then after the console is open it does nothing. \nIn the Neon installation and the other Oxygen installation, F2 just does nothing, not even open a new console when none is active.\nWould you have any idea I can try to get F2 back to work?","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":566,"Q_Id":49434458,"Users Score":0,"Answer":"I fixed it by installing the updates for PyDev. In Eclipse, Help - Check for updates - install pending updates for PyDev. Now I can use F2 to run code from selection in the console.","Q_Score":4,"Tags":"python,eclipse,keyboard-shortcuts,pydev","A_Id":52117212,"CreationDate":"2018-03-22T17:03:00.000","Title":"The F2 key not working in Eclipse Pydev, despite restarting","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I use Eclipse for Python development and depend on the F2 function key to send lines of code to the console. Recently, F2 has stopped working in my installation of Eclipse Neon. I have tried everything I can think of to get it to work again:\n\nclose and reopen the python module\nclose and reopen Eclipse (as recommended on Stackoverflow)\ncheck the key bindings to make sure F2 is properly bound, unbind it, rebind it, reset to default key bindings\nreboot my computer\ninstall new version of Eclipse, Oxygen, twice..\n\nIn one of the newly installed Oxygens, at least the first time I press F2, it does open the pop-up asking what console to start with, but then after the console is open it does nothing. \nIn the Neon installation and the other Oxygen installation, F2 just does nothing, not even open a new console when none is active.\nWould you have any idea I can try to get F2 back to work?","AnswerCount":4,"Available Count":3,"Score":-0.049958375,"is_accepted":false,"ViewCount":566,"Q_Id":49434458,"Users Score":-1,"Answer":"have the same issues after upgrading to \nEclipse IDE for C\/C++ Developers\nVersion: Oxygen.3 Release (4.7.3)\nBuild id: 20180308-1800\nPyDev for Eclipse 6.3.2.201803171248 org.python.pydev.feature.feature.group Fabio Zadrozny","Q_Score":4,"Tags":"python,eclipse,keyboard-shortcuts,pydev","A_Id":49435666,"CreationDate":"2018-03-22T17:03:00.000","Title":"The F2 key not working in Eclipse Pydev, despite restarting","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I use Eclipse for Python development and depend on the F2 function key to send lines of code to the console. Recently, F2 has stopped working in my installation of Eclipse Neon. I have tried everything I can think of to get it to work again:\n\nclose and reopen the python module\nclose and reopen Eclipse (as recommended on Stackoverflow)\ncheck the key bindings to make sure F2 is properly bound, unbind it, rebind it, reset to default key bindings\nreboot my computer\ninstall new version of Eclipse, Oxygen, twice..\n\nIn one of the newly installed Oxygens, at least the first time I press F2, it does open the pop-up asking what console to start with, but then after the console is open it does nothing. \nIn the Neon installation and the other Oxygen installation, F2 just does nothing, not even open a new console when none is active.\nWould you have any idea I can try to get F2 back to work?","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":566,"Q_Id":49434458,"Users Score":1,"Answer":"I have gotten it back to work, by uninstalling pydev 6.3 and re-installing pydev 6.1. I'm not sure why this works as I was working in 6.2 when the issue first arose. I tried to solve it by upgrading to 6.3, but that didn't work. For some reason, downgrading back to 6.1 now makes it work again.","Q_Score":4,"Tags":"python,eclipse,keyboard-shortcuts,pydev","A_Id":49438248,"CreationDate":"2018-03-22T17:03:00.000","Title":"The F2 key not working in Eclipse Pydev, despite restarting","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to deploy a Python app via mod_wsgi in Apache httpd, running into a strange error.\nI'm using my firm's custom python package (2.7), besides this there is another Python intsallation, shipped with the OS (different version, 2.6 something). The issue is, when I define the \nWSGIPythonHome and WSGIPythonPath variables in my httpd conf, I'm flooded with \"ImportError: no module named site\" errors in the error_log. Looking at other answers, defining those variables would be the solution for such errors.\nIf I switch user to the apache user, with being the PYTHONPATH and PYTHONHOME env variables set, when I try to start Python 2.7, I'm getting the same error.\nAfter unsetting the variables, Python is able to start normally.\nSo I've tried removing the WSGIPythonHome and WSGIPythonPath from the httpd conf, but in that case, nothing happens, the wsgi script is not executed, as nothing is pointing Apache to my python executable.\nThe mod_wsgi.so has been installed with pip, and loaded from the same path as my PYTHONPATH would be for 2.7","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":542,"Q_Id":49438421,"Users Score":0,"Answer":"It is likely that mod_wsgi Apache is using is compiled for Python 2.6. You cannot make mod_wsgi compiled for Python 2.6, work with a Python 2.7 installation or virtual environment.\nYou should verify what Python version mod_wsgi was compiled for by running ldd on the mod_wsgi.so binary. Don't assume it is using the pip installed version, you may still have system mod_wsgi installed.\nIf it is the system mod_wsgi package and it is compiled for Python 2.6, you will need to uninstall it.","Q_Score":0,"Tags":"python,apache,mod-wsgi","A_Id":49438521,"CreationDate":"2018-03-22T21:02:00.000","Title":"Unable to run python with mod_wsgi","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've downloaded Python about a year ago, and back then, I had trouble executing files from the terminal. So, being ye of little faith, I quit trying and forgot most of my Python knowledge. Now, I' revisiting Python, and it still doesn't work (I updated Python. And deleted it. And updated again) But it still does not work. I made sure I'm in the directory that Python is supposedly in. Please help.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":9018,"Q_Id":49440211,"Users Score":1,"Answer":"Even easier,\nlaunch again the setup of Python and click on 'Modify'.\nIn the \"Advanced Options\", check \"Add Python to environment variables\"","Q_Score":0,"Tags":"python-3.x,command-line,terminal","A_Id":60899827,"CreationDate":"2018-03-22T23:40:00.000","Title":"Python command is not working in terminal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I found an option to get python to play Presentation procedures, but not the other way around. I have a ton of code and rewriting it into a different language would be a nightmare.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":93,"Q_Id":49446868,"Users Score":2,"Answer":"No, there is no such conversion tool available at the moment.\nHowever, it is in principle possible to make it. PsychoPy Builder saves experiments in the open .psyexp format and then that is converted to Python code. Someone could write converters to other script structures and languages, for example, NeuroBS Presentation, PsychToolbox, etc.","Q_Score":1,"Tags":"python,psychopy,presentation,code-translation,neuroscience","A_Id":49451272,"CreationDate":"2018-03-23T09:56:00.000","Title":"Is there a way to implement a full Python (psychopy) procedure into neurobs Presentation without rewriting the whole code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a project to send, where basically I have to send an email using python.\nMy code is complete so I was about to send it.\nBecause of the fact the module smtplib needs my email log in, I compiled my code so people could no see my email and password, however, even compiled, when we look at the hex code, we can still see my email and password (and some print)\nIs there a way to compile so we have no information left after?\nThank you very much for your help and time !","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":88,"Q_Id":49480217,"Users Score":1,"Answer":"Generally it is a bad idea to hold sensitive information in the code. There is no uniformly the best way to do it, but common practices to store credentials include:\n\nin a separate code file not in your code base (local_settings.py, added to .gitignore)\nin a separate config file outside of the project (e.g. json or yml)\nenvironment variables (read using os.environ)\ncommand line parameters\nrequest as user input\na combination of all above","Q_Score":0,"Tags":"python,python-3.x,compilation,hex,pyc","A_Id":49480261,"CreationDate":"2018-03-25T19:47:00.000","Title":"remove remaining hex code in Pyc file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Coding is entirely new to me. \nRight now, I am teaching myself Python. As of now, I am only going over algorithms. I watched a few crash courses online about the language. Based on that, I don't feel like I am able to code any sort of website or software which leads me wonder if the libraries and frameworks of any programming language are the most important bit?\nShould I spend more time teaching myself how to code with frameworks and libraries?\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":43,"Q_Id":49526618,"Users Score":1,"Answer":"First of all, you should try to be comfortable with every Python mechanisms (classes, recursion, functions... everything you usually find in any book or complete tutorial). It could be useful for any problem you want to solve. \nThen, you should start your own project using the suitable libraries and frameworks. You must set a clear goal, do you want to build a website or a software ? You won't use the same libraries\/framework for any purpose. Some of them are really often used so you could start by reading their documentation.\nAnyhow, to answer your question, framework and libraries are not the most important bit of coding. They are just your tools, whereas the way you think to solve problems and build your algorithms is your art. \nThe most important thing to be a painter is not knowing how to use a brush (even if, of course, it's really useful)","Q_Score":1,"Tags":"python,frameworks,libraries","A_Id":49530470,"CreationDate":"2018-03-28T05:18:00.000","Title":"Are framework and libraries the more important bit of coding?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm writing a python program that implements the Huffman Compression. However, it seems that I can only read \/ write to bin file byte by byte instead of bit by bit. Is there any workaround for this problem? Wouldn't processing byte by byte defeat the purpose of compression since extraneous padding would be needed. Also, it'd be great if someone can enlighten me about the application of Huffman Compression with regards to this byte-by-byte problem. w","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":501,"Q_Id":49547478,"Users Score":0,"Answer":"Layer your code. Have a bottom io layer that does all file reads and writes either entire file at once or with buffering. Have a layer above that which processes the Huffman code bitstream by bits.","Q_Score":1,"Tags":"python,algorithm,compression,huffman-code","A_Id":49547639,"CreationDate":"2018-03-29T03:22:00.000","Title":"Reading bit by bit for Huffman Compression","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Afternoon,\nI recently came across AWS Lambda and Azure Functions. AWS imposes a limit on the size of zipped as well as unzipped files, which for python scripts need to include all of the dependent modules. I have been using lambda-uploader to package my script and it's module dependencies, but the pandas package is too big.\nI have seen examples of people completing machine learning and using pandas on AWS Lambda (a little outdated though) but I can't see how they're doing it. Any suggestions?","AnswerCount":5,"Available Count":1,"Score":0.0798297691,"is_accepted":false,"ViewCount":12267,"Q_Id":49567804,"Users Score":2,"Answer":"If you're using Python libraries, you can get rid of botocore, boto3 as they are already present in AWS's lambdas functions.","Q_Score":12,"Tags":"python,amazon-web-services,aws-lambda","A_Id":57400673,"CreationDate":"2018-03-30T02:57:00.000","Title":"How to reduce the size of packaged python zip files for AWS Lambda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to pytest and currently testing out different functionality. \nI currently have a testcase where I test out an endpoint, get a response, and this response has to be used in another test case to another endpoint, of which the result will be sued in a third testcase. \nIn a regular python script, this would be very simple (easy error handling as well).\nIs it possible to daisy chain test cases using pytest AND pass results (possibly as variables) from one test to the other?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1857,"Q_Id":49568232,"Users Score":0,"Answer":"That's bad practice. You do not want tests to be dependent.","Q_Score":1,"Tags":"python,pytest","A_Id":51505094,"CreationDate":"2018-03-30T04:09:00.000","Title":"How can I pass the result of one pytest to another pytest","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python function (using the Pythonista app) to show an image in the console. I have the image saved in a BytesIO object but the function requires a file path.\nIs there any way to give it a path to the bytesIO or somehow give it the image without needing to save it as a file?\nThe specific function is console.show_image(image_path)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":245,"Q_Id":49570299,"Users Score":1,"Answer":"The general answer is that if the function you call expects a filesystem path and cannot handle a file-like object instead then your only solution is to write your data to a file (and ask the function's author to add support for file-like object, or if it's OSS implement it by yourself and send a merge request).","Q_Score":0,"Tags":"python,file,pythonista","A_Id":49570784,"CreationDate":"2018-03-30T07:32:00.000","Title":"Python function requires path but I have an image stored in memory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have millions of images, and I am able to use OCR with pytesseract to perform descent text extraction, but it takes too long to process all of the images. \nThus I would like to determine if an image simply contains text or not, and if it doesn't, i wouldn't have to perform OCR on it. Ideally this method would have a high recall. \nI was thinking about building a SVM or some machine learning model to help detect, but I was hoping if anyone new of a method to quickly determine if an object contains text or not.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":285,"Q_Id":49576528,"Users Score":2,"Answer":"Unfortunately there is no way to tell if an image has text in it, without performing OCR of some kind on it.\nYou could build a machine learning model that handles this, however keep in mind it would still need to process the image as well.","Q_Score":0,"Tags":"python,classification,ocr,tesseract,text-extraction","A_Id":49577580,"CreationDate":"2018-03-30T14:47:00.000","Title":"Quick way to classify if an image contains text or not","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to implement an objective function that minimize the overlap of 2 irregular shaped 3d objects. While the most accurate measurement of the overlap is the intersection volume, it's too computationally expensive as I am dealing with complex objects with 1000+ faces and are not convex.\nI am wondering if there are other measurements of intersection between 3d objects that are much faster to compute? 2 requirements for the measurement are: 1. When the measurement is 0, there should be no overlap; 2. The measurement should be a scalar(not a boolean value) indicating the degree of overlapping, but this value doesn't need to be very accurate.\nPossible measurements I am considering include some sort of 2D surface area of intersection, or 1D penetration depth. Alternatively I can estimate volume with a sample based method that sample points inside one object and test the percentage of points that exist in another object. But I don't know how computational expensive it is to sample points inside a complex 3d shape as well as to test if a point is enclosed by such a shape.\nI will really appreciate any advices, codes, or equations on this matter. Also if you can suggest any libraries (preferably python library) that accept .obj, .ply...etc files and perform 3D geometry computation that will be great! I will also post here if I find out a good method.\nUpdate:\nI found a good python library called Trimesh that performs all the computations mentioned by me and others in this post. It computes the exact intersection volume with the Blender backend; it can voxelize meshes and compute the volume of the co-occupied voxels; it can also perform surface and volumetric points sampling within one mesh and test points containment within another mesh. I found surface point sampling and containment testing(sort of surface intersection) and the grid approach to be the fastest.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1361,"Q_Id":49584153,"Users Score":0,"Answer":"A sample-based approach is what I'd try first. Generate a bunch of points in the unioned bounding AABB, and divide the number of points in A and B by the number of points in A or B. (You can adapt this measure to your use case -- it doesn't work very well when A and B have very different volumes.) To check whether a given point is in a given volume, use a crossing number test, which Google. There are acceleration structures that can help with this test, but my guess is that the number of samples that'll give you reasonable accuracy is lower than the number of samples necessary to benefit overall from building the acceleration structure.\nAs a variant of this, you can check line intersection instead of point intersection: Generate a random (axis-aligned, for efficiency) line, and measure how much of it is contained in A, in B, and in both A and B. This requires more bookkeeping than point-in-polyhedron, but will give you better per-sample information and thus reduce the number of times you end up iterating through all the faces.","Q_Score":3,"Tags":"python,3d,computational-geometry,bin-packing","A_Id":49597211,"CreationDate":"2018-03-31T04:10:00.000","Title":"Measurement for intersection of 2 irregular shaped 3d object","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to implement an objective function that minimize the overlap of 2 irregular shaped 3d objects. While the most accurate measurement of the overlap is the intersection volume, it's too computationally expensive as I am dealing with complex objects with 1000+ faces and are not convex.\nI am wondering if there are other measurements of intersection between 3d objects that are much faster to compute? 2 requirements for the measurement are: 1. When the measurement is 0, there should be no overlap; 2. The measurement should be a scalar(not a boolean value) indicating the degree of overlapping, but this value doesn't need to be very accurate.\nPossible measurements I am considering include some sort of 2D surface area of intersection, or 1D penetration depth. Alternatively I can estimate volume with a sample based method that sample points inside one object and test the percentage of points that exist in another object. But I don't know how computational expensive it is to sample points inside a complex 3d shape as well as to test if a point is enclosed by such a shape.\nI will really appreciate any advices, codes, or equations on this matter. Also if you can suggest any libraries (preferably python library) that accept .obj, .ply...etc files and perform 3D geometry computation that will be great! I will also post here if I find out a good method.\nUpdate:\nI found a good python library called Trimesh that performs all the computations mentioned by me and others in this post. It computes the exact intersection volume with the Blender backend; it can voxelize meshes and compute the volume of the co-occupied voxels; it can also perform surface and volumetric points sampling within one mesh and test points containment within another mesh. I found surface point sampling and containment testing(sort of surface intersection) and the grid approach to be the fastest.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1361,"Q_Id":49584153,"Users Score":0,"Answer":"By straight voxelization:\nIf the faces are of similar size (if needed triangulate the large ones), you can use a gridding approach: define a regular 3D grid with a spacing size larger than the longest edge and store one bit per voxel.\nThen for every vertex of the mesh, set the bit of the cell it is included in (this just takes a truncation of the coordinates). By doing this, you will obtain the boundary of the object as a connected surface. You will obtain an estimate of the volume by means of a 3D flood filling algorithm, either from an inside or an outside pixel. (Outside will be easier but be sure to leave a one voxel margin around the object.)\nEstimating the volumes of both objects as well as intersection or union is straightforward with this machinery. The cost will depend on the number of faces and the number of voxels.","Q_Score":3,"Tags":"python,3d,computational-geometry,bin-packing","A_Id":49688037,"CreationDate":"2018-03-31T04:10:00.000","Title":"Measurement for intersection of 2 irregular shaped 3d object","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running my code from the shell(SSH) in google cloud as \n\npython3 mycode.py\n\nIf I close the shell, the computation stops. How can I start a computation and then close the shell(Computation takes a long Time:)).....come back later and see how it is doing. \nMy code keeps printing results after a certain number of iteration.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1024,"Q_Id":49603198,"Users Score":2,"Answer":"Well, in general what you can do is run the code in a way where you can detach from the interactive environment. Using a tool such as screen or tmux. However, Google Cloud Shell is not made for running background tasks, and if i recall correctly, it will terminate after an hour.\nYou might need to provision a virtual machine to run it on instead. I can recommend using tmux. With tmux, it will be as simple as running tmux and then in the new shell running your script python3 mycode.py. You can then detach using ctrl+b d or simply disconnect. When you reconnect you run tmux attach -dto get back to your script.","Q_Score":1,"Tags":"python-3.x,shell,google-cloud-platform,google-compute-engine","A_Id":49603363,"CreationDate":"2018-04-01T22:26:00.000","Title":"Google Cloud Shell scripting Issue","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am new to Appium. \nI want to control my android device via appium without sending any apk to phone.\nI have tried many examples but in each example everyone is pushing an apk and then controlling it using touches and keypress.\nI am not looking for an app testing instead I am looking for an android device testing using resorce id ,name,class or xpath.\nAnd will the procedure remain same for ios also ?\nCan anyone help me in writing a script in python?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1291,"Q_Id":49634265,"Users Score":0,"Answer":"I think the problem is like mine...want to control an android device or emulator with Appium, may be Mayank Shivhare already try to learn culebra and found the fact that....culebra is still not support by python 3 yet (same problem like me that prefer python 3.7 than python 2.7).\nI have the same problem..., what I understood right now is:\n\nAll environment should be set up first\nThe emulator should be run first...before type any code\nthen run Appium to make a gateway with IP and port.\nthe missing link is how to connect an emulator to appium via ip and port that provide by appium server.\nI can detect the emulator element by run 'uiautomatorviewer.bat' from sdk\\tools\\bin folder, the problem is the problem in number 3, is how to send a command to the emulator via appium. so the command to control emulator base on data that given by 'uiautomatorviewer.bat'\n\ncoding is about trial and error, so we need live interaction, to build source code. every developer has a personal interest in build a script or source code. so..to make easier, as beginner, we need live interaction that shows every error in every step our script or to make sure that every line of our script that we type is run smoothly in the android device or emulator.\nThe problem in learn appium is all manual already given finished script...without a really-really basic explanation...in my case, how to connect appium to emulator, send a command from python console, and see the script is work or not...\nwhat I mean is... we need the step by step explanation of script...because every beginner developers need a live 'trial and error' experience to understand how it works...","Q_Score":0,"Tags":"android,python,selenium,appium,android-uiautomator","A_Id":53939927,"CreationDate":"2018-04-03T15:50:00.000","Title":"How to control android device using appium and python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm having a problem with elastic beanstalk, in my application there is some piece of code that creates some files dynamically and now I want to persist these files for future use, so is there any way that I can push my dynamically created files to GitHub automatically, so in next deployment these changes will remain, as elastic beanstalk replace the old code with new code after each deployment, So How can I commit my changes and push them to GitHub repo from code, any suggestions?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":120,"Q_Id":49670491,"Users Score":1,"Answer":"You can user aws S3 or other storage service as file back-end. This will sole you problem.","Q_Score":0,"Tags":"python,django,amazon-web-services,deployment,amazon-elastic-beanstalk","A_Id":49670735,"CreationDate":"2018-04-05T10:47:00.000","Title":"Auto Deploy Elastic Beanstalk Changes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I defined some command line tools of python (take mycmd.py as an example), and saved them in the folder ~\/Scripts. Hence, I have to type (for example) python \/Scripts\/mycmd.py -o v. It is tedious to repeat the name of the folder \/Scripts. I want to run the command only inputting python mycmd.py -o v, even without cd. How should I do? Add a path to the original one?\nPS: in mac","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":66,"Q_Id":49728799,"Users Score":-1,"Answer":"Add the path to PYTHONPATH environment variable.","Q_Score":1,"Tags":"python,command-line,path","A_Id":49728849,"CreationDate":"2018-04-09T08:41:00.000","Title":"set path for command line of python (mac)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Background:\nI am using Django2 and Sentry for detecting my crash. In my gitlab pipe line. I used to has test job as a major concern to not break any features when deploy new feature.\nMany of my testcases contains Exception and Sentry does surge up.\nQuestion:\nDo I have any technique to suppress sentry for a while during pipeline running?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":19,"Q_Id":49771711,"Users Score":1,"Answer":"Well basically if there is a settings.py configuration that specify whether to send errors to Sentry, you could create a different one for test environment and turn off sentry logging.\nI currently use a separate test_settings.py file where I remove sentry (and related) from the INSTALLED_APPS. It works well enough for us.","Q_Score":0,"Tags":"python,sentry","A_Id":49841595,"CreationDate":"2018-04-11T09:42:00.000","Title":"Crash analytic surge up when runner running testcases","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a tika code in a server. I want to create an SFTP session with another server with files and run Apache tika on that server. I am using python as back end. Will this work ? is my approach correct ?\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":73,"Q_Id":49776224,"Users Score":0,"Answer":"So, what I was planning to do was not ideal . .\nApache Tika requires to scan physical files to fetch metadata. I made a bridge and started from sessions pulling files to the server Tika code was hosted.","Q_Score":0,"Tags":"python,sftp,apache-tika","A_Id":50650506,"CreationDate":"2018-04-11T13:19:00.000","Title":"using apache tika for scanning documents on servers using sftp","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have some add-ins that load on start up. I can't disable this from happening as I don't have administrator rights.\nI am writing a program that opens outlook and sends emails, but it is slowed down by these add ins. Is there a way to programmatically disable add-ins after opening outlook using python (e.g. using the win32com package)? \nI need to do the same thing for Excel too. Any advice would be appreciated.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":468,"Q_Id":49779995,"Users Score":1,"Answer":"You can disable the addins by setting the LoadBehavior value appropriately for the problematic addins in HKEY_CURRENT_USER\\Software\\Microsoft\\Office\\Outlook.","Q_Score":0,"Tags":"python,excel,outlook,outlook-addin,excel-addins","A_Id":49780598,"CreationDate":"2018-04-11T16:16:00.000","Title":"Python: How can I disable add-ins in Outlook and Excel?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have some add-ins that load on start up. I can't disable this from happening as I don't have administrator rights.\nI am writing a program that opens outlook and sends emails, but it is slowed down by these add ins. Is there a way to programmatically disable add-ins after opening outlook using python (e.g. using the win32com package)? \nI need to do the same thing for Excel too. Any advice would be appreciated.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":468,"Q_Id":49779995,"Users Score":0,"Answer":"Well the first advice is try to have the administrator rights on your computer to run the py script with no issue\nsecondly i think there is a way to do this as i came across a py lib in github but getting the administrative rights it better as it will be a issue in the future","Q_Score":0,"Tags":"python,excel,outlook,outlook-addin,excel-addins","A_Id":49780058,"CreationDate":"2018-04-11T16:16:00.000","Title":"Python: How can I disable add-ins in Outlook and Excel?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to openshift, we are trying to deploy a python module in a pod which is accessed by other python code running in different pods. When i was deploying, the pod is running and immediately crash with status \"Crash Loop Back Off\".This python code is an independent module which does not have valid entrypoint. So how to deploy those type of python modules in openshift. Appreciate for any solutions","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":67,"Q_Id":49783768,"Users Score":0,"Answer":"You don't. You deploy something that can run as a process, and as such, has a capability to contact with the external world in some way (ie. listen for requests, connect to message broker, send requests, read\/write to db etc.) you do not package and deploy libraries that on their own are inoperable to the cluster.","Q_Score":0,"Tags":"python,kubernetes,openshift","A_Id":49784080,"CreationDate":"2018-04-11T20:14:00.000","Title":"Kubernetes OpenShift for python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a python script that is scheduled to run at a fixed time daily\nIf 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\nI 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?\n(I have read methods to use C code to hide it but I am only familiar with Python)\nThank you","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":656,"Q_Id":49874829,"Users Score":1,"Answer":"Compile the source to the .pyc bytecode, and then move the source somewhere inaccessible.\n\nOpen a terminal window in the directory containing your script\nRun python -m py-compile (you should get a yourfile.pyc file)\nMove somewhere secure\nyour script can now be run as python \n\nNote 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.","Q_Score":0,"Tags":"python,password-protection","A_Id":49877159,"CreationDate":"2018-04-17T09:44:00.000","Title":"Password protect a Python Script that is Scheduled to run daily","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I was doing a pi project where pi communicates with a UHF ID card reader via hardware serial and read cards. Pi gets the card information through serial and upload them to a remote database. Also some other common peripherals like LCD, RTC are connected to pi. I programmed the project with python2.\nThe project works OK. But after 15 to 30 days later program crashes with error \n\nIllegal instruction\n\n. And when this happens python2 package no longer run. If I run python2 from a terminal it throws same error and exits. Just a single line as shown above.\nCan't understand why this is happening. I searched through internet and found that in some cases some modules cause this problem which are related to CPU instructions(Though they are for PCs). But in this case it is not some module which are the source of the problem because if it was then the python interpreter should work properly.\nWhat additional tests can I do to trace the problem?\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":134,"Q_Id":49874904,"Users Score":0,"Answer":"Should upgrade to new version of python series such as python 3.7, 3.8 and 3.9, because python 2.7 will move to 3.7","Q_Score":1,"Tags":"python,raspberry-pi","A_Id":68694530,"CreationDate":"2018-04-17T09:48:00.000","Title":"Illegal instruction when running python on raspberry pi","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working in vanilla Emacs 23 on various python programs, when I evaluate a buffer, an inferior python shell is started as expected and the scripts run fine...\nThis is all fine, however, when working on multiple (unrelated) projects, the same python instance is used, is there a way I can create a new inferior python shell per source file?\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":358,"Q_Id":49886186,"Users Score":1,"Answer":"When I need a new inferior python shell in emacs and want to specify which python buffers send code to each shell I do the following. This gives me a little more control.\n\nUse the M-x rename-buffer command to set the existing inferior shell buffer name to something like *Python-otherbuff*\n\n(setq-local python-shell-buffer-name \"Python-otherbuff\") in each buffer which should interact with the old inferior shell.\n\nUse the usual command to create a new inferior python shell (e.g. C-c C-p) which will create a buffer called *Python* which all python buffers will interact with by default.","Q_Score":2,"Tags":"python,emacs","A_Id":65496992,"CreationDate":"2018-04-17T19:36:00.000","Title":"Emacs: starting a new inferior python shell when evaluating buffer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"For one test in the middle of my test suite I need to use fullReset to completely clear any data stored in an app. I don't want to set fullReset as a desired capability for the entire test run as this will significantly slow it down. After each test I tear down and restart the app. Is it possible to only trigger a fullReset on one specific test class?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":227,"Q_Id":49900096,"Users Score":1,"Answer":"Create another class for full reset in the base package and extend that class wherever you want the test to use fullReset.","Q_Score":0,"Tags":"appium,appium-ios,python-appium","A_Id":49900635,"CreationDate":"2018-04-18T12:46:00.000","Title":"Is it possible to set a desired capability (fullReset) for a single test out of many?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a server that is live right now, there is some SMTP stuff I want to change the settings.py of my Django project. I have made the changes, however, I cannot get the server to detect the changes, and it throws a SMTPAuthentication error because the settings.py is still using the old settings.\nThe server is set up with nginx, and I have tried service nginx reload several times, and apachectl restart several times. As well as deleting any *.pyc files.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2110,"Q_Id":49903923,"Users Score":3,"Answer":"nginx cannot be actually running the site, as it is not a WSGI server. Presumably it is running as a proxy to something like gunicorn or uWSGI; it is those that you need to restart.","Q_Score":3,"Tags":"python,django,nginx,uwsgi","A_Id":49903965,"CreationDate":"2018-04-18T15:47:00.000","Title":"Django settings.py not updating on production","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Another team created python scripts within our organization for my team to run. Up until two weeks ago, we all ran them without any problems. Then one day, some users have been unable to run them successfully on the same machine.\nAll users are admins with LUA disabled. All users should have the same permissions. \nThe complicating factor here is the team created a \"framework\" which generates code from a combination of the framework, and an excel file for the tests being run. This prevents me from stepping through the code and finding where it's specifically failing. Beyond that, the same exact script runs on the same machine when another user trying to run it.\nSpecifically, in the script, it appears that when the affected users are running the script, IEDriverserver doesn't appear to open. No errors are given.\nIs there any environmental variables that could be specific to users that would cause this? Even a direction to look would be extremely helpful.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":612,"Q_Id":49908242,"Users Score":0,"Answer":"I encountered the similar issue today. I happen to solve it by unset PYTHONHOME and PYTHONPATH. Not sure if this helps.","Q_Score":0,"Tags":"python-3.x,selenium,selenium-webdriver,windows-7","A_Id":61651681,"CreationDate":"2018-04-18T20:10:00.000","Title":"Python script works for one user, but not another on same machine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Another team created python scripts within our organization for my team to run. Up until two weeks ago, we all ran them without any problems. Then one day, some users have been unable to run them successfully on the same machine.\nAll users are admins with LUA disabled. All users should have the same permissions. \nThe complicating factor here is the team created a \"framework\" which generates code from a combination of the framework, and an excel file for the tests being run. This prevents me from stepping through the code and finding where it's specifically failing. Beyond that, the same exact script runs on the same machine when another user trying to run it.\nSpecifically, in the script, it appears that when the affected users are running the script, IEDriverserver doesn't appear to open. No errors are given.\nIs there any environmental variables that could be specific to users that would cause this? Even a direction to look would be extremely helpful.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":612,"Q_Id":49908242,"Users Score":0,"Answer":"Does it always fail in the same part of the Python code? Does opening the Excel file have anything to do with it, perhaps? I mean, if someone has the Excel file open on a network drive, and someone else is trying to write to the file, i'm pretty sure this will trigger an error, unless the Excel file is 'shared'. Just a couple thoughts.","Q_Score":0,"Tags":"python-3.x,selenium,selenium-webdriver,windows-7","A_Id":50203447,"CreationDate":"2018-04-18T20:10:00.000","Title":"Python script works for one user, but not another on same machine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I 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?\nShould I replace Redis with RabbitMQ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":788,"Q_Id":49930990,"Users Score":0,"Answer":"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.\nI'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).\nGood luck!","Q_Score":1,"Tags":"python,django,asynchronous,redis,celery","A_Id":49931421,"CreationDate":"2018-04-19T22:13:00.000","Title":"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","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Hi I have a Python(version 3.6) script which i developed in my laptop. But i would need to run the script from another server. I have installed the same version of Python on the server but not the modules which are imported in my script. These modules are installed on my laptop though. \nIs it possible to run the puthon script from the server without installing the imported modules in the server?\nThanks\nShanto","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2326,"Q_Id":49934177,"Users Score":0,"Answer":"I think you can use pynistaller or py2exe or any other package for converting python scripts to executable files. \nOnce executable files(.exe) files are created you can run that file without installing python modules","Q_Score":2,"Tags":"python,module,server,libraries","A_Id":50198799,"CreationDate":"2018-04-20T04:48:00.000","Title":"Is it possible to run python script from another machine without installing imported modules?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Today I went from Windows 7 to Windows 10, and sadly I meet troubles with Sublime Text which is my main text editor. (my main specs are Intel Core i7, 8 GBRAM, 500 GB SSD on a laptop Dell XPS 14 L421x)\nRunning python in Spider is extremely fast (<1s). But in Sublime Text 3, just importing numpy, matplotlib and scipy takes up to 4 secondes. I really don't understand what is going on. I installed the last version of python 3.6.5 through Anaconda. I tested the same version on a Windows 7 computer and it does not have this issue (~1.5s for just the import).\nWould you have any clue about what is going on? Thank you!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":61,"Q_Id":49934424,"Users Score":0,"Answer":"I found the problem, it is just because my account was not Administrator of Windows. I don't know why dip down, but it solved the situation.","Q_Score":0,"Tags":"python,windows-10,sublimetext3","A_Id":49951255,"CreationDate":"2018-04-20T05:12:00.000","Title":"Import python packages slower on Windows 10 in Sublime Text","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to crawl IMDB and download the trailers of movies (either from YouTube or IMDB) that fit some criteria (e.g.: released this year, with a rating above 2). \nI want to do this in Python - I saw that there were packages for crawling IMDB and downloading YouTube videos. The thing is, my current plan is to crawl IMDB and then search youtube for '$movie_name' + 'trailer' and hope that the top result is the trailer, and then download it.\nStill, this seems a bit convoluted and I was wondering if there was perhaps an easier way. \nAny help would be appreciated.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1369,"Q_Id":49957297,"Users Score":0,"Answer":"There is no easier way. I doubt IMDB allows people to scrap their website freely so your IP is probably gonna get blacklisted and to counter that you'll need proxies. Good luck and scrape respectfully.\nEDIT: Please take a look at @pds's answer below. My answer is no longer valid.","Q_Score":0,"Tags":"python,youtube,web-crawler","A_Id":49957379,"CreationDate":"2018-04-21T15:23:00.000","Title":"Crawling IMDB for movie trailers?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can we use Two amazon lambda functions for one lex bot if one lambda function in python and other in node.js?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":506,"Q_Id":49980575,"Users Score":0,"Answer":"you can have two lambda functions for two different intents. You cannot have two lambda functions for the same intent","Q_Score":0,"Tags":"python,machine-learning,aws-lambda,chatbot,amazon-lex","A_Id":49984458,"CreationDate":"2018-04-23T11:59:00.000","Title":"Two amazon lambda functions for one lex bot","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm creating an image detection module, and I do a lot of math calculations around arrays.\nI know that C\/C++\u2019s array iterates faster than Python\u2019s\nI can't move my project to C\/C++, so I wanted to create an array module in C\/C++ and call it in Python.\nWhat I want to know:\n1) Is this viable? Or calling a module from another interpreter will slow down my program more than it will speed it up?\n2) Is there some Python package that does what I want?\nI feel like I haven\u2019t written enough info, but I can't think of anything else important.\n[EDIT] So I just went with numpy and it has everything I need :p, thanks everyone","AnswerCount":4,"Available Count":2,"Score":0.1488850336,"is_accepted":false,"ViewCount":111,"Q_Id":49984220,"Users Score":3,"Answer":"Both the array and the low level operations on it would have to be in C++; switching on a per element basis will have little benefit.\nThere are many python modules that have internal C\/C++ implementations. Simply wrapping a C or C++ style array would be pointless, as the built in python data types can basically be that.","Q_Score":0,"Tags":"python,c++,c,arrays","A_Id":49984333,"CreationDate":"2018-04-23T15:01:00.000","Title":"C++ Vector in Python for Perfomance","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm creating an image detection module, and I do a lot of math calculations around arrays.\nI know that C\/C++\u2019s array iterates faster than Python\u2019s\nI can't move my project to C\/C++, so I wanted to create an array module in C\/C++ and call it in Python.\nWhat I want to know:\n1) Is this viable? Or calling a module from another interpreter will slow down my program more than it will speed it up?\n2) Is there some Python package that does what I want?\nI feel like I haven\u2019t written enough info, but I can't think of anything else important.\n[EDIT] So I just went with numpy and it has everything I need :p, thanks everyone","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":111,"Q_Id":49984220,"Users Score":0,"Answer":"Try boost.python.\nIf you can port all the computational heavy stuff to C++, it'll be quite fast but if you need to switch continuously between C++ and python, you won't get much improvement.","Q_Score":0,"Tags":"python,c++,c,arrays","A_Id":49984679,"CreationDate":"2018-04-23T15:01:00.000","Title":"C++ Vector in Python for Perfomance","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Currently, we need a interpolation in a Image. I have used the scipy.misc.imresize. This function has two drawback:\n\nit can only output interger matrix, but I need a float result. \nthe speed of scipy.misc.imresize is a little slow","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":259,"Q_Id":49998519,"Users Score":0,"Answer":"cv2.resize is slightly faster than scipy.misc.imresize","Q_Score":0,"Tags":"python,image,performance,interpolation","A_Id":52720246,"CreationDate":"2018-04-24T09:50:00.000","Title":"which imresize is fastest in Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"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:\ntelethon.errors.rpc_error_list.FloodWaitError: A wait of 101 seconds is required\nAny idea how I can import all list without waiting?? Thanks!!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":287,"Q_Id":50012489,"Users Score":0,"Answer":"You can not import a large number of people in sequential. \u064fThe telegram finds you're sperm.\nAs a result, you must use \u200dsleep between your requests","Q_Score":0,"Tags":"python,csv,telegram,telethon","A_Id":50310718,"CreationDate":"2018-04-25T00:38:00.000","Title":"can't import more than 50 contacts from csv file to telegram using Python3","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using pytest to test my app.\npytest supports 2 approaches (that I'm aware of) of how to write tests:\n\nIn classes:\n\n\ntest_feature.py -> class TestFeature -> def test_feature_sanity\n\n\nIn functions:\n\n\ntest_feature.py -> def test_feature_sanity\n\nIs the approach of grouping tests in a class needed? Is it allowed to backport unittest builtin module?\nWhich approach would you say is better and why?","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":39428,"Q_Id":50016862,"Users Score":57,"Answer":"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).\nI 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.","Q_Score":59,"Tags":"python,pytest","A_Id":50028551,"CreationDate":"2018-04-25T07:54:00.000","Title":"Grouping tests in pytest: Classes vs plain functions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using pytest to test my app.\npytest supports 2 approaches (that I'm aware of) of how to write tests:\n\nIn classes:\n\n\ntest_feature.py -> class TestFeature -> def test_feature_sanity\n\n\nIn functions:\n\n\ntest_feature.py -> def test_feature_sanity\n\nIs the approach of grouping tests in a class needed? Is it allowed to backport unittest builtin module?\nWhich approach would you say is better and why?","AnswerCount":4,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":39428,"Q_Id":50016862,"Users Score":20,"Answer":"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:\n\nPut all tests for each function in a dedicated module\nPut all tests for each function in a class\n\nIn 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.\nThe result is one source function maps to one test module, and one source module maps to one test package.\nIn 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).\nIt 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.\nFinally, 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.","Q_Score":59,"Tags":"python,pytest","A_Id":57532692,"CreationDate":"2018-04-25T07:54:00.000","Title":"Grouping tests in pytest: Classes vs plain functions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using tweepy to get tweets pertaining to a certain hashtag(s) and then I send them to a certain black box for some processing. However, tweets containing any URL should not be sent. What would be the most appropriate way of removing any such tweets?","AnswerCount":3,"Available Count":1,"Score":0.3215127375,"is_accepted":false,"ViewCount":1195,"Q_Id":50044690,"Users Score":5,"Answer":"In your query add -filter:links.\nThis will exclude tweets containing urls.","Q_Score":1,"Tags":"python,twitter,tweepy","A_Id":50048998,"CreationDate":"2018-04-26T13:47:00.000","Title":"How do I filter out tweets containing any URL?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was wondering if there was a way to create an instance without a Key-Pair for testing purposes.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":225,"Q_Id":50047929,"Users Score":0,"Answer":"You can create an instannce without keypair however you will not be able to ssh into it or you can start it with ssm agent installed and running and use ec2 ssm service to send shell commands.","Q_Score":0,"Tags":"python,boto3","A_Id":50048241,"CreationDate":"2018-04-26T16:28:00.000","Title":"Boto3 Create Instance without a Key-Pair","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm actually aware that I can get the address which the email is sent from, but I wonder if I can get the user name of de sender too. I searched on the email module documentation but I didn't find anything about it.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":24,"Q_Id":50063795,"Users Score":0,"Answer":"Short answer: no, you can't.\nUsername of the sender remains between the SMTP server and the sender; it's never included in the data sent outside, unless the sender explicitly typed it into the email text. Note that there can be several hops between the originating SMTP server and the receiving SMTP server.\nIMAP servers are used to access received mail; they have no idea how it was sent.","Q_Score":0,"Tags":"python,email","A_Id":50066623,"CreationDate":"2018-04-27T13:47:00.000","Title":"Is there anyway I can get user name from a MIME object in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am 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.\nIn 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.\n\nWhat is the benefit \/ reason for having the whole code base served through lambdas as opposed to individual functions?\nIs there an execution time penalty if using flask\/django\/whatever else with serverless apps? \nIf this depends on the particular project, what would be the guidance when to use framework, and when to use individual functions?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":596,"Q_Id":50080592,"Users Score":0,"Answer":"Benefits. You can use known concept, and adopt it in serverless.\nPerformance. 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.\nLet'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? \n\nServerless 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.","Q_Score":3,"Tags":"python,python-3.x,aws-lambda","A_Id":50080743,"CreationDate":"2018-04-28T20:06:00.000","Title":"Why use zappa\/chalice in serverless python apps?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"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.\nDoes anyone know how I can accomplish that!?\nTks","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1106,"Q_Id":50110748,"Users Score":2,"Answer":"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.\nIn 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.","Q_Score":1,"Tags":"python,jwt,hmac","A_Id":51356271,"CreationDate":"2018-05-01T02:43:00.000","Title":"How to calculate the HMAC(hsa256) of a text using a public certificate (.pem) as key","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am a novice python user and I use Atom to code in python. Sometimes, I use python 'os' module to get the working directory and in some cases, I have to navigate through directory\/folders to get to where I want the code to run. e.g. say my starting working directory is \"C:\\Users\\XYZ\" and I want to change directory to some folder named \"ABC\" in some directory path under D:. Currently, I have to open an explorer window to figure out where the 'ABC' folder is and then copy paste the directory in Atom and swap '\\' with '\\' and use os.chdir function. Is there an easier way or some Atom package where I press the first letter of the folder and it gives me autocomplete suggestions? I tried os.listdir() but copy paste using that is too cumbersome. I know that I can just create my file in that directory to start with but I want to learn if I can navigate through folders the way using autocomplete suggestions.\nAny help would be great.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":479,"Q_Id":50137099,"Users Score":0,"Answer":"This is not exactly what you want but may help you. There is an Atom extension \"platformio-ide-terminal\" which when run will open a regular bash shell at the bottom of your Atom window. Using this you can easily move around your directories using unix commands. Hope this helps some.","Q_Score":0,"Tags":"python,python-3.x,ide,intellisense,atom-editor","A_Id":50142286,"CreationDate":"2018-05-02T14:26:00.000","Title":"Autocomplete directory\/folder path in Atom (for python)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to leave a script running on an EC2 instance after I close the SSH client. The script is running on an activated tensorflow_p36 virtual anaconda environment.\nI have tried to use screen and tmux but to no avail ( I issue these commands when the venv is active). I get a ModuleNotFoundError: No module named 'tensorflow' even though when I try conda env list I see that I'm using the tensorflow_p36 environment.\nDo you have any ideas?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":319,"Q_Id":50142626,"Users Score":1,"Answer":"Have you tried using nohup {your command} &? \nThis has previously worked for me.","Q_Score":0,"Tags":"python,tensorflow,amazon-ec2,ssh,anaconda","A_Id":50142728,"CreationDate":"2018-05-02T20:00:00.000","Title":"Leave a tensorflow (anaconda venv) script running on EC2 instance","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to compile a old VS2010 project in VS2015 with boost.python 1_67_0 from 1_53 and python 35.\nGetting it compile was not too hard, just a few tweaks to include path and updating a couple of python 2 string handling to python 3. \nBut I am stuck on linking because the linker fails at:\nLINK : fatal error LNK1104: cannot open file 'boost_python-vc100-mt-gd-1_67.lib'\nWhich really does not make sense because the library version should be vc140. In the library path there does exist libboost_python35-vc140-mt-gd-x32-1_67.lib and a few others libboost_python35-vc140* options.\nWhere is it getting the name 'boost_python-vc100-mt-gd-1_67.lib' from? (i.e. is this something I missed in the configuration?)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":206,"Q_Id":50144712,"Users Score":0,"Answer":"Under Visual Studio Boost uses boost\/configure\/auto_link.hpp to generate the library names and add them to the linker's dependencies. One of the arguments to this bit of code is BOOST_LIB_NAME which for boost::python is defined in boost\/python\/detail\/config.hpp. In version 1_67_0 this is currently: \n#define BOOST_LIB_NAME boost_python##PY_MAJOR_VERSION##PY_MINOR_VERSION\nWhere the python patchlevel.h has the definitions for PY_MAJOR_VERSION and PY_MINOR_VERSION.\nThis means that the library name itself does not need to explicitly added to the your Visual Studio project. Just the path to the boost libraries directory.\nFor me I needed to remove any (boost) library names from: \n\nConfiguration Properties > Linker > Input > Additional Dependencies\nConfiguration Properties > Linker > All Options > Additional Dependencies\n\nAnd needed to ensure that I built boost::python with the shared (dll) libraries since I would building a DLL. The static libraries are libboost*.lib and the shared libraries are boost*.lib. To force the generation of the shared libraries I used:\nC:\\dev\\boost\\boost_1_67_0> b2.exe link=shared,static --with-python -a","Q_Score":0,"Tags":"c++,boost-python,programmers-notepad","A_Id":50219742,"CreationDate":"2018-05-02T23:00:00.000","Title":"VisualStudio 2015 linker looking for VS 2010 library","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a device which is sending packet with its own specific construction (header, data, crc) through its ethernet port.\nWhat I would like to do is to communicate with this device using a Raspberry and Python 3.x.\nI 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.\nBut now I would like to read incoming raw packet sent by the device and store it somewhere on my RPI to use it later.\nI 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.\nWhat 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.\nThanks,\nAlban","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":914,"Q_Id":50151655,"Users Score":0,"Answer":"Did you try using ettercap package (ettercap-graphical)? \nIt should be available with apt. \nAlternatively you can try using TCPDump (Java tool) or even check ip tables","Q_Score":2,"Tags":"python,linux,sockets,raspberry-pi,ethernet","A_Id":50182669,"CreationDate":"2018-05-03T09:34:00.000","Title":"Read raw ethernet packet using python on Raspberry","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Sometimes I resort to using ipdb for debugging a Python script, which has a very nice autocomplete feature.\nThe problem is, the script usually runs through a shell pipeline that processes its output (for instance python script.py |& tee \"stdout.txt\").\nTo me it seems like there is no answer to this (either live without autocomplete, or disable the stdout piping).\nMy question is made up of two parts: \n\nIs there any way to have both autocomplete and stdout processing?\nIf not, exactly why not?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":238,"Q_Id":50177948,"Users Score":0,"Answer":"In the end I worked around this by avoiding shell pipes, and writing the output file from Python itself. \nI can watch the file change live using less +F.\nI guess I was asking for too much interactivity from L\/Unix pipes.","Q_Score":2,"Tags":"shell,autocomplete,pipe,ipython,ipdb","A_Id":59560248,"CreationDate":"2018-05-04T15:04:00.000","Title":"Tab completion in ipdb not working when output is processed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm 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:\nContract:\n\npragma solidity ^0.4.0;\n\ncontract test {\n function test(){\n\n }\n\n function return_true() public returns (bool) {\n return true;\n }\n\n function return_address() public returns (address) {\n return 0x111111111111111111111111111111111111111;\n }\n}\n\nPython unittest code\n\nfrom web3 import Web3, EthereumTesterProvider\nfrom solc import compile_source\nfrom web3.contract import ConciseContract\nimport unittest\nimport os\n\n\ndef get_contract_source(file_name):\n with open(file_name) as f:\n return f.read()\n\n\nclass TestContract(unittest.TestCase):\n CONTRACT_FILE_PATH = \"test.sol\"\n DEFAULT_PROPOSAL_ADDRESS = \"0x1111111111111111111111111111111111111111\"\n\n def setUp(self):\n # copied from https:\/\/github.com\/ethereum\/web3.py\/tree\/1802e0f6c7871d921e6c5f6e43db6bf2ef06d8d1 with MIT licence\n # has slight modifications to work with this unittest\n contract_source_code = get_contract_source(self.CONTRACT_FILE_PATH)\n compiled_sol = compile_source(contract_source_code) # Compiled source code\n contract_interface = compiled_sol[':test']\n # web3.py instance\n self.w3 = Web3(EthereumTesterProvider())\n # Instantiate and deploy contract\n self.contract = self.w3.eth.contract(abi=contract_interface['abi'], bytecode=contract_interface['bin'])\n # Get transaction hash from deployed contract\n tx_hash = self.contract.constructor().transact({'from': self.w3.eth.accounts[0]})\n # Get tx receipt to get contract address\n tx_receipt = self.w3.eth.getTransactionReceipt(tx_hash)\n self.contract_address = tx_receipt['contractAddress']\n # Contract instance in concise mode\n abi = contract_interface['abi']\n self.contract_instance = self.w3.eth.contract(address=self.contract_address, abi=abi,\n ContractFactoryClass=ConciseContract)\n\n def test_return_true_with_gas(self):\n # Fails with HexBytes('0xd302f7841b5d7c1b6dcff6fca0cd039666dbd0cba6e8827e72edb4d06bbab38f') != True\n self.assertEqual(True, self.contract_instance.return_true(transact={\"from\": self.w3.eth.accounts[0]}))\n\n def test_return_true_no_gas(self):\n # passes\n self.assertEqual(True, self.contract_instance.return_true())\n\n def test_return_address(self):\n # fails with AssertionError: '0x1111111111111111111111111111111111111111' != '0x0111111111111111111111111111111111111111'\n self.assertEqual(self.DEFAULT_PROPOSAL_ADDRESS, self.contract_instance.return_address())\n\nI 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.\n\nWhy does calling return_true with transact={\"from\": self.w3.eth.accounts[0]} cause the return value of the function to be HexBytes(...)?\nWhy does the address returned by return_address differ from what I expect?\n\nI think I have some sort of fundamental misunderstanding of how gas affects function calls.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":792,"Q_Id":50194364,"Users Score":2,"Answer":"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.\nDiscounting 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.\n\nOfftopic, 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.\nEDIT\nForgot 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.\nI hope it helps!","Q_Score":0,"Tags":"python,ethereum,solidity,web3","A_Id":58494505,"CreationDate":"2018-05-05T21:56:00.000","Title":"Unintuitive solidity contract return values in ethereum python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"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? \nIf so, is it a built-in function?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1347,"Q_Id":50204638,"Users Score":1,"Answer":"Retries are not a feature of gRPC Python at this time.","Q_Score":4,"Tags":"python,grpc","A_Id":50340007,"CreationDate":"2018-05-06T21:22:00.000","Title":"Does gRPC have the ability to add a maximum retry for call?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Pipenv seems to work only in the directory where the Pipfile lives. Maybe I'm trying to use it in a way it is not designed for.\nFor example, I installed a tool called \"leo\" (an editor) and no surprise that I will go to many folders and start pipenv run Leo and it will start to install another virtual environment. What's the workaround?","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":10256,"Q_Id":50205311,"Users Score":1,"Answer":"It's really hard to google this but I found the best solution.\nTo easily activate a virtual environment anywhere with pipenv, you can use pew.\nOnce you pip install pew, you can easily do \"pew workon myvenv\".\nPew uses pipenv under the hood and it works on Windows too.","Q_Score":15,"Tags":"python,virtualenv,pipenv","A_Id":50288075,"CreationDate":"2018-05-06T23:05:00.000","Title":"pipenv: only works in a installed folder?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm aware of the Run Keyword and Continue on Failure \/ Run Keyword And Ignore Error \/ Run keyword and return status Builtin keywords but I have a very wide set of test cases that should not be stopped for any reason on a specific scenario and I was wondering if there is an option not to make the execution stop on a failure by default, without having to manage it through these keywords and adding a non-business related syntax in my upper layer keywords.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2227,"Q_Id":50227900,"Users Score":1,"Answer":"Although it feels a bit counter intuitive that you should want to continue when you've encountered an erronous situation, given that you may no longer be in control of the application. This in itself should be prevented. However, that said. \nGiven that you are already familiar with the family of Run and continue keywords, there is not much else to suggest and to answer the question with an affirmative: No. \nThe only approach is to wrap the keywords in a Run and Continue keyword.","Q_Score":0,"Tags":"python,testing,automated-tests,robotframework,atdd","A_Id":50230159,"CreationDate":"2018-05-08T07:11:00.000","Title":"Is there a way to configure Robot Framework so the execution is not stopped by a failure","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We have a service running on Tornado, it is written asynchronously. I suspect that somewhere in the code there is a blocking call that hurts performance.\nIs there a way in Tornado to find this code section \/ function call? \nOr can I find code that holds the IOLoop longer than X ms?\nThanks\nAlex","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":211,"Q_Id":50257066,"Users Score":3,"Answer":"In Python 3+ and Tornado 5+, set the environment variable PYTHONASYNCIODEBUG=1. In older versions of either Tornado or Python, call IOLoop.current().set_blocking_log_threshold(0.5).\nEither way, this will cause a message to be logged whenever a call blocks for more than half a second.","Q_Score":2,"Tags":"python,tornado","A_Id":50257492,"CreationDate":"2018-05-09T15:31:00.000","Title":"How can I find a blocking call inside Tornado webserver?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Perhaps this is a broad question, but I haven't found an answer elsewhere, so here goes.\nThe Python script I'm writing needs to run constantly (in a perfect world, I recognize this may not be exactly possible) on a deployed device. I've already dedicated time to adding \"try...except\" statements throughout so that, should an issue arise, the script will recover and continue to work.\nThe issue is that I'm not sure I can (nor should) handle every single possible exception that may be thrown. As such, I've decided it may be better to allow the script to die and to use systemd to restart it.\nThe three options:\n\nMaking no attempt to handle any exception, and just allowing systemd to restart it whenever it dies.\nMeticulously creating handlers for every possible exception to guarantee that, short of loss of power, interpreter bug, or heat death of the universe, the script will always run.\nA mix of the two -- making an effort to prevent crashes in some cases while allowing them in others and letting systemd restart the script.\n\nThe third choice seems the most reasonable to me. So the question is this: What factors should be considered when optimizing between \"crash-proof\" code and allowing a crash and restart by systemd?\nFor some more application specific information: there is a small but noticeable overhead involved with starting the script, the main portion will run between 50 to 100 times per second, it is not \"mission critical\" in that there will be no death\/damage in the event of failure (just some data loss), and I already expect intermittent issues with the network it will be on.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":47,"Q_Id":50262750,"Users Score":1,"Answer":"All known exceptional cases should be handled. Any undefined behavior is a potential security issue. \nAs you suggest, it is also prudent to plan for unknown exceptions. Perhaps there's also a small memory leak that will also cause the application to crash even when it's running correctly. So, it's still prudent to have systemd automatically restart it if it fails, even when all expected failure modes have been handled.","Q_Score":0,"Tags":"python,exception-handling,crash,systemd","A_Id":50263853,"CreationDate":"2018-05-09T22:08:00.000","Title":"\"Crash-proofing\" script vs.using systemd to guarantee near-constant operation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm using PyDotnet to expose a .Net library in Python. I've hit a snag where I need to call a generic method, but can't figure out the syntax or if it's simply not support.\ne.g.\npublic T DoSomething(T myData) { .... }\nHow would I call this from Python?\n\nUpdate:\nThat is the correct syntax, thanks. However, in my case I get an exception trying to call the method with the type. I'm not sure what I'm doing wrong. I'm using that syntax but am getting an exception.\nThe .NET method declaration looks like:\npublic T SpliceSeries(\n T lowPriorityTimeSeries, \n T highPriorityTimeSeries)\n where T : UserScripting.TimeSeries\nIn python I'm calling it as follows:\nmyInstance.SpliceSeries[DerivedTimeSeriesType](myarg1, myarg2)\nNB where myarg1 & 2 are of type DerivedTimeSeriesType, which is .NET class derived from UserScripting.TimeSeries.\nThe exception is:\nException: System.Runtime.InteropServices.SEHException (0x80004005): External component has thrown an exception. at InteropPython.throw_invalid_cast(basic_string\\,std::allocator > ) at InteropPython.DynamicCallableInstance.Invoke(DynamicCallableInstance , object , tuple args)\nIs there anything I can do to debug this under the hood?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":109,"Q_Id":50271422,"Users Score":0,"Answer":"I'm not sure but I think generics are supported through [] syntax,\nDoSomething[T]","Q_Score":0,"Tags":"c#,python,generics","A_Id":50368810,"CreationDate":"2018-05-10T11:02:00.000","Title":"PyDotNet call generic method from Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"The default version of python installed on my mac is python 2. I also have python 3 installed but can't install python 2.\nI'd like to configure Hyrdrogen on Atom to run my script using python 3 instead.\nDoes anybody know how to do this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4266,"Q_Id":50304519,"Users Score":0,"Answer":"I used jupyter kernelspec list and I found 2 kernels available, one for python2 and another for python3\nSo I pasted python3 kernel folder in the same directory where python2 ken=rnel is installed and removed python2 kernel using 'rm -rf python2'","Q_Score":3,"Tags":"python,python-3.x,jupyter,atom-editor,hydrogen","A_Id":56453522,"CreationDate":"2018-05-12T09:01:00.000","Title":"Using Hydrogen with Python 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a python program which features a C++ core python wrapped. It's written in parallel as it is computationally very expensive and I'm currently making it run on a server in remote on a Ubuntu 16.04 platform.\nThe problem I'm experiencing is that, at a certain number of cycles (let's say 2000) for my test case, it freezes abruptly without giving error messages or anything. I detected the part of the code where it stops and is a python function which doesn't feature any for cycle (so I assume it's not stuck into a loop). I tried to simply comment the function where it gets stuck out of the code, as it does minor calculations and now, at the exact same number of cycles, it gets stuck a little bit ahead, this time inside the C++ written part. I'm starting to assume that a possibility is some memory problem related to the server. \nDoing htop from terminal when the code is stuck I can see the units involved in the computation are fully loaded as they are currently involved in some unknown calculations. Moreover, the memory involved in the process (at least when the process is already stuck) is not fully occupied so it may not be a RAM problem neither. \nI also tried to reduce drastically the number of output written at every cycle (which, I admit, where consistent in size) but nothing. With the optimum number of processors it takes like 20 minutes to get to the critical point of 2000 cycles so the problem is not easy reproducible.\nIt is the first time I'm experiencing these sort of problems, Is there anything else I can do to highlight the issue?\nThanks for the answer","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":48,"Q_Id":50307008,"Users Score":1,"Answer":"Here is something you could try.\nWrite a code which checks which iterations is taking place and store all the variables at the start of the 2000th iteration.\nThen use the same variable set to run the iteration again. \nIt won't solve your problem, but it will help in reducing the testing time, and consequently the time it takes for you to find the problem.\nIf it is definitely a memory issue, the code will not get stuck at 2000 (That's where you start) but will get stuck at 4000.\nThen you can monitor memory at 2000th iteration and replicate that.","Q_Score":0,"Tags":"python,c++,memory,server,freeze","A_Id":50307173,"CreationDate":"2018-05-12T13:58:00.000","Title":"Parallel Python-C++ program freezes (memory?)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python3 script that reads non ascii text files, makes modifications and writes them back. I can launch that script from Atom with Package\u2192Script\u2192Run Script menu command and python3 complains that input text files are not Ascii:\nUnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 37: ordinal not in range(128)\nBut when I copy the very command used by Atom (the first line in the output pane) into the terminal, then everything works as expected and all the files are processed correctly.\nHow can I tell Atom to not restrict python3 to ascii?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":435,"Q_Id":50308426,"Users Score":1,"Answer":"The problem is that when launched from Atom's script package, python does not inherit the system context.\nOne solution is to create a profile from menu Packages\u2192Script\u2192Configure script for which the environment variable field reads for example LANG=fr_FR.UTF-8, what is important is the UTF-8 part.","Q_Score":0,"Tags":"python-3.x,atom-editor,non-ascii-characters","A_Id":50313900,"CreationDate":"2018-05-12T16:30:00.000","Title":"configure python3 in Atom for non ascii files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"The official Python documentation explains ord(c) \n\nord(c):\n Given a string representing one Unicode character, return an integer representing the Unicode code point of that character. For example, ord('a') returns the integer 97 and ord('\u20ac') (Euro sign) returns 8364. This is the inverse of chr().\n\nIt does not specify the meaning of ord, google searches are not helpful.\nWhat's the origin of it?","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":7187,"Q_Id":50314440,"Users Score":4,"Answer":"Return the integer ordinal of a one-character string.\nI took this from ord.doc in python command line. ord meaning ordinal of a one character.","Q_Score":26,"Tags":"python,unicode,built-in,ordinal,ord","A_Id":57918743,"CreationDate":"2018-05-13T08:58:00.000","Title":"What does the name of the ord() function stand for?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm creating a discord bot, and I want to add it to group DM's so I can keep my server levels lower. However, you can't add people who aren't friends to group DM's. Is there a way to get a discord bot to accept friend requests?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":7073,"Q_Id":50337904,"Users Score":6,"Answer":"Not possible. Bot accounts do not have permission to use Discord's relationships endpoint. This means no friending and no blocking, and by extension means no bots in group DMs.","Q_Score":2,"Tags":"python,discord.py","A_Id":50338842,"CreationDate":"2018-05-14T19:44:00.000","Title":"How to make a discord bot add you as friend","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have some modbus TCP code written under pymodbus 1.2\nthe relevent code was\nresult = modbus_client.read_holding_registers(40093, 3)\nAfter updating to pymodbus 1.4.0 it wouldn't work until I cargo culted the new unit parameter into the function call (teh examples all had unit=1 in\nthem):\nresult = modbus_client.read_holding_registers(40093, 3, unit=1)\nwhat does the unit parameter in pymodbus read_ holding_registers() mean?\nI can't seem to find an explanation anywhere.\nThe source says \":param unit: The slave unit this request is targeting\",\nbut I don't understand what this means, nor what selection other than 1 might be used.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1866,"Q_Id":50359986,"Users Score":6,"Answer":"The Modbus protocol was originally developed long before TCP\/IP was popular (late 70s I think). It was used on serial connections mostly. Some serial hardware protocols like RS485 allow daisy-chaining. The modbus master (in your case Python) can poll many slaves on a single serial port. Only the slave that was requested will respond. The address of the slave is the Unit in this case. Once Modbus was adapted to TCP\/IP, the protocol allowed this \"unit address\" to be used to create multiple slaves behind a single IP address. Most of the time, if using TCP\/IP there is a single address of 1. On Wikipedia they refer to this as \"Station address.\"\nI'm not sure why you would need to include this in the call to the method since it is a kwarg that is defaulted to 1 anyway.","Q_Score":5,"Tags":"python,modbus,modbus-tcp,pymodbus","A_Id":50360335,"CreationDate":"2018-05-15T22:25:00.000","Title":"What does the pymodbus \"unit\" parameter mean?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am building a notification model with Redis as database. With every addition to a particular key in the database, I notify the remote client(written with Redis-py) using Redis's pubsub feature and also a HTTP based notification. \nWhile running performance test and comparing the times between Redis PUBSUB notification and HTTP Response are fairly close( redis still being faster than HTTP by a few ms. Example. Redis notification takes 47 ms and HTTP notification takes 56 ms). \nI was assuming Redis PUBSUB would be much faster than HTTP. Is this the expected performance of redis notification over HTTP ? Is there a faster way to push notifications from Redis db (faster than HTTP)?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1261,"Q_Id":50360981,"Users Score":0,"Answer":"What is your ping to client instance? If underlying network is slow, there is nothing much you can do. Only switch to UDP custom protocol. Because expected performance of Redis PUBSUB is about 4k op\/s with regular hardware. Also what is the message size you are transferring? If it is high, you're also bound to your network speed.","Q_Score":0,"Tags":"python,http,testing,redis,notifications","A_Id":50368728,"CreationDate":"2018-05-16T00:46:00.000","Title":"Redis Pubsub performance for remote clients","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How do I turn my python turtle script to .exe? I tried py2exe and it did execute my script but the cmd showed up for like 1 milisecond. I think it is because I am using turtle graphics instead of normal python script. Is there any way to turn my turtle program into .exe?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":819,"Q_Id":50370233,"Users Score":1,"Answer":"Use done() or exitonclick() for the last command","Q_Score":0,"Tags":"python,python-3.x,py2exe,turtle-graphics","A_Id":50370355,"CreationDate":"2018-05-16T11:53:00.000","Title":"How to turn Python Turtle to .exe","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to execute a python file coded for Graphical user Interface using pyqt modules using ssh. It gives me a message \nX11 connection rejected because of wrong authentication.\nQXcbConnection: Could not connect to display localhost:10.0\nI tried several ways checking for the x11 forwarding etc etc.Nothing seems to work. Please help me out.\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1490,"Q_Id":50372055,"Users Score":0,"Answer":"ssh by default does not forward the X session, so your program on will try to open its window on the remote host (where it will be rejected in most cases because the X server on the remote host is either not running at all (e. g. if it is a headless server) or because it isn't configured to display the stuff. And even if it would accept the window of your application, it would display it on the remote host's display, not on your local one. So that wouldn't be what you want either.\nTry ssh -X \u2026 when starting your application via ssh. This will tell ssh to forward the X session so that your application on the remote host will send its window back to the X server running on your local machine which it will be accepted and displayed.","Q_Score":1,"Tags":"python,python-2.7,ssh,pyqt5","A_Id":50372449,"CreationDate":"2018-05-16T13:18:00.000","Title":"Executing pyqt files through ssh","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently working with IBMi. I want an automatic mail after completing few jobs for confirmation. How can I achieve this? I can run Python in my system.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":321,"Q_Id":50372456,"Users Score":3,"Answer":"IBM has built in commands depending on your OS release. They do require setting up the IBM SMTP server. SNDSMTPEMM and SNDDST are the most used.\nThere are also third party products like my MAILTOOL software (www.bvstools.com\/mailtool.html) that makes interacting with cloud servers like Office 365 and Gmail much easier than then IBM SMTP server.\nPHP may also have some built in email capabilities as well as python. But if you're looking for a command line interface after running jobs the first two are probably your best bet, depending on if you want to set up the IBM SMTP server or not.","Q_Score":1,"Tags":"python-3.x,ibm-midrange","A_Id":50372734,"CreationDate":"2018-05-16T13:37:00.000","Title":"How to automate mail in IBM i system","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"In order to manage all my python paths for my project and have them available as soon as I start python interpreter, I created a project.pth in the project home directory having relative paths in it,\nActually, to be read, I need to do a site.addsitedir(my_project_home_dir) each time I start the interpreter. \nI tried setting PYTHONPATH or create a .pth in site-packages pointing to my project home directory, but project.pth is still not read automatically when I start the interpreter.\nThe only thing that works is to put my project.pth in site-packages, but by doing that, I have to transform my project relative paths to absolute paths.\nSo it there a master .pth file where I can specify my project home directory so I can have my project.pth located in that directory to be read automatically ?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":270,"Q_Id":50373834,"Users Score":0,"Answer":"Finally I found 2 ways : \n1) First, note that .pth files also accept lines beginning with 'import' and execute them. So the solution was to create project.pth inside site-packages importing a module in my project home dir that do actually the site.addsitedir()\n2) Other possibility : use the environment variable PYTHONSTARTUP : it will execute any module you want at python startup. You can specify a module that do the site.addsitedir() or even directly add paths into sys.path","Q_Score":0,"Tags":"python","A_Id":50405275,"CreationDate":"2018-05-16T14:40:00.000","Title":"Is possible to add a python site directory permanently?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I don't want to check if it has Internet connectivity! I just want to check if it's connected to the WiFi network (I'd have already given its SSID in the WPA_supplicant file).. This network won't have Internet access.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":19922,"Q_Id":50388069,"Users Score":0,"Answer":"t=\"$(ifconfig wlan0 | awk '\/inet addr\/{print substr($2,6)}')\"\necho $t\nw=${#t}\necho $w\ni run this code output comes 0.\nif i am running simple is command\nt=\"$(ifconfig wlan0 | awk '\/inet addr\/{print substr($2,6)}')\" echo $t w=${#t} echo $w\noutput comes like w=0 echo","Q_Score":2,"Tags":"python,python-3.x,raspberry-pi,wifi,raspbian","A_Id":68903032,"CreationDate":"2018-05-17T09:33:00.000","Title":"Check status if Raspberry Pi is connected to any WiFi network (Not Internet necessarily) using Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using a pi3 which talks to an arduino via serial0 (ttyAMA0)\nIt 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.\nCan 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)\nI have googled around for answers but most hits are about using multiple serial ports or getting a serial port to work at all.\nCheers","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":68,"Q_Id":50404863,"Users Score":1,"Answer":"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\n\nwhen a local process puts a message on the serial port everyone can\nsee it and it gets sent to remote. \nwhen a remote message arrives on\nserial, the first local process to get it, gets it. The others\ncan't see it. \nfor some reason, minicom has privilege over arriving\nmessages. This is why two minicoms break the message.","Q_Score":0,"Tags":"python,serial-port,raspberry-pi3","A_Id":50575853,"CreationDate":"2018-05-18T06:14:00.000","Title":"basic serial port contention","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've searched everywhere for a solution to this problem but I haven't found it yet. \nI know that Autodesk Inventor can be automated with Python using win32com package by:\nwin32com.client.Dispatch(\"Inventor.Application\")\nHowever I can't find the \"prodID\" that is needed to use this package with Fusion 360 and no documentation for automation ever being done this way with this package.\nI need to be able to control a range of other processes so it would be ideal if I could use Python to launch Fusion 360 and perform operations without having to load the script within the application itself. Any help would be appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":302,"Q_Id":50411526,"Users Score":0,"Answer":"The Fusion 360 API is not a COM API so it's not possible to use win32com to drive it. To use the API, your program must be either an add-in or script running from within Fusion 360.","Q_Score":0,"Tags":"python,api,win32com,autodesk,fusion360","A_Id":51386354,"CreationDate":"2018-05-18T12:37:00.000","Title":"Python to Automate Fusion 360 with COM","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Odroid running Ubuntu Mate 16.04 and ROS Kinetic. I have wiringPi2 installed for accessing the GPIO pins. I am able to use the GPIO pins through a Python script, but they require sudo access. I have a ROS node (written in Python) in which I want to access the GPIO pin data and publish to a topic. But, I am not able to do so, because wiringPi2 required sudo access, and ROS is not defined in root.\nI have tried using wiringPiSetupSys() function which does not require sudo access, but that does not work i.e. I am not able to get the GPIO pin data without sudo access.\nAll the solutions to similar problems for Raspberry Pi platform don't seem to work for Odroid.\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":315,"Q_Id":50443037,"Users Score":0,"Answer":"Unfortunately, I could not find a fix to the problem with the exact specifications mentioned. However, when I tested the same code on a Raspberry Pi 3 with Raspbian, it works correctly. \nSo, I have concluded that the issue lies in the OS used i.e. Ubuntu Mate 16.04. \nSo, a solution might be to use Raspbian on Odroid itself. I am yet to test whether that works out.\nUpdate : Raspbian doesn't exist as such for Odroid, so some other work around might be required.","Q_Score":0,"Tags":"python,ros,gpio,odroid,wiringpi","A_Id":50580997,"CreationDate":"2018-05-21T06:17:00.000","Title":"Odroid GPIO pins in ROS without sudo access","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Is there something sys.minint in python similar to sys.maxint ?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":3394,"Q_Id":50446353,"Users Score":1,"Answer":"You can use float('-inf') if that meets your criteria otherwise you can do -1*sys.maxsize","Q_Score":4,"Tags":"python,mapreduce","A_Id":69917530,"CreationDate":"2018-05-21T10:00:00.000","Title":"Is there something sys.minint in python similar to sys.maxint?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have built 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.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":224,"Q_Id":50447302,"Users Score":0,"Answer":"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. \nIn case of custom channel, you will have to custom develop the UI components.","Q_Score":0,"Tags":"python-3.x,amazon-web-services,aws-lambda,chatbot,amazon-lex","A_Id":50462554,"CreationDate":"2018-05-21T10:54:00.000","Title":"Using aws lambda to render an html page in aws lex chatbot","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I would like to write a script in Python to read a public Twitter profile. Specifically, I'd like to check for Tweets with images, and download those images (eventually, I'd like to add this as a cron job). I was looking into tweepy as a Twitter API wrapper. However, from what I understand, the Twitter API requires authentication even for actions that access public data - is that correct?\nSince all I need is to access a single public user timeline, going through the rigmarole of authenticating (and then having those credentials sitting on my computer in I'm not sure how secure a form) seems a little overkill.\nAre there other solutions out there (particularly Python-based) for reading public Twitter data?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2189,"Q_Id":50459620,"Users Score":3,"Answer":"Yes, Twitter does require, authentication to access any public\/private data of user. You need to create an app on Twitter to access the data. The app is required to keep a check on the number of requests, etc. made by a particular client, to prevent any abuse. This authentication is a general process followed by other API providers as well and this is the only recommended way. \nAnother advantage of creating a Twitter App is that other users can give permissions to your app and then you can access their private data as well such as DM, etc. \nAnother approach is web-scraping, but I would consider it as unethical as twitter is already providing it's API. Also you would need to update your scraping script each time there is some front end change by the Twitter developers.","Q_Score":2,"Tags":"python,twitter","A_Id":50459886,"CreationDate":"2018-05-22T04:07:00.000","Title":"Building script to access public Twitter data, without authentication","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to implement an observer design pattern. My thoughts are, if this is deployed, and another system update has occurred and restarted the server, would the observers\/subscribers be lost when the server has restarted?\nSorry for this newbie question.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":32,"Q_Id":50499733,"Users Score":1,"Answer":"Your question doesn't specify any tools you are using neither the deployment methods and softwares so the best I can say is that any non-persistent data will be deleted on restart. This counts for the subscribers your server has saved in a variable, for example.\nIn web development, you go around this problem (and that of lost of connection) by having \"temporary subscriptions\" and by not implementing functionalities with solutions needing consistency in connection.\nHowever, what you could do is give the clients some sort of unique id which could be stored in a database along with data that can restore the connection.","Q_Score":0,"Tags":"python,deployment,observer-pattern,production-environment","A_Id":50499841,"CreationDate":"2018-05-24T01:45:00.000","Title":"how observer design pattern on production behave?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to use pytest to run some tests. My package contains a setup.cfg file where I've stated all the pytest options\n[tool:pytest]\n addopts =\n --verbose\n unit\n\nas it is visible I've added the unit directory to find the test files. This works fine and all the tests from the directory get executed during the normal build process.\nActual Problem - \nNow I have another directory integ where I have my integration tests which I want to run sometimes but do not want them as a part of my build process. I have created another command line option to run my integ tests but I am not able to figure out how to provide the file set correctly for the same\nI've tried pytest --ignore=unit integ through command line but it runs all my tests from unit as well as integ. I want to run the tests present in integ only and ignore the tests from unit. What am I missing here?\n[update]\nWhen I run pytest --ignore=unit\/test_file.py integ it ignores the tests in test_file but when I use pytest --ignore=unit\/*.py integ it says no matches found: --ignore=test\/*.py\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":761,"Q_Id":50508746,"Users Score":1,"Answer":"--override-ini=testpaths=test_integ solved my problem. I was able to override the options from my setup.cfg file using this.","Q_Score":1,"Tags":"python,unit-testing,pytest","A_Id":50510001,"CreationDate":"2018-05-24T11:53:00.000","Title":"Python Pytest ignore tests from a directory mentioned in the setup.cfg file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"when i import mxnet using import mxnet as mx in intellij (python) then compier generate error \n\nOSError: [WinError 126] The specified module could not be found\" \n\nand shows trackcall shows \n\nline 1 \"import mxnet as mx\" in test.python \n mxnet already in env\/lib","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":284,"Q_Id":50545193,"Users Score":0,"Answer":"I had the same problem.\nPip did not download correct version of MXnet for my version of CUDA (10.2).\nThe DLL which is not found is for the CUDA version for which MXNet was downloaded. \nI solved the problem by accessing the repository and directly downloading the correct package.\nIn my case it was mxnet_cu102mkl-2.0.0b20200504-py2.py3-none-win_amd64.whl.\nIt worked normally after this.","Q_Score":0,"Tags":"python,intellij-idea,mxnet","A_Id":62376387,"CreationDate":"2018-05-26T17:07:00.000","Title":"importing mxnet in python window 10 using intellj","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I downloaded multiple modules (Discord API, cx_Freeze) (pip download, Windows 10) and now I wanted to use them. \nBut when I want to import them, it says there isn\u2019t any module. \nFrom my former Python using (before resetting computer) I\u2018ve added a pycache folder and it worked for one module. I\u2018m not able to reproduce it for other modules. What to do?\n\nI\u2018ve only one Python version (3.6.5) on PC.\nI\u2018ve checked the \\site-packages folder and they\u2018re there.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":464,"Q_Id":50546451,"Users Score":0,"Answer":"If you are using python3 then try downloading the library using \n\npip3 install libname\n\nbut if you are using python2 then install the library using \n\npip2 install libname or just pip install libname\n\ntry with these command and reply","Q_Score":0,"Tags":"python,python-3.x,api,module,python-import","A_Id":50546470,"CreationDate":"2018-05-26T19:45:00.000","Title":"Python: ModuleNotFound Error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can you write video to memory? I use Raspberry Pi and I don't want to keep writing and deleting videowriter objects created on sd card (or is it ok to do so?).\nIf conditions are not met I would like to discard written video every second. I use type of motion detector recording and I would like to capture moment (one second in this case) before movement has been detected, because otherwise written video loses part of what happened. I use opencv in python environment.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1432,"Q_Id":50559105,"Users Score":1,"Answer":"Video files will often, or even generally, be too big to fit in your main memory so you will be unlikely to be able to just keep the entire video there.\nIt also worth noting that your OS itself may decide to move data between fast memory, slower memory, disk etc as it manages multiple processes but that is likely not important in this discussion.\nIt will depend on your use case but a typical video scenario might be:\n\nreceive video frame from camera or source stream\ndo some processing on the video frame - e.g. transcode it, detect an object, add text or images etc\nstore or send the updated frame someplace\ngo back to first step\n\nIn a flow like this, there is obviously advantage in keeping the frame in memory while working on it, but once done then it is generally not an advantage any more so its fine to move it to disk, or send it to its destination.\nIf you use cases requires you to work on groups of frames, as some encoding algorithms do, then it may make sense to keep the group of frames in memory until you are finished with them and then write them to disk.\nI think the best answer for you will depend on your exact use case, but whatever that it is it is unlikely that keeping the entire video in memory would be necessary or even possible.","Q_Score":0,"Tags":"python,python-3.x,opencv,video,video-capture","A_Id":50564217,"CreationDate":"2018-05-28T04:25:00.000","Title":"How to write video to memory in OpenCV","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been moving from php to python for my web-development. Have selected django as my prefeered framework. One thing that bugs is the time it takes for my changes of the python code to reload during development. ~10 sec roughly. \nProbably some of my seconds are due to my selected setup of docker-for-mac with mounted volume. But even if it was down to 5sec it would be annoying. I have moved away from the built-in django development server, over to apache 2.4 with mod_wgsi, this improves the speed of the application a lot, but no the python code reloading.\nI know it's like comparing apples and oranges, but coming from php my code changes are available immediately. Does anyone have any tips to speed this up?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1326,"Q_Id":50562698,"Users Score":4,"Answer":"Traced it back to slow disk access with Docker for Mac.","Q_Score":0,"Tags":"python,django,macos,docker,development-environment","A_Id":51999326,"CreationDate":"2018-05-28T09:04:00.000","Title":"How to speed up django development - Code reload","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am having trouble mocking the function. Even if I mock, it still sends an email.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":853,"Q_Id":50566566,"Users Score":1,"Answer":"Propagate a boolean \"mock_if_true\" and at the very last moment do not send the email. This is simple\/stupid and OK as long as you do not have many such booleans.\nOR: override the python class method (if you have one) to mock it\nOR: consider separating the code building the email object from the code sending it. So you may easily test if the object is properly built.","Q_Score":0,"Tags":"python-3.x,unit-testing,python-unittest","A_Id":50566622,"CreationDate":"2018-05-28T12:32:00.000","Title":"How to unit test mock a mail sending function without sending mail python? I am using unittest.mock function","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have read that python generates a .pyc file when we execute a python script for the first time and stores it in a _pycache directory but what will happen if python script has an error at some line. will it generate bytecode?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":79,"Q_Id":50567248,"Users Score":1,"Answer":"Python never deletes a cache (bytecode) file, so if it gets written it stays. It gets written after compilation (if there are no SyntaxErrors) and before execution\u2014even before finding out that, say, an import foo on the first line refers to a nonexistent module.\nSo you can almost say that the file is written unless a SyntaxError is raised, except that other things can raise that: an import inside the first module, an exec\/eval\/compile, or an explicit raise. It is possible to distinguish these programmatically if needed by counting traceback frames to see if the (first) module ever began execution.","Q_Score":0,"Tags":"python,python-3.x","A_Id":50567979,"CreationDate":"2018-05-28T13:08:00.000","Title":"what happens if a python program contains an error, will it generate a .pyc file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have measurements of channel impulse responses as complex CSI's. There are two transmitters Alice and Bob and the measurements look like\n[real0], [img0], [real1], [img1], ..., [real99], [img99] (100 complex values).\nAmplitude for the Nth value is ampN = sqrt(realN^2 + imgN^2)\nHow do I get the frequency and phase values out of the complex CSI's?\nAny help would be appreciated.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":364,"Q_Id":50587784,"Users Score":0,"Answer":"In Matlab, you do abs(csi) to get the amplitude. To get the phase, angle(csi). Search for similar functions in python","Q_Score":1,"Tags":"python,frequency,phase,amplitude,csi","A_Id":52261793,"CreationDate":"2018-05-29T15:14:00.000","Title":"How to get phase and frequency of complex CSI for channel impulse responses?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have measurements of channel impulse responses as complex CSI's. There are two transmitters Alice and Bob and the measurements look like\n[real0], [img0], [real1], [img1], ..., [real99], [img99] (100 complex values).\nAmplitude for the Nth value is ampN = sqrt(realN^2 + imgN^2)\nHow do I get the frequency and phase values out of the complex CSI's?\nAny help would be appreciated.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":364,"Q_Id":50587784,"Users Score":0,"Answer":"complex-valued Channel State Information ?\npython has cmath, a standard lib for complex number math\nbut numpy and scipy.signal will probably ultimately be more useful to you","Q_Score":1,"Tags":"python,frequency,phase,amplitude,csi","A_Id":50593481,"CreationDate":"2018-05-29T15:14:00.000","Title":"How to get phase and frequency of complex CSI for channel impulse responses?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to create a test case that solves a rebase conflict, but first I need a way to cause the rebase conflict when doing a git pull --rebase.\nIs there a programmatic way of creating a rebase conflict scenario?\nThe test will be for a GitPython program.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":102,"Q_Id":50588986,"Users Score":2,"Answer":"To quickly create a rebase conflict, you can do the following:\n\nmodify a file, commit and push to the remote repository\nmake a change to the same file on the same line\namend the last commit with git commit -a --amend -C HEAD. The HEAD commit hash has now changed\nrun git pull --rebase\n\nYou'll end up with a conflict at the line you modified.\nTo clean up: you may want to git reset --hard origin\/[your-branch] after your test to get back to step 1.","Q_Score":0,"Tags":"git,git-rebase,git-pull,gitpython,git-merge-conflict","A_Id":50590695,"CreationDate":"2018-05-29T16:28:00.000","Title":"How to create a git pull --rebase conflict for testcase?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"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?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":252,"Q_Id":50590788,"Users Score":0,"Answer":"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.\nEasy to use database options include sqlite (use the sqlite3 python library) and MongoDB (I use the mongoengine python library for my Slack bot).","Q_Score":0,"Tags":"python,python-3.x,discord.py","A_Id":50590881,"CreationDate":"2018-05-29T18:31:00.000","Title":"Discord bot with user specific counter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am looking for a wait to schedule tasks based on the reception of an email. \nMore precisely, I received an email with some attached data every week and I need to add these data into a database (and process some information). Is there a way to do it automatically? \nWould airflow be a good option to do this? I found that airflow can send email but I did not find anything about reading mails. \nI know it is possible to read email and download attached file in python. But what would be the best way to check if a specific email is received (defined by a sender) and process its data as soon as it is received ?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":912,"Q_Id":50601903,"Users Score":0,"Answer":"You could schedule some BashOperator or PythonOperator that periodically checks new mail and if they find one they start processing it. While I cannot give you any specific library, I am sure there must be a way to read and handle email in Python.","Q_Score":4,"Tags":"python-3.x,email,airflow","A_Id":50606478,"CreationDate":"2018-05-30T10:05:00.000","Title":"airflow : wait to receive email and process data contained in attached file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Instead of iterating through each element in a matrix and checking if random() returns lower than the rate of mutation, does it work if you generate a certain amount of random indices that match the rate of mutation or is there some other method?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":54,"Q_Id":50610831,"Users Score":0,"Answer":"Yes. \nSuppose your gene length is 100 and your mutation rate is 0.1, then picking 100*0.1=10 random indices and mutating them is faster than generating & checking 100 numbers.","Q_Score":0,"Tags":"python,numpy,statistics,genetic-algorithm","A_Id":50734768,"CreationDate":"2018-05-30T17:55:00.000","Title":"Mutation algorithm efficiency","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a bunch of python classes that are responsible for validating files like so:\n\njava file validator\nhtml file validator\ncss file validator\njavascript file validator\n\nAll of these classes define a validate_file(path) and validate_string(string) function.\nIn the client code of my application, I store all of these validators in an array and I iterate through all of them and call the methods on them in exactly the same way.\nIs there a purpose in my case of defining a base \"validator\" class which defines these methods as abstract? How can I benefit from making these individual classes adhere to the base class? Or maybe in other words, what features would be unlocked if I had a base class with all of these validators implementing it?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":41,"Q_Id":50622529,"Users Score":3,"Answer":"If you ever write code that needs to process mixed types, some of which might define the API method, but which shouldn't be considered \"validators\", having a common base class for \"true\" validators might be helpful for checking types ahead of time and only processing the \"true\" validators, not just \"things that look like validators\". That said, the more complex the method name, the less likely you are to end up with this sort of confusion; the odds of a different type implementing a really niche method name by coincidence are pretty small.\nThat said, that's a really niche use case. Often, as you can see, Python's duck-typing behavior is good enough on its own; if there is no common functionality between the different types, the only meaningful advantages to having the abstract base class are for the developer, not the program itself:\n\nHaving a common point of reference for the API consumer makes it clear what methods they can expect to have access too\nFor actual ABCs with @abstractmethod decorated methods, it provides a definition-time check for subclasses, making it impossible for maintainers to omit a method by accident","Q_Score":1,"Tags":"python,oop","A_Id":50622721,"CreationDate":"2018-05-31T10:48:00.000","Title":"What is the purpose of base classes in Python if you're already referring to the implementation classes consistently","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a bunch of python classes that are responsible for validating files like so:\n\njava file validator\nhtml file validator\ncss file validator\njavascript file validator\n\nAll of these classes define a validate_file(path) and validate_string(string) function.\nIn the client code of my application, I store all of these validators in an array and I iterate through all of them and call the methods on them in exactly the same way.\nIs there a purpose in my case of defining a base \"validator\" class which defines these methods as abstract? How can I benefit from making these individual classes adhere to the base class? Or maybe in other words, what features would be unlocked if I had a base class with all of these validators implementing it?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":41,"Q_Id":50622529,"Users Score":2,"Answer":"Base classes in Python serve to share implementation details and document likenesses. We don't need to use a common base class for things that function similarly though, as we use protocols and duck typing. For these validation functions, we might not have a use for a class at all; Java is designed to force people to put everything inside classes, but if all you have in your class is one static method, the class is just noise. Having a common superclass would enable you to check dynamically for that using isinstance, but then I'd really wonder why you're handling them in a context where you don't know what they are. For a programmer, the common word in the function name is probably enough.","Q_Score":1,"Tags":"python,oop","A_Id":50622740,"CreationDate":"2018-05-31T10:48:00.000","Title":"What is the purpose of base classes in Python if you're already referring to the implementation classes consistently","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am developing the ad-hoc network. I want to get MAC address of remote raspberry using his IP address. \nI am doing this code \nimport sys,os\nos.system ('sudo arp -n 115.0.0.2') \ni am getting all things like hWthype, name of device and Flags Mask, HWaddress but i need only HWaddress \nCan i body help me how I can extract only MAC address of remote raspberry using python code instead of cmd command?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":196,"Q_Id":50631473,"Users Score":0,"Answer":"you should use Grep command an catch MAC address with a regular expression to retrieve the line of the mac address.\nThen use cut command to select only the address.\nPost ifconfig output so we can help you better","Q_Score":0,"Tags":"python-3.x,networking,raspberry-pi3,mac-address","A_Id":50640031,"CreationDate":"2018-05-31T19:27:00.000","Title":"How to get the MAC address of remote raspberry using his ip address using python code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a list of S3 keys for the same bucket my_s3_bucket.\nWhat is the most efficient way to figure out which of those keys actually exist in aws S3. By efficient I mean with low latency and hopefully low network bandwidth usage.\nNote: the keys don't share the same prefix so filtering by a single prefix is not effective\nThe two suboptimal approaches I can think of:\n\nCheck the existence of each key, one-by-one\nList all keys in the bucket and check locally. This is not good if the total number of keys is large since listing the keys will still incur many network calls.\n\nIs there any better alternative?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":208,"Q_Id":50638573,"Users Score":2,"Answer":"To answer your question: there is not alternative exposed by the S3 API.\nUsing multiple threads or asynchronous I\/O are solid ways to reduce the real time required to make multiple requests, by doing them in parallel, as you mentioned.\nA further enhancement that might be worth considering would be to wrap this logic up in an AWS Lambda function that you could invoke with a bucket name and a list of object keys as arguments. Parallellize the bucket operations inside the Lambda function and return the results to the caller already parsed and interpeted, in one tidy response. This would put most of the bandwidth usage between the function and S3 on the AWS network within the region, which should be the fastest possible place for it to happen. Lambda functions are an excellent way to abstract away any AWS interaction that requires multiple API requests. \nThis also allows your Lambda function to be written in a different language than the main project, if desired, because the language does not matter across that boundary -- it's just JSON crossing the border between the two. Some AWS interactions are easier to do (or to execute in complex series\/parallel fashion) in some languages than in others, in my opinion, so for example, your function could be written in Node.JS even though your project is written in python, and this would make no difference when it comes to invoking the funcrion and using the response it generates.","Q_Score":1,"Tags":"python,amazon-web-services,amazon-s3,boto3","A_Id":50645869,"CreationDate":"2018-06-01T07:49:00.000","Title":"What is the most efficient way in python of checking the existence of multiple s3 keys in the same bucket?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I got temperature, pressure, and altitude readings on my PI using a sensor:\n\nThe problem is, to see the results, I have to execute the code.py every time by myself. I am trying to automate it somehow so it will keep running itself for the time I want. \nOnce that is automated, would like to save the results and analyze the output after some time.\n\nIs there a way I can write code for both the tasks?\nThank you.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":540,"Q_Id":50640980,"Users Score":0,"Answer":"The time module is your friend here. You can set up an infinite loop with while True: and use time.sleep(secs) at the end of the loop (after output).","Q_Score":1,"Tags":"python,python-2.7","A_Id":50641103,"CreationDate":"2018-06-01T10:03:00.000","Title":"How to write an autoscript in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have 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.","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":11411,"Q_Id":50667214,"Users Score":0,"Answer":"I would look in the atom installed plugins in settings.. you can get here by pressing command + shift + p, then searching for settings.\nThe only reason I suggest this is because, plugins is where I installed swift language usage accessibility through a plugin that manages that in atom.\nOther words for plugins on atom would be \"community packages\"\nHope this helps.","Q_Score":3,"Tags":"python,python-3.x,editor,atom-editor","A_Id":50682856,"CreationDate":"2018-06-03T14:02:00.000","Title":"How can I change the default version of Python Used by Atom?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have 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.","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":11411,"Q_Id":50667214,"Users Score":0,"Answer":"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.","Q_Score":3,"Tags":"python,python-3.x,editor,atom-editor","A_Id":50846354,"CreationDate":"2018-06-03T14:02:00.000","Title":"How can I change the default version of Python Used by Atom?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have 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.","AnswerCount":4,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":11411,"Q_Id":50667214,"Users Score":10,"Answer":"I am using script 3.18.1 in Atom 1.32.2\nNavigate to Atom (at top left) > Open Preferences > Open Config folder.\nNow, Expand the tree as script > lib > grammars\nOpen python.coffee and change 'python' to 'python3' in both the places in command argument","Q_Score":3,"Tags":"python,python-3.x,editor,atom-editor","A_Id":53507376,"CreationDate":"2018-06-03T14:02:00.000","Title":"How can I change the default version of Python Used by Atom?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have 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.","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":11411,"Q_Id":50667214,"Users Score":0,"Answer":"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.","Q_Score":3,"Tags":"python,python-3.x,editor,atom-editor","A_Id":71299879,"CreationDate":"2018-06-03T14:02:00.000","Title":"How can I change the default version of Python Used by Atom?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I've started tinkering with python recently and I'm on my way to create my very first telegram bot mainly for managing my Raspberry Pi and a few things connected to it. The bot is done but I would like to send a message to all the users that have already interacted with the bot when it starts, basically saying something like \"I'm ready!\", but I haven't been able to find any information about it.\nIs there any specific method in the API already done to do this? Or should I create another file to store the chat_id from all the users and read it with python?\nThank you all for your help!! Regards!","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":3875,"Q_Id":50668567,"Users Score":1,"Answer":"You should save users in database or file.After that use for to send_message one by one to all users that you have in database or file.","Q_Score":1,"Tags":"python,telegram-bot,python-telegram-bot","A_Id":50695439,"CreationDate":"2018-06-03T16:31:00.000","Title":"Send a message to all users when the bot wake up","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Working with Professional edition of PyCharm, I'm trying to configure a server for remote deployment of my project over SFTP with OpenSSH + authentication agent as auth type. I have tried to configure PyCharm in Settings > Build, Execution and Deployment > Add server. However, even though I setup and verify successful configuration by Test SFTP connection button, as soon as I click Apply or OK, the User name becomes blank for some reason. Thereafter, when I try to sync with the remote server, the connection fails.\nI've found a possible workaround by changing Host name to user@host form instead, which works, but then I can't use the same server configuration when I try to setup a remote interpreter under Project > Project Interpreter > Add SSH interpreter. (there it shows my host url as ssh:\/\/null@host). I'm guessing the null is there because PyCharm is somehow not saving the username. I've tried to edit the .idea\/webServers.xml file, but couldn't find appropriate key-value pair to change there for user name to be preserved.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":4374,"Q_Id":50671746,"Users Score":21,"Answer":"I solved it by changing the standard way to change credentials in Pycharm. \nTo do this go to Settings\/Preferences | Appearance & Behavior | System Settings | Passwords and choose the KeePass option. \nThat solved the problem for me. \nApparently there are problems storing on native keychain. (I'm on Mint 18.3)","Q_Score":18,"Tags":"python,pycharm,jetbrains-ide","A_Id":51944689,"CreationDate":"2018-06-03T23:01:00.000","Title":"PyCharm remote deployment: user name not being saved","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Working with Professional edition of PyCharm, I'm trying to configure a server for remote deployment of my project over SFTP with OpenSSH + authentication agent as auth type. I have tried to configure PyCharm in Settings > Build, Execution and Deployment > Add server. However, even though I setup and verify successful configuration by Test SFTP connection button, as soon as I click Apply or OK, the User name becomes blank for some reason. Thereafter, when I try to sync with the remote server, the connection fails.\nI've found a possible workaround by changing Host name to user@host form instead, which works, but then I can't use the same server configuration when I try to setup a remote interpreter under Project > Project Interpreter > Add SSH interpreter. (there it shows my host url as ssh:\/\/null@host). I'm guessing the null is there because PyCharm is somehow not saving the username. I've tried to edit the .idea\/webServers.xml file, but couldn't find appropriate key-value pair to change there for user name to be preserved.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4374,"Q_Id":50671746,"Users Score":0,"Answer":"What worked for me was first going to the following tab:\nPreferences -> Build, Execution, Deployment -> Deployment [Connection Tab]\nand then inserting my in the \"User name\" blank.\nNote: your user name appears in the ip address of you ec2. e.g. username@@xxx.amazonaws.com","Q_Score":18,"Tags":"python,pycharm,jetbrains-ide","A_Id":63552421,"CreationDate":"2018-06-03T23:01:00.000","Title":"PyCharm remote deployment: user name not being saved","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We are building a Python app to receive file from another app, process the received file and send the processed file back to that app.\nFor the transfer of file we are considering options SFTP and messaging queue.Below are our requirements\n\nSecurely transfer files\nAcknowledge the file and notify the sender apps for any failures\nLoad balance the requests for file processing\nTo be able verify the status of file sent by the sender app \n\nWhich do you think is better suited given this scenario SFTP or message queue? I know each one has its own merits and demerits but wanted to get some insight and also find if something is being overlooked","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":135,"Q_Id":50705041,"Users Score":0,"Answer":"Message-driven systems depend almost entirely on the quality and reliability of their broker, and as I have no experience with QPID's brokers I cannot comment on that crucial facet of the decision. However, Qpid uses AMQP, and should you run into trouble with the selected broker, switching to another should not be overly complex.\nNow that is is out of the way, let's have a look at your requirements. In my opinion your requirements are mostly \"natural\" properties of a good messaging system, so you get properly working, reliable implementations of your requirements without having to layer mechanisms on top of a file transfer protocol.\n\nSecurely transfer files\n\nAMQP and SFTP are probably quite comparable wrt security, if properly implemented\n\nAcknowledge the file and notify the sender apps for any failures\n\nAlmost automatic using the appropriate delivery guarantee mode for QPID, messy to do via sftp.\n\nLoad balance the requests for file processing\n\nAlso effortless by having all consumers attached to the same queue, avoiding double consumption in a way that avoids message loss is hard to get right with just sftp. \n\nTo be able verify the status of file sent by the sender app\n\nNot 100% sure what you mean here, but AMQP has mechanisms to ensure that the sender knows with certainty that a message has been properly accepted by the broker, and that a file has been correctly received and processed by the receiver (manual acknowledgement mode).\nOne argument that wasn't mentioned yet is high availability: message brokers, being crucial elements of many enterprise processing chains, have extensive high availability features to avoid downtime and message loss.","Q_Score":0,"Tags":"python-3.x,sftp,message-queue,messaging","A_Id":50705844,"CreationDate":"2018-06-05T16:38:00.000","Title":"File transfer between apps","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to deploy WSGi based app that's built using Python, Flask on AWS Lambda. \nBut, it seems that the round trip of the request is going but when the request is being returned the werkzeug module is not able to call LambdaContext: Not a callable object. \n'LambdaContext' object is not callable: TypeError\nTraceback (most recent call last):\nFile \"\/home\/ubuntu\/venv\/local\/lib\/python2.7\/site-packages\/flask\/app.py\", line 1997, in call\nFile \"\/home\/ubuntu\/venv\/local\/lib\/python2.7\/site-packages\/flask\/app.py\", line 1989, in wsgi_app\nFile \"\/tmp\/pip-install-Xytrxp\/Werkzeug\/werkzeug\/wrappers.py\", line 1277, in call\nTypeError: 'LambdaContext' object is not callable\nI am trying to use serverless to deploy but my problem is that when i build a deployment package using serverless it's going to go beyond 250 MB which is the limit of AWS Lambda\nI have built the package using Zappa by removing some of the unnecessary files in python packages and the size of that is 248 MB. I am able to use that to deploy but using serverless deploy is throwing issues. \nSo, is any one aware of what actually serverless does? Can we include serve.py and wsgi.py files in the AWS Lambda deployment package? \nIf yes, what are more changes needed to be able to just add these python files to deployment package to make the application wrapped on serverless.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":833,"Q_Id":50711086,"Users Score":0,"Answer":"I was able to handle this by using serverless-wsgi. We just need to include wsgi.py and .wsgi_app files and need to put wsgi.handler as the Lambda Function Handler","Q_Score":1,"Tags":"python,amazon-web-services,aws-lambda,serverless","A_Id":50750689,"CreationDate":"2018-06-06T01:34:00.000","Title":"Deploying WSGi app on AWS Lambda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I was adding final touches to a python code when my computer unexpectedly shut down. When I turned it back on and opened the file, it was blank. Is it possible for me to recover the contents of that file?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":203,"Q_Id":50729289,"Users Score":0,"Answer":"Unless it was backed up somewhere automatically, it's gone permanently.","Q_Score":0,"Tags":"python,recovery","A_Id":50730707,"CreationDate":"2018-06-06T20:43:00.000","Title":"Unexpected computer shutdown while python file wasn't saved","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Any library in Robot Framework has two categories of keywords. The keywords to carry out a regular test step (e.g. Click Button) and the keywords that verify certain thing (e.g. Table Column Should Contain). The latter keywords typically have the word \"Should\" in them.\nI assume that Robot Framework only puts PASS or FAIL status for the executed test cases in the report. How can I distinguish the FAIL test cases failed due to test step keywords versus failed due to test verification keywords?\nFor example, the calculator test case clicks 2, +, 2, = buttons and then verifies answer 4 as part of the last keyword (e.g. Should Be Equal As Numbers). If it fails while failing to click any button then I will consider it as \"Failed to carry out its actual verification\" (my result processing script will not log a bug here). However, if it fails while actually verifying the result then it is a valid bug associated with the test case (my result processing script can take action accordingly, like logging a bug).\nIf there are no techniques for generating the result file as per my requirement (PASS, FAIL and maybe FAIL_TO_VERIFY statuses), then I am seeking a technique to process the result or log xml to identify the kind of failure (FAIL vs FAIL_TO_VERIFY) for every FAIL test case.\nPS: I have already figured out the bug logging part in my result processing script. So consider it as out of scope for the above question.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3153,"Q_Id":50732910,"Users Score":0,"Answer":"Can you please check this keyword Register Keyword To Run On Failure in selenium2library , this keyword will allow to execute any other keyword when your slenium2library keywords fail. so you can call your bug reporting keyword here","Q_Score":1,"Tags":"python,robotframework","A_Id":50733615,"CreationDate":"2018-06-07T04:21:00.000","Title":"Robot Framework: How to distinguish the test case FAIL due to regular test step keyword failure versus verification test step failure","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I would like to ask if there is another way to disable creation of __pycache__ in the server. \nMy problem is it keeps generating even if I already set environment variable to PYTHONDONTWRITEBYTECODE=1\nI want to disable __pycache__ because I only keep 5 releases in deployment. This cache is preventing the deletion of the 6th release because the cache is owned by root and can only be deleted through sudo. \nI am using capistrano for deployment.\nThank you for your response!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":11666,"Q_Id":50752302,"Users Score":19,"Answer":"I already resolved this issue. export PYTHONDONTWRITEBYTECODE=1 works. The generation of pycache folder is in the docker (I used docker as well). What I did is inside the docker, I have this export PYTHONDONTWRITEBYTECODE=1 So it solved the issue. thank you for your help.","Q_Score":12,"Tags":"python,python-3.x,capistrano","A_Id":50789208,"CreationDate":"2018-06-08T01:53:00.000","Title":"Python3 __pycache__ generating even if PYTHONDONTWRITEBYTECODE=1","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is a bit out there but I have a module that I can import, but i dont know where it is, and module.__file__ doesnt work on it.\nIm trying to set up VSCode for 3ds Max python development and this one module (pymxs) is somehow hidden somewhere where intellisense or pylint cant see it, so I get errors every time i use it, and autocomplete doesnt work. The code runs just fine though, and i can use inspect.getmembers() on it just fine.\nNow what I would be interested in doing is just outputting the whole module in to a text file, so that hopefully intellisense\/pylint will be able to read it.\nIs that possible?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":172,"Q_Id":50776805,"Users Score":0,"Answer":"The file pymxs.py unfortunately doesn't exist, the module only exists at runtime, i.e. when running your script in 3ds max. So at this point there's no existing solution to get autocomplete for pymxs in an external editor.\nIn the editor inside 3ds max however they have autocomplete these days, so maybe (just maybe) it's possible to create a plugin that communicates with max and retrieves this information during runtime, but no idea where you would even start with that, or if it's even possible.\nAnother solution could be to create wrapper functions for your most commonly used pymxs functions, and in that way get autocomplete from your wrapper library. Note however that with this approach everything in pymxs might not be possible to add here as it is using runtime information. Let's for example say you run myobject = rt.selection[0] Depending on if myobject becomes a teapot or a box or whatever at runtime, different functions will be available, such as radius and height. If you know what you will get maybe you can cast the output to your wrapper class or something like that.","Q_Score":0,"Tags":"python,visual-studio-code,3dsmax","A_Id":68572493,"CreationDate":"2018-06-09T17:23:00.000","Title":"Extracting an imported python module to a file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When a python script with non ASCII character is compiled using py_compile.compile it does not complaint about encoding. But when imported gives in python 2.7\nSyntaxError: Non-ASCII character '\\xe2' in file\nWhy is this happening? whats the difference between importing and compiling using py_compile?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":172,"Q_Id":50795296,"Users Score":1,"Answer":"It seems that Python provides two variants of its lexer, one used internally when Python itself parses files, and one that is exposed to Python through e.g. __builtins__.compile or tokenizer.generate_tokens. Only the former one checks for non-ASCII characters, it seems. It's controlled by an #ifdef PGEN in Parser\/tokenizer.c.\nI have a qualified guess on why they did it this way: In Python 3, non-ASCII characters are permitted in .py files, and are interpreted as utf-8 IIRC. By silently permitting UTF-8 in the lexer, 2.7's tokenizer.generate_tokens() function can accept all valid Py3 code.","Q_Score":3,"Tags":"python-2.7,encoding,compilation,python-import","A_Id":55231546,"CreationDate":"2018-06-11T10:09:00.000","Title":"encoding in py_compile vs import","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"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. \nMy dilemma is this: How do I know that these third-party packages are not sharing my credentials with developers\/etc?\nThank you in advance for your input.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":53,"Q_Id":50806632,"Users Score":0,"Answer":"Thanks everyone for comments. \nTo 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.","Q_Score":0,"Tags":"python,security,sftp,paramiko","A_Id":50827731,"CreationDate":"2018-06-11T22:00:00.000","Title":"Security of SFTP packages in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python script that records audio from an I2S MEMS microphone, connected to a Raspberry PI 3. \nThis script runs as supposed to, when accessed from the terminal. The problem appears when i run it as a service in the background. \nFrom 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.\nFor audio capturing i use the pyaudio library and for making the script a service i have utilized the supervisor utility.\nAny ideas what the problem might be and how i can make my script to have access to asoundrc when it runs as a service?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":127,"Q_Id":50812469,"Users Score":2,"Answer":"The ~\/.asoundrc file is looked for the home directory of the current user (this is what ~ means).\nPut 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.","Q_Score":1,"Tags":"python,raspbian,audio-recording,alsa","A_Id":50812689,"CreationDate":"2018-06-12T08:22:00.000","Title":"Python script as service has not access to asoundrc configuration file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"What are pros and cons of Fabric and Plumbum python libraries for local\/remote command execution? What are use cases when one library should be used and other is not? What are the differences attention should be drawn to?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":799,"Q_Id":50816468,"Users Score":3,"Answer":"background and suggested comparison methodology\n(oops it's a dead post)\nBoth tools are fun, allow either local or remote work, but have differences in the things they are supposed to solve, i.e. \"terminology\", and both are basically pretty much obsolete by modern deployment\/automation tooling (like ansible, and many others that chose DSL way, e.g. terraform).\nTheir advantage over more modern ones are lack of \"opinionated\" approach about the \"how\", and more on \"what\".\nSuggested comparison criteria:\n\n\"Pythonness\" vs. \"Shellness\" (i.e. how \"pythonic\" the user code with each is)\nSpecial Capabilities\nROI with 2 types of maintainers of your \"automation\" code (ops vs. devs, let's put \"QA\" as something in between)\n\nFabric (my last work was done at 1.8 take this with a grain of time salt):\n\nmore pythonic, than shellish, this means easy to support by both old tools and new - i.e. editors, IDEs would be easy to setup\nmany many context processors, many decorators, very nice\neasier to adopt by developers, a bit more traction would come from ops people\n\nPlumbum\n\nThe user code can be either pythonic or shellish\n\"shell combinators\" are a killer feature to get senior shell\/perl folk onboard, but it uses dynamic imports, so editors\/IDEs are a bit trickier to setup.\nDue to 1. You will get 'ops' people on board easier, because of mimicking shell constructs in Plumbum, but please install good coding conventions.\n\nEpilogue\nHaving worked with both toolkits (with lots of fun) and then having switched to ansible - I feel confident to claim - both tools are now superseded by ansible.\nyou can do most automation tasks with existing ansible modules, and what you can't - you can write a plugin or module for it (in any language), or just call shell module.\nMy consideration would be this:\n\nif your team of maintainers has good level of programming skills (Esp. in python), as a requirement - you'd be ok with using either fabric, Plumbum (it has more cool hacks ;)) or Ansible.\nif you have multi-level multi-team organization, I would simply bet on Ansible - it has lower learning curve, and allows to grow up easily.\n\nGood day.","Q_Score":4,"Tags":"python,compare,fabric,plumbum","A_Id":51920412,"CreationDate":"2018-06-12T11:49:00.000","Title":"Fabric vs Plumbum: differences, use cases, pros and cons","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"What are pros and cons of Fabric and Plumbum python libraries for local\/remote command execution? What are use cases when one library should be used and other is not? What are the differences attention should be drawn to?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":799,"Q_Id":50816468,"Users Score":0,"Answer":"They're pretty much the same thing. The biggest win for fabric over plumbum is the ability to connect to multiple hosts in parallel, which is more or less indispensible when you're working with a non-trivial setup. fabric also offers a couple of contrib helpers that let you upload jinja templates, upload files, and transfer files back to the local system. I personally find the fabric api to be far more intuitive for working with remote servers.\nYMMV, of course, but both are geared towards being very close to shell commands. That said, my team and I are focused on ansible for most configuration \/ deploy flows. Fabric does offer some power over ansible at the expense of having to roll your own idempotence.","Q_Score":4,"Tags":"python,compare,fabric,plumbum","A_Id":51397324,"CreationDate":"2018-06-12T11:49:00.000","Title":"Fabric vs Plumbum: differences, use cases, pros and cons","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to start a python script via java and send the data via socket back to the java program.\nMy problem is that when I start the python script after the SocketServer is created with Runtime.getRuntime().exec(\"python3 ~\/Documents\/sensor\/sensorADC.py\");\nno connection is established and no data is transmitted.\nBut when I start the script manually via CLI, everything works fine.\nThe timing of the program start shouldn't be the problem, because I already tried different ways and orders.\nThe java program is a javaFx application.\nEDIT: tested in Linux\n2nd Edit:\n private void startPythonScript () {\n try {\n measureProcess = Runtime.getRuntime().exec(\"python3 ~\/Documents\/sensor\/sensorADC.py\")); \n } catch (IOException e) {\n e.printStackTrace();\n }\n }\nWhat am I missing?\nThank you in advance","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":98,"Q_Id":50821130,"Users Score":0,"Answer":"I \"solved\" it.\nI compiled it with pyinstaller and now it works. Python seems to be the problem here.\nBut I don't know why....\nFor others I compiled it to an executable with pyinstaller --onefile sensor.py","Q_Score":3,"Tags":"java,python","A_Id":50843052,"CreationDate":"2018-06-12T15:46:00.000","Title":"Java start python process","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"Maximum number of subscription possible by paho-mqtt python library.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":481,"Q_Id":50835415,"Users Score":1,"Answer":"Normally subscriptions are held by the broker, not the client. The broker just forwards messages to the client that match a topic pattern and the client passes that received message to the callback.\nHow those topic patterns are stored will differ from broker to broker, but assuming even the most naive implementation of an array then the limit would likely to be the size of an int on the platform the broker was running on, which is likely to be larger than any sensible system would ever hit.\nIf the client library is keeping track of the list of subscribed topics (which I don't believe the Paho libraries do as there is no need), then the list is likely to be on the same scale as the broker.\nAlso be aware that you can subscribe to wildcard topics, this would hold a single slot in any list, but could match any number of actual topic a message is published on.","Q_Score":0,"Tags":"python-3.x,mqtt,paho","A_Id":50836002,"CreationDate":"2018-06-13T10:54:00.000","Title":"what is maximum number for subsciption can be handle by paho- mqtt","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have python 3 file that run a SVN deployment. Basically run \"python3 deploy.py update\" and following things happen:\n\nClose site\nBackup Ignore but secure files\nSVN revert -R .\nSVN update \nTrigger tasks\nOpen site\n\nThat all sounds simple and logical, but for one thought going around my head \"SVN is writing files, including python files and sub module helpers that are trigger the SVN subprocess\" \nI understand that python files are read and processed and only through some tricky reload will python reload. And I understand if SVN change python source then update would only take effect on next run. \nBut question is \"should keep this structure or move file to root and run SVN to be safe side\" \nApplies to GIT or any python changes","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1449,"Q_Id":50844415,"Users Score":0,"Answer":"From what I know it is safe to change python (i.e. .py) file while python is running, after .pyc file has been created by python (i.e. your situation). You can even remove .py file and run .pyc just fine. \nOn the other hand SVN revert -R . is dangerous here as it would attempt removing .pyc files, so either screw up your python or fail by itself.","Q_Score":0,"Tags":"python,git,svn,deployment","A_Id":50844763,"CreationDate":"2018-06-13T18:58:00.000","Title":"Safe to change python file during run time?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"The module 'discord' I installed in the command prompt which I ran as administrator can't be found. It's located in my site-packages directory along with some other modules such as setuptools which when I import, are imported successfully without error. However, discord which is in the same directory doesn't. In the environment variables I have Path which I've specified to site-packages but I still receive the error that discord cannot be found.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2176,"Q_Id":50848070,"Users Score":0,"Answer":"That error is common on Python version 3.7\n\nIf you are trying to run your bot or discord app with Python 3.7 and getting an error such as Invalid Syntax, we recommend that you install Python 3.6.x instead. Discord.py isn't supported on 3.7 due to asyncio not supporting it.\n Remember to add Python to PATH!\n\nInstall an older version of PY to run discord!","Q_Score":0,"Tags":"python,module,discord","A_Id":51535001,"CreationDate":"2018-06-14T00:33:00.000","Title":"I Installed a Module Called Discord and When Using \"import discord\" I Get the Error: \"ModuleNotFoundError: No module named 'discord'\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a byte representation of a string, no idea what is the encoding, I know that b'\\x04\\x00\\x00\\x00\\xf0\\x9f\\x90\\x9f\\x00' represents (fish character). Is it possible to find the encoding based on this information?\nI checked print(b'\\x04\\x00\\x00\\x00\\xf0\\x9f\\x90\\x9f\\x00') prints , so terminal knows its encoding, not me.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":387,"Q_Id":50852989,"Users Score":0,"Answer":"\\xf0\\x9f\\x90\\x9f is the UTF-8 encoded character U+1F41F FISH.\nThe rest are useless NUL bytes and one 0x04 EOT byte, which don't do a lot usually.","Q_Score":0,"Tags":"python,encoding,character-encoding","A_Id":50853166,"CreationDate":"2018-06-14T08:29:00.000","Title":"Find encoding based on input and output","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm automating some software tests at the moment and I was wondering if it's possible to pass or fail a test in python so that RF shows the same result. For example, I'm doing an install test and at the end I check through the registry to confirm a clean install. If anything is missing I want to be able to essentially exit(0) and have RF show a fail, but just returns \"[ ERROR ] Execution stopped by user.\"","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1648,"Q_Id":50864593,"Users Score":2,"Answer":"Tests fail when a keyword fails. Keywords fail when they throw an exception (or call a keyword that throws an exception). So, you can write a keyword that executes your script and throws an exception if the return code is non-zero.\nIn other words, what you want won't happen automatically, but is extremely easy to implement.","Q_Score":1,"Tags":"python,automation,robotframework","A_Id":50866020,"CreationDate":"2018-06-14T19:29:00.000","Title":"Returning a pass\/fail to robot framework from python code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I got to thinking that if we store data in a text file, it is stored in a linear fashion. While you can store things in sorted order, there\u2019s always the chance that the thing you\u2019re looking for is last in the file. \nIn my algorithms course, there was a lot of talk about efficient ways to organize data within a Java\/python\/C program. You can create a binary search tree object, and all is well. But nothing was mentioned about storing a hard copy of said data in an efficient manner. \nMy question is this: Is there a way to store a hard copy of some data in a binary search tree format? So that when you go to read from the file in Java, for example, Java can quickly \u201cjump\u201d left or right, and process the data in an efficient manner?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":217,"Q_Id":50868156,"Users Score":0,"Answer":"My question is this: Is there a way to store a hard copy of some data\n in a binary search tree format? So that when you go to read from the\n file in Java, for example, Java can quickly \u201cjump\u201d left or right, and\n process the data in an efficient manner?\n\nThere is no special impediment to storing binary search tree data on disk -- even in ways that can be processed fairly directly. You rely on fixed-size storage units, and that allows you to use some form of storage unit indices in place of pointers. Disk storage is basically random-access, though at the device and O\/S levels, I\/O is performed in blocks of device- and filesystem-dependent size.\nThere are other variations on search trees that tend to be more efficient for use with disk storage, however. B-trees, for example, were designed and are used for this purpose. In general, these variations produce shorter, wider trees, often tuned so that nodes are the size of one disk block.","Q_Score":0,"Tags":"java,python,c,text-files,binary-search-tree","A_Id":50869325,"CreationDate":"2018-06-15T01:49:00.000","Title":"Storing a hard copy of data in a binary search tree format","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm writing a project on extracting a semantic orientation from a review stored in a text file.\nI have a 400*2 array, each row contains a word and it's weight. I want to check which of these words is in the text file, and calculate the weight of the whole content. \nMy question is - \nwhat is the most efficient way to do it? Should I search for each word separately, for example with a for loop? \nDo I get any benefit from storing the content of the text file in a string object?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":194,"Q_Id":50871201,"Users Score":0,"Answer":"This may be out of the box thinking, but if you don't care for semantic\/grammatic connection of the words:\n\nsort all words from the text by length\nsort your array by length \n\n.\n\nWrite a for-loop:\nCall len() (length) on each word from the text. \nThen only check against those words which have the same length. \n\nWith some tinkering it might give you a good performance boost instead of the \"naive\" search. \nAlso look into search algorithms if you want to achieve an additional boost (concerning finding the first word (of the 400) with e.g. 6 letters - then go \"down\" the list until the first word with 5 letters comes up, then stop. \nAlternatively you could also build an index array with the indexes of the first and last of all 5-letter words (analog for the rest), assuming your words dont change.","Q_Score":0,"Tags":"python,arrays,text","A_Id":50871541,"CreationDate":"2018-06-15T07:46:00.000","Title":"How to search for a set of words in a text file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to use tesseract-ocr on AWS EC2 machine using python.\nI have install tesseract-ocr, pytesseract and set TESSDATA_PREFIX=\/usr\/local\/share\/tessdata... but still geting below error while calling image_to_string method of pytesseract.\n\npytesseract.pytesseract.TesseractNotFoundError: tesseract not\n installed or it's not in your path","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":885,"Q_Id":50874626,"Users Score":0,"Answer":"you have to add tesseract installation folder to path too. if you have done that already, you might need to restart once or at least sign out and sign in. TESSDATA is the path you give for tesseract to access the language data.","Q_Score":0,"Tags":"python,amazon-web-services,amazon-ec2,ocr,python-tesseract","A_Id":50874671,"CreationDate":"2018-06-15T11:23:00.000","Title":"AWS EC2 machine giving \"pytesseract.pytesseract.TesseractNotFoundError: tesseract not installed or it's not in your path\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to convert PNG image file to text using pytesseract. It is giving me the below error.\nTesseractError: (1, 'Tesseract Open Source OCR Engine v3.05.00dev with Leptonica Warning in pixReadMemPng: work-around: writing to a temp file \nlibpng warning: Application built with libpng-1.4.3 but running with 1.5.14 Error in pixReadStreamPng: png_ptr not made Error in pixReadMemPng: pix not read Error in pixReadMem: png: no pix returned Error during processing.')\nWhen i do tesseract -v\ntesseract 3.05.00dev\n leptonica-1.72\n libjpeg 9 : libpng 1.5.14 : libtiff 4.0.3 : zlib 1.2.5 : libopenjp2 2.1.0","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2484,"Q_Id":50876458,"Users Score":0,"Answer":"I also meet this problem, and I can't find the answer on the internet.\nBut I try to download the tesseract-ocr and install it, then:\n\nset environment variable, TESSDATA_PREFIX:\"C:\\Program Files (x86)\\Tesseract-OCR\\tessdata\"\nadd C:\\Program Files (x86)\\Tesseract-OCR to the path variable.\nedit pytesseract.py in Line 35, tesseract_cmd = 'C:\\\\Program Files (x86)\\\\Tesseract-OCR\\\\tesseract.exe'\n\nWhen I call pytesseract.image_to_string(img) in anaconda prompt, it return a string. My Environment\uff1a\n\npytesseract 0.2.6\npillow 5.2.0\ntesseract 4.00.00alpha","Q_Score":0,"Tags":"python-3.x,libpng,python-tesseract,libtiff,leptonica","A_Id":54167994,"CreationDate":"2018-06-15T13:18:00.000","Title":"Tesseract Open Source OCR Engine v3.05.00dev with Leptonica Warning in pixReadMemPng","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to have all cost and ressources used of each IAM users. \nUnfortunately, i can have only the cost of my master account. I know that i can create a organization and set OU and users AWS account to have a detail and record each events, but the ressources used by 'users' are used only for my application, i don't need to have real account, and i can't automatises all deployements if i must set password and credentials manually . \nOne solutions also is to create CloudTrail and Cloudwatch to record each events services but i found this 'too heavy' and i will need to calculate myself the cost because it only get the datas which are used. \nI would like to know if they are exists others systemes to do that in preference with boto3.\nThank you for your responses. \nHave a nice day\/night.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":123,"Q_Id":50918798,"Users Score":5,"Answer":"Costs are not easily associated back to \"users\".\nAWS resources are associated with an AWS Account. When a user creates a resource (eg an Amazon EC2 instance), IAM will confirm that they have permission to launch the resource, but the resource itself is not associated with the user who created it.\nYou would need to add tags to resources to have more fine-grained association of costs to people\/projects\/departments. These tags can be used in billing reports to provide cost breakdowns.","Q_Score":1,"Tags":"python-3.x,amazon-web-services,boto3","A_Id":50919163,"CreationDate":"2018-06-18T23:37:00.000","Title":"How to get a summary of ressources\/cost used per IAM users in AWS?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm a bit confused regarding unittests. I have an embedded system I am testing from outside with Python.\nThe issue is that after each test is passed I need to reset the system state. However if a test fails it could leave the system in an arbitrary state I need to reset. After each test I go back to the initial state but if an assertion fails it will skip that part.\nTherefore, what's the proper way to handle this situation? Some ideas I have are:\n\nPut each test in a try, catch, finally but that doesn't seem so right (unittest already handles test exceptions).\nPut each test in a different class and invoke tearDown() method at the end of it\nCall initSystemState() at the beggining of each test to go back to init state (but it is slower than resetting only what needs to be reset at the end of the test)\n\nAny suggestions? Ideally if I have testSpeed() test there should be a testSpeedOnStop() function to be called at the end. Perhaps unittest is not the right tool for this job also as all the functions have side-effects and are working together so maybe I should lean more towards integration tests libraries which I haven't explored.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":105,"Q_Id":50923683,"Users Score":0,"Answer":"Setting state is done in the setUp(self) method of the test class.\nThis method is automatically called prior to each test and provides a fresh state for each instance of the tests.\nAfter each test, the tearDown method is run to possibly clean up remnants of failed tests.\nYou can write a setUp \/ tearDowm to be executed befora and after all tests; more elaborate tests may require stubbing or mocking objects to be build.","Q_Score":0,"Tags":"python,unit-testing,integration-testing,python-unittest","A_Id":50923716,"CreationDate":"2018-06-19T08:17:00.000","Title":"Execute system state reset upon unittest assertation fail","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is best practice for incorporating git repositories into the own project which do not contain a setup.py? There are several ways that I could imagine, but it doesn't seem clear which is best.\n\nCopy the relevant code and include it into the own project \npro:\n\nOnly use the relevant code, \n\ncon: \n\ngit repo might be updated\nneed to do this for every project again\nfeels like stealing\n\nCloning the repository and writing a setup.py and install it with pip\npro:\n\neasy\npackage can be updated\ncan use package like any normal pip package\n\ncon: \n\nfeels weird\n\nClone the repository and add the path to the project's search path \npro:\n\neasy\npackage can be updated\n\ncon: \n\nneeding to adjust the search path also feels strange","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":54,"Q_Id":50930336,"Users Score":1,"Answer":"In my opinion, you forgot the best option: Ask the original project maintainer to make the package available via pip. Since pip can install directly from git repositories this doesn't take more than a setup.py -- in particular, you don't need a PyPI account, you don't need to tag releases, etc.\nIf that's not possible then I would opt for your second option, i.e. provide my own setup.py file in a fork of the project. This makes incorporating upstream changes pretty easy (basically you simply git pull them from the upstream repo) and gives you all the benefits of package management (automatic installation, dependency management, etc.).","Q_Score":0,"Tags":"python,git,pip","A_Id":50930519,"CreationDate":"2018-06-19T14:00:00.000","Title":"Python: incorporate git repo in project","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to understand how Exception Handling is done in Robot. I want to handle exceptions from multiple testcases using some generic way.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2153,"Q_Id":50969989,"Users Score":0,"Answer":"You can use below two keywords for that:\n\nRun Keyword And Continue On Failure\nRun Keyword And Ignore Error based on ur requirement, however i suggest to go with 2nd one as you'll be able to store output and status","Q_Score":0,"Tags":"java,python,robotframework","A_Id":51022339,"CreationDate":"2018-06-21T13:37:00.000","Title":"How to handle exceptions in Robot Framework?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In my code, I have a few debug lines using logging modules.\nHowever, when running the program, I saw a lot of other debug messages that is not from my code. \nLooks like it is from the other modules that I use in the code, is there a way to disable the log (debug) messages that is not from my code (modules)?\nIf not, what is usually the common practice?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":29,"Q_Id":51012313,"Users Score":0,"Answer":"logging.setLevel(logging.CRITICAL) will disable pretty much all non-critial logging accross all loggers (I think at least...)\nafter that you can set your logger to have a more reasonable threshold\nlogging.getLogger(\"my_logger\").setLevel(logging.DEBUG)\nI think that should work ... without extensively testing it at all","Q_Score":0,"Tags":"python,logging,module","A_Id":51012462,"CreationDate":"2018-06-24T17:26:00.000","Title":"Is there a way to disable log message that is from module I use?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I do have a problem which many people faced already, but after searching through different solutions for hours, I still haven't solved my problem.\nFor a project, I need Phyton to read my Data from my arduino-uno. Therefore I need the import serial (or import pyserial, I tried both) this doesn't work. I tried installing the library (not really sure where to store it than) but that didn't help either. I also tried using \"pip install pyserial\" in the console, but that didn't work as well.\nWhatever i do i allwas get this error:\n\n\n\npip install pyserial\n File \"\", line 1\n pip install pyserial\n ^\n SyntaxError: invalid syntax\n\n\n\nI reinstalled Python now as 2.7 and deleted everything Python related. But when i put in pip install pyserial i still geht the same Error\nCould someone please help me with this?\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":11832,"Q_Id":51025585,"Users Score":0,"Answer":"Problem Solved!\nSeems like my computer doesn't like python.\nThanks for your help","Q_Score":1,"Tags":"python,arduino-uno","A_Id":51068968,"CreationDate":"2018-06-25T14:13:00.000","Title":"Import serial to Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a problem with \"TESSEROCR\" python library.\nI am using ubuntu 16 (remote connection) , python 3.6, tesseract 4.\nI have managed to install it using PIP or CPPFLAGS=-I\/usr\/local\/include pip install tesserocr method.\nHowever the problem is:\nOnce I open Python and type: import tesserocr python shuts down and I'm back into terminal. I tried to reinstall, build from source and even multiple combination of different versions. \nI have no idea where to look for.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":273,"Q_Id":51062268,"Users Score":0,"Answer":"So there are two problems which I faced while installing Tesserocr library to use System Tesserocr:\n\nI needed to install python-dev as the TesserOCR Library has some dependences which are available only in python-dev. sudo apt install python3-dev\nYou need to set your locale, for which I used export LC_ALL=C.\n\nAfter activating my virtualenv, I did simply pip install tesserocr and it worked like charm.","Q_Score":0,"Tags":"python,ubuntu,tesseract","A_Id":59137298,"CreationDate":"2018-06-27T11:59:00.000","Title":"Tesserocr crashes python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"In python, what is the best to run fft using cuda gpu computation?\nI am using pyfftw to accelerate the fftn, which is about 5x faster than numpy.fftn.\nI want to use pycuda to accelerate the fft. I know there is a library called pyculib, but I always failed to install it using conda install pyculib.\nIs there any suggestions?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1084,"Q_Id":51066245,"Users Score":1,"Answer":"I want to use pycuda to accelerate the fft\n\nYou can't. PyCUDA has no built-in FFT support of any kind.","Q_Score":1,"Tags":"python,cuda,cufft","A_Id":51066356,"CreationDate":"2018-06-27T15:12:00.000","Title":"the best way to conduct fft using GPU accelaration with cuda","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a question in relation to encryption on the server.\nSo I am making a chat\/mail system in which users are able to send messages to one another.\nBefore the message is sent, I run a script on my backend that encrypts the message, my question has to do with the decrypting.\nIn my database, I have a table that holds the encrypted messages, I do not want my database to hold any decrypted message. How do get the decrypted message to the users without holding any decrypted messages on my server?\nThank you.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":44,"Q_Id":51069309,"Users Score":0,"Answer":"Your question is almost certainly misguided. You usually don't want to encrypt messages from one user to another on the server, and you almost never want to decrypt them on the server.\n\nFirst, the whole point of public-key encryption is that nobody but the user and their own trusted software has access to the user's private key.\nYou don't want to store users' private keys on the server\u2014that would mean that if your server gets hacked, or some disgruntled employee wants to sabotage your company, they can decrypt every message in the world. Most users won't trust such a system, and they shouldn't.\nSo you have to do the decryption on the receiving user's client, where their private key is accessible.\n\nUsually, you also want to do the encryption on the sending user's client. Otherwise, every message is being sent in plaintext to the server, where a hacker (or an unscrupulous server company) could easily steal it before it's encrypted. Again, users won't, and shouldn't, trust such a design.\nThis means the sending client needs the recipient's public key, of course. But that's easy to manage: You store everyone's public key on the server, and add a command that the sending client can use to fetch the recipient's public key.\nIn some designs, you want to use a separate out-of-band mechanism for sharing public keys instead. For example, if you're using GPG, and want to rely on its web of trust instead of using your server to manage trust in identities, you'd give the client a way to import public keys and store them, or you'd give it a way to interact with an existing key store.\n\nIf you really want to do PK encryption entirely on the server, you can. It just doesn't provide much security benefit.\nTo do this, you could store every user's private key in the database. Then, you just fetch the encrypted message and the private key and decrypt it before sending. Then the plaintext is only available in some short-lived memory buffer, instead of in the database. But notice that this is no better than just not encrypting things at all. Sure, anyone who can access your database can't directly get the decrypted messages\u2014but they can get the encrypted messages and the keys needed to decrypt them, which is just as good. In fact, it's better for the attacker, because now they can decrypt other messages using the same private key, sign messages to impersonate the user, etc.\nAlternatively, you can have the user submit the private key whenever they want to fetch a message. You then pull the encrypted message out of the database, decrypt it with the private key, and send it to the user. Now both the private key and the plaintext live only in temporary memory. But this still adds almost nothing over not encrypting at all. The messages\u2014and, worse, the private keys\u2014are traveling as plaintext over the open internet. Plus, anyone who can hack your server can't pull the private keys out of your database, but they can just store them as they come in.","Q_Score":0,"Tags":"python,encryption","A_Id":51069417,"CreationDate":"2018-06-27T18:29:00.000","Title":"Public and private key encryption delivery","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm running a miner on my Raspberry Pi at 100% CPU performance. I want the Raspberry Pi to send some tweets about his temperature and Hashrate over twitter. So far I've written a script which does its job well... To keep the miners performance it's important for me which method consumes less power\/performance.\nWhat would you use? Cronjobs or sleep?\nAny help would be very appreciated!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":165,"Q_Id":51077547,"Users Score":2,"Answer":"Cronjobs should be more efficient. There are always being check out by the system, if you use sleep you would be still checking for cronjobs (even if there's no job to run) so sleep is innecesary.","Q_Score":1,"Tags":"python,performance,cron,sleep","A_Id":51077745,"CreationDate":"2018-06-28T07:53:00.000","Title":"Do cronjobs have better performance than sleep functions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"For a project I'm working on, I'm supposed to use XBee radio modules, which isn't super important, except that I have to read and write to their serial port in order to use them. I'm currently working with Python and ROS, so I'm attempting to send TransformStamped messages over the XBees.\nMy question is, unless I'm misunderstanding how Serial.read() and Serial.write() work, how can I tell how many bytes to read? I was planning on using Pickle to serialize the data into a string, and then sending that over the serial ports. Is there a better way that I've overlooked? Is there some sort of loop that would work to read data until the end of the pickled string is read?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":144,"Q_Id":51089252,"Users Score":0,"Answer":"The short answer is, serial.read() cannot tell you how many bytes to read. Either you have some prior knowledge as to how long the message is, or the data you send has some means of denoting the boundaries between messages. \nHint; knowing how long a message is is not enough, you also need to know whereabouts in the received byte stream a message has actually started. You don't know for sure that the bytes received are exactly aligned with the sent bytes: you may not have started the receiver before the transmitter, so they can be out of step. \nWith any serialisation one has to ask, is it self delimiting, or not? Google Protocol buffers are not. I don't think Pickle is either. ASN.1 BER is, at least to some extent. So is XML.\nThe point is that XBee modules are (assuming you're using the ones from Digi) just unreliable byte transports, so whatever you put through them has to be delimited in some way so that the receiving end knows when it has a complete message. Thus if you pickle or Google Protocol Buf your message, you need some other way of framing the serialised data so that the receiving end knows it has a complete message (i.e. it's seen the beginning and end). This can be as simple as some byte pattern (e.g. 0xffaaccee00112233) used to denote the end of one message and the beginning of the next, chosen so as to be unlikely to occur in the sent messages themselves. Your code at the receiving end would read and discard data until is saw that pattern, would then read subsequent data into a buffer until it saw that pattern again, and only then would it attempt to de-pickle \/ de-GPB the data back into an object. \nWith ASN.1 BER, the data stream itself incorporates effectively the same thing, saving you the effort. It uses tags, values and length fields to tell its decoders about the incoming data, and if the incoming data makes no sense to the decoder in comparison to the original schema, incorrectly framed data is easily ignored.\nThis kind of problem also exists on tcp sockets, though at least with those delivery is more or less guaranteed (the first bytes you receive are the first bytes sent). A Digimesh connection does not quite reach the same level of guaranteed delivery as a tcp socket, so something else is needed (like a framing byte pattern) for the receiving application to know that it is synchronised with the sender.","Q_Score":0,"Tags":"python,serialization,deserialization,ros,robotics","A_Id":51144344,"CreationDate":"2018-06-28T18:27:00.000","Title":"Using serializing an object in python for use with an XBee","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to find out if anyone has suggestions on how to create a script that can easily be edited to create a custom Maya node with just adding in some arbitrary values of any type.\nBasically, I would want to be able to specify an attribute type (string type, float type, ect), and to be able to fill in the values for those types and have the script generate a custom node easily.\nExcited to hear back any suggestions.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":940,"Q_Id":51101012,"Users Score":1,"Answer":"You can create an empty group node and add any arbitrary attribute to it. This has the disadvantage that you cannot filter by node type. But you can use a special naming convention to filter for these type of nodes.\nIf you need your own node type, you can easily create your own nodetype with a simple python api script. Then you can fill in any additional attributes as you like.","Q_Score":1,"Tags":"python,maya,maya-api","A_Id":51103390,"CreationDate":"2018-06-29T11:45:00.000","Title":"Autodesk Maya API Custom Node","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to deploy a simple service to AWS Lambda (on Python 3.6) that requires PIL. I'm using the serverless framework, so to start I simply did pip3 freeze > requirements.txt on an ec2 instance with my code and all of the dependencies installed, and when I called the Lambda function I got the following error (from CloudWatch logs):\nUnable to import module 'lambda_function': No module named 'PIL'\nI then tried to install & package pillow manually by doing pip3 install pillow -t .vendor and added the following to my serverless.yml:\npackage:\n include:\n - .vendor\/**\nBut I'm still getting the same error. Am I doing something wrong?\nEDIT: It seems that not using the serverless architecture and instead packaging the dependencies myself fixed the issue. Why is this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1110,"Q_Id":51106025,"Users Score":0,"Answer":"This is because pillow is not a standard python library found in AWS Lambda environment by default. To include and use it in your code you need to make a custom deployment package with all your dependicies and your code included and then deploy it. \nAnd this is what you did to make it run.","Q_Score":0,"Tags":"python-3.x,aws-lambda,pillow,serverless-framework,serverless","A_Id":51166542,"CreationDate":"2018-06-29T16:30:00.000","Title":"AWS Lambda Python PIL\/pillow import error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've got a simple Telegram bot, I don't think the code matters but I used telebot library.\nI uploaded it to pythonanywhere, installed virtual environment and all libraries that needed. \nWhenever I type python.script.py in the bash console, script works for, say, 5 hours, then it stops. How do I make it run forever?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":241,"Q_Id":51115038,"Users Score":2,"Answer":"PythonAnywhere does not keep consoles running forever. They need to be stopped on occasion to manage the service. See the PythonAnywhere documentation for details about keeping tasks running.","Q_Score":0,"Tags":"python,telegram,pythonanywhere","A_Id":51116139,"CreationDate":"2018-06-30T12:44:00.000","Title":"Telegram bot stops after a few hours on pythonanywhere","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm wondering what the symbol is or if I am even able to get historical price data on BTC, ETH, etc. denominated in United States Dollars. \nright now when if I'm making a call to client such as: \nClient.get_symbol_info('BTCUSD')\nit returns nothing\nDoes anyone have any idea how to get this info? Thanks!","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":4098,"Q_Id":51127720,"Users Score":3,"Answer":"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.\nTo solve that use BTCUSDT\nChange BTCUSD to BTCUSDT","Q_Score":2,"Tags":"python,api,bitcoin,cryptocurrency,binance","A_Id":51128924,"CreationDate":"2018-07-01T23:33:00.000","Title":"Binance API: how to get the USD as the quote asset","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have three scripts:\nconfig.yaml and script.py and slurm.sh\nI am submitting job to the job scheduler in Slurm using the slurm.sh file which calls the script.py file and the script.py files loads the config from the config.yaml file.\nIt would look like this:\nsbatch slurm.sh\nNow, I change the config.yaml and submit another job. However, if both jobs are in the queue, the config.yaml file will be overwritten and both jobs will use the same configuration. \nIs there any way to tell the slurm scheduler to cache the config.yaml file as well? I know it is dont for the slurm.sh file.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":67,"Q_Id":51169224,"Users Score":1,"Answer":"There is no way to achieve that. You should modify your script (.sh) to point to the proper configuration file before submission, and create as many configuration files as needed.\nAnother option could be to convert the configuration file entries to command line parameters (if possible) before submission and submit a script with a fully configured command line (so no need to read the .yaml file).","Q_Score":0,"Tags":"python,config,slurm,sbatch","A_Id":51175506,"CreationDate":"2018-07-04T08:33:00.000","Title":"How to tell slurm to cache config file for multiple submissions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am using 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 \nldap.SERVER_DOWN: {u'info': 'Transport endpoint is not connected', 'errno': 107, 'desc': u\"Can't contact LDAP server\"}\nCan somebody please help me if there exists any attribute which can give result code for successful LDAP search operation.\nThanks,\nRadhika","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":549,"Q_Id":51174045,"Users Score":0,"Answer":"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.\n(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.)\nIn 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.","Q_Score":0,"Tags":"python-ldap","A_Id":51365948,"CreationDate":"2018-07-04T12:45:00.000","Title":"search_s search_ext_s search_s methods of python-ldap library doesn't return any Success response code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm running a large suite of python tests using pytest, and some test results depend on the running order of the tests. For example if test B runs after test A then it can fail due to some initializations done in test A that affect test B.\nTo circumvent this problem I would like to run each test in a new process, but the tests should still run sequentially and not in parallel.\nIs there a way to do that with pytest?","AnswerCount":2,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":1955,"Q_Id":51187188,"Users Score":-2,"Answer":"I would recommend that you implement setup_method() and teardown_method() that can cleanup initializations you do in the tests. This way you can get rid of dependencies you have with the order of execution of your tests.\nThe other alternative would be to use a fixture. \nBut if you dont want to run the tests in parallel, I dont see the advantage of starting each test in a new process. Although if you still need it, you can start a new process in your setup_method() and attach the current test to this process. Your teardown_method() can then kill this process.","Q_Score":4,"Tags":"python,pytest","A_Id":51187357,"CreationDate":"2018-07-05T08:57:00.000","Title":"pytest - run each test in a separate process","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way to use github3.py python library to access github with a SSH key?\nI'm trying to create a service that writes on some repositories using a machine user for security reasons.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":138,"Q_Id":51192262,"Users Score":1,"Answer":"Unfortunately, the GitHub API doesn't provide a way to authenticate with SSH keys. Thus, github3.py provides no way to login using SSH keys.","Q_Score":0,"Tags":"python,github-api,github3.py","A_Id":51211308,"CreationDate":"2018-07-05T13:13:00.000","Title":"github3.py login using ssh keys","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In our setup we have a central RabbitMQ instance running on three hosts, each with its own URL.\nFor maintenance, any of these hosts may go down at any time for several hours. When this happens, we would like to connect to one of the other hosts.\nWe have been using aio_pika.connect_robust to connect, but it only accepts a single host as parameter.\nIt would be perfect if the reconnect could happen seamlessly in the background. A worker could get a message from the connection to one host, work on it and then acknowledge it over a different connection.\nWhat would be the best way to solve this?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1779,"Q_Id":51210556,"Users Score":2,"Answer":"A worker could get a message from the connection to one host, work on it and then acknowledge it over a different connection\n\nThat's not possible, since acks are tied to channels. When the first channel closes, RabbitMQ will re-enqueue the message and will re-deliver it to another consumer.\nIt looks as though aio-pika does not support multiple hosts from which to choose to connect. I recommend either trapping connection-related exceptions yourself to choose another host, or put haproxy between your application and RabbitMQ.","Q_Score":3,"Tags":"rabbitmq,python-asyncio,pika,reconnect","A_Id":51223805,"CreationDate":"2018-07-06T12:30:00.000","Title":"Robust aio-pika connection to multiple RabbitMQ hosts","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I use 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.\nVSCode Version: May 2018 (1.24)\nOS Version: Windows 10 \nLet's say I have 20 unit tests in a particular project.\nI run the tests by right clicking on a unit test file and click 'Run all unit tests'\nAfter the run is complete, the results bar displays how many tests are passed and how many are failed. (e.g. 15 passed, 5 failed).\nAnd I can run\/debug individual test because there is a small link on every unit test function for that.\nIf I re-run the tests from same file, then the results bar displays the twice number of tests. (e.g. 30 passed, 10 failed)\nAlso the links against individual test functions disappear. So I cannot run individual tests.\nThe only way to be able to run\/debug individual tests after this is by re-launching the VS code.\nAny suggestions on how to fix this?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2562,"Q_Id":51215617,"Users Score":0,"Answer":"This was a bug in Python extension for VS code and it is fixed now.","Q_Score":1,"Tags":"python,python-2.7,visual-studio-code","A_Id":53988353,"CreationDate":"2018-07-06T17:58:00.000","Title":"Python Unit test debugging in VS code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I have a python project on my VPS that I want to always be running, and when I push an update through git, it updates its files and restarts. How would I do this? (A discord.py rewrite bot exactly)","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":332,"Q_Id":51218139,"Users Score":1,"Answer":"You could add a GitHub webhook to a Discord channel and make your bot listen to it. If it detects a push message, make it run git pull and quit. Then, just run the bot in a loop with while true; do python bot.py; done.\nAlternatively, write another script that will listen for HTTP requests from a GitHub webhook and kill the bot. You'll probably need to save the PID using bash.","Q_Score":1,"Tags":"python-3.x,git,ubuntu,vps,discord.py-rewrite","A_Id":51218248,"CreationDate":"2018-07-06T22:02:00.000","Title":"How to have a VPS auto update on git pushes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a weird problem! I made a client \/ server Python code with Bluetooth in series, to send and receive byte frames (for example: [0x73, 0x87, 0x02 ....] ) \nEverything works, the send reception works very well ! \nThe problem is the display of my frames, I noticed that the bytes from 0 to 127 are displayed, but from 128, it displays the byte but it adds a C2 (194) behind, for example: [0x73, 0x7F, 0x87, 0x02, 0x80 ....] == [115, 127, 135, 2, 128 ....] in hex display I would have 73 7F C2 87 2 C2 80 .. , we will notice that he adds a byte C2 from nowhere! \nI think that since it is from 128! that it is due to a problem of signed (-128 to 127) \/ unsigned (0 to 255).\nAnyone have any indication of this problem?\nThank you","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":72,"Q_Id":51242202,"Users Score":0,"Answer":"0xc2 and 0xc3 are byte values that appear when encoding character values between U+0080 and U+00FF as UTF-8. Something on the transmission side is trying to send text instead of bytes, and something in the middle is (properly) converting the text to UTF-8 bytes before sending. The fix is to send bytes instead of text in the first place.","Q_Score":1,"Tags":"python-3.x,bluetooth,byte,frames","A_Id":51245089,"CreationDate":"2018-07-09T09:26:00.000","Title":"Trouble displaying signed unsigned bytes with python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is a great package for Bayesian optimization of hyperparameters (especially mixed integer\/continuous\/categorical...and has shown to be better than Spearmint in benchmarks). However, clearly it is meant for Linux. What do I do...?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":216,"Q_Id":51254986,"Users Score":0,"Answer":"First you need to download swig.exe (the whole package) and unzip it. Then drop it somewhere and add the folder to path so that the installer for SMAC3 can call swig.exe.\nNext, the Resource module is going to cause issues because that is only meant for Linux. That is specifically used by Pynisher. You'll need to comment out import pynisher in the execute_func.py module. Then, set use_pynisher:bool=False in the def __init__(self...) in the same module. The default is true.\nThen, go down to the middle of the module where an if self.use_pynisher....else statement exists. Obviously our code now enters the else part, but it is not setup correctly. Change result = self.ta(config, **obj_kwargs) to result = self.ta(list(config.get_dictionary().values())). This part may need to be adjusted yet depending on what kind of inputs your function handles, but essentially you can see that this will enable the basic example shown in the included branin_fmin.py module. If doing the random forest example, don't change at all...etc.","Q_Score":0,"Tags":"python-3.x,optimization,bayesian","A_Id":51254987,"CreationDate":"2018-07-09T22:42:00.000","Title":"How to get SMAC3 working for Python 3x on Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to write a python script to read a large logfile (1GB+), extract IP addresses in each line, store these IPs, remove duplicates, locate in another files the the hostnames related to these IPs and rewrite the hostnames to a new logfile containing the original data.\nNow the question: What is the best way to deal with memory, files, etc? I mean, I see two approaches:\n\nRead the original logfile, extract IPs and write to a new file (tmp_IPS.txt, remove dupes, search these IPs line by line on another files (hostnames.txt), write the results to tmp_IPS.txt, read and rewrite original logfile. In this case, I will process less IPs (without the dupes).\nRead the original logfile, read the IPs and search each IP on the hostnames.txt, write the rows on original logfile + hostnames. In this case, I will process a lot of duplicated IPs. I can also write the found IPs and hostnames to a new file or to memory, but I really don't know what is better.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":950,"Q_Id":51255950,"Users Score":0,"Answer":"The most efficient way to deal with large log files in this case is to read and write at the same time, line by line, to avoid loading large files into memory. You should load the IP-to-hostname mapping file hostnames.txt in to a dict first if hostnames.txt is relatively small; otherwise you should consider storing the mapping in an indexed database)","Q_Score":0,"Tags":"python,memory,file-io","A_Id":51256102,"CreationDate":"2018-07-10T01:09:00.000","Title":"The most efficient (or professional) way to read, proccess and write a file with Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I've got an automated mailing system with MIMEText, and I would like to change the font of the text in one line.\nHow do I do that, can you help me please?\nThanks.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2587,"Q_Id":51285184,"Users Score":0,"Answer":"MIMEText should support HTML tags, so you can just wrap Text<\/font> tags around it. This is of course assuming that your clients are reading the message with a client that will parse the HTML tags.","Q_Score":0,"Tags":"python,email,fonts,size","A_Id":51285274,"CreationDate":"2018-07-11T12:11:00.000","Title":"Python - How to change the font with MIMEText","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've got an automated mailing system with MIMEText, and I would like to change the font of the text in one line.\nHow do I do that, can you help me please?\nThanks.","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":2587,"Q_Id":51285184,"Users Score":2,"Answer":"MIMEText will generate the mail in plaintext (which is generated in a monospaced font, and there's nothing you can do about it) and as HTML.\nWith HTML, you could simply wrap your e-mail in a font or font face (the last one, if you need to indicate only the font's family) tag:\nYour e-mail here<\/font>\nObs: you can only accomplish that if your recipient is reading mail in an HTML capable email client.","Q_Score":0,"Tags":"python,email,fonts,size","A_Id":51285279,"CreationDate":"2018-07-11T12:11:00.000","Title":"Python - How to change the font with MIMEText","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is the difference between $PATH variable, sys.path and os.environ? I understand that they both serve as paths where python searches packages. But it'd be nice to have more elaborate response.\nJust a working case from my practice is when I used the script with only os.environ before import on Ubuntu 16.04 I got ImportError: No module named XXX. At the same time on MacOS it worked well. After I added sys.path on Ubuntu I could get import module well.\nThanks for the explanation at Advance.","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":8363,"Q_Id":51288512,"Users Score":4,"Answer":"sys.path\nIs a list of strings that specifies the search path for modules. Initialized from the environment variable PYTHONPATH, plus an installation-dependent default.\nos.environ\nIs a mapping object representing the string environment. For example, environ['HOME'] is the pathname of your home directory (on some platforms), and is equivalent to getenv(\"HOME\") in C.\nEnvironment variable PATH\nSpecifies a set of directories where executable programs are located. In general, each executing process or user session has its own PATH setting.","Q_Score":17,"Tags":"python-3.x","A_Id":51291905,"CreationDate":"2018-07-11T14:48:00.000","Title":"Difference between $PATH, sys.path and os.environ","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"While using tweepy I came to know about encode(utf-8). I believe encode utf-8 is used to display tweets only in English, Am i right in this regard beacuse I want to make data sets of tweets which are only Written in English, so I can process that tweets for NLP","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":875,"Q_Id":51292190,"Users Score":0,"Answer":"No, UTF-8 is a mechanism for encoding Unicode content. This means that it supports almost all scripts of the vast majority of human languages.","Q_Score":1,"Tags":"python,utf-8,internationalization,tweepy","A_Id":51292254,"CreationDate":"2018-07-11T18:35:00.000","Title":"Python Tweepy Encode(utf-8)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is more a conceptual question. I am unit testing a script I wrote that has multiple modules. I have a main.py and a formatting.py. My coverage is at 100% for formatting but my main.py is at 30%. In my main, I just call all of the functions inside formatting. Do i need to just test them again in main directly? This seems like a waste of time? Maybe I am not understanding correctly. Thanks in advance","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":117,"Q_Id":51292465,"Users Score":1,"Answer":"Usually the trick is to test what external function does by itself and not other functions that are called and are already tested. This is not a problem if internal functions are actually called, just avoid testing them again.\nIf you want to avoid calling internal functions though, you may try dependecy injection or mocking.\nIf your external function is simple enough, you may forgo testing it, 100% coverage is not a rule.","Q_Score":1,"Tags":"python,unit-testing","A_Id":51292632,"CreationDate":"2018-07-11T18:56:00.000","Title":"unit test main.py with other modules","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is more a conceptual question. I am unit testing a script I wrote that has multiple modules. I have a main.py and a formatting.py. My coverage is at 100% for formatting but my main.py is at 30%. In my main, I just call all of the functions inside formatting. Do i need to just test them again in main directly? This seems like a waste of time? Maybe I am not understanding correctly. Thanks in advance","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":117,"Q_Id":51292465,"Users Score":1,"Answer":"The fact that internal pieces are tested allows you to capitalize on it by reducing the number of the tests required for the new, higher level method.\nThere always will be some redundancy between those, but decent and straightforward seams would allow you to have a very few tests for the new level. \nThe guys in the other answers are talking about considering those tests as integrational, but I would claim that you also would need some tests in isolation for the upper function itself with all already tested dependencies being mocked and excluded. \nIt's not always necessary, but please be aware that you end up with a mixed test otherwise, since there's a new functionality on the top level.","Q_Score":1,"Tags":"python,unit-testing","A_Id":51293145,"CreationDate":"2018-07-11T18:56:00.000","Title":"unit test main.py with other modules","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is more a conceptual question. I am unit testing a script I wrote that has multiple modules. I have a main.py and a formatting.py. My coverage is at 100% for formatting but my main.py is at 30%. In my main, I just call all of the functions inside formatting. Do i need to just test them again in main directly? This seems like a waste of time? Maybe I am not understanding correctly. Thanks in advance","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":117,"Q_Id":51292465,"Users Score":1,"Answer":"A good rule of thumb for unit testing is to:\n\nseparate your code from the part that does logic and the part that does input\/output\nunit test the part that does logic\nnot unit test the part that does i\/o\n\nBut how will you know the program works then? Well, how about some integration tests? For example, if you're writing a command line script, an integration test might run it the whole script with some inputs and check if the script did the right thing, without even considering how it is structured.\nDepending on your needs and the size of the script, you might decide to have unit tests, integration tests or both.","Q_Score":1,"Tags":"python,unit-testing","A_Id":51292746,"CreationDate":"2018-07-11T18:56:00.000","Title":"unit test main.py with other modules","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to translate PDFs files using translation API and output it as PDF by keeping the format same. My approach is to convert the PDF to word doc and to translate the file and then convert it back to PDF. But the problem, is there no efficient way to convert the PDF to word. I am trying to write my own program but the PDFs has lots of formats. So I guess it will take some effort to handle all the formats. So my question, is there any efficient way to translate there PDFs without losing the format or is there any efficient way to convert them to docx. I am using python as programing language.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":3080,"Q_Id":51303812,"Users Score":1,"Answer":"Probably not.\nPDFs aren't meant to be machine readable or editable, really; they describe formatted, laid-out, printable pages.","Q_Score":0,"Tags":"python,pdf,docx","A_Id":51303850,"CreationDate":"2018-07-12T10:54:00.000","Title":"Translate pdf file by keeping the formating Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any Python equivalent of Scala's Case Class? Like automatically generating constructors that assign to fields without writing out boilerplate.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":11592,"Q_Id":51342228,"Users Score":1,"Answer":"The other answers about dataclass are great, but it's worth also mentioning that:\n\nIf you don't include frozen=True, then your data class won't be hashable. So if you want parity with Scala case classes (which automatically define toString, hashcode and equals) then to get hashcode, you will need @dataclass(frozen=True)\neven if you do use frozen=True, if your dataclass contains an unhashable member (like a list), then the dataclass won't be hashable.\nhash(some_data_class_instance) will be equal if the values are equal (and frozen=True)\nFrom a quick empirical test, equality comparisons don't appear to be any faster if your type is hashable. Python is walking the class members to compare equality. So even if your frozen dataclass has all hashable members (e.g. tuples instead of lists), it will still walk the values to compare equality and be very slow.","Q_Score":19,"Tags":"python,scala","A_Id":66616777,"CreationDate":"2018-07-14T18:19:00.000","Title":"Python equivalent of Scala case class","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Actually I have 2 questions. I added google, facebook and twitter sign in to my android app. I use firebase sign in for register and login. After that I will use my own python server. Now, I want to add auto sign in. Namely, after first login, it won't show login page again and it will open other pages automatically. I searched but i didn't find a sample for this structure. How can I do auto sign in with facebook, google, twitter in my android app. And how my server know this login is success and it will give user's data to clients in securely.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":460,"Q_Id":51347328,"Users Score":0,"Answer":"You need to do a web-service call from Android side just after login from firebase, stating in your server that this user has logged in to your app. You can store the access token provided by firebase or you can generate yours on web service call and thereby authenticate user with that token for user specific pages.","Q_Score":1,"Tags":"android,firebase-authentication,facebook-login,google-signin,python-server-pages","A_Id":51347386,"CreationDate":"2018-07-15T10:05:00.000","Title":"Auto sign in with Google, Facebook and Twitter in Android App","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm 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? \nAlso does anyone else have any other suggestion on how to measure latency across the network?","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":1991,"Q_Id":51357410,"Users Score":3,"Answer":"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.\nIf the subscriber and client are synchronized.\n\nFill the payload with the time stamp value at the client and transmit\nthis packet to subscriber. At the subscriber again take the time\nstamp and take the difference between the time stamp at the\nsubscriber and the timestamp value in the packet.\nThis gives the time taken for the packet to reach subscriber from\nclient.\n\nIf the subscriber and client are not synchronized.\nIn this case measurement of latency is little tricky. Assuming the network is symmetrical.\n\nStart the timer at client before sending the packet to subscriber.\nConfigure subscriber to echo back the message to client. Stop the\ntimer at the client take the difference in clock ticks. This time\nrepresents the round trip time you divide it by two to get one\ndirection latency.","Q_Score":2,"Tags":"python,c++,mqtt,latency,paho","A_Id":51363050,"CreationDate":"2018-07-16T08:18:00.000","Title":"How to measure latency in paho-mqtt network","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"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? \nAlso does anyone else have any other suggestion on how to measure latency across the network?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":1991,"Q_Id":51357410,"Users Score":2,"Answer":"on_message() is called on the subscriber when the message reaches the subscriber.\nOne way to measure latency is to do a loop back publish in the same client e.g.\n\nSetup a client\nSubscribe to a given topic\nPublish a message to the topic and record the current (high resolution) timestamp.\nWhen on_message() is called record the time again\n\nIt 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).\nAlso latency will be influenced by the load on the broker and the number of subscribers to a given topic.\nThe 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.","Q_Score":2,"Tags":"python,c++,mqtt,latency,paho","A_Id":51361548,"CreationDate":"2018-07-16T08:18:00.000","Title":"How to measure latency in paho-mqtt network","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way to completely disable cookies from the Tornado server? I'm not using them for my public-facing site and I don't want to have the annoying pop-up to get European compliance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":101,"Q_Id":51365906,"Users Score":0,"Answer":"The only time Tornado sets cookies on its own is if you use the xsrf_cookies application setting. If you turn that off and there are no other calls to set_cookie or set_secure_cookie in your application, no cookies will be set. \nXSRF is a serious security issue and you should carefully consider whether you need an alternative solution if you don't use xsrf_cookies. However, if you don't have any other cookies (or equivalent forms of authentication), you're probably OK.","Q_Score":0,"Tags":"python,cookies,tornado","A_Id":51372029,"CreationDate":"2018-07-16T16:01:00.000","Title":"Turn off cookies in Tornado","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I want to execute a python script in ionic as we execute python script in php\nIs there any way of doing that?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":735,"Q_Id":51393759,"Users Score":1,"Answer":"As far as I know, python scripts are not executed in Ionic. By writing python code we can though, access services which are written in Python by writing the API call from 'providers' in ionic.","Q_Score":1,"Tags":"php,python,python-3.x,ionic-framework,ionic3","A_Id":51393804,"CreationDate":"2018-07-18T04:48:00.000","Title":"How to execute python script in ionic framework similarly it execute in a php file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was trying to add some folders to my path, so I added a .pth file to my site-packages folder. When it didn't work (I printed sys.path and it doesn't contain any of the paths I wrote in the file) , I tried to find the .pth file from within python and I noticed that the name of one of the folders in the path contains a . in it.\nCould that be the reason why the .pth file wasn't processed? or any other suggestions why Its not working?\nI don't think I can change the folder name, it was created when I created a virtual environment, and I think that if I'll change it, it might mess up other things.\nThe path to the .pth is - home\/pomicelltohar\/venv\/3_6\/lib\/python3.6\/site-packages\/pomicell.pth\nsys.path is \n['', '\/home\/pomicelltohar\/venv\/3_6\/lib\/python36.zip', '\/home\/pomicelltohar\/venv\/3_6\/lib\/python3.6', '\/home\/pomicelltohar\/venv\/3_6\/lib\/python3.6\/lib-dynload', '\/home\/pomicelltohar\/anaconda3\/lib\/python3.6', '\/home\/pomicelltohar\/venv\/3_6\/lib\/python3.6\/site-packages']","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":823,"Q_Id":51403479,"Users Score":1,"Answer":"The problem was that I wrote the paths in the .pth file with ~\/ instead of using the full path \/home\/pomicelltohar","Q_Score":0,"Tags":"python,path,pythonpath,pth","A_Id":51476127,"CreationDate":"2018-07-18T13:37:00.000","Title":"pth file is not processed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a django file server. The server works perfectly on my laptop & localhost (with external hard drive) but when I transferred it to my Raspberry Pi running Raspbian, it starts acting up.\nI did a lot of googling and tried every possible solution but it does not work. \nHere is my problem:\nI have connected an external hard drive to my raspberry pi. I believe it has write permissions because I can easily write to it with mkdir. I have also set this directory which is \/media\/pi\/SAMSUNG\/media as my MEDIA_ROOT. \nNow I have set up Apache2, WSGI and Django, everything works, I have set up all the permissions and everything, but still when django tries to access the hard drive, whether it be to read or write, I get an error [Errno 13] Permission denied: '\/media\/pi\/SAMSUNG'. \nI have fixed this in the past with chown -R 777 but it does not work this time. \nUnfortunetly, I have no idea what I am doing when it comes to servers and file permissions, so I have no idea what code to attach. Can some please help me?\nI will attach all the necessary code on request.\nThank you","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":165,"Q_Id":51410594,"Users Score":0,"Answer":"On raspbian you have to be careful when using external drives. Have you edited the file \/etc\/fstab? This is necessary to mount the drive also correctly after restarts and when the file is temporarily disconnected and then connected again.\nIf you did this correctly, then the drive will have the permissions you gave it when mounting and Django should be able to access it\/write to it.\nBR","Q_Score":0,"Tags":"python,django,apache2,file-permissions","A_Id":51410717,"CreationDate":"2018-07-18T20:36:00.000","Title":"Permission denied when django writes to external device","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have deployed a webapplication Python Django Rest Framework Front end is Vue js and Database is Mysql.\nHosted the website on digital ocean i am using CPU Optimized Droplets with the below configuration 8 GB 4 vCPUs i facing performance issue the site is very slow though the hosting is CPU optimized with 8gb of ram.\nWhen i checked the error log i am able to find [CRITICAL] WORKER TIMEOUT (pid:9116) i increased the timeout time of the gunicorn still i am facing the same issue.\n1)I want to increase the performance \n2)I want to fix the timeout issue i have increased the value in gunicorn as nginx the maximum value is 75s i have not done any addition to it. what will be th best solution.\nKindly help me is there any alternative ways to test the performance of the site.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1064,"Q_Id":51436451,"Users Score":0,"Answer":"I think you need optimization\nTips on optimizing your django rest on production server .\n\nCheck your queries. Best way to check this is using the django debug toolbar, it will show how many queries you produce and if you think there is a lot, then optimize your queries. Ex. use prefetch_related or select_related to join the tables or else it will query one by one.\nIndex your tables, try to index the columns you're always using on querying. Just be careful on indexing, just index the columns you really wanted because the downside will be slower on update, delete and add.\nCheck your database health, if you perform delete or update frequently those data actually stored somewhere and it is still part of your indexes, it called Dead Rows, you can remove this by perform some commands like vacuum if your are using postgres.\nScale up your server, this actually depends on the request\/traffic of your server, check the RAM or CPU spikes for you to determine the needed units. As experience, I have atleast 10m row of data on some of my tables, which in some scenario I cross refer it to a 30k data, on 2gb RAM and 1gb CPU working fine in few simultaneous request.","Q_Score":0,"Tags":"python,django,nginx,webserver,gunicorn","A_Id":51439974,"CreationDate":"2018-07-20T06:36:00.000","Title":"Gunicorn Timeout Server Slow issues","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to generate html email, that would show data based on dropdown menu selection within email. I have been looking around and could not find anything suitable for this use case.\nCurrently my procedure is that I use Python to generate all required data and than render html template with Jinja2 package.\nWhat I would like to have is first part of email to be static and than under that section have a dropdown menu, which would render rest of email based on selection. I wonder if that is even possible (on side note, I can not use JS, as it is blocked for mails that are generated)?\nThank you and best regards,\nBostjan","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1050,"Q_Id":51441100,"Users Score":2,"Answer":"You will have to work with css's :active property to work around js here.\nYour problem will be the broad variety of email programms, outlook and such will fail to process this correctly.","Q_Score":2,"Tags":"python,html,dynamic,jinja2,dropdown","A_Id":51441195,"CreationDate":"2018-07-20T11:03:00.000","Title":"Dynamic html email with dropdown","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"This question was asked few times on stackoverflow. However, what I'm trying to do is a little bit different.\nI'm trying to port python to QNX. Compiling all the source files and statically linking it to a \"Hello World\" script using python c API works. \nI'm having problem with the struct module. I tried compiling struct into a shared library and placing it at the exec_prefix path specified by python. When I try to import it, It tries to load the module but it complains about unknown symbols.\nIt says something like \n\nUnknown symbol: _PyUnicode_FormatAdvancedWriter referenced by\n _struct.so\n\nI get a lot of unknown symbol errors like this. I included the header and source files of all these unknown symbols and it ends up throwing other unknown symbol errors. \nI might be doing something completely wrong. Any ideas on how I can link them?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":678,"Q_Id":51444888,"Users Score":1,"Answer":"I'm answering my own question since I figured out the fix. If anyone else is having the same problem, you have to export all the symbols to the dynamic symbol table at link time. To do this, you have to pass a flag -E to the linker i.e -Wl, -E. That should solve the problem. \nThis is a qcc specific flag so if you're experiencing this problem in gcc, you can try passing --whole-archive flag to the linker.","Q_Score":2,"Tags":"python,c,python-3.x,linker-errors,qnx-neutrino","A_Id":51655464,"CreationDate":"2018-07-20T14:32:00.000","Title":"How to statically link the python interpreter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need a means to make accessible a PR from a fork submitted to a repository via GitPython. Once I have the PR and it's commits available I should be able to use it how I plan to, but so far haven't seen any support to pull\/clone commits included in a Peer Review from a fork. Does anyone know if this isn't supported or am I overlooking it? \nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":83,"Q_Id":51484682,"Users Score":0,"Answer":"It took longer than I'd like to admit, but I believe I figured out what was needed. \nrepo = git.Repo('name_of_repo')\nrepo.remotes.fetch(refspec='pull\/#\/head')","Q_Score":0,"Tags":"python,python-3.x,git,github","A_Id":51486546,"CreationDate":"2018-07-23T17:54:00.000","Title":"How to obtain PR form git via GitPython","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to 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?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":134,"Q_Id":51498056,"Users Score":2,"Answer":"Unfortunately this won't be possible as when you trigger a shutdown naoqi will exit as well and destroy your service. \nIf you are coding in c++ you could use a destructor, but there is no proper equivalent for python... \nAn 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. \nNote: 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!)","Q_Score":0,"Tags":"python,nao-robot,pepper,choregraphe","A_Id":51566036,"CreationDate":"2018-07-24T11:59:00.000","Title":"How can I handle Pepper robot shutdown event?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Why would the file system (CIRCUITPY) of an Adafruit board running CircuitPython not show up when connecting it to a suitable host via a micro usb cable?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1381,"Q_Id":51543804,"Users Score":1,"Answer":"Besides your first answer about the cable, because of the relatively inexpensive nature of the boards and direct access to their power\/ground sometimes the EPROMs that the file system are hosted on just go bad and give unexpected results. Best idea is to:\n\nTest your environment with another board.\nReflash micro python on your board so you can start from scratch (didn't mention if you'd tried that).","Q_Score":0,"Tags":"usb,adafruit,micropython","A_Id":51622090,"CreationDate":"2018-07-26T16:44:00.000","Title":"Why might an Adafruit CircuitPython board's filesystem fail to mount?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Does anyone have 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\"?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":712,"Q_Id":51547675,"Users Score":1,"Answer":"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.\nof 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.\nthe 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.\nI 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 :)","Q_Score":2,"Tags":"automation,ironpython,spotfire","A_Id":51674710,"CreationDate":"2018-07-26T21:21:00.000","Title":"Triggering email out of Spotfire based on conditions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a minimization problem, that is modeled to be solved in Gurobi, via python.\nBesides, I can calculate a \"good\" initial solution for the problem separately, that can be used as an upper bound for the problem.\nWhat 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.\nCan anybody help me how to set this upper bound in the Gurobi?\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":438,"Q_Id":51550870,"Users Score":0,"Answer":"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 ?","Q_Score":0,"Tags":"python,initialization,gurobi,upperbound","A_Id":51712765,"CreationDate":"2018-07-27T04:42:00.000","Title":"How to set an start solution in Gurobi, when only objective function is known?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In some progam languages for example PHP, deleting an item do not re-index automatically the array , i want to know the behaviour of a Python list after deleting an item with del()...","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":44,"Q_Id":51582380,"Users Score":0,"Answer":"Index changes to reflect content.","Q_Score":0,"Tags":"python,list","A_Id":51582413,"CreationDate":"2018-07-29T16:36:00.000","Title":"Behaviour after deleting list item from List in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When compiling python to javascript using transcrypt I've noticed the syntax error reporting is more vague than the standard python syntax error reporting. Since the code cannot be compiled using the standard python compiler as it would throw syntax errors due to the transcrypt syntax is there a way to get more specific syntax error reporting that resembles the python compiler?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":157,"Q_Id":51621205,"Users Score":0,"Answer":"In some cases: yes, in general: no.\nTranscrypt syntax IS Python syntax, since both use CPython's ast module to parse the source code.\nBut Transcrypt programs may call JavaScript code, which won't work in CPython.\nSo while many Transcrypt modules can also be used with CPython, the ones directly using JavaScript can not.\nFor those modules, the (syntax and semantics) error reporting of the CPython interpreter is unavailable.\nOne note about the __pragma__'s. Indeed even those syntactically are simply function calls, although semantically they work at compile time.\nNote that running Transcrypt modules with the CPython interpreter is the core of what Transcrypt's back-to-back autotesting system is all about. Without this possibility it would be very hard to avoid regression bugs in new releases.\nCorrect Transcrypt behavior is simply defined as \"what CPython would do\"...","Q_Score":0,"Tags":"python,transcrypt","A_Id":51965168,"CreationDate":"2018-07-31T20:02:00.000","Title":"When compiling python using transcrypt is it possible to get standard python error logging?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Context: I implemented tests which use docker-py to create docker networks and run docker containers. The test runner used to execute the tests is pytest. The test setup depends on Python (Python package on my dev machine), on my dev machines docker daemon and my dev machines static ip address. In my dev machine runtime context the tests run just fine (via plain invocation of the test runner pytest). Now I would like to migrate the tests into gitlab-ci. gitlab-ci runs the job in a docker container which accesses the CI servers docker daemon via \/var\/run\/docker.sock mount. The ip address of the docker container which is uses by gitlab-ci to run the job in is not static like in my dev machine context. But for the creation of the docker networks in the test I need the ip address.\nQuestion: How can I get the appropriate ip address of the docker container the tests are executed in with Python?","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":2714,"Q_Id":51629194,"Users Score":-1,"Answer":"When you run docker you can share the same network as the host if asked.\nAdd to the run command --network host\nSuch parameter will cause the python network code be the same as you run the code without container.","Q_Score":2,"Tags":"python,docker,gitlab,dockerpy","A_Id":51630443,"CreationDate":"2018-08-01T08:57:00.000","Title":"How can I get the host ip in a docker container using Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have several python and PHP multi-threading scripts running on an old 2015 Mac el capitain OS with 4 cores that take only a few minutes each to complete.\nBought a 2018 18 core iMac pro running high Sierra and now those same scripts take 40 hours EACH to complete. Any hints what I can due to solve this problem? Anyone else, threading with php or python on high Sierra or an iMac pro?\nReally dumbfounded right now.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":65,"Q_Id":51644050,"Users Score":0,"Answer":"I called apple and they said to wipe the system completely clean with a new install of the MAC OS system because the issue could be due to a conflict in software. I did that and it did fix the issue. So I will have to step through all my software installations to identify the one conflicting with the threading.","Q_Score":0,"Tags":"php,python,multithreading,macos,pthreads","A_Id":51644914,"CreationDate":"2018-08-02T00:39:00.000","Title":"Threading in Python or PHP is 100 times slower on my 2018 18 core iMac","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way to deploy Volttron or Volttron agents without exposing the source code of agents?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":46,"Q_Id":51646924,"Users Score":0,"Answer":"While there is no way included in the platform to do this there are tools that make it possible.\nThe first thing is that even if you only deployed python byte code the original source is easy to derive from this byte code. This is a waste of time.\nI would try compiling your Agent code into C with Cython and then compile that into a pyc module(s) before deployment. Ultimately the module is run directly with the python interpreter so this should just work.","Q_Score":0,"Tags":"python,python-2.7,volttron","A_Id":51680639,"CreationDate":"2018-08-02T06:33:00.000","Title":"Is there any way to deploy volttron with code protection?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have certain files in a directory named benchmarks and I want to get code coverage by running these source files.\nI have tried using source flag in the following ways but it doesn't work.\ncoverage3 run --source=benchmarks\ncoverage3 run --source=benchmarks\/\nOn running, I always get Nothing to do.\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1447,"Q_Id":51673082,"Users Score":0,"Answer":"coverage run is like python. If you would run a file with python myprog.py, then you can use coverage run myprog.py.","Q_Score":0,"Tags":"ubuntu-14.04,python-3.6,coverage.py","A_Id":51679505,"CreationDate":"2018-08-03T12:50:00.000","Title":"how to use coverage run --source = {dir_name}","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to know if it's possible to get the email language setting of a user using python. To be more specific, I'm trying to set up an email notification system that notifies users by email when they receive a message, I don't want to really use their browser language setting because the sender and receiver could have different language setting on their browser. I want to know if it's possible, knowing the receiver's email, to get the language setting of their email?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":41,"Q_Id":51681793,"Users Score":1,"Answer":"Nope, simply because like the browser that is a per-application per-install thing. Why not simply prompt the user for their preferred language when you get permission to send the notification?","Q_Score":0,"Tags":"python,email","A_Id":51712333,"CreationDate":"2018-08-04T01:53:00.000","Title":"get email receiver language setting python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can I get the embed of a message to a variable with the ID of the message in discord.py?\nI get the message with uzenet = await client.get_message(channel, id), but I don't know how to get it's embed.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5406,"Q_Id":51688392,"Users Score":5,"Answer":"To get the first Embed of your message, as you said that would be a dict():\nembedFromMessage = uzenet.embeds[0]\nTo transfer the dict() into an discord.Embed object:\nembed = discord.Embed.from_data(embedFromMessage)","Q_Score":1,"Tags":"python,python-3.x,discord,discord.py","A_Id":55555605,"CreationDate":"2018-08-04T18:15:00.000","Title":"Discord.py get message embed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I had problems with importing oauth2 package. In in the init.py file there is a problem with this line getting executed, from ._compat import PY3 . I don't know why installing and running oauth2 is such a mess","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":266,"Q_Id":51690431,"Users Score":1,"Answer":"this worked for me:\nfrom oauth2._compat import PY3\nthe error you were getting suggests that you were trying to import __main__.compat instead of oauth2._compat","Q_Score":0,"Tags":"python-3.x,oauth-2.0","A_Id":51692171,"CreationDate":"2018-08-04T23:55:00.000","Title":"I am getting No module named 'oauth2._compat'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any way to implement http connector for sending messages(MT) in Jasmin? According to documentation jasmin HTTP API supports smpp connector only. \nUpdate 1:\nMore information of scenario:\nI have 4 sms providers that I need to implement using Jasmin.\none of them is using SMPP protocol and is working fine with jasmin using smpp connector.\nOther 3 have http protocol (call url with params to send SMS).\nI want to use http protocol with jasmin to use its routing and other stuff.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1158,"Q_Id":51700964,"Users Score":1,"Answer":"Jasmin only supports HTTP client connectors for MO (mobile originated) messages. \nHaving found myself with the same scenario as yourself, I found the simplest solution was to write an SMPP-to-HTTP service which allows Jasmin to connect to it and relay MT messages via HTTP. Hope that helps","Q_Score":3,"Tags":"python,sms-gateway,jasmin-sms","A_Id":57054186,"CreationDate":"2018-08-06T05:19:00.000","Title":"Jasmin HttpConnector for MT","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any way to implement http connector for sending messages(MT) in Jasmin? According to documentation jasmin HTTP API supports smpp connector only. \nUpdate 1:\nMore information of scenario:\nI have 4 sms providers that I need to implement using Jasmin.\none of them is using SMPP protocol and is working fine with jasmin using smpp connector.\nOther 3 have http protocol (call url with params to send SMS).\nI want to use http protocol with jasmin to use its routing and other stuff.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1158,"Q_Id":51700964,"Users Score":0,"Answer":"Here is the overview for adding Http MT support in Jasmin:\nAdd connector class and manager for http MT connector\nAdd router manager\nModify smpp protocol module and detach http mt call from this module before it is dispatched to smpp queue. Detachment will be done after router has selected your custom connector and user balance etc is deducted from user account but before transaction is queued. \nBy detachment means use your own queue (rabbitmq queue) and and publish your transaction on this. \nCreate subscriber for rabbitmq and response back as required. \nUsing this method will return same message id and responses like smpp. \nFor more details or help please comment.","Q_Score":3,"Tags":"python,sms-gateway,jasmin-sms","A_Id":57823022,"CreationDate":"2018-08-06T05:19:00.000","Title":"Jasmin HttpConnector for MT","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"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?\nI know how to add a custom field to project.project model. But don't know the next step.\nWhat 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?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":24,"Q_Id":51719138,"Users Score":0,"Answer":"I found that if project has notifications option \"\nVisible by following customers\" enabled then one can configure subscription for each follower. \nTo not receive e-mails when new task is added to the project: unmark the checkbox \"Task opened\" in the \"Edit subscription of User\" form.","Q_Score":0,"Tags":"python,email,task,project,odoo-10","A_Id":52330973,"CreationDate":"2018-08-07T05:02:00.000","Title":"On project task created do not send email","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is it possible to run my run my python script on AWS lambda 24\/7 without the 5mins limit?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":957,"Q_Id":51721079,"Users Score":0,"Answer":"That is not the purpose of AWS Lambda. If you want to run something 24\/7, you'll be better off using an ec2 instance.","Q_Score":0,"Tags":"python,aws-lambda","A_Id":51721222,"CreationDate":"2018-08-07T07:22:00.000","Title":"How can I run my python script on AWS lambda 24\/7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"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.\nMy 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?\nLet'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?\nIt's that possible? If it is how can I do it?\nReal examples:\nThere are programs that offer a terminal where you can execute python to do things in the program like:\n\nMaya by Autodesk\nNuke by The foundry\nHoudini by Side Effects\n\nNote: It has to be Cross-platform solution","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":73,"Q_Id":51738921,"Users Score":1,"Answer":"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.\nTo distribute the complete python installation, like Panda3D does, you'll have to include it in the chosen installer software.","Q_Score":0,"Tags":"python,pythonpath,python-packaging,python-config","A_Id":51739051,"CreationDate":"2018-08-08T05:01:00.000","Title":"How can I pack python into my project?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am using a volume when running a docker container with something like docker run --rm --network host --volume $PWD\/some_dir:\/tmp\/some_dir .... Inside the container I am running Python code which creates the directory \/tmp\/some_dir (overrides it in case it's already there) and puts files into there. If I run the docker container on my local dev machine the files are available on my dev machine in \/tmp\/some_dir after running the container.\nHowever if I run the same container as part of a gitlab-ci job (\"docker in docker\", the container is not the image used for the job itself) the files are not accessible in \/tmp\/some_dir (the directory exists).\nWhat could be a reason for the missing files?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":128,"Q_Id":51767194,"Users Score":0,"Answer":"Did you checked the good directory on the good server ? \nCreating a $PWD\/some_dir in a DinD context, The result should be in a some_dir created in docker user home dir in the server running Gitlab CI container.","Q_Score":2,"Tags":"python,docker,gitlab-ci","A_Id":51767336,"CreationDate":"2018-08-09T12:34:00.000","Title":"Share directory in docker container with parent scope docker container in gitlab-ci?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Twitter announced that Site Streams, User Streams, and legacy Direct Message endpoints, originally slated for retirement on June 19th 2018, will be deprecated on Wednesday August 16, 2018 which provides 3 months from today\u2019s release of the Account Activity API for migration.\nI am wondering it those APIs have an effect on Tweepy.Stream class","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":90,"Q_Id":51773215,"Users Score":0,"Answer":"I am wondering it those APIs have an effect on Tweepy.Stream class\n\nYes. Tweepy is not a special case. On August 16, the streaming APIs will be shut off, and any code in Tweepy which interacted with them will no longer function.","Q_Score":0,"Tags":"python,twitter,tweepy","A_Id":51773664,"CreationDate":"2018-08-09T17:55:00.000","Title":"Does Twitter's changes to their public APIs affect Tweepy?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We use built-in unittest (or Django's wrappers) for testing a Python project. \nIn some of those tests, we use libs like freezegun or mock, which aren't used anywhere in the production codebase. \nOur CI that runs tests installs all deps before a test run, so usually we'd put those in dev-deps. \n\nIs it common to leave those in the dev-packages section of the Pipfile, or should test-related packages also reside in packages?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":198,"Q_Id":51791457,"Users Score":2,"Answer":"a small note about mock since Python v3.3 it's part of the unittest module.\nSaid that, in theory would be better to keep those kind of packages in the dev-dependencies.\nIn practice you could ignore the problem unless you\n\nyou have tons of dependencies\nsome dependency is hard to install (maybe it requires a C compiler installed or something similar)","Q_Score":1,"Tags":"python,unit-testing,testing,pipenv,pipfile","A_Id":51791651,"CreationDate":"2018-08-10T17:32:00.000","Title":"If I only use a library during test suite runs, should it be in normal or dev packages in my Pipfile?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need 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. \nSteps I need done in the script.\n1) I need to open the application.\n2) Open the \u201cOpen Network Stream\u2026\u201d tab (Can be done with Ctrl+N).\n3) Type a string of characters \u201cString of characters\u201d\n4) Push \u201cEnter\u201d twice on the keyboard.\nI\u2019ve checked various websites across the internet and could not find any information regarding this. I am sure it\u2019s 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?\nNote: Using Linux based OS (Raspbian).\nThank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":20,"Q_Id":51791754,"Users Score":0,"Answer":"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)\nWhen you want to replicate the settings on a different machine, simply copy the settings to the same location.","Q_Score":0,"Tags":"python,shell,vlc","A_Id":51791818,"CreationDate":"2018-08-10T17:54:00.000","Title":"How do I write a script that configures an applications settings for me?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Does f.seek(500000,0) go through all the first 499999 characters of the file before getting to the 500000th?\nIn other words, is f.seek(n,0) of order O(n) or O(1)?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":4765,"Q_Id":51801213,"Users Score":1,"Answer":"It would depend on the implementation of f. However, in normal file-system files, it is O(1).\nIf python implements f on text files, it could be implemented as O(n), as each character may need to be inspected to manage cr\/lf pairs correctly.\n\nThis would be based on whether f.seek(n,0) gave the same result as a loop of reading chars, and (depending on OS) cr\/lf were shrunk to lf or lf expanded to cr\/lf \n\nIf python implements f on a compressed stream, then the order would b O(n), as decompression may require some working of blocks, and decompression.","Q_Score":14,"Tags":"python,file,io,big-o,fseek","A_Id":51801243,"CreationDate":"2018-08-11T15:34:00.000","Title":"Complexity of f.seek() in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My small AWS EC2 instance runs a two python scripts, one to receive JSON messages as a web-socket(~2msg\/ms) and write to csv file, and one to compress and upload the csvs. After testing, the data(~2.4gb\/day) recorded by the EC2 instance is sparser than if recorded on my own computer(~5GB). Monitoring shows the EC2 instance consumed all CPU credits and is operating on baseline power. My question is, does the instance drop messages because it cannot write them fast enough?\nThank you to anyone that can provide any insight!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":56,"Q_Id":51814464,"Users Score":1,"Answer":"It depends on the WebSocket server.\nIf your first script cannot run fast enough to match the message generation speed on server side, the TCP receive buffer will become full and the server will slow down on sending packets. Assuming a near-constant message production rate, unprocessed messages will pile up on the server, and the server could be coded to let them accumulate or eventually drop them.\nEven if the server never dropped a message, without enough computational power, your instance would never catch up - on 8\/15 it could be dealing with messages from 8\/10 - so instance upgrade is needed.\nDoes data rate vary greatly throughout the day (e.g. much more messages in evening rush around 20:00)? If so, data loss may have occurred during that period.\nBut is Python really that slow? 5GB\/day is less than 100KB per second, and even a fraction of one modern CPU core can easily handle it. Perhaps you should stress test your scripts and optimize them (reduce small disk writes, etc.)","Q_Score":0,"Tags":"python,amazon-s3,amazon-ec2","A_Id":51814600,"CreationDate":"2018-08-13T02:25:00.000","Title":"(AWS) What happens to a python script without enough CPU?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to use Crontab to schedule a shell script that runs the main python script. I had tried putting shebang #!\/usr\/local\/bin\/python in the first line of python script but it errorred out with \"cannot importing certain packages\". However, if I call the python script in the shell script by \/usr\/local\/bin\/python python_script.py, it worked. Any ideas why I can't use the shebang #!\/usr\/local\/bin\/python directly in python instead of the way calling in the shell as mentioned above (it's not elegant)?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":269,"Q_Id":51833010,"Users Score":0,"Answer":"This is very likely an issue with your environment variables. Most likely you've got different entries in your PATH or PYTHONPATH variables.\nTo see the difference, you could have your script be a bash script and have it echo the output of env and compare it to your shell's env.","Q_Score":0,"Tags":"python,shell,shebang","A_Id":62348071,"CreationDate":"2018-08-14T02:44:00.000","Title":"Python Shebang Doesn't Work #!\/usr\/local\/bin\/python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a Lambda function that takes a list of tasks to be run at the time specified. This time can vary. \nI am using SNS to trigger another Lambda function that in turn runs the tasks.\nThese tasks need to be run at specified time. Is it possible to publish a message to SNS using Lambda at the specified time? \nOr send the message to SNS, but SNS in turn triggers Lambda at the specified time?\nAny option would do.\nP.S. I know there is an option of using Cloud Watch events, but I do not want to use any more services.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":299,"Q_Id":51872050,"Users Score":0,"Answer":"It appears that your requirement is to trigger an AWS Lambda function at specific times.\nThis can be done by using Amazon CloudWatch Events, which can take a cron-like expression to run a Lambda function at desired time intervals or specific times. This functionality was originally in the Lambda console, but was moved to CloudWatch Events when more services added scheduling capabilities.\nHowever, CloudWatch Events cannot trigger an Amazon SNS message. If you need SNS to trigger Lambda, then you'll need CloudWatch Events to trigger a Lambda function that sends a message to SNS (which then triggers Lambda functions). Obviously, it would be cleaner to avoid SNS altogether unless you specifically need to fan-out the message to multiple subscriptions\/Lambda functions.","Q_Score":0,"Tags":"python-2.7,aws-lambda,amazon-sns","A_Id":51895628,"CreationDate":"2018-08-16T07:46:00.000","Title":"Trigger SNS at specified time","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"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.\nI 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.\nSo one server sends a file to another server, which somehow realises this and accepts it and processes it.\nThe 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.\nI have come across HTTP Post requests, but not sure if that's what I need or quite how to implement it.\nI 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.\nAny help with what I should be using much appreciated, thanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":32,"Q_Id":51897917,"Users Score":0,"Answer":"Maybe I didn't quite understand your request but this is the solution I imagined:\n\nYou create a Frontend with WebSocket support that connects to Server A\nServer B (the one running on the raspberry) sends a POST request\nwith the JSON to Server A\nServer A accepts the JSON and sends it to all clients connected with the WebSocket protocol\n\nServer B ----> Server A <----> Frontend\nThis way you do not expose your Raspberry directly and every request made by the Frontend goes only to Server A.\nTo 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.","Q_Score":1,"Tags":"javascript,php,python,html,apache","A_Id":51898164,"CreationDate":"2018-08-17T14:49:00.000","Title":"Post file from one server to another","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I see in the documentation that there's a __deepcopy__ method that can be used to extend the behavior of deepcopy beyond the built-in types. However, the documentation for NamedTuple (the class version in the typing module) doesn't mention anything about it. But since it provides defaults for hashing and equality testing, I was wondering, does it provide a default for deep copying as well?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1375,"Q_Id":51901253,"Users Score":5,"Answer":"NamedTuple doesn't define a special __deepcopy__ handler, but it doesn't need to. __deepcopy__ is only necessary to override\/customize the default deep copying behavior (which just uses the pickle special methods, __reduce_ex__ or __reduce__); for classes defined in Python (as opposed to C extension types), the default behavior is generally correct\/complete. object itself provides useful default pickling behaviors for all non-extension types, assuming all their attributes are themselves picklable, e.g. no open file objects or the like.\nSince NamedTuple is Python level, and has no special copying needs, it doesn't bother to implement a custom handler. You'd need to do so yourself only if some of the attributes of your NamedTuple are unpicklable and don't themselves define __deepcopy__.","Q_Score":2,"Tags":"python,python-3.x,deep-copy","A_Id":51901320,"CreationDate":"2018-08-17T18:45:00.000","Title":"Does `copy.deepcopy` work with `NamedTuple`s in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"As I was fiddling some bash scripting on osx, I seemed to have done irreparable damage to my python installation.\nLong story short, I typed hash python in the terminal and now I can't use python.\nLets say I try:\npython code_to_run.py \nI get:\npython is hashed (\/path\/to\/my\/python)\nI've tried hash -r and hash -d python to no avail.\nAny suggestions?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":56,"Q_Id":51901570,"Users Score":0,"Answer":"In the manual for Bash:\n\nhash [-lr] [-p filename] [-dt] [name]\nEach time hash is invoked, the full pathname of the command name is determined by searching the directories in $PATH and remembered.\nAny previously-remembered pathname is\ndiscarded. If the -p option is supplied, no path search is performed, and filename is used as the full file name of the command.\nThe -r option causes the shell to forget\nall remembered locations. The -d option causes the shell to forget the remembered location of each name. If the -t option is\nsupplied, the full pathname to which each\nname corresponds is printed. If multiple name arguments are supplied with -t, the name is printed before the hashed full pathname.\nThe -l option causes output to be dis-\nplayed in a format that may be reused as input. If no arguments are given, or if only -l is supplied, information about remembered\ncommands is printed. The return status\nis true unless a name is not found or an invalid option is supplied.\n\nhash -r worked for me (I guess if you have an important hash then this is not for you). First time I noticed this system.","Q_Score":1,"Tags":"python,bash,macos,hash","A_Id":71031247,"CreationDate":"2018-08-17T19:10:00.000","Title":"OSX -- python is hashed (\/urs\/local\/cellar\/python\/2.7\/etc)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have 2 projects which use the same API modules, which i have written myself. These API modules encapsulate existing imported functions from pypi libraries.\nIf I have to write unit tests for my API - should the unit tests modules be present in every project which uses my API or should there be a separate project for API testing?\nThe API is one for all so logically I would open a separate project for API testing, but what if the projects get passed around between people who don't own the API testing project? Then if the implementation of the inner imported functions in the API changes unit testing will be needed.\nI suppose the question regards API of any language but my projects are specifically in Python.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":61,"Q_Id":51915622,"Users Score":0,"Answer":"I would recommend to consider the code and its unit-test as belonging to the same component. They should, for example, reside in the same repository of your version control system. For example, if the code evolves, most likely the unit-tests also need to be adjusted accordingly. Therefore, there is no much value in treating them as different components.\nTaking up the example from your two projects and the API they both use: The API together with its tests forms a component. Thus, the API is developed conceptually independently from the projects. For example, if during the work on your project P1 you detect a bug in the API, then you fix the API component directly in its repository (possibly by first extending the API's unit-test suite to also capture that bug), make a new release of the API component, and then use that new release within P1, but probably also update P2 to use the new release.\nYou can, however, consider providing your API component in a package to the clients (your projects P1 and P2) that does not contain the unit-tests, if you prefer. The development on the API would in any case not take place from within P1 or from within P2, but directly in the API's repository.\nTo summarize: Do not separate the code and its tests into separate modules. Instead, put the code and its tests into one repository, but separate from the clients.","Q_Score":2,"Tags":"python,unit-testing,python-unittest","A_Id":55976441,"CreationDate":"2018-08-19T07:52:00.000","Title":"Python unit testing a self-written API module - better in separate project?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently joined a Telegram bot that requires user interaction every few hours.\nBasically I Log into the bot, press a button, check text and then press another button.\nIs it possible to automate such a task? \nThank you","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":177,"Q_Id":51916924,"Users Score":1,"Answer":"Telegram Bot API doesn't allow bots to interact with other bots. So bots won't be useful for such task.Only way to do that is to use Telegram Core API (the API used in telegram clients), make a custom Telegram client, and do the task through it.","Q_Score":0,"Tags":"python-3.x,automation,telegram,telegram-bot,scrape","A_Id":51965732,"CreationDate":"2018-08-19T10:53:00.000","Title":"How to automate a Telegram bot?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We have a RabbitMQ server running under Docker. We both publish and receive messages from code in both Ruby and Python, all of which is almost exactly straight from the online tutorial examples. After a short number of messages, the Python version starts to only receives every other message. The Ruby script continues to receive all of them.\nWhile not exactly RabbitMQ experts, we've checked the code and it's so close the official tutorials that it's hard to see that we're making any big mistakes. Plus it works initially anyway.\nIs there anything that could be causing this odd behaviour?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":176,"Q_Id":51928575,"Users Score":0,"Answer":"The answer, as hinted at by Pascal, was that it needed to be set to 'Fan-Out'. Thanks for the tip.","Q_Score":1,"Tags":"python,ruby,rabbitmq","A_Id":51932396,"CreationDate":"2018-08-20T10:15:00.000","Title":"Every other message missing with Rabbit MQ","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"i want to do something as a parametric study in Abaqus, where the parameter i am changing is a part of the assembly\/geometry. \nImagine the following:\nA 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.\nNow, 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. \nI 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. \nSince I'm new to Abaqus scripting etc, i wonder which is the best way to make this work.\nwould you guys generate 8 input files for one position of the cube and calculate \nthem manually or is there a way to let abaqus somehow iterate different assemblys?\nI guess i should wright a python script, but i don't know how to make the ropes the parameter that is changing.\nAny help is appreciated!\nThanks, Tobi","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":854,"Q_Id":51966721,"Users Score":0,"Answer":"In case someon is interested, i was able to do it the following way:\nI 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)\nThen i saved the fieldoutput in a certain simple txt file which i was able to analyse via matlab.\nThen 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. \nThis way, i was able to do geometric parametric studies in abaqus using matlab and python.\nCode will be uploaded soon","Q_Score":0,"Tags":"python,abaqus","A_Id":52174746,"CreationDate":"2018-08-22T12:17:00.000","Title":"Abaqus: parametric geometry\/assembly in Inputfile or Python script?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"i'm trying use PyBeacon package to make some Eddystone-UID using Raspberry PI 3+ device. Executing PyBeacon -i 321654987654321a321654a456b54699 command, for example, and using the Google App called \"Beacon Tools\" to register the Eddystone-UID beacon (ok detected into unregistered layer), when i try to register, the app tell me \"failed to connect\".\nWhen i use a hardware beacon with Eddystone support, i must to config each beacon in \"configure mode\" to can access OK using the app.\nIs it possible register into Google Beacon Plataform the eddystone beacons created using PyBeacon package?\nthanks alot!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":427,"Q_Id":51973957,"Users Score":0,"Answer":"The user interface for the Beacon Tools app is confusing. It does two very different things:\n\nRegistration - this sets up the beacon on Google's servers and ties it to your Google account.\nProvisioning - this tries to set the beacon hardware configuration (identifiers, transmission rate, etc.) on the physical hardware beacon itself by connecting to the beacon hardware over a bluetooth connection. This only works on a hardware beacons that implement Google's Eddystone Bluetooth GATT registration service. (Most hardware beacons don't even do this.) And even then, this only works when you beacon is in configurable mode. \n\nThe fact that you see \"failed to connect\" suggest you are doing 2 when really what you want to do is 1.","Q_Score":0,"Tags":"python,raspberry-pi3,eddystone","A_Id":51974208,"CreationDate":"2018-08-22T19:33:00.000","Title":"PyBeacon eddystone-UID","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to write a script to find out the RAM-ROM usage (RAM = bss + data,\nROM = rodata + text) of and object file. I tried with a GreenHills compiler tool that generates a report, but for some cases it doesn't work. Is there a way to find the memory sections to calculate the usage ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":739,"Q_Id":51980841,"Users Score":0,"Answer":"@B. Vlad You should count alignments when allocations in memory are done too. As suggested above, the only reliable way is to use linker output, as it will provide \"memory\" map of the objects with addresses they are loaded to( before loaded in memory though).","Q_Score":0,"Tags":"c++,c,windows,python-3.x","A_Id":51991026,"CreationDate":"2018-08-23T07:53:00.000","Title":"How to find the ram rom usage (.bss .text .rodata .data) of an object file *.o?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I've spent the good majority of a month on this issue. I'm looking for a way to extract geometry elements (polylines, text, arcs, etc.) from a vectorized PDF organised by the file's OCGs (Optional Content Groups), which are basically PDF layers. Using PDFminer I was able to extract geometry (LTCurves, LTTextBoxes, LTLines, etc.); using PyPDF2, I was able to view how many OCGs were in the PDF, though I was not able to access geometry associated with that OCG. There were a few hacky scripts I've seen and tried online that may have been able to solve this problem, but to no avail. I even resorted to opening the raw PDF data in a text editor and half hazardly removing parts of it to see if I could come up with some custom parsing technique to do this, but again to no avail. Adobe's PDF manual is minimal at best, so that was no help when I was attempting to create a parser. Does anyone know a solution to this. \nAt this point, I'm open to a solution in any language, using any OS (though I would prefer a solution using Python 3 on Windows or Linux), as long as it is open source \/ free. \nCan anyone here help end this rabbit hole of darkness? Much appreciated!","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1724,"Q_Id":51993507,"Users Score":5,"Answer":"A PDF document consists of two \"types\" of data. There is an object oriented \"structure\" to the document to divide it into pages, and carry meta data (like, for instance, there is this list of Optional Content Groups), and there is a stream oriented list of marking operators that actually \"draw\" content onto the page. \nThe fact that there are OCG's, and their names, and a bit about them is stored on object oriented content, and can be extracted by parsing the object content fairly easily. But the membership of the OCG's is NOT stored in the object structure. It can only be found by parsing the Content Stream. A group of marking operators is a member of a particular OCG group when it is preceeded by the content operator \/OC \/optionacontentgroupname BDC and followed by the operator EMC.\nParsing a content stream is a less than trivial task. There are many tools out there that will do this for you. I would not, myself, attempt to build such a parser from scratch. There is little value in re-writing the wheel.\nThe complete syntax of PDF is available from many sources. Search the web for \"PDF Specification 1.7\", or \"ISO32000-1:2008\". It is a daunting document to read, but it does supply all of the information needed to create both and object and a content parser","Q_Score":1,"Tags":"python,pdf,pypdf2,pdfminer,ocg","A_Id":52012277,"CreationDate":"2018-08-23T20:04:00.000","Title":"Extract Geometry Elements from PDF by OCG (by Layer)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"If requests.Session() can handle cookies and does almost everything that app.test_client() does. Then why use the app.test_client()?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":3506,"Q_Id":52028124,"Users Score":2,"Answer":"test_client is already prebuilt into flask, this makes it easier for people to quickly test their programs. Both the requests utility and test_client server the same functionality, so the usage is just based on personal preference.","Q_Score":11,"Tags":"python,python-3.x,flask","A_Id":52045779,"CreationDate":"2018-08-26T16:21:00.000","Title":"Why use Flask's app.test_client() over requests.Session() for testing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am writing unit tests (using Python 3.7, Pytest 3.6 and tox 3.0) for a function that compiles a series of shell commands as a list of strings, and then executes them using the subprocess module. The shell commands do the following:\n\ncreates a filename from the function arguments.\ncd into a given directory.\nchecks for a file with a certain name and removes it if it exist.\ncreates a new file with the same name.\nexecutes a program and pipes the output into the new file.\n\nMy test right now is mocking the subprocess module, and then asserting that it was called with a list of strings that contains all the expected commands given some test arguments. \nIs there a way to test that the commands do what they are supposed to? Right now my test is only checking if the list of commands I feed to the subprocess module is the same as the one I have asserted it to be. This does not tell me whether the commands are the right ones for what I am trying to achieve. Rather it only serves as a test on whether I can write down the same string in two different source files.\nCan I simulate the side effects that I expect the shell commands to have?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1572,"Q_Id":52072544,"Users Score":1,"Answer":"Your question combines two interesting topics: a) Testing code generated from a code generator and b) testing shell code.\nFor testing code from a generator, you have in principle to do the following: i) test that the generator creates the code that is expected - which you have already done, ii) test that the code snippets \/ pieces which the generator glues together actually behave (independently and in combination) as it is intended (which in your case are the shell code pieces that in the end together will form a valid shell program) - this is the part about testing shell code that will be adressed below, and iii) test that the inputs that control the generator are correct.\nIt is comparable with a compiler: i) is the compiler code, ii) are assembly code snippets that the compiler combines to get the resulting assembly program, and iii) is the source code that is given to the compiler to get it compiled. Once i), ii) and iii) are tested, there is only seldom the need to also test the assembly code (that is, on assembly code level). In particular, the source code iii) is ideally tested by test frameworks in the same programming language.\nIn your case it is not so clear how part iii) looks and how it can be tested, though.\nRegarding the testing of shell code \/ shell code snippets: Shell code is dominated by interactions with other executables or the operating system. The type of problems that lies in interactions in shell code goes in the direction of, am I calling the right executables in the right order with the arguments in the right order with properly formatted argument values, and are the outputs in the form I expect them to be etc. To test all this, you should not apply unit-testing, but integration testing instead.\nIn your case this means that the shell code snippets should be integration-tested on the different target operating systems (that is, not isolated from the operating system). And, the various ways in which the generator puts these snippets together should also be integration tested to see if they together operate nicely on the operating system.\nHowever, there can be shell code that is suitable for unit-testing. This is, for example, code performing computations within the shell, or string manipulations. I would even consider shell code with calls to certain fundamental tools like basename as suitable for unit-testing (interpreting such tools as being part of the 'standard library' if you like). In your case as you describe the generated shell code\n\ncreates a filename from the function arguments.\n\nThis sounds like one example of a good candidate for 'unit-testing' shell code: This filename creation functionality could be put into a shell function and then be tested in isolation.","Q_Score":1,"Tags":"python-3.x,shell,unit-testing,zsh","A_Id":55927559,"CreationDate":"2018-08-29T08:08:00.000","Title":"Unit testing of shell commands called in a python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I need some assistance with migrating with Heroku as I've added git+https:\/\/github.com\/Rapptz\/discord.py@rewrite#egg=discord.py[voice] into my requirements.txt file and I'm confused as when I do that, it doesn't change to rewrite, even if I still import discord. I have changed all my code to rewrite, like for example: bot.say to ctx.send. All of that is done, but when I place git+https:\/\/github.com\/Rapptz\/discord.py@rewrite#egg=discord.py[voice] into my requirements.txt file, it still thinks it's async. Please help as I tried so much just to get this working and I can't seem to find a way.\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":710,"Q_Id":52075155,"Users Score":1,"Answer":"LOL wait woops I just had to add yarl<1.2 to requirements.txt","Q_Score":0,"Tags":"python,asynchronous,heroku,discord,discord.py-rewrite","A_Id":52083610,"CreationDate":"2018-08-29T10:24:00.000","Title":"How do I change from Discord.py async to rewrite while using Heroku?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We have bought a Pixhawk 2.1 flight controller , and we are working on a university project ; the project is that we have to solve a puzzle by a drone ( which contains a raspberry pi 3 ) and send the right way coordinates to a small car . \nOur problem is that we shouldn\u2019t use any remote controller on the drone . So the drone should fly to a specific altitude and then should start looking for the puzzle and solve it . \nWe have tried to use dronekit python . We could connect to the drone by the code but we couldn\u2019t make it arm and take off .\nIs Pixhawk 2.1 support arming and take off with out using any ground station or remote control? . If it does we hope that you send us a code and the method . Because we have search a lot and the project dead line is very near .\nThank you for your time ...","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1733,"Q_Id":52102682,"Users Score":0,"Answer":"To control the drone using raspberry , pixhawk should comminucate with GPS . If you trying to arm it in a closed area probably it wont arm . Because , your code should contain like \"guided\" mode it require GPS. If this is not helpful . Test again cominication between rpi and pixhawk","Q_Score":2,"Tags":"python,automation,dronekit","A_Id":52791875,"CreationDate":"2018-08-30T17:39:00.000","Title":"How can I arm and takeoff the drone with Pixhawk and raspberry by dronekit python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm writing a Python 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.\nBTW, 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.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1347,"Q_Id":52106861,"Users Score":0,"Answer":"Answer my own question. I use IFTTT to forward the message to Slack and use Slack API to access the message.","Q_Score":0,"Tags":"python,automation,sms,sms-verification","A_Id":52124085,"CreationDate":"2018-08-31T00:05:00.000","Title":"How can I get SMS verification code in my Python program?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Twilio to send and receive SMS messages from a Python application. The issue is that their tutorials use ngrok as a way to get through the firewall but I don't want to have to run ngrok every time I run my app and the URL changes every time ngrok runs so I have to change the webhook url on Twilio every time. Is there a better way around this? Is this something that requires a server?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1159,"Q_Id":52123648,"Users Score":2,"Answer":"There are two options that you have.\n\nThe paid option of ngrok allows you to set a persistent url so that you don't have to chance the webhook url on Twilio each time.\nIf you have a server, then you would also be able to set a persistent url to your server.\n\nUnfortunately, the free version of ngrok does not allow you to set a persistent url.","Q_Score":0,"Tags":"python,twilio,webhooks","A_Id":52123715,"CreationDate":"2018-08-31T23:30:00.000","Title":"How to generate fixed webhook url?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wrote a program that takes the picture from my webcam and also takes the screenshot of my screen and send them to my email. I used SimpleCV module to take the picture from webcam and pyautogui module to take the screenshot of my screen. I compiled my script using pyinstaller using command pyinstaller -w -i myicon.ico web_shot.py -F I ran the compiled exe file to my another computer but gave me fatal error failed to execute web_shot. Later I removed everything related with pyautogui (thinking that it is the thing that is throwing the error). I again compiled the rest of my script and again got the same error. Again I thought problem might be in SimpleCV module so I removed everything related with SimpleCV module and again compiled the rest of script using pyinstaller. This time I didn't get any error. It worked fine.\nI have written all my codes in python 2.7.15 (32-bit) because SimpleCV module doesn't support python 3+.\nI think pyinstaller is unable to recognize or compile the SimpleCV module. I tried other compiling script like py2exe, cx_Freeze but could not get success.\nHow can I compile my this script without getting fatal error?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":137,"Q_Id":52134367,"Users Score":1,"Answer":"The fatal error is caused due to missing of opencv_ffmpeg341.dll in your directory where you have .exe file is.\nSolve it by copying opencv_ffmpeg341.dll from C:\\\"your python installed path\"\\Lib\\site-packages\\cv2 to the same path where your executable (.exe) is.","Q_Score":0,"Tags":"python-2.7,simplecv","A_Id":54653393,"CreationDate":"2018-09-02T05:54:00.000","Title":"Getting fatal error after compiling python script containing SimpleCV module","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Since Python is implemented in C, I am confused how the developers managed to make the Python builtin len function run on any sequence in constant time, O(1), while C's string function strlen runs in linear time, O(n). \nWhat is the secret behind Python's builtin len functions's time complexity? If we were to write program in C, would it be best practice to copy Python's code for len if we ever wanted to a fast C program involves sequence length?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":4064,"Q_Id":52134512,"Users Score":2,"Answer":"Any string\/list in python is an object. Like many objects, it has a __len__ method, which stores the length of the list. When we call len, __len__ gets called internally, and returns the stored value, which is an O(1) operation.","Q_Score":5,"Tags":"python,c,time-complexity","A_Id":52134543,"CreationDate":"2018-09-02T06:22:00.000","Title":"What is the secret behind Python's len() builtin time complexity of O(1)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"rb+ and wb+ both read from and write to a binary file, so what makes them different?\nIs it the order they read and write?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":13401,"Q_Id":52148524,"Users Score":6,"Answer":"In short\n\nrb+ does not create the file from scratch\nwb+ does create the file from scratch\n\nthere are no differences aside that.","Q_Score":2,"Tags":"python,file","A_Id":52148623,"CreationDate":"2018-09-03T11:06:00.000","Title":"What is the difference between \"rb+\" and \"wb+\"?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a rather odd situation where I will have multiple interfaces connected to the same network. When I receive a broadcast or multicast message, I would like to know what interface it came from. It there a way to do that in C or ideally Python?\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":65,"Q_Id":52196479,"Users Score":0,"Answer":"The most obvious one would be to bind several sockets, each to one interface only - do not listen to 0.0.0.0.","Q_Score":2,"Tags":"python,c,sockets,network-programming,udp","A_Id":52196631,"CreationDate":"2018-09-06T04:23:00.000","Title":"How do you know which interface a broadcast message came from?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So far I have investigated two different ways of persistently tracking player attribute skills in a game. These are mainly conceptual except for the threading option I came up with \/ found an example for.\nThe case:\nSolo developing a web game. Geo political simulator but with a little twist in comparison to others out there which I won't reveal.\nI'm using a combination of Flask and SQLAlchemy for which I have written routes for and have templates extending into a base dynamically. \nCurrently running it in dev mode locally with the intention of putting it behind a WSGI and a reverse proxy like Nginx on the cloud based Linux vm.\nAbout the player attribute mechanics - a player will submit a post request which will specify a few bits of information. First we want to know which skill, intelligence, endurance etc. Next wee need to know which player, but all of this will be generated automatically, we can use Flask-LoginManager to get the current user with our nifty user_loader decorator and function. We can use the user ID it provides to query the rest of it, namely what level the player is. We can specify the math used to decide the wait time increase later in seconds.\nThe options;\nOption 1:\nAs suggested by a colleague of mine. Allow the database to manage the timings of the skills. When the user submits the form, we will have created a new table to hold skill upgrade information. We take a note of what time the user submitted the form and also we multiply the current skill level by a factor of X amount of time and we put both pieces of data into the database. Then we create a new process that manages the constant checking of this table. Using timedelta, we can check if the amount of time that has elapsed since the form was submitted is equal to or greater than the time the player must wait until the upgrade is complete.\nOption 2:\nImport threading and create a class which expects the same information as abovr supplied on init and then simply use time.sleep for X amount of time then fire the upgrade and kill the thread when it's finished.\nI hope this all makes sense. I haven't written either yet because I am undecided about which is the most efficient way around it.\nI'm looking for the most scalable solution (even if it's not an option listed here) but one that is also as practical or an improvement on my concept of the skill tracking mechanic.\nI'm open to adding another lib to the package but I really would rather not.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":42,"Q_Id":52199075,"Users Score":0,"Answer":"I'll expand on my comment a little bit:\nIn terms of scaleability:\n\nWhat if the upgrade processes become very long? Hours or days?\nWhat if you have a lot of users\nWhat if people disconnect and reconnect to sessions at different times?\n\nHopefully it is clear you cannot ensure a robust process with option 2. Threading and waiting will put a continuous and potentially limiting load on a server and if a server fails all those threads likely to be lost.\nIn terms of robustness:\nOn the other hand if you record all of the information to a database you have the facility to cross check the states of any items and perform upgrade\/downgrade actions as deemed necessary by some form of task scheduler. This allows you to ensure that character states are always consistent with what you expect. And you only need one process to scan through the DB periodically and perform actions on all of the open rows flagged for an upgrade.\nYou could, if you wanted, also avoid a global task scheduler altogether. When a user performs an activity on the site a little task could run in the background (as a kind of decorator) that checks the upgrade status and if the time is right performs the DB activity, otherwise just passes. But a user would need to be actively in a session to make sure this happens, as opposed to the scheduled task above.","Q_Score":0,"Tags":"python,python-3.x,sqlite,flask-sqlalchemy,flask-login","A_Id":52216293,"CreationDate":"2018-09-06T07:50:00.000","Title":"Most efficient way of tracking player skill upgrades","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Python is a scripting language. It is hard to protect python code from being copied. No 100% protection is required but at least slow down those who have bad intentions. Is it possible to minify\/uglify python code the way javascript front-end code is being done today?\nEDIT: The python code will be used in Raspberry Pi, not server. On raspberry pi, anyone can take out the SDcard and gain access to the python code.","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":12334,"Q_Id":52231326,"Users Score":0,"Answer":"Nuitka.net is a perfect way to convert your python code to compiled object code. This makes reverse engineering and exposing your algorithms extremely hard. Nuitka can also produce an standalone executable that is very portable.\nWhile this may be a way to preserve trade secrets, it comes with some hard limitations.\na) some python libs are already binary distros which are difficult to bundle in a standalone exe (e.g. xgboost, pytorch).\nb) wide pip distribution of a binary package is an exercise in deep frustration because it is linked to the cpython lib. manylinux and universal builds are vast wasteland waiting to be mapped and documented.\nAs for the downvotes, please consider that 1) not all python runs on servers - some run on the edge, 2) non-open source authors need to protect their intellectual property, 3) smaller always makes for faster installs.","Q_Score":9,"Tags":"python,minify","A_Id":70440091,"CreationDate":"2018-09-08T01:53:00.000","Title":"Is it possible to minify python code like javascript?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Python is a scripting language. It is hard to protect python code from being copied. No 100% protection is required but at least slow down those who have bad intentions. Is it possible to minify\/uglify python code the way javascript front-end code is being done today?\nEDIT: The python code will be used in Raspberry Pi, not server. On raspberry pi, anyone can take out the SDcard and gain access to the python code.","AnswerCount":5,"Available Count":3,"Score":0.0798297691,"is_accepted":false,"ViewCount":12334,"Q_Id":52231326,"Users Score":2,"Answer":"python is executed server-side. while sometimes it's fun to intentionally obfuscate code (look into perl obfuscation ;), it should never be necessary for server-side code.\nif you're trying to hide your python from someone but they already have access to the directories and files it is stored in, you have bigger problems than code obfuscation.","Q_Score":9,"Tags":"python,minify","A_Id":52231350,"CreationDate":"2018-09-08T01:53:00.000","Title":"Is it possible to minify python code like javascript?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Python is a scripting language. It is hard to protect python code from being copied. No 100% protection is required but at least slow down those who have bad intentions. Is it possible to minify\/uglify python code the way javascript front-end code is being done today?\nEDIT: The python code will be used in Raspberry Pi, not server. On raspberry pi, anyone can take out the SDcard and gain access to the python code.","AnswerCount":5,"Available Count":3,"Score":0.1194272985,"is_accepted":false,"ViewCount":12334,"Q_Id":52231326,"Users Score":3,"Answer":"Sure, you could uglify it, but given the fact that python relies on indentation for syntax, you couldn't do the equivalent minification (which in JS relies largely upon removing all whitespace).\nBeside the point, but JS is minified to make it download faster, not obfuscate it.","Q_Score":9,"Tags":"python,minify","A_Id":52231349,"CreationDate":"2018-09-08T01:53:00.000","Title":"Is it possible to minify python code like javascript?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We have one of the our python script which when executed manually works 100% fine,but when I try to execute it through PHP it is not getting executed. Does not give any exception or error.\nThere is no problem with script path. Is there any way to identify this ??","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":30,"Q_Id":52233671,"Users Score":0,"Answer":"Following are the possibilities,\n\nerror reporting is not enabled\ndue to change in relative paths, your script is not working\n\nAlso can you provide the full exec statement, it will be helpful for us.","Q_Score":0,"Tags":"php,python,laravel","A_Id":52233988,"CreationDate":"2018-09-08T08:59:00.000","Title":"Script executing manually but not executing through PHP.","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I used django console email backend in development and It worked fine. Now for test I tried production with gunicorn and nginx, but I have no email backend for now so I used django console email backend again for sending emails, where can I see emails? is there any log to check them? or In production console backend wouldn't work?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":103,"Q_Id":52234988,"Users Score":0,"Answer":"The logs will be visible in the gunicorn logs, you need to configure the logfile in gunicon configuration.","Q_Score":0,"Tags":"python,django,gunicorn","A_Id":52236595,"CreationDate":"2018-09-08T11:45:00.000","Title":"Django console email backend in production with gunicorn and nginx","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a python lambda which turns out to be a bit long so we decided to split it into modules. and now when i try to import the module in the lambda_handler its seems to be giving following error \nUnable to import module 'defghi': attempted relative import with no known parent package\nabc.py which has got lambda_handler in it, is trying to import the defghi.py methods as follows\nfrom defghi import some_method_1, some_method_2\ntried this as well\nfrom .defghi import some_method_1, some_method_2\n\nboth the files are in the same directory\nany sort of help would be appreciated, Thanks in adavance","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1488,"Q_Id":52275725,"Users Score":0,"Answer":"Finally got that working it was the build scripts which where causing the issue in my project.\nThe build script which created the zip file where expecting only one .py file in the directory which was a problem. So the zip created never had other files which then gave error cannot import. \nSo to answer the question its perfectly fine to split the big lambdas into modules and keep them a bit readable and import into the main lambda_handler the required modules.","Q_Score":1,"Tags":"aws-lambda,python-3.6","A_Id":52369163,"CreationDate":"2018-09-11T12:15:00.000","Title":"python lambda not able to import user defined modules","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am looking for a way to set up a Lambda trigger, where if any files are uploaded into the S3 bucket, the trigger will push\/copy the file(s) to the SFTP server.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1207,"Q_Id":52316168,"Users Score":0,"Answer":"You have to use the following algorithm: \n\nLog in to AWS console,\nLambda service,\nCreate a new lambda function (choose a proper runtime);\n\nThen you have to set a trigger (a left pane). If you want to trigger your lambda by s3 bucket then click on s3. \nThen you have to configure your trigger (choose your bucket and trigger action). \nAfter you complete all of this steps it's a time to write a handler file.\nDo not forget that every single trigger has to be in the same region as lambda.","Q_Score":0,"Tags":"python,amazon-web-services,amazon-s3,aws-lambda","A_Id":52323243,"CreationDate":"2018-09-13T14:42:00.000","Title":"Is there a Lambda trigger that will push\/copy files from S3 bucket to the SFTP server?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to compute the center of mass of solid objects constructed with a CAD software that are saved with the STEP format.\nHas someone experience with this type of files? How can I extract that information?\n(I'm working with python, but I also know a little bit of C).","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":208,"Q_Id":52374335,"Users Score":0,"Answer":"Have you looked at FreeCAD or pythonOCC?","Q_Score":0,"Tags":"python,cad,step","A_Id":52376749,"CreationDate":"2018-09-17T19:12:00.000","Title":"How to compute the center of mass of a solid geometry contained in a STEP file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a conceptual question about doing test driven development with Django, may also apply to other frameworks as well.\nTDD states that the firts step in the development cycle is to write failing tests. \nSuppose for a unit test, I want to verify that an item is actually created when a request arrives. To test this functioanlty, I want to issue a request with the test client, and check with the db that this object is actully created. To be able to do that, I need to import the related model in the test file, but as the first step is writing this test, I don't even have a model yet. So I won't be able to run the tests to see them fail.\nWhat is the suggested approach here? Maybe write a simpler test first, then modify the test after enough level of production code is implemented?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":321,"Q_Id":52389183,"Users Score":0,"Answer":"In Django, the approach is always to recreate a working environment for testing and staging. In testing the data is fake, in staging the data is \"old\" or very similar to the production.","Q_Score":2,"Tags":"python,django,testing,tdd","A_Id":52389672,"CreationDate":"2018-09-18T14:44:00.000","Title":"Test Driven Development with Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to automate the typing process in a video game. Players are given an on-screen QWERTY keyboard layout that they can navigate with the control stick (up, down, left, right) in order to select a letter to type. I was wondering if there was a module for Python (or some other resource I could explore) that would help my program find a path across the keyboard as it types each letter in a given message. In other words, if the first letter typed was \"A\" and the next letter was \"B\", the module would know that the program should move 1 space down on the keyboard and 4 spaces to the right.\nCurrently, I have the program resetting to the \"G\" key after each letter is typed (allowing me to use fixed-directions as the program parses each character in the desired message). As you can imagine, this is quite inefficient and defeats the purpose of automating the typing in the first place.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":75,"Q_Id":52390106,"Users Score":3,"Answer":"Associate to each letter a position.\nFor example, Q would be (0,0), W (0,1), Z is (0,2), ... A (1,0) ...\nThis way it is very simple to find the shortest path (simple vectors substraction)\nTo compute the path Q -> S : \n(0,0) - (1,1) = (-1,-1) so you need to do 1 down then 1 right.","Q_Score":2,"Tags":"python,algorithm,keyboard","A_Id":52390530,"CreationDate":"2018-09-18T15:34:00.000","Title":"How to determine optimal route across keyboard","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running pylint in an environment where certain import libraries are not available and are 3rd party. As a result, pylint generates an error class wrong-import-order C0411 for these imports. \nIs there a way to instruct which should be considered 3rd party?\n\nPylint 2.1.1 \nPython 3.6.3","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":839,"Q_Id":52445342,"Users Score":5,"Answer":"Yes, that would be known-third-party, which you can set under [IMPORTS]:\n# Force import order to recognize a module as part of a third party library.\nknown-third-party=your modules","Q_Score":7,"Tags":"python-3.x,pylint","A_Id":52468110,"CreationDate":"2018-09-21T13:57:00.000","Title":"Is there a way to instruct Pylint which libraries should be considered 3rd party?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have several 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.\nThe 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.\nThe 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?\nThe option should allow executing all tests at all and every test on his own.\nAlso I would have some theoretical questions.\nIf 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?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":40,"Q_Id":52468137,"Users Score":0,"Answer":"I can only given an answer on the \"are there other options for me\" part of your question...\nThe use of such a complex setup for unit-tests (pulling docker images etc.) makes me suspicious:\nIt 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.\nOn 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.\nIf 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.","Q_Score":0,"Tags":"python,python-3.x,unit-testing,singleton","A_Id":55788176,"CreationDate":"2018-09-23T16:36:00.000","Title":"Python3.6 and singletons - use case and parallel execution","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using iPython 5.5.0, when i run my script which takes input for input.csv I get the following error:\nIn [1]: %run \"C:\\myrootFolder\\pythoncode\\testfile.py input.csv\"\nERROR:root:File `u'In [1]: %run \"C:\\myrootFolder\\pythoncode\\testfile.py input.csv.py' not found.\nSame way I am unable to execute.. %run \"C:\\Python27\\Scripts\\mysite\\manage.py runserver\"\nSimilar error occurs, What am I doing wrong.\nTIA.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":47,"Q_Id":52496972,"Users Score":0,"Answer":"Found the issue it should be \n%run \"C:\\myrootFolder\\pythoncode\\testfile.py\" \\input.csv","Q_Score":0,"Tags":"python,django,ipython","A_Id":52497020,"CreationDate":"2018-09-25T11:20:00.000","Title":"Error while using iPython for executing a python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"We have installed Centos 6.x in one or our VM and it has come with default Python 2.6 installed. On top of it we have installed Python 2.7 and configured Python 2.7 as default in \/usr\/bin\/. When I type python in my command line it gives version Python 2.7. But when I execute my python script file test.py it is using Python 2.6 instead of Python 2.7. Did I miss any configurations to tell my scripts to use Python 2.7 instead of Python 2.6 on my machine?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":66,"Q_Id":52499341,"Users Score":1,"Answer":"Since it sounds like you set up your command line correctly, I would first try looking at your script. Did you try including the shebang at the top of your script? #!\/usr\/bin\/env python2.7","Q_Score":0,"Tags":"python,python-2.7,centos6","A_Id":52499590,"CreationDate":"2018-09-25T13:25:00.000","Title":"How to tell python script files to use particular version of python if there are multiple versions of python are installed on the machine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have two python files (Iron Python 2.7) and a .net dll file.\n\nabc.py\ndef.py\nghi.dll\n\nabc.py is the Main file that contains the code for Windows Forms application and def.py is a supporting file that has the functions. ghi.dll is a third party api file that has been modified to dll.\nI want to create this to an Windows Forms Application executable to distribute it to others in my team.\nUsed Visual Studio 2017 to write the code.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":721,"Q_Id":52501442,"Users Score":1,"Answer":"Create a folder and copy all the required .net dlls from the C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework.NETFramework\\v4.0 folder and copy all the required files from the C:\\Program Files (x86)\\IronPython 2.7\\Lib folder\nCopy the ipyc.exe from C:\\Program Files (x86)\\IronPython 2.7 folder and copy pyc.py from C:\\Program Files (x86)\\IronPython 2.7\\Tools\\Scripts folder\nOpen Command Prompt and navigate to the appropriate folder and use the following command\n ipyc def.py \/main:abc.py \/target:winexe","Q_Score":0,"Tags":".net,executable,ironpython","A_Id":52524477,"CreationDate":"2018-09-25T15:10:00.000","Title":"How to build a executable for ironpython files and a .Net dll file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can i import Robot Keywords file from Python script and execute keywords from that file and generate report like Robot html report.\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":229,"Q_Id":52516100,"Users Score":0,"Answer":"You cannot import a robot keyword file from a python script, unless that script is using the low level robot API to run a test. \nRobot keywords can only be used from within a running robot test.","Q_Score":0,"Tags":"python,robotframework","A_Id":52516514,"CreationDate":"2018-09-26T10:55:00.000","Title":"How can i import Robot Keywords file from Python script and execute keywords from that file and generate report","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"All,\nWriting to see if anyone has any input on what they feel the best tech would be for the following scenario. Be it python, solr, redis, memcache, etc.\nThe situation is as follows.\nI have 100 million+ binary strings which are around 1100 characters long...\n'0010100010101001010101011....'\nWhat in your opinion would be the most logical way to do the following?\nFor a given string of the same number of characters, what would be the most efficient way to find the closest match? By closest, I mean sharing the greatest number of 0's and 1's at a given position. Hamming Distance, I believe.\nMy use case would actually involve taking 100k or so strings and trying to find their best match in the pool of 100 million+ strings.\nAny thoughts? No particular tech has to be used, just preferably something that is fairly common.\nCurious to see what ideas anyone may have. \nThanks,\nTbone","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":131,"Q_Id":52558975,"Users Score":0,"Answer":"You could use numpy, R, or MATLAB, or anything else that works with large matrices for this:\nSay you have a NxM matrix A, where N is len(string) and M is the number of strings. And say you have a string S you're trying to match. You could:\n\nSubtract the array version of S from A \nTake the the absolute value of all the elements of the result of (1)\nSum the result of (2) along the axis of N\nArgsort the result of (3) to find the indexes of the strings that have the lowest distance to S.","Q_Score":0,"Tags":"python,elasticsearch,solr,redis,memcached","A_Id":52559199,"CreationDate":"2018-09-28T16:00:00.000","Title":"Comparing Large Number of Binary Strings","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"All,\nWriting to see if anyone has any input on what they feel the best tech would be for the following scenario. Be it python, solr, redis, memcache, etc.\nThe situation is as follows.\nI have 100 million+ binary strings which are around 1100 characters long...\n'0010100010101001010101011....'\nWhat in your opinion would be the most logical way to do the following?\nFor a given string of the same number of characters, what would be the most efficient way to find the closest match? By closest, I mean sharing the greatest number of 0's and 1's at a given position. Hamming Distance, I believe.\nMy use case would actually involve taking 100k or so strings and trying to find their best match in the pool of 100 million+ strings.\nAny thoughts? No particular tech has to be used, just preferably something that is fairly common.\nCurious to see what ideas anyone may have. \nThanks,\nTbone","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":131,"Q_Id":52558975,"Users Score":0,"Answer":"You are basically trying to conduct nearest neighbor search in Hamming space on Elasticsearch. \nRegarding this, a recently proposed FENSHSES method from [1] seems to be the state-of-the-art one on Elasticsearch.\n[1] Mu, C, Zhao, J., Yang, G., Yang, B. and Yan, Z., 2019, October. Fast and Exact Nearest Neighbor Search in Hamming Space on Full-Text Search Engines. In International Conference on Similarity Search and Applications (pp. 49-56). Springer, Cham.","Q_Score":0,"Tags":"python,elasticsearch,solr,redis,memcached","A_Id":59490564,"CreationDate":"2018-09-28T16:00:00.000","Title":"Comparing Large Number of Binary Strings","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have some pretty fragile code that I want to refactor. It's not very easy to unit test by itself because it interacts with database queries and Django form data.\nThat in itself is not a big deal. I already have extensive tests that, among other things, end up calling this function and check that results are as expected. But my full test suite takes about 5 minutes and I also don't want to have to fix other outstanding issues while working on this.\nWhat I'd like to do is to run nosetests or nose2 on all my tests, track all test_xxx.py files that called the function of interest and then limit my testing during the refactoring to only that subset of test files.\nI plan to use inspect.stack() to do this but was wondering if there is an existing plugin or if someone has done it before. If not, I intend to post whatever I come up with and maybe that will be of use later.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":34,"Q_Id":52572977,"Users Score":1,"Answer":"You can simply raise some exception in the function and do one run. All tests that fail do call you function.","Q_Score":0,"Tags":"python,unit-testing,introspection","A_Id":52573171,"CreationDate":"2018-09-29T22:12:00.000","Title":"finding out which particular tests call some functions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"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\".\nHow 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?\nI 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 :\/","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":108,"Q_Id":52580345,"Users Score":1,"Answer":"You should override onecmd to achieve desired functionality.","Q_Score":1,"Tags":"python","A_Id":52580602,"CreationDate":"2018-09-30T17:25:00.000","Title":"Python's cmd.Cmd case insensitive commands","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"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:\n\nJAMPchip@DESKTOP-BOB968S:~\/examples\/dae$ python3 run_disease.py\n\nI receive the following output:\n\nWARNING: Could not locate the 'ipopt' executable, which is required\n for solver\n ipopt Traceback (most recent call last): File \"run_disease.py\", line 15, in \n results = solver.solve(instance,tee=True) File \"\/usr\/lib\/python3.6\/site-packages\/pyomo\/opt\/base\/solvers.py\", line\n 541, in solve\n self.available(exception_flag=True) File \"\/usr\/lib\/python3.6\/site-packages\/pyomo\/opt\/solver\/shellcmd.py\", line\n 122, in available\n raise ApplicationError(msg % self.name) pyutilib.common._exceptions.ApplicationError: No executable found for\n solver 'ipopt'\n\nWhen I run \"make test\" in the IPOPT build folder, I reecieved:\n\nTesting AMPL Solver Executable...\n Test passed! Testing C++ Example...\n Test passed! Testing C Example...\n Test passed! Testing Fortran Example...\n Test passed!\n\nBut my one major concern is that in the \"configure\" output was the follwing:\n\nchecking for COIN-OR package HSL... not given: No package 'coinhsl'\n found\n\nThere 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?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1060,"Q_Id":52596464,"Users Score":0,"Answer":"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.","Q_Score":0,"Tags":"python,pyomo,ipopt","A_Id":52612398,"CreationDate":"2018-10-01T18:01:00.000","Title":"\"No package 'coinhsl' found\": IPOPT compiles and passes test, but pyomo cannot find it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a few test cases that are in unittest.Testcase class. I skip a couple of them. At the end of the run, can I get a list of those skipped tests?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":125,"Q_Id":52602278,"Users Score":2,"Answer":"If you are running the tests at the command line, say, as:\npython3 -m unittest\nthen you can use the -v verbose option to list the result of each test, and look for the skipped ones.\npython3 -m unittest -v\nIf the list is long, you can just grep for 'skipped' in the output. E.g.\npython3 -m unittest -v | grep skipped","Q_Score":1,"Tags":"python,python-3.x,python-unittest","A_Id":66822507,"CreationDate":"2018-10-02T05:01:00.000","Title":"Is there a method\/property\/var to get a list of skipped tests in python3 unittest?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I call shutil.rmtree('\/') Will I nuke my entire drive or does the function have an inner check for this case?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":491,"Q_Id":52614688,"Users Score":3,"Answer":"rmtree doesn't have any special logic in it. If you have permissions to \/ (e.g., the program is run by root), you will indeed wipe your installation.","Q_Score":3,"Tags":"python,linux,shutil","A_Id":52614802,"CreationDate":"2018-10-02T18:55:00.000","Title":"Will shutil.rmtree() check for the root directory?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Python script that will regulary check an API for data updates. Since it runs without supervision I would like to be able monitor what the script does to make sure it works properly. \nMy initial thought is just to write every communication attempt with the API to a text file with date, time and if data was pulled or not. A new line for every imput. My question to you is if you would recommend doing it in another way? Write to excel for example to be able to sort the columns? Or are there any other options worth considering?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":245,"Q_Id":52622752,"Users Score":1,"Answer":"I would say it really depends on two factors \n\nHow often you update\nHow much interaction do you want with the monitoring data (i.e. notification, reporting etc)\n\nI have had projects where we've updated Google Sheets (using the API) to be able to collaboratively extract reports from update data. \nHowever, note that this means a web call at every update, so if your updates are close together, this will affect performance. Also, if your app is interactive, there may be a delay while the data gets updated. \nThe upside is you can build things like graphs and timelines really easily (and collaboratively) where needed. \nAlso - yes, definitely the logging module as answered below. I sort of assumed you were using the logging module already for the local file for some reason!","Q_Score":0,"Tags":"python,api,logfile","A_Id":52622826,"CreationDate":"2018-10-03T08:23:00.000","Title":"Python API implementing a simple log file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to manage a supergroup on Telegram.\nI'm wondering if there's a way to filter certain words (like curse words) through a bot?\nIf there is, I would much appreciate if you help me coding it.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2978,"Q_Id":52635712,"Users Score":0,"Answer":"If your bot is the admin with the priviledge of deleting messages, it can remove any message it wants. \nMake sure that you have turned the group privacy of the bot off.","Q_Score":0,"Tags":"java,python,bots,telegram,telegram-bot","A_Id":52641993,"CreationDate":"2018-10-03T21:07:00.000","Title":"Telegram bot to filter certain words","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to automize my routine tasks such as changing 1 word in huge AutoCAD .DWG file with a lot of text blocks (objects in autocad). So, can I open it by Python? And how?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2024,"Q_Id":52664745,"Users Score":3,"Answer":"Your best bet here is to convert the file first into something like SVG or .dxf and go from there. It's not easy getting the data from a .dwg file in python.\nYou can make the conversion to SVG in python too using subprocess and a command line convert tool like cad2svg.","Q_Score":0,"Tags":"python,autocad,dwg","A_Id":52664929,"CreationDate":"2018-10-05T11:33:00.000","Title":"DWG source by Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have two classesClassA and ClassB with the same content and structure but just with different names. I saved an object of ClassA using pickle.dump to a binary file. However, I want to now load it in a different program which only has access to ClassB. Loading this file using pickle.load fails now as it can't find the ClassA description and thus throws some error like No module named ClassA exists.\nTo solve this, I manually investigated the saved binary file, and found the required class name ClassA coded in ASCII in the file. I guessed that it was looking for this exact class name, which resulted in the above error. Upon changing this name from ClassA to ClassB inside this binary file, the code seemed to be correctly loading the object, but now as ClassB. Which is what i wanted.\nHowever, since i manually edited this file, I was wondering if there would be any adverse effects down the line for doing this. Or is it, if it works it ain't stupid scenario.\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1118,"Q_Id":52675046,"Users Score":2,"Answer":"None of the pickle formats use offsets into the file or any kind of compression or encryption, so changing the name is fine even if it changes the length. You have to know that the text \u201cClassA\u201d doesn\u2019t appear for some other reason, of course, and that your editor won\u2019t mangle the file\u2014say, by trying to do character decoding\/encoding.\nThat said, in this situation I\u2019d probably create a dummy package to give ClassA the correct name rather than edit the pickle.","Q_Score":1,"Tags":"python,pickle","A_Id":52675343,"CreationDate":"2018-10-06T01:49:00.000","Title":"Manually editing a dumped pickle file in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working in RedHat OpenStack project and I need to know good test cases for reliability, performance, and function test cases for RedHat OpenStack. I already looked at the Tempest test. but I'm asking if there's any other test I can follow?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":124,"Q_Id":52684200,"Users Score":1,"Answer":"I realize that you mention that you've already looked at Tempest, but I would strongly encourage you to take a second look. I understand that the documentation is a little underwhelming and tailoring the tempest configuration to your deployment can be a significant time investment. Beyond its documentation, it's a well-maintained OpenStack project and running sanity checks doesn't take too long to configure. The results can be truly revealing.\nCreate a tempest workspace and conduct sanity checks with --smoke or -s\nCreate a workspace with tempest init myworkspace. This will create the directory structure for you based off of what exists in \/etc\/tempest. If you've already configured your \/etc\/tempest, you're a step ahead, otherwise, you'll need to configure your myworkspace\/etc\/tempest.conf before running any test.\nOnce your workspace is configured for your deployment, execute tempest run --smoke from the workspace directory. This will execute ~100 smoke tests for basic cloud functionality and sanity testing. With my modest deployment, this doesn't take more than 3-5 minutes to get some worthwhile results.\nResults from --subunit\nContinuing with the myworkspace directory, running your smoketests with the --subunit flag (tempest run --smoke --subunit) produces the html-exportable subunit docs at workspace\/.stestr\/$iteration where $iteration is a 0-indexed iteration of tempest run you've executed.\nFor example, after your first iteration, run subunit2html .stestr\/0 to generate a well-formatted results.html for your review.\nBeyond Smoketesting\nIf you start here and iterate, I think it naturally progresses into running the full gamut of tests. The workflow is a bit different from the smoke testing:\n\nGenerally start with tempest cleanup --init-saved-state which will produce a pre-test state of your cloud, a veritable snapshot of the resources you do not want to cleanup in post. The state is stored at saved_state.json.\nRun your tests with options tailored to your deployment, most basically tempest run.\nAfter analyzing your results, a run of tempest cleanup will destroy resources that do not exists in the saved_state.json file.","Q_Score":0,"Tags":"python,cloud,integration-testing,redhat,openstack","A_Id":52689994,"CreationDate":"2018-10-06T23:29:00.000","Title":"Test cases for Redhat OpenStack?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I would like to pull messages from a RabbitMQ queue, wrap them in a object and dispatch for some kind of processing. Ofcourse I could iteratively do that until the queue is empty, but I was wondering if there is any other way (some flag of some kind) or a neater way.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":202,"Q_Id":52699030,"Users Score":1,"Answer":"RabbitMQ does not support batches of messages, so you do indeed need to consume each message individually. \nMaybe an alternative would be to batch the messages yourself by publishing one large message with all the required content.","Q_Score":0,"Tags":"python-2.7,rabbitmq,pika","A_Id":52726069,"CreationDate":"2018-10-08T09:18:00.000","Title":"Is it possible to pull all messages from a RabbitMQ queue at once?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've written a small flask rest api application and a related client library that uses requests to interface with the api. And now I'm writing test cases using pytest. The tests directly against the flask app run fine using the built in test client.\nHowever, now I'm trying to run tests against the flask app through the client library, and it's failing with errors like:\n\nInvalidSchema(\"No connection adapters were found for '%s'\" % url)\n\nAs I understand, I can separately mock out the requests calls, but is there a way I can test the client library directly against the flask application?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":247,"Q_Id":52729749,"Users Score":1,"Answer":"If you test client library it better to choose mocks your API.\nBut if you want to test client(library) <-> server(flask) integration you need to make some preparation of environment. Like configure client, start server on the same host and port. And then run the tests.","Q_Score":0,"Tags":"python,flask,python-requests,pytest","A_Id":52731357,"CreationDate":"2018-10-09T21:43:00.000","Title":"Testing a flask application with a client that uses requests","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am new in the Cloud\nand I have an python script that I call from a bash script with parameters. this app run on Linux and required some python modules as well. \nI would like to deploy this app on the AWS cloud and make it run on a given schedule.\nWhat is the best way to deploy this app (AWS Lambda or EC2).\nThanks\nNono","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":293,"Q_Id":52745181,"Users Score":2,"Answer":"Cheapest way is AWS Lambda, but you'll have to get rid of the bash script and modify your Python script some.\nEasiest way is EC2, because it's just a Linux server that you can login to and install whatever you want and setup your script on a cron job just like your local Linux server.","Q_Score":0,"Tags":"python,amazon-web-services,amazon-ec2,aws-lambda","A_Id":52745223,"CreationDate":"2018-10-10T16:50:00.000","Title":"Deploy Python\/Bash application on Aws","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am using python and getting this error.\n\nimport telegram\ntelegram.Bot(token = '###############')\n\nWhen I run this, appears: \n\"AttributeError: module 'telegram' has no attribute 'Bot'\"\nAny ideas how to solve this?","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":15267,"Q_Id":52749629,"Users Score":1,"Answer":"Note that your file name (.py) does not the same with your package name.","Q_Score":6,"Tags":"python,api,telegram,attributeerror","A_Id":57895181,"CreationDate":"2018-10-10T22:29:00.000","Title":"AttributeError: module 'telegram' has no attribute 'Bot'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"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.\nNow i am also supposed to write some unit tests for this in pytest or the unittest module in Python.\nMy 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.\nI think only the data validation part in the task can be tested using unittest and not the creation of files in different formats right ?\nAny ideas would be immensely helpful.\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":511,"Q_Id":52763725,"Users Score":0,"Answer":"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.\nSo 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? \nAnd 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. \nYou should always test that valid data passes and that incorrect doesn't at each step of your work flow.","Q_Score":1,"Tags":"python,pytest,python-unittest","A_Id":52763853,"CreationDate":"2018-10-11T15:24:00.000","Title":"Writing unit tests in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Problem\nI want to secure my Raspberry pi in a special way.\nI would like to start up raspberry pi without entering a password as pi user.\nHowever, I want pi user to have zero privilege. Cant read a file, cant copy a file, simply nothing. And without access to root->'sudo su'. On the other hand when raspberry pi starts itself with pi user, I want backend process to be running as root. So to put it simply, I want it like in a zoo - two worlds but neither of them can enter the other. Clients can be present, see what process are running, see files in directories, but cant read it, copy, remove and etc. In the same time I want the backend to be untouched and running and writing files.\nReason:\nI have raspberri pi product - customer get it home, when plug in power supply,RPi starts up and runs backend programs with root privilege and communicates with my desktop software.\nBut I dont want curious customer that plugs in HDMI and see my code. I also dont want him to take the SD card and extract the code. \nI heard its possible to reverse engineer the code even if compiled. So I simply want the programs(python script) to be there but cannot be accessed in any way.\nIs it possible to make such protection?\nThanks in advance","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":2009,"Q_Id":52777186,"Users Score":4,"Answer":"You may consider to use the following approach \n\nUse at least two levels of hashing with MAC address and ARM chip serial number (via cat \/proc\/cpuinfo) with additional secret keys. Run your program only if the stored license key is the same as the result of doubly-hashed functions.\nOptionally, you could rewrite critical part of your code in C, compile it statically, and remove all debug symbols. Call it using Python. \nQuick optimization of your code using cython. Call its generated shared objects with a python caller script. Distribute only the shared objects and the python caller script.\n\nThis will prevent most people from reverse engineering your codes.","Q_Score":0,"Tags":"python,raspberry-pi,root,privileges,protection","A_Id":52777984,"CreationDate":"2018-10-12T10:05:00.000","Title":"Raspberry pi protection against reverse engineering the codes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to copy a file in one folder in source bucket to another folder in the same bucket under source folder using boto3. \nSource bucket: Testing\nSource Path: A\/B\/C\/D\/E\/F..\nI have some files in C, which I need to move to E. \nMy problem is, lambda is running in loop for this. I have this lambda which get triggered when my file comes to C, and then ut trigger another one to do something else. Now between these two, I have to move the file from C to E and then trigger the lambda to perform next operation. \nAnyone have any insight how I can fix that issue of lambda running in loop?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1103,"Q_Id":52787895,"Users Score":1,"Answer":"In S3 there is no folder. You'd better see it as a bucket-key-value. The folder-like representation you see in the console is just a visualisation.\nYour Lambda is triggered by an event of file modification in your bucket. You have to play with the prefix and the suffix of the S3 event.\nDo you control the name of the file you put in S3?\n\nYes. Suppose your filename always starts with new. Set your event with prefix: A\/B\/C\/new. When a file get in A\/B\/C\/new... the lambda is triggered because it matches the prefix, when the same files goes to A\/B\/C\/D\/E\/new... no lambda is triggered because the prefix doesn't match.\nNo. Then change your folder hierarchy. Set your event with prefix: A\/B\/C\/. Move the file to any key (i.e. \"folder\") that doesn't start with A\/B\/C, for example A\/B\/E. Thus, the second key will not match the prefix.\n\nThe suffix is not of any help unless you may rename the suffix of the file. If you are able to rename the file you create an event with suffix: .abc, and when moving the file you rename it to something ending in .xyz. Thus only the .abc files will trigger the Lambda, wherever they are situated.","Q_Score":0,"Tags":"python,amazon-s3,aws-lambda","A_Id":52788511,"CreationDate":"2018-10-12T22:47:00.000","Title":"Copy files in nested folders in S3 bucket","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to retrieve the text data for a specific twitter account and save it for a ML project about text generation, is this possible using the Twitter API?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":164,"Q_Id":52807824,"Users Score":0,"Answer":"Yes. It is possible. Try tweepy. It is a wrapper for Twitter API.","Q_Score":0,"Tags":"python,text,twitter","A_Id":52807837,"CreationDate":"2018-10-14T23:02:00.000","Title":"How do\/can I retrieve text data from a Twitter account in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a selection of pdfs that I want to text mine. I use tika to parse the text out of each pdf and save to a .txt with utf-8 encoding (I'm using windows)\nMost of the pdfs were OCR'd before I got them but when I view the extracted text I have \"pn\u00c1nn\u00bf\u00a1c\" instead of \"Ph\u00e1draig\" if I view the PDF.\nIs it possible for me to verify the text layer of the PDF (forgive me if thats the incorrect term) Ideally without needing the full version of Acrobat","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":66,"Q_Id":52807830,"Users Score":1,"Answer":"It sounds like you are dealing with scanned books with \"hidden OCR\", ie. the PDF shows an image of the original document, behind which there is a layer of OCRed text.\nThat allows you to use the search function and to copy-paste text out of the document.\nWhen you highlight the text, the hidden characters become visible (though this behaviour maybe depends on the viewer you use).\nTo be sure, you can copy-paste the highlighted text to a text editor.\nThis will allow you to tell if you are actually dealing with OCR quality this terrible, or if your extraction process caused mojibake.\nSince OCR quality heavily depends on language resources (dictionaries, language model), I wouldn't be surprised if the output was actually that bad for a low-resource language like Gaelic (Old Irish?).","Q_Score":0,"Tags":"python-3.x,pdf,utf-8,character-encoding,apache-tika","A_Id":52842615,"CreationDate":"2018-10-14T23:03:00.000","Title":"How to identify if text encoding issue is my processing error or carried from the source pdf","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any way I can stop the whole robot test execution with PASS status?\nFor some specific reasons, I need to stop the whole test but still get a GREEN report.\nCurrently I am using FATAL ERROR which will raise a assertion error and return FAIL to report.\nI was trying to create a user keyword to do this, but I am not really familiar with the robot error handling process, could anyone help?\nThere's an attribute ROBOT_EXIT_ON_FAILURE in BuiltIn.py, and I am thinking about to create another attribute like ROBOT_EXIT_ON_SUCCESS, but have no idea how to.\nEnvironment: robotframework==3.0.2 with Python 3.6.5","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3462,"Q_Id":52846338,"Users Score":0,"Answer":"If I understood you correctly, you need to pass the test execution forcefully and return green status for that test, is that right? You have a built in keyword \"Pass Execution\" for that. Did you try using that?","Q_Score":0,"Tags":"python-3.x,robotframework","A_Id":55419982,"CreationDate":"2018-10-17T02:07:00.000","Title":"How to stop the whole test execution but with PASS status in RobotFramework?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using the Python Spotify library Spotipy with a Raspberry Pi, and I am wondering why there is a 50 song limit when trying to see the user's saved songs? I have looked at the documentation, but I am still confused on the reason. If you answer this thank you so much.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":196,"Q_Id":52866626,"Users Score":0,"Answer":"They don't expect users to be regularly retrieving all of a user's songs, only a portion of them (and potentially by filtered query). In addition, it could be a waste of data if 100 songs are sent, but the user only ends up using one song. \nFifty is a sensible limit, and there is pagination to allow for accessing more than fifty songs in a series of smaller requests (rather than one large request).","Q_Score":0,"Tags":"python,api,spotify,spotipy","A_Id":52866661,"CreationDate":"2018-10-18T03:34:00.000","Title":"Spotipy- Why is there a 50 song limit when getting saved songs?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is it possible to read e-mail flags Seen, Unseen and restore them as the were before reading e-mail using imaplib in Python?\nI couldn't find yet any information regarding reading these flags but there is plenty of examples setting Seen, Unseen etc. flags. I would appreciate if somebody would guide me to the right direction.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":486,"Q_Id":52875116,"Users Score":1,"Answer":"A big thanks goes to @stovfl and @Max in comments. I successfully made my program work using imap_conn.fetch(uid, '(BODY.PEEK[HEADER])'). On the other side if somebody needs read-only access they can use imap_conn.select('Inbox', readonly=True)","Q_Score":1,"Tags":"python,email,imaplib","A_Id":53003650,"CreationDate":"2018-10-18T13:24:00.000","Title":"Reading \\Seen, \\Unseen flags using imaplib in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been asked to provide a list of every behave Feature and Scenario we run as part of our regression pack for a document to an external client (not the steps) \nAs our regression test suite is currently around 50 feature files with at least 10 scenarios in each I would rather not copy and paste manually. \nIs there a way to export the Feature name and ID and then the name and ID of each scenario that comes under that feature either to a CSV or text file? \nCurrently our behave tests are run locally and I am using PyCharm IDE to edit them in.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1326,"Q_Id":52876099,"Users Score":0,"Answer":"I have found a roundabout way to do this. \nSet Behave to export to an external txt file using the command\noutfiles = test_list\nThen use the behave -d command to run my tests as a dry run. \nThis then populates the txt file with the feature, scenario and step of every test. \nI can export this to Excel and through filtering can isolate the feature and scenario lines removing the steps and then use text to columns to split the feature\/scenario description from its test path\/name. \nIf there is a less roundabout way of doing this it would be good to know as it looks like this is information we will need to be able to provide on a semi regular basis moving forwards.","Q_Score":0,"Tags":"python-behave","A_Id":52890157,"CreationDate":"2018-10-18T14:17:00.000","Title":"Behave print all tests to a text file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed Python 3.7 on my system and I am running one simple python file in which imports a .pyd file. When running the script I got error like:\n\nTraceback (most recent call last):\n File \"demoTemp\\run.py\", line 1, in \n from pyddemo import fun\n ModuleNotFoundError: No module named 'pyddemo'\n\npyddemo is pyd file.\nIs there any dependency for pyd file?\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":886,"Q_Id":52886756,"Users Score":0,"Answer":"I found solution of my problem its just mismatch of python version in which I have created pyd and python version in which I am using it.","Q_Score":1,"Tags":"python-3.x","A_Id":52890342,"CreationDate":"2018-10-19T06:12:00.000","Title":"PYD file not found","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"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.\nI 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.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1383,"Q_Id":52890995,"Users Score":1,"Answer":"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.\n2 versions of Python\nWhen 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.\nJenkins\nThere are many ways of performing it:\n\nyou can prepare separate jobs for both python 2 and 3 versions of tests and run them from jenkins file\nyou 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)","Q_Score":2,"Tags":"python,jenkins,github,continuous-integration,jenkins-pipeline","A_Id":52892540,"CreationDate":"2018-10-19T10:55:00.000","Title":"Running Jenkinsfile with multiple Python versions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"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?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":77,"Q_Id":52901800,"Users Score":0,"Answer":"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.\nAs you see I don't write your code. If you need anymore advise please ask!","Q_Score":1,"Tags":"python,python-2.7,video-tracking","A_Id":52943459,"CreationDate":"2018-10-20T01:58:00.000","Title":"How to find redundant paths (subpaths) in the trajectory of a moving object?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to create a script (Script #1) that writes a file that can only be read once globally, and then another script (Script #2) that reads this file only if it was never read before in the world.\nExample Situation:\nI create a CSV file with my Script #1 and email this CSV file to 10 people, who are on different computers.\nAll 10 try to run this file with my Script #2:\nExpected behaviour:\nThe first person in the world to run Script #2 with this file gets a message saying they are the first person to read this file and can actually see the content.\n2nd -10th person that try to read the file get a message saying someone has already read it before and can't access the file.\nHow can I accomplish this?\nThis is not something very serious, so I'm not really worried about security of the process, but want it to work.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":232,"Q_Id":52908310,"Users Score":0,"Answer":"Not Giving the whole process because it will be a large explanation but you can do the below mention points\n\nEncrypt the file first.\nSecond the script which you want to read the content of your file must be linked with a server application from which it will receive decryption key and send data to server about whether the file is read before or not. It's like if the file readed earlier then the server don't send the decryption key.\nThen after receiving the key the script should decrypt the file and read it.","Q_Score":0,"Tags":"python,file,csv,encryption","A_Id":52911860,"CreationDate":"2018-10-20T17:32:00.000","Title":"How to ensure that globally a file can be read only once by my python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Since FMI version 2.0 we have methods: get_variable_unit() and get_variable_display_unit() that brings the information from the Modelica code for the FMU-module. What I can see there is no impact on what you obtain from get_variable_data() from the FUM-module on the results from a simulation. \nIs there any python-package today that facilitate consistent handling of units in diagrams showing simulated data with JModelica, similar to what you get in for instance OpenModelica in the graphical user interface there?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":81,"Q_Id":52923501,"Users Score":0,"Answer":"My contact at Modelon says that they welcome third party to contribute here. Perhaps more interesting now to do since PyFMI is on GitHub since end of 2019.","Q_Score":1,"Tags":"python,fmi,jmodelica","A_Id":60427611,"CreationDate":"2018-10-22T06:32:00.000","Title":"FMU-module method get_variable_unit() and more","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"For a project work, I need to measure the volume level either from a recorded audio file or in real time recording using a mic. After my primary research, I have tried using soundfile library. The file was read using soundfile and using 20*np.log10(np.sqrt(np.mean(np.absolute(a)**2))), I have calculated the dB value. I'm getting a negative value for the sound file. But a normal sound may be in the range of 50-70 dB and I'm getting a negative value. Can anybody help me to sort out this?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":10925,"Q_Id":52943151,"Users Score":1,"Answer":"You need to add reference of sound i.e 20 log10(P rms_value\/P ref)+120 dB to get the data in the range of dB scale, Pref can be tuned from your input module","Q_Score":2,"Tags":"python,numpy,signal-processing,wav,pyaudio","A_Id":59115025,"CreationDate":"2018-10-23T07:12:00.000","Title":"Python: Get volume decibel Level real time or from a wav file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I 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.\nI thought that the easiest thing, might just be to shutdown the pi from the other pi. But I have no experience on this subject.\nI don't need an exact guide (I appreciate all the help I can get) but does anyone know how one might do this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":531,"Q_Id":52949880,"Users Score":0,"Answer":"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).\nIf the answer is yes, you can simply connect to your PI through SSH, and call shutdown.sh. \nI 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). \nYou could make a smartphone app, or any kind or code that can connect to SSH (all of them).","Q_Score":0,"Tags":"python,button,ssh,raspberry-pi","A_Id":52950146,"CreationDate":"2018-10-23T13:07:00.000","Title":"Shutdown (a script) one raspberry pi with another raspberry pi","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So my directory currently looks something like this \nsrc\n \\aws_resources\n \\s3\n s3file.py\n util.py\ntest\n mytest.py\nI'm running the mytest.py file and it essentially imports the s3 file, while the s3 file imports the util.py file\nMy mytest.py says \nfrom src.aws_resources.s3 import *\n\nbut when I run the test file I get an error \nImportError: No module named aws_resources.util\n\nI tried adding \nfrom src.aws_resources import util to mytest.py but I still get the same error. Any suggestions would be appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":672,"Q_Id":52952756,"Users Score":0,"Answer":"Your current working directory is test, which means any import line will look into the test folder to find modules, if not found, go to the other paths existing in your sys.path (e.g. PYTHONPATH) to find.\nHere are my two assumptions:\n1.) src is not part of your PYTHONPATH\n2.) In your s3file.py you have this line (or similar): from aws_resources.util import *\nSince aws_resources is not a valid folder under test, and it couldn't be found under any of your sys.path, the Python interpreter couldn't find the module and rasied ImportError.\nYou can try one of the following:\n1.) Restructure your folder structure so that everything can be immediately referenced from your current working directory.\n2.) Handle the from aws_resources.util import * line in your s3file.py if you are importing it from another working directory.\n3.) Add src into your PYTHONPATH, or move it to a folder identified in PATH\/PYTHONPATH so you can always reference back to it.\nThe approach really depends on your use case for src and how often it gets referenced elsewhere.","Q_Score":0,"Tags":"python,python-2.7,import","A_Id":52952937,"CreationDate":"2018-10-23T15:28:00.000","Title":"\"No module named \" found when importing file that imports another file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to run the PVWatts model (concretely to get pvwatts_dc) on an Amerisolar 315 module which doesn't seem to appear. What I am trying to do is to replicate the steps in the manual, which only requires system DC size. \nWhen I go into the power model, the formula says g_poa_effective must be already angle-of-incidence-loss corrected. How do I do this correction? I've thought about using the physical correction formula pvlib.pvsystem.physicaliam(aoi), but is this the right track?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":77,"Q_Id":52957433,"Users Score":1,"Answer":"Yes, use an incident angle modifier function such as physicaliam to calculate the AOI loss, apply the AOI loss to the in-plane direct component, then add the in-plane diffuse component.","Q_Score":0,"Tags":"python,pvlib","A_Id":52973320,"CreationDate":"2018-10-23T20:32:00.000","Title":"running PVWatts for module system not in Sandia DB (python library)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to check if root user exist in AWS account using Python or any cli command.\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":724,"Q_Id":52994223,"Users Score":0,"Answer":"Try these commands\naws iam list-users\naws iam list-roles","Q_Score":0,"Tags":"python","A_Id":52994379,"CreationDate":"2018-10-25T16:37:00.000","Title":"Check if Root user exist in AWS account","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"When i opened the iDEA and try to run my project , i got the below error.\n\n2:12 PM Unknown Module Type\n Cannot determine module type (\"PYTHON_MODULE\") for the following module:\"test\"\n The module will be treated as a Unknown module.\n\nI dint make any changes as far i remember and the project was working until last week.\nAny help would be appreciated.\nRegards\nmadhu","AnswerCount":1,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":2819,"Q_Id":53051728,"Users Score":10,"Answer":".idea hidden folder is the project settings created by any Intellij IDEA IDE. The .idea folder must be clear -- no conflict in dependencies. E.g., for C++ cmake based project you need C++ ide such as Clion. Clion configures .idea based on Cmake projects. \nNow, your problem when you try to open Cmake C++ project into non C++ IDE (such as Pycharm), the .idea folder conflicts. And you see such above problems. \nTo fix this issue, just delete the .idea folder. And re open your IDE.","Q_Score":3,"Tags":"python,python-3.x,intellij-idea","A_Id":54300815,"CreationDate":"2018-10-29T18:30:00.000","Title":"Cannot determine module type (\"PYTHON_MODULE\") for the following module","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am doing a project where I want to build a model that estimates the number of retweets at a given time for a given tweet bearing a certain keyword, so that when a new tweet with the same keyword comes in, I can track its number of retweets and see if there is any anomaly. For that, on top of collecting a large number of tweets with that certain keyword for modeling, I need to know for each of the tweets what was the number of retweets on day 1, day 2, etc (the unit of time is arbitrary here, can be in days or in minutes) since it was created. \nI've done some research on stackoverflow, but I have not seen a solution for this particular problem. I understand that twitter API allows you to search for tweets with keywords, but it only gives you the tweets' current number of retweets but not the historical performance. \nI would really appreciate it if anyone can point me to the right direction. Thank you very much!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":270,"Q_Id":53068167,"Users Score":0,"Answer":"There's no API method in any of Twitter's API tiers (standard, premium or enterprise) that would enable you to do this. You'd need to have already been listening for the Tweets, record the Tweet IDs, check them every day for total engagement numbers, and then record the differential every day.","Q_Score":1,"Tags":"python,api,twitter,web-scraping","A_Id":53071904,"CreationDate":"2018-10-30T15:49:00.000","Title":"Get Historical Tweet Metadata from Twitter API in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an account on Gator.\nI am trying to run a php script as follows\n;$command = escapeshellcmd('.\/simple.py 2>&1');\n$output = shell_exec($command);\necho $output\nI would like to get as output anything that the python script prints to screen, but the output is empty no matter what I try (I use standard print in python","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":498,"Q_Id":53068529,"Users Score":0,"Answer":"$command = escapeshellcmd('.\/simple.py 2>&1');\n\nescapeshellcmd is a form of surrender, it's php stupidity, it gets used as a DWIM band-aid when the programmer has lost control of the command-line.\nIt's breaking your stderr redirection.\nUse escapeshellarg where you need to escape shell stuff.\n$command = escapeshellarg('.\/simple.py') . ' ' . '2>&1';","Q_Score":0,"Tags":"php,python","A_Id":53071635,"CreationDate":"2018-10-30T16:10:00.000","Title":"How to call python from php on a remote server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"The file structure looks like this:\n\/email1\/spam\n\/email2\/spam\n\/email3\/spam\n...\nNow, copy all files under all 'spam' directories to a new directory called \/email_data\/spam\nI tried to use shutil.copytree, but it only copy the first directory (copytree requires the destination must not exists).\nThen I tried distutils.dir_util.copy_tree, it works, but I don't know why everytime after its copy, there will be some duplicated files. (e.g. spam_email.txt, spam_email_1.txt). There should be 15045 files, but the code copy 16545 which 1500 more...","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":700,"Q_Id":53075402,"Users Score":0,"Answer":"Finally, I found rsync is very easy to use, as metatoaster said, just use os.system(command).\nActually distutils.dir_util.copy_tree works as well, there is no duplication error of copy, the source directory itself has duplicated files...","Q_Score":0,"Tags":"python,copy","A_Id":53078361,"CreationDate":"2018-10-31T02:23:00.000","Title":"How to use python to copy full directory and its contents overwrittenly?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a code in Oracle which is optimized and create weekly data. The problem is I also want my Oracle code trigger Python to run and create data in Python and save. Is there any possibility to execute my Python code automatically?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4810,"Q_Id":53096146,"Users Score":0,"Answer":"i use windows task planner with a .bat script to run my python code everyday.","Q_Score":1,"Tags":"python,oracle,optimization,triggers","A_Id":56313703,"CreationDate":"2018-11-01T06:22:00.000","Title":"How can I trigger a Python code automatically?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a code in Oracle which is optimized and create weekly data. The problem is I also want my Oracle code trigger Python to run and create data in Python and save. Is there any possibility to execute my Python code automatically?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4810,"Q_Id":53096146,"Users Score":0,"Answer":"you can use crons jon, task schedule to run the script in particular time. If you want to run the script as service you can use celery and crontab module.","Q_Score":1,"Tags":"python,oracle,optimization,triggers","A_Id":53096355,"CreationDate":"2018-11-01T06:22:00.000","Title":"How can I trigger a Python code automatically?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to connect to a remote rabbitmq server. I have the correct credentials and vhost exists on the remove server, but I cannot connect.\nI get the error \n\npika.exceptions.ProbableAccessDeniedError: (530, 'NOT_ALLOWED - vhost\n test_vhost not found')\n\nI have struggled with this for a while but I can't seem to get what the problem is.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":10124,"Q_Id":53102929,"Users Score":7,"Answer":"I figured it out. On my local machine I am using rabbitmq version 3.5.7 while on the remote rabbitmq is on version 3.7.0\nI had been declaring my vhost without a slash '\/' on 3.5.2 and it has been working well but I realized that adding a slash before declaring the vhost worked on version 3.7.0 .\nSo now I use \/test_vhost instead of just test_vhost","Q_Score":8,"Tags":"python,rabbitmq,pika","A_Id":53117628,"CreationDate":"2018-11-01T14:05:00.000","Title":"RabbitMQ Error 530 vhost not found with pika","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to repeatedly execute a curl command with a python script, is there a better way to do such a task?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":201,"Q_Id":53118542,"Users Score":2,"Answer":"Below findings can help you in linux environment.\nYou can do that with the help of a cron jab. \nSteps to setup a cron job:\n\nOpen crontab by the command \"crontab -e\" on the shell\nPaste the following in the file and correct the path\n0 * * * * \/home\/sshashank\/script.py\nMake sure you have given proper permissions to the folders where python script is going to run, folder where it is going to access(files\/logs). \nPlease provide absolute path and not relative path.","Q_Score":0,"Tags":"python,swagger-ui","A_Id":53118698,"CreationDate":"2018-11-02T12:21:00.000","Title":"How: Python Script to execute Terminal Command every hour?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I know that it is possible to turn python files into .exe files but why would you need to do that? What are the benefits?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":32,"Q_Id":53137109,"Users Score":0,"Answer":"A lot of the time, it has to do with bundling.\nConsider that when you go to distribute a standalone Python program, you often have to assume that whomever the program is intended for already has, at the very least, a Python interpreter of a compatible version installed. Similarly, if your program uses packages or modules which aren't part of the Python standard library, you will also have to make the assumption that the intended users also have your program dependencies installed or are using pip to install it via your listed setup.py dependencies. Typically these are not good assumptions.\nThere are a number of ways of addressing this issue, and bundling a Python interpreter with the necessary dependencies installed into the distribution itself is a popular one. For Windows users in particular, many developers like to release such bundles as .exe files using a C or C++ wrapper for the sake of user convenience: A user need only double click the bundled program to launch it with minimal setup. This is how a lot of \".py to .exe\" conversion programs work, such as the popular py2exe Python package.","Q_Score":0,"Tags":"python-3.x","A_Id":53137226,"CreationDate":"2018-11-04T01:55:00.000","Title":"Why would you need to turn a python file into an executable?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"How can I get this to happen in Apache (with python, on Debian if it matters)?\n\nUser submits a form\nBased on the form entries I calculate which html file to serve them (say 0101.html)\nIf 0101.html exists, redirect them directly to 0101.html\nOtherwise, run a script to create 0101.html, then redirect them to it.\n\nThanks!\nEdit: 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.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":100,"Q_Id":53142553,"Users Score":0,"Answer":"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.","Q_Score":1,"Tags":"python,apache,cgi","A_Id":53142803,"CreationDate":"2018-11-04T15:50:00.000","Title":"Apache - if file does not exist, run script to create it, then serve it","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to push some files up to s3 with the AWS CLI and I am running into an error:\nupload failed: ... An HTTP Client raised and unhandled exception: unknown encoding: idna\nI 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. \n$> python --version\n Python 3.6.7\nIf 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.","AnswerCount":5,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":6262,"Q_Id":53144254,"Users Score":8,"Answer":"I had the same problem in Windows.\nAfter 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.\nI also tried to install MSI installer x32 and the problem was missing.","Q_Score":12,"Tags":"python-3.x,amazon-s3,aws-cli","A_Id":54337242,"CreationDate":"2018-11-04T18:53:00.000","Title":"AWS CLI upload failed: unknown encoding: idna","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to push some files up to s3 with the AWS CLI and I am running into an error:\nupload failed: ... An HTTP Client raised and unhandled exception: unknown encoding: idna\nI 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. \n$> python --version\n Python 3.6.7\nIf 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.","AnswerCount":5,"Available Count":2,"Score":-0.0798297691,"is_accepted":false,"ViewCount":6262,"Q_Id":53144254,"Users Score":-2,"Answer":"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.\n\naws s3 cp sourcedir s3bucket --recursive --acl\n bucket-owner-full-control --profile profilename\n\nIt 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\nThis error was not consistent. The file for which upload failed, it might succeed if I try to run it again. It was quite weird.\nTried on trial and error basis and it started working well.\nSolution:\n\nUninstalled Python 3 and AWS CLI.\nInstalled Python 2.7.15\nAdded python installed path in environment variable PATH. Also added pythoninstalledpath\\scripts to PATH variable. \nAWS CLI doesnt work well with MS Installer on Windows Server 2008, instead used PIP. \n\nCommand: \n\npip install awscli\n\nNote: for pip to work, do not forget to add pythoninstalledpath\\scripts to PATH variable.\nYou should have following version:\nCommand: \n\naws --version\n\nOutput: aws-cli\/1.16.72 Python\/2.7.15 Windows\/2008ServerR2 botocore\/1.12.62\nVoila! The error is gone!","Q_Score":12,"Tags":"python-3.x,amazon-s3,aws-cli","A_Id":53693183,"CreationDate":"2018-11-04T18:53:00.000","Title":"AWS CLI upload failed: unknown encoding: idna","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using SMTPlib package to create multiple emails in one application and the code works fine to send email. But, I want to be able to schedule each email to be sent at different day\/time. \nFor instance, one at 9AM Monday and another at 12 Noon Wed. \nI looked at some slightly different questions and answers on SO, where the recommendation is use of Crontab. However, Crontab is only helpful to schedule the entire application not individual parts of the application.\nSched package is also available, but I am not familiar with it and hence not sure, if I can efficiently use this for my use case. \nAppreciate your thoughts","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":49,"Q_Id":53157403,"Users Score":0,"Answer":"Maybe you should create separate python file\/process responsible only for sending emails. You can run it when you need to queue\/send emails and you might just kill it afterwards.","Q_Score":0,"Tags":"python-3.x,email,scheduler","A_Id":53157641,"CreationDate":"2018-11-05T15:32:00.000","Title":"Schedule Multiple Emails Python 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to run a program on our cluster environment which requires python 2.7. The thing is the version installed on the cluster is 2.6.6. Therefore, I tried to update the python version in my own folder. To do so, first I used module avail python command, but nothing showed up!!! Afterward, I tried which python2.7 on the command line, and I noticed that it exist in \/usr\/bin\/python2.7. Going into the given subfolder, I tried module load python2.7 but I faced the following error:\nModuleCmd_Load.c(208):ERROR:105: Unable to locate a modulefile for 'python2.7'\nI would be very thankful if someone could tell me how can I solve my problem.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":277,"Q_Id":53173713,"Users Score":0,"Answer":"The module command you use needs to find a modulefile for the module python2.7 you try to load. If such modulefile is found it usually updates the shell environment to active the software in question.\nIn the situation you describe, it seems there is no python module available by default currently. Which means you either:\n\nneed to find the modulepath to activate with the module use command where those python modulefiles are located\nor write a modulefile to enable this python2.7 installation and save it in an existig modulepath directory","Q_Score":0,"Tags":"python-2.7,cluster-computing,python-2.6,updating,environment-modules","A_Id":53185454,"CreationDate":"2018-11-06T14:16:00.000","Title":"Updating Python in my folder on the cluster","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have created a lambda that iterates over all the files in a given S3 bucket and deletes the files in S3 bucket. The S3 bucket has around 100K files and I am selecting and deleting the around 60K files. I have set the timeout for lambda to max (15 minutes) timeout value. The lambda is consistently returning \"network error\" after few minutes though it seems to run in the background for sometime even after the error is returned. How can get around this?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":14183,"Q_Id":53180543,"Users Score":1,"Answer":"I was testing another function and this error came up as a result. Reading a little in the documentation I found that I activated the throttle option, that it reduces the amount of rate for your function.\nThe solution is to create another function and see if the throttle is making that error.","Q_Score":4,"Tags":"python,amazon-web-services,amazon-s3,aws-lambda,boto3","A_Id":65430231,"CreationDate":"2018-11-06T21:47:00.000","Title":"AWS Lambda : Calling the invoke API action failed with this message: Network Error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am planning to run scripts to copy S3 files from one bucket to other bucket in same region( same account and different account - both cases are there). I am using Python scripts and running on EC2 instance. \n1) Will the performance depend on EC2 server type?\n2) What is the best way to improve performance when copying S3 files from one account to another ( and also one bucket to another in same account, same region) . Given they are in same region and different regions. File sizes are around 1 GB each with total size of 5TB\nThanks\ntom\nLet me know if you need any other information.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":290,"Q_Id":53231038,"Users Score":2,"Answer":"No, in this instance the type of EC2 will not matter because you are using the AWS network to transfer data from 1 bucket to another. If you wanted to spin off parallel processing of the data (Run multiple s3 cp at the same time) then you would choose a specific instance, but in your case a T2 Small would do just fine.","Q_Score":0,"Tags":"python-3.x,amazon-s3,amazon-ec2","A_Id":53232124,"CreationDate":"2018-11-09T17:57:00.000","Title":"aws s3 to s3 copy using python script on EC2","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'd like to fetch mails from a server, but I also want to control when to delete them.\nIs there a way to do this?\nI know this setting is very usual in mail clients, but it seems this option is not well supported by POPv3 specification and\/or server implementations.\n(I'm using python, but I'm ok with other languages\/libraries, Python's poplib seems very simplistic)","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":964,"Q_Id":53231525,"Users Score":2,"Answer":"POP3 by design downloads and removes mail from a server after it's successfully fetched. If you don't want that, then use the IMAP protocol instead. That protocol has support to allow you to delete mail at your leisure as opposed to when it's synced to your machine.","Q_Score":2,"Tags":"python,pop3,poplib","A_Id":53231559,"CreationDate":"2018-11-09T18:34:00.000","Title":"Fetch mails via POP3, but keep them on the server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any way to get all games that user has played while using Discord?\nSo based on that I can give them specific roles.\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1082,"Q_Id":53233805,"Users Score":1,"Answer":"You'd have to store them, there is no history of games played available in the API","Q_Score":1,"Tags":"python,discord.py-rewrite","A_Id":53254574,"CreationDate":"2018-11-09T22:01:00.000","Title":"How to get all games that user has played while using Discord with discord.py","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using pytest-xdist plugin to run some test using the @pytest.mark.parametrize to run the same test with different parameters.\nAs part of these tests, I need to open\/close web servers and the ports are generated at collection time.\nxdist does the test collection on the slave and they are not synchronised, so how can I guarantee uniqueness for the port generation.\nI can use the same port for each slave but I don't know how to archive this.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":304,"Q_Id":53234370,"Users Score":0,"Answer":"I figured that I did not give enough information regarding my issue.\nWhat 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.\nEach 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.\nEventually, I make sure that the job ids will be in the rand on 1024-65000 and used that for the port.","Q_Score":0,"Tags":"python,pytest,xdist,pytest-xdist","A_Id":53282799,"CreationDate":"2018-11-09T23:03:00.000","Title":"pytest-xdist generate random & uniqe ports for each test","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I\u2019m currently working on a Raspberry Pi\/Django project slightly more complex that i\u2019m used to. (i either do local raspberry pi projects, or simple Django websites; never the two combined!)\nThe idea is two have two Raspberry Pi\u2019s collecting information running a local Python script, that would each take input from one HDMI feed (i\u2019ve got all that part figured out - I THINK) using image processing. Now i want these two Raspberry Pi\u2019s (that don\u2019t talk to each other) to connect to a backend server that would combine, store (and process) the information gathered by my two Pis\nI\u2019m 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\u2019m therefore expecting no more than a dozen binary timestamped data points per second.\nNow what is the smart way to do it here ? \n\nDo i make contact to the backend every second? Every 10 seconds?\nHow 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 \u201cbulk updates\u201d for django but i\u2019m not sure that covers it entirely)\nHow 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?\n\nBasically, i\u2019m 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.\nPS: 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\u2019t be an issue.\nPPS: i\u2019m using a django backend (even if it seems a little overkill) \n a\/ because i already know the framework pretty well\n b\/ because i\u2019m 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.\nThank you very much !","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1234,"Q_Id":53249599,"Users Score":2,"Answer":"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.\nOtherwise 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.","Q_Score":1,"Tags":"python,django,raspberry-pi,iot,bulk-load","A_Id":53249964,"CreationDate":"2018-11-11T14:15:00.000","Title":"Sending data to Django backend from RaspberryPi Sensor (frequency, bulk-update, robustness)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Could not find a version that satisfies the requirement pcap (from versions: )\nNo matching distribution found for pcap","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":391,"Q_Id":53251242,"Users Score":0,"Answer":"The Python package name is libpcap, not pcap.","Q_Score":0,"Tags":"python,libpcap","A_Id":53251267,"CreationDate":"2018-11-11T17:19:00.000","Title":"pcap pakage to python project error is pcap.h not found","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want a help in robotics stuff..\nMy Question is ... : \nHow to connect my robotic car ( car is having raspberry pi as controller) with my computer via internet .. so the I can control the car from my computer's keybord.. \nPreviously i was using VNC and made a python tkinter script (stored at raspberry pi) and by the help of vnc i control the car but it was not good .. \nMost of the time the when i press the key, function works after sometime and worst thing was that it stores all the commands in a queue or buffer .. \nSo realtime operation was not happenping ( like: if i press forward arrow key for 2 seconds, it evoked moveForward() 20 times which is equal to 2 meters forward move and takes 4 seconds to travel .. BUT after that if i press right arrow key then it evokes moveRight() .. the worst part is it will execute after finishing the moveForward() stored in a queue i.e after 4 seconds .. and not on real time)\nIs there any way to control\/give command to raspberry pi on real time and not in a queue manner via socketing or other thing ?\nnote : i have a static ip address with specific port open and it has to be done over internet.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":72,"Q_Id":53275066,"Users Score":0,"Answer":"The appearance of your car might mainly relate to the whole system response time. The Raspberry Pi may be not fast enough. If there is no necessary, analog signal may on real time.","Q_Score":0,"Tags":"python,sockets,raspberry-pi,real-time,remote-connection","A_Id":53275756,"CreationDate":"2018-11-13T06:30:00.000","Title":"Remote connection between Raspberry pi and other computer through python over internet on real time","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a hosting plan through Godaddy that only supports python 2.6.6. I have been able to install python 2.7 and 3.6 through SSH and run scripts, pip, no problems.\nWhen I try and run a PHP script that calls a python script from SSH, it works just fine using my new python installs, but when I open the PHP script in a browser, it will only run 2.6.6.\nWhy is this? Is there a way to get around this without getting a VPS?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":311,"Q_Id":53284175,"Users Score":0,"Answer":"I have found a sneaky way around this. I used SSH2 PHP extension to call the python3.","Q_Score":0,"Tags":"php,python","A_Id":53285381,"CreationDate":"2018-11-13T15:21:00.000","Title":"Python on a shared hosting server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I've coded a Telegram bot (python-telegram-bot) and I would like to know if there's a way to open an app from the bot.\nTo be more accurate, the bot searches torrent links and the original idea was to send that links directly to qBitTorrent in the user's computer but unfortunately I'm stuck in that step, so for the moment I though about give the user the magnet link so it can be pasted in the qBitTorrent app. The thing is that it would great to automaticly open the app from the bot.\nThanks in advance!","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":2070,"Q_Id":53298734,"Users Score":2,"Answer":"A bot can't open an external app","Q_Score":3,"Tags":"python,python-3.x,bittorrent,python-telegram-bot","A_Id":53457627,"CreationDate":"2018-11-14T11:04:00.000","Title":"Any way to open an app from Telegram bot?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've coded a Telegram bot (python-telegram-bot) and I would like to know if there's a way to open an app from the bot.\nTo be more accurate, the bot searches torrent links and the original idea was to send that links directly to qBitTorrent in the user's computer but unfortunately I'm stuck in that step, so for the moment I though about give the user the magnet link so it can be pasted in the qBitTorrent app. The thing is that it would great to automaticly open the app from the bot.\nThanks in advance!","AnswerCount":4,"Available Count":2,"Score":-0.049958375,"is_accepted":false,"ViewCount":2070,"Q_Id":53298734,"Users Score":-1,"Answer":"I was also trying to do this, but that was not possible. But as workaround you can make a simple site that opens the app and make Telegram open that.","Q_Score":3,"Tags":"python,python-3.x,bittorrent,python-telegram-bot","A_Id":68702798,"CreationDate":"2018-11-14T11:04:00.000","Title":"Any way to open an app from Telegram bot?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am just starting the process of learning to access APIs using Python. Initially I presumed OAuth User IDs were generated or supplied by the API owner somehow. Would it actually be fabricated by myself, using alphanumerics and symbols? This is just for a personal project, I wouldn't have a need for a systematic creation of IDs. The APIs I am working with are owned by TDAmeritrade.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":54,"Q_Id":53306198,"Users Score":1,"Answer":"OAuth is has no capabilities for any type of provisioning of users or credentials.\nOAuth 2.0 provides for the Delegation of Authorization\n\nBy the Resource Owner (User)\nto the OAuth Client (Application)\nfor Access to a Resource Server (Website or Api or ???)","Q_Score":1,"Tags":"python,api,oauth","A_Id":53307184,"CreationDate":"2018-11-14T17:56:00.000","Title":"Creation of OAuth User IDs","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a fairly involved setup.py cython compilation process where I consider multiple things such as openMP support and the presence or absence of C headers. Specifically, FFTW is a library that computes the FFT, and is faster than numpy's FFT, so if fftw3.h is available, I compile my module against that, otherwise I fallback onto numpy.\nI would like to be able to remember how the package was compiled i.e. did the compiler support openMP and which FFT library was used. All this information is available when running setup.py but not later on and can be useful e.g. if the user would like to run a function using multiple cores, but openMP was not used during compilation, everything will run on one core. Remembering this information would allow me to show a nice error.\nI am unsure what the best way to do this would be. There are plenty of options such as writing a file with the data and then reading it when necessary, but is there any standard way to do this? Basically, I'm trying to emulate numpy's show_config, but am unsure what the best way to do this would be.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":25,"Q_Id":53340990,"Users Score":1,"Answer":"I have not attempted this, but my suggestion would to mimic the config.h-behavior one sees with autotools-based building: your setup.py generates a set of definitions that you either invoke via commandline or use via a generated header file - and then you can use this to feed e.g. a compiled extension function to return an approriate data-structure. But whatever you do: I have not come across a standardized way for this.","Q_Score":1,"Tags":"python,cython","A_Id":53341180,"CreationDate":"2018-11-16T15:36:00.000","Title":"Saving Python package setup configuration for later use","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to run an Arducam MT9J001 camera on a raspberry pi 3b+. I am getting the following error when I try to run the program, \"ImportError: libcblas.so3: cannot open shared object file: No such file or directory.\" I have the computer vision software downloaded onto the raspberry pi, though it seems that it is still not working. I'm not sure what other information is viable to this project, but if there is something else I should be specifying please let me know. Thanks in advance!","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":91576,"Q_Id":53347759,"Users Score":26,"Answer":"Exact same solution as @thvs86 but here's a single 1 line copy-paste so you don't have to insert each command individually:\npip3 install opencv-contrib-python; sudo apt-get install -y libatlas-base-dev libhdf5-dev libhdf5-serial-dev libatlas-base-dev libjasper-dev libqtgui4 libqt4-test","Q_Score":32,"Tags":"python,linux,raspberry-pi3,importerror","A_Id":54954503,"CreationDate":"2018-11-17T02:50:00.000","Title":"ImportError: libcblas.so.3: cannot open shared object file: No such file or directory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"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? \nWhat 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.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":34,"Q_Id":53370709,"Users Score":2,"Answer":"If I were you, with time constaraints, and bound to use a specific framework. I'll go in the following manner: \n\nList down the use cases I desire to implement using the framework \nIdentify the APIs provided by the framework that helps me implement the use cases\nPrototype the usecases based on the available documentation and reading\n\nThe 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. \nThe 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.","Q_Score":0,"Tags":"python,oop,frameworks","A_Id":53370875,"CreationDate":"2018-11-19T08:19:00.000","Title":"How do I efficiently understand a framework with sparse documentation?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to compress a set of strings in Python and get details, stats, and all the data from the compression to analyze it later (like the substring that appeared more times, the ones that were more useful for the compression, etc).\nRight now I am using zlib because it comes with Python - and I didn't found anything in the documentation, but I could change the compression method if I get enough data.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":88,"Q_Id":53379238,"Users Score":1,"Answer":"I am not aware of any compressor that collects such information. The search for matching strings, for example, is handled opportunistically, and there is no tracking of the same strings showing up more than once.","Q_Score":0,"Tags":"python,statistics,zip,compression,zlib","A_Id":53385239,"CreationDate":"2018-11-19T16:49:00.000","Title":"Compress string in Python and get details, stats, etc","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have to run pdf2image on my Python Lambda Function in AWS, but it requires poppler and poppler-utils to be installed on the machine. \nI 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.\nWould any of you know how to generate poppler binaries, put it on my Lambda package and tell Lambda to use that?\nThank you all.","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":6645,"Q_Id":53403399,"Users Score":0,"Answer":"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.\nThe binary files should go in a zip folder having structure as:\npoppler.zip -> bin\/poppler\nwhere poppler folder contains the binary files. This zip folder can be then uploaded as a layer in AWS lambda.\nFor pdf2image to work, it needs poppler path. This should be included in the lambda function in the format - \"\/opt\/bin\/poppler\".\nFor example,\npoppler_path = \"\/opt\/bin\/poppler\"\npages = convert_from_path(PDF_file, 500, poppler_path=poppler_path)","Q_Score":8,"Tags":"python,aws-lambda,poppler","A_Id":62793956,"CreationDate":"2018-11-20T23:58:00.000","Title":"How to install Poppler to be used on AWS Lambda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"It just keeps failing when I do sudo apt-get upgrade because it failed to upgrade some package that based on Python3. The error was: undefined symbol: XML_SetHashSalt. I'd been searching around for solutions but there is no such answer on StackOverflow.\nThen at the end, I found an answer on not very related question mention that the library path for libexpat.so.1 pointing to \/usr\/local\/lib\/ may cause the issue. So I try to rename libexpat.so.1 to libexpat.so.1-bk then it works.\nSo I just re-post it here, hope it helps for anyone facing it.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1034,"Q_Id":53405066,"Users Score":0,"Answer":"It seems that you have broken your system.\nIf you are using apt, the \/usr\/local\/ should never be used.\nIf you are using \/usr\/local\/, do not use apt to manage your installation.","Q_Score":1,"Tags":"python-3.x","A_Id":53405117,"CreationDate":"2018-11-21T03:58:00.000","Title":"Apt-get error \"undefined symbol: xml_sethashsalt\" when install\/update python3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to use the AWS IoT basicPubSub.py script to test my AWS connection, but I keep getting this error. I have tried various fixes, but cannot resolve the problem. \nI have tried it using my MacBook and RPi and still have the same issue.\nssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:720)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":445,"Q_Id":53431396,"Users Score":0,"Answer":"I am not sure how I managed to fix this problem, I tried the following items to fix the problem:\nRe-created all the certificates\nRe-installated CLI using sudo\nInstalled ssl (sudo apt-get install -y libssl-dev)\nI going to do a fresh installation on my RPi and repeat the steps to understand how this was resolved and fixed.","Q_Score":0,"Tags":"python,python-3.x,amazon-web-services,ssl,ssl-certificate","A_Id":53579254,"CreationDate":"2018-11-22T12:47:00.000","Title":"SSL error - certificate verify failed - AWS IOT (basicPubSub.py)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am trying to find all atoms of type A in a VASP POSCAR and then randomly add \"n\" atoms of type B in a sphere of radius (\"r\") centered at each site of type A atom using pymatgen and return each time a new POSCAR.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":165,"Q_Id":53464739,"Users Score":1,"Answer":"This isn't currently a pre-built transformation in pymatgen. You could script it yourself, by creating a new PeriodicSite, changing its position to a random vector using numpy, and appending it to the Structure.","Q_Score":0,"Tags":"python,numpy,pymatgen","A_Id":54369709,"CreationDate":"2018-11-25T04:51:00.000","Title":"add atoms randomly around an atom in vasp poscar using pymatgen","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using the Eclipse 4.9.0 with pydev installed on it. The pydev version is 7.0.3.201811082356\nIf I create a package called a.b.c in the Python project then Eclipse displays it hierarchically in the project explorer window. To see the Python modules under a.b.c you need to expand a, b, and then C. What I would like to see is flattened version i.e. a.b.c so I just click once to expand it and see all the modules under it. If any of you have developed Java in Eclipse you would know what I am talking about. In Java if you create a package called a.b.c then Eclipse will show it as a.b.c so you just expand it once to see all the classes under package a.b.c.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":41,"Q_Id":53474657,"Users Score":0,"Answer":"I know what you're talking about, unfortunately, this feature is not available in the PyDev package explorer (I think only JDT actually has that feature).\nSo, unfortunately, right now, you have to expand the actual folders to see your structure (there's no flattened version available).","Q_Score":0,"Tags":"python,eclipse,pydev","A_Id":53484821,"CreationDate":"2018-11-26T04:06:00.000","Title":"How to flatten the packages in Eclipse with pydev?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"pre:\n\nI installed both python2.7 and python 3.70\neclipse installed pydev, and configured two interpreters for each py version\nI have a project with some py scripts\n\nquestion:\nI choose one py file, I want run it in py2, then i want it run in py3(manually).\nI know that each file cound has it's run configuration, but it could only choose one interpreter a time. \nI also know that py.exe could help you get the right version of python.\nI 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.\nso, is there a way just like right click the file and choose \"run use interpreter xxx\"?\nor, does pydev has the ability to choose interpreters by \"#! python2\"\/\"#! python3\" at file head?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":324,"Q_Id":53496898,"Users Score":1,"Answer":"I didn't understand what's the actual workflow you want...\nDo 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? \nSo, please give more information on what's your actual problem and what you want to achieve...\n\nOptions to run a single file in multiple interpreters:\n\nAlways 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).\nCreate 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).","Q_Score":0,"Tags":"python,eclipse,pydev","A_Id":53516276,"CreationDate":"2018-11-27T09:51:00.000","Title":"how to run python in eclipse with both py2 and py3?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a bytearray, for example [0x6B, 0x6A, 0x6D, 0x6C].\nFor reasons out of my control the bytes are 'incorrect', and need to be fixed. The output I want is a bytearray like [0xAB, 0xCD].\nSo in my example, I want to ignore the '6' part of the byte. (6 is just an example, it can change).\nI'm currently doing this by:\n\nLooping over pairs of bytes\nConverting the bytes to a hex string, like '6B6A'\nTaking the 4th and 2nd character of the string to build 'AB'\nConvert that 'AB' hex string to a byte\n\nI already have a solution that works but it feels 'wrong' to use string manipulation with numerical values.\nI'm not proficient with bitwise operators and I'm not sure if I can use bitwise operators, or something else entirely, to do this in a faster and\/or more efficient way.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":112,"Q_Id":53499051,"Users Score":0,"Answer":"After a little trial and error:\nTo get 0x0B from 0x6B, I can do 0x6B & 0x0F.\nTo get 0xA0 from 0x6A, I can do the same as above, and then result << 4.\nThen I can add these values together to produce 0xAB.","Q_Score":2,"Tags":"python","A_Id":53499476,"CreationDate":"2018-11-27T11:51:00.000","Title":"How to clean\/fix these bytes without string operations?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hi I am new to python I found that if we use pytest, fixtures that defined in conftest.py can be directly referenced without needing import in test module. Similarly, if we are using pytest-mock, a fixture called mocker can be referenced any where in the test modules as long as the test is triggered by pytest, no need to do import either. I think there must be one or multiple python language features that enable such kind of thing. What are they? If your answers can assume that I am from Java\/C++ background that will be great!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":96,"Q_Id":53510600,"Users Score":0,"Answer":"the pytest fixture system registers fixtures by name, and then looks those names up in the fixture registry, not the actual python module you are currently in\nso you dont need to import them in each test module, and plugins for pytest can provide them","Q_Score":0,"Tags":"python,pytest","A_Id":53593520,"CreationDate":"2018-11-28T01:08:00.000","Title":"Why pytest can reference fixture without import?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can i do these two things:\n\nIs there any library in dart for Sentiment Analysis? \nCan I use Python (for Sentiment Analysis) in dart? \n\nMy 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. \nCan anyone please help me to solve this Problem.?\nOr is there any way that I can do text sentiment analysis in the flutter app?","AnswerCount":5,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":36968,"Q_Id":53519266,"Users Score":10,"Answer":"You can create an api using Python then serve it your mobile app (FLUTTER) using http requests.\nI","Q_Score":21,"Tags":"python,dart,python-requests,flutter,dart-pub","A_Id":56864092,"CreationDate":"2018-11-28T12:15:00.000","Title":"Python and Dart Integration in Flutter Mobile Application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to delete multiple email messages in Outlook from python via win32com module. \nI understand there is a VBA method MailItem.Delete() available to win32com via COM and it works; but it is VERY VERY slow when deleting more than one email since one would have to delete emails sequentially ie loop over the MailItem collection of emails. \nIs there any way to delete a selected collection of mailItems at once, something like MailItemCollection.DeleteAll()? \nAlso, if above is not possible; is it at all possible to delete many emails via multi-threaded approach ie divide the collection of mailItems into, let's say, 4 subsets; have 4 threads operate on those? \nI figure since I can delete multiple emails in outlook via its GUI very fast, there has to be a way where I can do the same thing via COM API.","AnswerCount":6,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5723,"Q_Id":53523943,"Users Score":0,"Answer":"I've implemented an alternative solution in local Outlook, by moving email \u00edtems from.inbox folder to deleted items folder or to an archive folder, by using VBA code or Outlook filter rules directly.\nThis way, I just mannualy empty the deleted items folder once a week (of course this periodic step can also be programmed).\nI observed that this strategy can be more efficient instead of delete item per item using code (you mentioned the internal.indexes problem).","Q_Score":2,"Tags":"python,api,outlook,com,win32com","A_Id":70914440,"CreationDate":"2018-11-28T16:24:00.000","Title":"python win32com: Delete multiple emails in Outlook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to design an algorithm that takes in a resistance value and outputs the minimum number of resistors and the values associated with those resistors. I would like the algorithm to iterate through a set of resistor values and the values in the set can be used no more than n times. I would like some direction on where to start.\nSeries: Req = R1 + R2 +...\nParallel: (1\/Req) = (1\/R1) + (1\/R2) +...\nInput:\n100000 (100k)\nSet: {30k, 50k, 80k, 200k}\nOutput: \n2 resistors in series: 50k + 50k \n2 resistors in parallel: 200k || 200k","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":241,"Q_Id":53543066,"Users Score":1,"Answer":"This is actually quite hard, best I can do is propose an idea for an algorithm for solving the first part, the concept of including parallels looks harder as well, but maybe the algorithm can be extended.\nIf you define a function \"best\", which takes a target resistance as input and outputs the minimal set of resistors that generates that resistance. E.G: if you only had 10K resistors, best(50K)=5*10K.\nThis function \"best\" has the following properties for a set of available resistors [A, B, C,...]:\n\nbest(A) = A for any A in the set.\nbest(Target) = min(best(Target-A) + A), best(Target-B) + B,...)\nbest(0)=0\nbest(x)=nonsense, if x<0 (remove these cases)\n\nThis can be used to reductively solve the problem. (I'd probably recommend storing the variables down the tree as you go along.\nHere's an example to illustrate a bit:\n\nAvailableSet = [10K, 100K]\nTarget = 120K\nFirst iteration:\nbest(120K) = min[ best(110K) + 10K, best(20K) + 100K]\ncalculate each subtree:\nbest(110K) = min[best(100K) + 10K, best(10K) + 100K]\nThis is now finalised as we can calculate everything in the min(_) by using the properties, so work back up the tree:\nbest(110K) = 100K + 10K ( I suppose if there is a tie like in this case pick a permuation randomly)\nbest(120K) = min[best(110K) + 10K , best(20K) + 100K] = ... = 100K + 10K + 10K\nThat should work as a solution to the first half of the problem, you may be able to extend this by adding extra properties, but it will make it harder to solve the problem reductively in this way.\nProbably the best way is to solve this first half of the problem and use a different algorithm to find the best solution using parallels and decide which is minimal in each case.","Q_Score":3,"Tags":"python,c++,algorithm","A_Id":53544202,"CreationDate":"2018-11-29T16:03:00.000","Title":"Algorithm to find minimum number of resistors from a set of resistor values. (C++ or Python)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Lambda function to send messages from a SQS deadletter to another SQS, but now I want to customize it, where I can specificate the range of the dates, type, another among, maybe from AWS CLI where I can specificate the configuration test event. Exist a way to do this? Thanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":628,"Q_Id":53559308,"Users Score":0,"Answer":"You can do this using lambda function which will first read SQS messages from queue1 and you can use that and customize (add your logic of addition of strings\/dates) and then write to SQS queue 2 from your lambda function.","Q_Score":0,"Tags":"python-2.7,aws-lambda,amazon-sqs,dead-letter","A_Id":53563570,"CreationDate":"2018-11-30T14:20:00.000","Title":"How to filter messages that I want to send to SQS - AWS Lambda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am experimenting with VSCode to edit a python program I have. It is about 3000 lines long. I have loaded Microsoft's Python extension for VSCode. Most things work well -- linting, etc.\nHowever, when I use F12 to jump to a definition of function or method, it can take 10 or 15 seconds to complete. Finding the usages of a function is (usually and surprisingly) must faster. All symbols I am searching for are in this same file.\nDo others have this problem? I don't think it is my machine's limitations, because I've been using VSCode with TypeScript for 6 months, and in that environment, which included 1000s of files, jumping to definitions was always very fast.\nThanks.\nVic","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":580,"Q_Id":53562204,"Users Score":0,"Answer":"Really this should go onto the github issue tracker for the extension. not here","Q_Score":2,"Tags":"python,visual-studio-code","A_Id":54347840,"CreationDate":"2018-11-30T17:26:00.000","Title":"VSCode and Python extension: Navigating to symbols is very very slow","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have some python code I'm writing that's interfacing real-world hardware. It's replacing a hardware PLC. What I'm planning is when an event trigger happens to kick off multiple threads to effect certain 'on' actions, then go to sleep for a set interval, and then perform the corresponding 'off' actions. For example: at trigger, spawn a thread that turns the room lights on. Then go to sleep for 20 minutes. Then turn the lights off and terminate the thread.\nHowever, I will have situations where the event trigger re-occurs. In that scenario I want the entire sequence to start over. My original plan was to use threads with unique names, so if a trigger occurs, check if the 'lights' thread exists, if if does kill it, and then re-spawn a new 'lights' thread. But in researching around these parts, it seems like people are suggesting that killing a thread is a Very Bad Thing to do. \nSo what would a better approach be to handling my situation? Note that in my example I only talked about one thread- but in reality there will be many different threads controlling many different devices.\nThis is python 3.x on a Rapberry Pi running raspbian, using rpi.gpio to monitor my input triggers and an I2C relay board for my output devices in case any of that info is useful. \nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":132,"Q_Id":53571617,"Users Score":0,"Answer":"the reason for not killing off threads is that it's easy to do it in a way that doesn't give the code any chance to \"clean up\" appropriately. i.e. finally blocks not run, resources leaked, etc\u2026\nthere are various ways to get around this, you could wait on an Event as suggested by @J\u00e9r\u00f4me, treating a timeout as a signal to carry on\nasyncio is another alternative as Cancelled exceptions tend to get used to clean up nicely and don't have the problems associated with killing native threads","Q_Score":0,"Tags":"python,multithreading,raspbian","A_Id":53571806,"CreationDate":"2018-12-01T14:09:00.000","Title":"Best way to restart (from beginning) a thread that is sleeping?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed Google Assistant on Raspberry Pi 3. My program has some output as fixed audio. Can I use Raspberry Pi 3 to speech it? The problem is that when using other programs to read, I have to turn off google assistant and turn on when finished speechding. Because they all use the same output device","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":291,"Q_Id":53589322,"Users Score":1,"Answer":"You can send text queries to the Assistant, and you could theoretically send a query in the background of \"Repeat after me X\" and the Assistant will repeat it. That may work for static or simple text.","Q_Score":0,"Tags":"python,raspberry-pi3,google-assistant-sdk","A_Id":53599234,"CreationDate":"2018-12-03T07:36:00.000","Title":"How use google assistant as a text to speech tool Raspberry","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to implement machine learning on hardware platform s which can learning by itself Is there any way to by which machine learning on hardware works seamlessly?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":68,"Q_Id":53592665,"Users Score":0,"Answer":"Python supports wide range of platforms, including arm-based. \nYou raspberry pi supports Linux distros, just install Python and go on.","Q_Score":0,"Tags":"python,machine-learning,raspberry-pi,artificial-intelligence,robotics","A_Id":53592746,"CreationDate":"2018-12-03T11:15:00.000","Title":"How to embed machine learning python codes in hardware platform like raspberry pi?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to implement machine learning on hardware platform s which can learning by itself Is there any way to by which machine learning on hardware works seamlessly?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":68,"Q_Id":53592665,"Users Score":0,"Answer":"First, you may want to be clear on hardware - there is wide range of hardware with various capabilities. For example raspberry by is considered a powerful hardware. EspEye and Arduio Nano 33 BLE considered low end platforms.\nIt also depends which ML solution you are deploying. I think the most widely deployed method is neural network. Generally, the work flow is to train the model on a PC or on Cloud using lots of data. It is done on PC due to large amount of resources needed to run back prop. The inference is much lighter which can be done on the edge devices.","Q_Score":0,"Tags":"python,machine-learning,raspberry-pi,artificial-intelligence,robotics","A_Id":67797110,"CreationDate":"2018-12-03T11:15:00.000","Title":"How to embed machine learning python codes in hardware platform like raspberry pi?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have few questions about programming a game (3d or 2d) with a python language and Unity game engine\nCan we make a game with python in Unity game engine?\nif yes how?\nplease share basic tutorials about this topic.","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":29060,"Q_Id":53618324,"Users Score":3,"Answer":"Currently there is not a way to directly use python within unity. You can use an interpreter that will call functions. This can only take you so far beyond the built in functions that unity currently used. \nSince you already know Python and probably learned Java in school or have at least seen it. C# is a very simple language to pick up that is very versatile so I would recommend learning it.\nOtherwise you can go Piglet or Arcade Game Engine. These engines are built for Python, Piglet does not need outside libraries \/ dependencies. You could also go with a Blueprint style coding method, both are available with unity and unreal.","Q_Score":3,"Tags":"python,python-3.x,unity3d","A_Id":53618520,"CreationDate":"2018-12-04T17:18:00.000","Title":"can we make a game with python in unity?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am programming in Python (in Sublime Text 3) and auto-complete feature works for 90% of the modules. Modules like os, sys, unittest...\nBut now I am trying to use modules like selenium and numpy and they don't have auto-complete feature.\nI am using Anaconda (conda) package distribution and I am using Anaconda ST3 Plugin. Also tried something called (a plugin) Selenium Snippets. None of that helps.\nPlease, any suggestions would be much appreciated.\nJuris.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3455,"Q_Id":53695279,"Users Score":0,"Answer":"OK. This is sorted by Trial and Error. Basically, I had to point my Sublime Text Anaconda Plugin to my Anaconda Package Managers path. I have edited the settings for Anaconda plugin and set the path like that:\n\"python_interpreter\": \"\/media\/Work\/anaconda3\/bin\/python\",\nAfter that, it picked up all the packages from Anaconda (Conda)\nThanks!","Q_Score":1,"Tags":"python,autocomplete,anaconda","A_Id":53696825,"CreationDate":"2018-12-09T18:16:00.000","Title":"Anaconda auto-complete for Python does not work","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Assuming the storage size is important: \nI have a long list of digits (0-9) that I want to write to a file. From a storage standpoint, would it be more efficient to use ASCII or UTF-8 as an encoding? \nIs it possible to create a smaller file using something else?","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":2642,"Q_Id":53695343,"Users Score":4,"Answer":"There is absolutely no difference in this case; UTF-8 is identical to ASCII in this character range.\nIf storage is an important consideration, maybe look into compression. A simple Huffman compression will use something like 3 bits per byte for this kind of data. If there are periodicity patterns, a modern compression algorithm can take it even further.","Q_Score":1,"Tags":"python,encoding","A_Id":53695378,"CreationDate":"2018-12-09T18:22:00.000","Title":"ASCII vs UTF-8?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have few python and fortran code developed for conducting scientific simulations for a research problem. 90% of the code can only be executed as a serial process as the solution procedure is implicit. Often, while running the code in my laptop, I have noticed that it occupies 1 full core of the CPU at 90-100% all the time during simulation and each simulation lasts for 10+ hours.\nBut now as I need to run the same code multiple times, it has becomes too slow to do it in my laptop and it limit smooth functioning for other activities during the period of the simulation. My code generally requires low memory (<1 GB) but high computational power. It requires no data transfer while running the simulation. Below are the two answers I seek:\n\nWhich ec2 instance type in Amazon Web Service (AWS) would be the best fit? \nIs it advisable to run, say 7 separate codes within an 8 vCPU machine or 7 codes in separate 2 vCPU multiple machines. I find the pricing for the latter in AWS to be economical. Also since high CPU rate is a requirement for my code, I have noticed that lower cores seems to offer more CPU speed.\n\nI would appreciate anyguidance in this matter.\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":288,"Q_Id":53695443,"Users Score":1,"Answer":"this answer might be a bit late for you (2 and half years on), but in case you're still interested!\nThe best fit for the machine depends on what you need for the work you are doing. It can be a tradeoff between cost and speed. For example, if you run an 8-core machine with 8 concurrent processes, it will be done 8 times faster than the same speed cpu core. You could also run your process across multiple virtual machines.\nWith today's AWS instances, you can scale all the way up to 36 cores on a single machine. But in your AWS account, you could run hundreds of cores concurrently. So developing a way to run the code across machines will help you as you need to scale out.\nAt my company, we run hundreds of fortran programs concurrently across 40 computers in AWS and have been using spot instances instead of on-demand instances to lower costs.","Q_Score":1,"Tags":"python,amazon-web-services,amazon-ec2,fortran,scientific-computing","A_Id":68184895,"CreationDate":"2018-12-09T18:35:00.000","Title":"Running multiple Python\/FORTRAN codes for scientific computations with Amazon EC2","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"HIHello everyone\nI have a Raspberry Pi that contain some data,\non another side, I have a server with a server, also there is a webpage connecting with the same server.\nwhat do I need? \n1- the Raspberry Pi must send its data to a server \n2-if the user set some data to the database by webpage the Raspberry Pi must get this data \n3-Raspberry Pi must listen to the database to know if there is an update or not.\nwhat the best way to do these points, is there any protocol for IoT can do these? \nI need any hint :) \nthank u for all.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":483,"Q_Id":53715817,"Users Score":0,"Answer":"Try connecting your RPi with your server through any means of local area connection, it could be a connection through a wifi network or using a lan cable or even through serial ports. If successful in this attempt then you can access disk drive folders inside the server. In the webpage running on server ,make it listen for certain values and write the status to a text file or an database. Then make RPi to continuously monitor those file for data updation and make it work according to it.","Q_Score":0,"Tags":"php,python,database,raspberry-pi,iot","A_Id":53722341,"CreationDate":"2018-12-11T00:40:00.000","Title":"how set\/get data from Raspberry Pi to server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My goal is to add 10M contacts to telegram.\nHow can we add contacts to telegram using telegram API? \nI have tried using telethon in which I batched 500 contacts in one request. However, telegram responded all such requests with all contacts in retry_contacts and none were imported.\nI have also found out a solution to convert the txt file of\n10M contacts to csv file and import them using an android app.\nBut this takes approx 10 mins for 10k contacts. So this won't be\na good idea for adding 10M contacts.\nAny other method for having this done is also welcomed.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":9550,"Q_Id":53730525,"Users Score":9,"Answer":"This is not possible. Telegram has deliberately set limits on the number of contacts you can add. Initially you can add about 5000 contacts and after that you can add about 100 more every day. This is because of security not decreasing their API load. If you could add 10M numbers, you could easily map @usernames to numbers which is against Telegram privacy policy.\nIn my experience, the best practical option is to add an array of 10 numbers each time using telethon's ImportContactsRequest, until you get locked. Then try 24 hours later again until you get locked again, and so on. This is the fastest solution and due to Telegram restrictions, if you only have 1 SIM card, it takes around 274 years to add 10M contacts.","Q_Score":6,"Tags":"python,automation,contacts,telegram,telethon","A_Id":53736422,"CreationDate":"2018-12-11T18:46:00.000","Title":"How to add Millions of contacts to telegram?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am making a telegram chatbot with python. I need to add a lot of options (around 185) in the keyboard for the users to select. For e.g. they press a button topic which leads to a \"message please select your topic\" then a new replyMarkupKeyboard with these 185 buttons.\nHaving trouble making a keyboard with so many buttons, I tried enabling the keyboard_resize=True but to no avail. After a certain number of buttons the keyboard becomes cluttered and the topics become squished. For e.g. when topics are few: Politics, Sports etc. when topics are more Pl, Sp, etc. The words on these buttons get squished.\nI want a slider or dropdown in my keyboard to accommodate these 185 buttons.\nPlease help","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":845,"Q_Id":53754564,"Users Score":0,"Answer":"Thanks @Ivan Vinogradov , I worked around that problem using an If condition on topics and by creating categories.Like if category=1 then show these 10 topics ...so on and so forth I was able to manage this part.","Q_Score":1,"Tags":"telegram-bot,python-telegram-bot","A_Id":53825696,"CreationDate":"2018-12-13T03:21:00.000","Title":"telegram Bot Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have some python scripts that require a good machine. Instead of starting instances manually on GCP or AWS, then making sure all python libraries are installed, can I do it through python for example so that the instance is on only for the time needed to run the script?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":255,"Q_Id":53767911,"Users Score":1,"Answer":"If you're in AWS you could just create Lambda functions for your scripts and set those on a timer via Lambda or use Cloudwatch to trigger them.","Q_Score":0,"Tags":"python,amazon-web-services,google-cloud-platform,cloud","A_Id":53767992,"CreationDate":"2018-12-13T18:16:00.000","Title":"How can I run a python script on Google Cloud project or AWS instances without manually firing them up?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Folks,\nI plan to use Python and various python packages like robot framework, appium, selenium etc for test automation. But as we all know, python and all the package versions keep revving. \nIf we pick a version of all of these to start with, and as these packages up rev, what is the recommended process for keeping the development environment up to date with the latest versions?\nAppreciate some guidance on this.\nThanks.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":349,"Q_Id":53781907,"Users Score":5,"Answer":"If you wrote the code with a given version of a library, updating that library in the future is more likely to break your code than make it run better unless you intend to make use of the new features. Most of the time, you are better off sticking with the version you used when you wrote the code unless you want to change the code to use a new toy. \nIn order to ensure that the proper versions of every library are installed when the program is loaded on a new machine, you need a requirements.txt document. Making one of these is easy. All you do is build your program inside a virtual environment (e.g. conda create -n newenv conda activate newenv) Only install libraries you need for your program and then, once all of your dependencies are installed, in your terminal, type pip freeze > requirements.txt. This will put all your dependencies and their version information in the text document. When you want to use the program on a new machine, simply incorporate pip install -r requirements.txt into the loading process for the program. \nIf you containerize it using something like docker, your requirements.txt dependencies can be installed automatically whenever the container is created. If you want to use a new library or library version, simply update it in your requirements.txt and boom, you are up to date.","Q_Score":4,"Tags":"python,pip,pypi","A_Id":53782145,"CreationDate":"2018-12-14T14:46:00.000","Title":"Managing Python and Python package versions for Test Automation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"i installed Raspbian on my Raspberry Pi and it has Python 3 IDLE to write code. What confuses me is, that if i execute \"python\" in the command of my Raspberry Pi, it says the Python version is 2.7?\nCan someone help?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":676,"Q_Id":53788686,"Users Score":2,"Answer":"As long as it won't cause you any issues, you can try running python3. If you have Python 2 and 3 installed, from my experience python usually runs Python 2, so I guess you'll have to be specific.","Q_Score":0,"Tags":"python,raspberry-pi,python-idle","A_Id":53788695,"CreationDate":"2018-12-15T01:00:00.000","Title":"Python 3 IDLE (Shell) but only Python 2.7 installed on Raspberry Pi?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a project that requires us to track whether a reply has been sent for an email. We send mails using Gmail API and its getting send successfully without any issues. But if some user has setup an auto response service and that service has a different subject the gmail treats it as a seperate thread.\nIn my backend I get specific threads from users and iterate to check if there is any entry present in the messages having header 'To' as the mail creator. \nIt works as it should but Iam not able to track emails outside the thread. Is there any solution to do this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":373,"Q_Id":53791507,"Users Score":0,"Answer":"By thread I'm assuming you mean \"E-mail\" thread and not \"processing thread\".\nI'm also assuming that you might be looking for the \"References\" or \"In-reply-to\" headers to identify the email threads, but in my opinion, if that information is not added by the auto-responder, then you should be looking for other headers like the Reply-to which theoretically should identify with the original address that you sent an email to, that combined with looking for the newest thread associated with that email you could make a list of potential associated threads. If that information is not present, you could only do the time difference approach and for example if the sent email was at 10:40 and the auto-responder replies at 10:41 then that might be a match, but if you send 1000 emails to different addresses in a very short amount of time then your life is a lot more difficult and I'm not sure it's even possible in that case.","Q_Score":0,"Tags":"python-3.x,gmail-api","A_Id":53792087,"CreationDate":"2018-12-15T10:30:00.000","Title":"Tracking Email replies","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"As the title says, I have an app hosted on Heroku that seems to have more than one instance running. This is a problem because I am trying to keep track of single letter posts on a GroupMe in order to see if they spell anything. I am using python and a global string variable that I can add the characters to. Since there is more than one instance, there is more than 1 global variable so sometimes the character gets added to one or the other which defeats the purpose of the program. Has anyone else run into this problem or found a fix to this? Thanks.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":106,"Q_Id":53799174,"Users Score":1,"Answer":"So after thinking about possible ways to fix it, I decided to try to keep my global variables inside a json file and then edit that each time. This worked as I believe that even if there were 2 version of the actual code running, they should both edit the same json file.","Q_Score":2,"Tags":"python,heroku,groupme","A_Id":53806183,"CreationDate":"2018-12-16T03:22:00.000","Title":"My Heroku app seems to be running more than 1 instance","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"If python 3 is stable and Centos 7 is a modern version, why not include it in the official repositories as well as python 2?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":81,"Q_Id":53836616,"Users Score":1,"Answer":"CentOS 7 ships with Python 2 as it is a critical part of the CentOS base system. Python 3 must be installed alongside Python 2 through the CentOS SCL so that default system tools continue to work properly.","Q_Score":1,"Tags":"python-3.x,centos7","A_Id":53836941,"CreationDate":"2018-12-18T15:48:00.000","Title":"Why Redhat does not include python 3 in centos 7?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to run my Python code in raspberry Pi 3 and I keep getting the error: ImportError: no module named playsound. I have already successfully installed playsound (using the command: pip install playsound).","AnswerCount":5,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":23474,"Q_Id":53851972,"Users Score":0,"Answer":"In my case, one module worked with pip3 install pygame but not playsound. I snooped through python files to see the difference between pygame and playsound. I found out that playsound was not in its folder: C:\\Users\\USER\\AppData\\Local\\Programs\\Python\\Python39\\Lib\\site-packages.\nSo I moved it to C:\\Users\\USER\\AppData\\Local\\Programs\\Python\\Python39\\Lib\\site-packages\\playsound-1.2.2.dist-info\nBut remember to put it back after compiling it so you can use the module. Somehow it worked for me.","Q_Score":0,"Tags":"python,raspberry-pi3,raspbian,importerror,python-playsound","A_Id":67811688,"CreationDate":"2018-12-19T13:10:00.000","Title":"ImportError: no module named playsound","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to run my Python code in raspberry Pi 3 and I keep getting the error: ImportError: no module named playsound. I have already successfully installed playsound (using the command: pip install playsound).","AnswerCount":5,"Available Count":4,"Score":0.1194272985,"is_accepted":false,"ViewCount":23474,"Q_Id":53851972,"Users Score":3,"Answer":"Just change from playsound import playsound to import playsound","Q_Score":0,"Tags":"python,raspberry-pi3,raspbian,importerror,python-playsound","A_Id":58259842,"CreationDate":"2018-12-19T13:10:00.000","Title":"ImportError: no module named playsound","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to run my Python code in raspberry Pi 3 and I keep getting the error: ImportError: no module named playsound. I have already successfully installed playsound (using the command: pip install playsound).","AnswerCount":5,"Available Count":4,"Score":0.0399786803,"is_accepted":false,"ViewCount":23474,"Q_Id":53851972,"Users Score":1,"Answer":"The best solution that worked for me is uninstalling playsound using pip uninstall playsound and then installing it again using pip install playsound.","Q_Score":0,"Tags":"python,raspberry-pi3,raspbian,importerror,python-playsound","A_Id":62380329,"CreationDate":"2018-12-19T13:10:00.000","Title":"ImportError: no module named playsound","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to run my Python code in raspberry Pi 3 and I keep getting the error: ImportError: no module named playsound. I have already successfully installed playsound (using the command: pip install playsound).","AnswerCount":5,"Available Count":4,"Score":-0.0399786803,"is_accepted":false,"ViewCount":23474,"Q_Id":53851972,"Users Score":-1,"Answer":"The problem according to the best of my knowledge, it is the environment, by default the raspberry pi is running python2 on the command terminal, and I guess you are running your program on thonny idle or the python3 idle, so what you are doing is your are using python2 environment to install playsound(Terminal) and then using the python3 environment to run your program.\nSo what I did is i used this command on the terminal\nsudo apt-get remove python2.7 --purge\nsudo apt-get install python3.5\npip3 install playsound\nand behold no module error.","Q_Score":0,"Tags":"python,raspberry-pi3,raspbian,importerror,python-playsound","A_Id":66258752,"CreationDate":"2018-12-19T13:10:00.000","Title":"ImportError: no module named playsound","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have always heared that compile time languages (Java, C++ etc) are statically typed and interpreted languages (PHP, Python etc) are dynamically typed, But the question is why they are, Why not a compile time language can be dynamically type and vice versa?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":69,"Q_Id":53858766,"Users Score":1,"Answer":"This depends strictly on the language e.g. Java has mixed mode where the code that runs less often is only interpreted. Code compilation can be expensive so if the compiled code is not executed many times after the compilation the effort spent compiling will not be worth it.","Q_Score":0,"Tags":"java,php,python,typed","A_Id":53858825,"CreationDate":"2018-12-19T20:33:00.000","Title":"Why dynamically type languages are interpreted and statically type languages are compile time language?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have always heared that compile time languages (Java, C++ etc) are statically typed and interpreted languages (PHP, Python etc) are dynamically typed, But the question is why they are, Why not a compile time language can be dynamically type and vice versa?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":69,"Q_Id":53858766,"Users Score":1,"Answer":"It's not really true. Java bytecodes can be interpreted, indeed they were only interpreted up until around JDK 1.1.5ish. JavaScript is often compiled.\nHowever, an interpreter for a dynamic language is really easy to write. Perhaps try it. Statically typed languages are a bit more difficult, so you may as well compile it anyway. On the other hand, to reasonably compile a dynamic language takes some effort.","Q_Score":0,"Tags":"java,php,python,typed","A_Id":53858794,"CreationDate":"2018-12-19T20:33:00.000","Title":"Why dynamically type languages are interpreted and statically type languages are compile time language?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a project for my Linear Algebra class. I am stuck with a small problem. I could not find any method for finding the row-echelon matrix form (not reduced) in Python (not MATLAB).\nCould someone help me out?\nThank you.\n(I use python3.x)","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":3252,"Q_Id":53875432,"Users Score":3,"Answer":"Bill M's answer is correct. When you find the LU decomposition the U matrix is a correct way of writing M in REF (note that REF is not unique so there are multiple possible ways to write it). To see why, remember that the LU decomposition finds P,L,U such that PLU = M. When L is full rank we can write this as U = (PL)-1M. So (PL)-1 defines the row operations that you have to preform on M to change it into U.","Q_Score":2,"Tags":"python,python-3.x,matrix","A_Id":53992065,"CreationDate":"2018-12-20T20:15:00.000","Title":"How to find row-echelon matrix form (not reduced) in Python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I 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. \nAfter 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\n\nPersonal Experience background:\n-I know how to code. Was a Electrical Engineering major, not a CS major.\n-I know how to pull in stock data for individual tickers into excel. \nFamiliar with using filtering and custom studies on ThinkOrSwim.\nApplied Context: \nFrom 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. \n\nHere's where I am having trouble figuring out what the next step is:\n-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. \n-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? \n\nI 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. \nI 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.\nI am aware that Quantopia and other web based Quant platforms are around. Are these my best bets for backtesting? Any thoughts on them? \n\nAm I making this too complicated? \nBacktesting 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. \n\nRandom 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.\n\nThank 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.\nTwitter:@b_gumm","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":603,"Q_Id":53878551,"Users Score":0,"Answer":"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). \nI 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.","Q_Score":0,"Tags":"python,excel,stocks,universe,back-testing","A_Id":53965459,"CreationDate":"2018-12-21T02:43:00.000","Title":"Backtesting a Universe of Stocks","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We need a cloud service to run automated tests written in Python on top of Behave BDD \/ Appium environment.\n1 - What are some good options in the market for cloud automated tests and reporting?\n2 - We used App Center with Xamarin.UITests before but I believe they support only Java Appium clients, is that correct?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":373,"Q_Id":53883778,"Users Score":2,"Answer":"We use Browserstack for Python+Appium automation, you can test on real devices or on emulators\/simulators.\nCurrently we are on App Automate - 1 parallel test (1 user) plan. This is testing on real Android and iOS devices (either manual or automated) and there is no limit on the number of testing minutes per month. It seems like a good option for now. \nSetup is pretty easy, you need to upload .apk or .ipa file to their server with REST command and response will be used for 'app' capability. For starting test you only need to provide username and access key, you use this as server URL when starting Webdriver.\nThey have around 40 Android devices and most of them are either Samsung or Google devices, for iOS they have all devices.\nReporting could be a bit better, although you can see text and Appium logs along with videos of recorded sessions, you will see each session on it's own in the dashboard, there is currently no option to see how whole test suite performed, so we use nose-html-reporting for test suite reports.\nYou can test against your dev\/internal environments, just need to download their binary file and run it with your access key and you can start testing against local env. \nCS replies pretty quick on queries.\nHope that helps, if you've any questions about it let me know.\nP.s. I haven't tried other cloud options like Sauce labs or Perfecto so can't say much about it.","Q_Score":2,"Tags":"appium,python-appium","A_Id":54037020,"CreationDate":"2018-12-21T11:11:00.000","Title":"Cloud testing services for Appium \/ Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to call a function from a python file that is located outside the django project directory from views.py. I have tried importing the python file but running the django server says \"no module named xxxx\".\nTree structure is given below.\n\n\n\u251c\u2500\u2500 auto_flash\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 __init__.py\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 test.py\n\u2514\u2500\u2500 fireflash\n \u251c\u2500\u2500 detection_reports\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 admin.py\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 admin.pyc\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 __init__.py\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 __init__.pyc\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 migrations\n \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 __init__.py\n \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 __init__.pyc\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 models.py\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 models.pyc\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 __pycache__\n \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 __init__.cpython-35.pyc\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 templates\n \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 detection_reports\n \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 home.html\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 tests.py\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 views.py\n \u2502\u00a0\u00a0 \u2514\u2500\u2500 views.pyc\n \u251c\u2500\u2500 fireflash\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 __init__.py\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 __init__.pyc\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 __pycache__\n \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 __init__.cpython-35.pyc\n \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 settings.cpython-35.pyc\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 settings.py\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 settings.pyc\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 ui_cgi.py\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 urls.py\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 urls.pyc\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 wsgi.py\n \u2502\u00a0\u00a0 \u2514\u2500\u2500 wsgi.pyc\n \u251c\u2500\u2500 __init__.py\n \u2514\u2500\u2500 manage.py \n\nProject name here is \"fireflash\" and there is an app in that project named \"detection_reports\". There is another directory named \"auto_flash\" that has same location as \"fireflash\". What I want to do is to import test.py file from \"auto_flash\" in detection_reports.views and call a function from views. Importing like this \"from auto_flash import test\" throws error \"no module named auto_flash\".","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2173,"Q_Id":53916918,"Users Score":0,"Answer":"I have tried all of the above mentioned solutions, but the cleaner solution was to append the path for auto_flash to syspath and the issue was resolved. Thanks to all of you for the efforts.","Q_Score":1,"Tags":"python,django,django-views","A_Id":53986048,"CreationDate":"2018-12-24T19:00:00.000","Title":"How to import python function from another file into django views","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to call a function from a python file that is located outside the django project directory from views.py. I have tried importing the python file but running the django server says \"no module named xxxx\".\nTree structure is given below.\n\n\n\u251c\u2500\u2500 auto_flash\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 __init__.py\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 test.py\n\u2514\u2500\u2500 fireflash\n \u251c\u2500\u2500 detection_reports\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 admin.py\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 admin.pyc\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 __init__.py\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 __init__.pyc\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 migrations\n \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 __init__.py\n \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 __init__.pyc\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 models.py\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 models.pyc\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 __pycache__\n \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 __init__.cpython-35.pyc\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 templates\n \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 detection_reports\n \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 home.html\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 tests.py\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 views.py\n \u2502\u00a0\u00a0 \u2514\u2500\u2500 views.pyc\n \u251c\u2500\u2500 fireflash\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 __init__.py\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 __init__.pyc\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 __pycache__\n \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 __init__.cpython-35.pyc\n \u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 settings.cpython-35.pyc\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 settings.py\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 settings.pyc\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 ui_cgi.py\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 urls.py\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 urls.pyc\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 wsgi.py\n \u2502\u00a0\u00a0 \u2514\u2500\u2500 wsgi.pyc\n \u251c\u2500\u2500 __init__.py\n \u2514\u2500\u2500 manage.py \n\nProject name here is \"fireflash\" and there is an app in that project named \"detection_reports\". There is another directory named \"auto_flash\" that has same location as \"fireflash\". What I want to do is to import test.py file from \"auto_flash\" in detection_reports.views and call a function from views. Importing like this \"from auto_flash import test\" throws error \"no module named auto_flash\".","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2173,"Q_Id":53916918,"Users Score":0,"Answer":"Move auto_flash to fireflash\nIn detection_reports add from auto_flash import test.py","Q_Score":1,"Tags":"python,django,django-views","A_Id":53935367,"CreationDate":"2018-12-24T19:00:00.000","Title":"How to import python function from another file into django views","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a python server application that I wish to put onto my server. I have tried to run the python scripts on my server, I moved the file with sftp and I installed the dependancies with pip. No luck, it doesn't use my modules even after I install them. It says the module I installed isn't a thing, when when I run pip again it says it is already there. I read about standalone executables a little, but I only found documentation on windows ones. I know Linux cannot run exe files, but is there something similar. \nAnother thing might be my unfamiliarity with pip. I use the terminal in py charm which automatically puts my pip modules into files. When I do that on my ubuntu machines there is no file created in my directory. (Feels like a problem to me)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":158,"Q_Id":53918501,"Users Score":0,"Answer":"So I don't want to leave this open in case anyone else see this and needs help. I had forgotten to install my modules, so I did that, and then to run my two programs I just use screen now to host different terminals for each program. It isn't very hard.","Q_Score":0,"Tags":"python,linux,ubuntu,server,executable","A_Id":54282962,"CreationDate":"2018-12-25T00:14:00.000","Title":"Making a python standalone Linux executable on windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"if someone find my telegram chat ID (instead of my phone number or username), what can do with that?\nis it dangerous?!\nis it a big deal that someone can find my ID? should I worry about it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3297,"Q_Id":53924548,"Users Score":2,"Answer":"If someone with a (user)bot wants to send you a message, they can do that via the userID only. But only if they have \"seen\" you. Seeing you is considering their client to receive a message from you, be it in a private message or group.\nBots can only send you a message if you have started it in a private chat, otherwise they can only send you a message in a group they share with you.\nSo there is no real risk of people knowing your ID.","Q_Score":2,"Tags":"telegram,telegram-bot,python-telegram-bot,telepot","A_Id":54479855,"CreationDate":"2018-12-25T18:02:00.000","Title":"what can be done by a telegram chat ID?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have looked around for this and not found any good answers. I Just pulled python from git and built it on Windows 10. The python.exe file works fine when in the build location but, if you copy or move the folder you built into you get the following error upon running python.exe:\n\nFatal Python error: Py_Initialize: unable to load the file system\n codec LookupError: no codec search functions registered: can't find\n encoding\nCurrent thread 0x000060c8 (most recent call first):\n .\\python Fatal Python error:\n Py_Initialize: unable to load the file system codec\n ModuleNotFoundError: No module named 'encodings'\nCurrent thread 0x00004f50 (most recent call first):\n\nThis is strange cause if you run python from the build directory\nD:\\Users\\brazg\\Documents\\GitHub\\cpython\\PCbuild\\amd64 it runs fine.\nI would like to know why python.exe doesn't run if the amd64 directory is moved out of PCbuild.\nAs a side note I cannot find any information for setting up the Python root folder after building from source.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":263,"Q_Id":53927434,"Users Score":0,"Answer":"This is an answer from the perspective of someone that hasn't built python from source before.\nTo answer my own question, what needs to be done after moving the Python binaries to a different location out of the cpython\\PCbuild is you need to copy the Lib directory from the pulled sources because the encodings directory is in cpython\\Lib.\nEven though you the build is in cpython\\PCbuild\\ it still reads from cpython\\Lib which makes sense but, I think should be made more clear in the official python documentation.\nIf you copy the amd64 directory to a new location you need to copy the cpython\\Lib directory into the amd64 directory. You can also delete all the .exp, .lib and .pdb files that were built with python from running build.bat. As they are all the compiler's linker and debug information.\nI wish it was made more clear that cpython\\PCbuild\\ read up to cpython\\Lib when run.","Q_Score":0,"Tags":"python,python-3.x,build,windows-10","A_Id":53934781,"CreationDate":"2018-12-26T04:32:00.000","Title":"No modules named 'encodings' if python 3 directory is moved after building from source code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created a chatbot using AWS lex and Lambda. Bot works as expected. I have store the slot data into sessionAttributes. The issue I am facing is when I communicate with bot from my website and if I open another tab of my site, it does't show the previous chat which happened in older tab(here both tabs are open).\nOn every new tab chat starts from start.\nRequirement is to continue from where it was left in previous tab.\nAm I missing any flow here ? I have gone though AWS doc but didn't get any clear picture to do the same. Any example of the same will help better.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":116,"Q_Id":53946681,"Users Score":0,"Answer":"You need to store the chat into some database of your own. On page load, you need to fetch the chat of current session or current user (based on your requirement).\n That way even if the user refreshes the page or open up a new tab, he will be able to see the chat he already had with the chatbot.","Q_Score":0,"Tags":"python,amazon-web-services,aws-lambda,chatbot,amazon-lex","A_Id":53955733,"CreationDate":"2018-12-27T14:32:00.000","Title":"maintain aws lex chat communication on all pages of website","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a project using GNU Radio and USRP radios (Ettus B205mini). I would like to vary the output power based on an incoming signal strength. For example, given a frequency (let's say 900MHz), output power should scale with the strength of a control tone on that frequency. Is this possible to do out-of-the-box or would I need to code a new block for it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":370,"Q_Id":53949090,"Users Score":0,"Answer":"Should be possible. You can convert signal to signal power with the \"complex to magnitude square block\"; then scale that to something useful (i.e. between 0 and 1) with the \"multiply const\" block, or use any other combination of arithmetic blocks to achieve the desired power \/ power curve.\nThen, you'd typically low-pass filter the result, and use it with a \"Multiply\" block to scale the complex numbers you feed into the \"USRP Sink\".","Q_Score":0,"Tags":"python,gnuradio,gnuradio-companion","A_Id":53950103,"CreationDate":"2018-12-27T18:03:00.000","Title":"GNU Radio: Varying output power based on incoming signal strength","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a folder with around several thousand RGB 8-bit-per-channel image files on my computer that are anywhere between 2000x2000 and 8000x8000 in resolution (so most of them are extremely large).\nI would like to store some small value, such as a hash, for each image so that I have a value to easily compare to in the future to see if any image files have changed. There are three primary requirements in the calculation of this value:\n\nThe calculation of this value needs to be fast\nThe result needs to be different if ANY part of the image file changes, even in the slightest amount, even if just one pixel changes. (The hash should not take filename into account).\nCollisions should basically never happen.\n\nThere are a lot of ways I could go about this, such as sha1, md5, etc, but the real goal here is speed, and really just any extremely quick way to identify if ANY change at all has been made to an image.\nHow would you achieve this in Python? Is there a particular hash algorithm you recommend for speed? Or can you devise a different way to achieve my three goals altogether?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":585,"Q_Id":54000349,"Users Score":1,"Answer":"The calculation of this value needs to be fast\nThe result needs to be different if ANY part of the image file changes, even in the slightest amount, even if just one pixel changes.\n (The hash should not take filename into account).\nCollisions should basically never happen.\n\n\n\nHash calculation (may differ according to the hashing algorithm) of large files take time, if it needs to be fast, try to choose an efficient hashing algorithm for your task. You can find information about how they compare to each other. But, before checking hash, you can optimize your algorithm by checking something else.\nIf you decided to use hashing, this is the case. The hash value will be changed even if a small part of image has changed.\nCollisions may be (very rare, but not never) happen. This is the nature of hash algorithms\n\nExample to 1st (optimizing algorithm), \n\nCheck file size.\nIf sizes are equal, check CRC\nIf CRCs are equal, then calculate and check hash. (both requires passing the file)\n\nOptionally, before checking hashes, you can partially calculate and compare hashes, instead of all the file.\nIf most of your files will be more likely different, then checking other things before calculating hash probably will be faster.\nBut if most of your files will be identical, then the steps before the hashing will just consume more time. Because you'll already have to calculate the hash for most of files.\nSo try to implement most efficient algorithm according to your context.","Q_Score":0,"Tags":"python,database,python-3.x,image,hash","A_Id":54000556,"CreationDate":"2019-01-02T01:44:00.000","Title":"Hashing 1000 Image Files Quick as Possible (2000x2000 plus resolution) (Python)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on my Raspberry Pi, that is handling some WS2812B RGB-LEDs. I can control the light and everything with the neopixel library and Python. So fine right now.\nI want this Python script running an infinite loop that only deals with light management. Dimming LEDs, changing color and lots more. But, I want to be able to get commands from other scripts. Let's say I want to type in a shell command that will change the color. In my infinite Python script (LED Handler), I will be able to recognize this command and change the color or the light mode softly to the desired color. \nOne idea is, to constantly look into a text file, if there is a new command. And my shell script is able to insert command lines into this text file.\nBut can you tell me, if there is a better solution of doing it?\nMany thanks in advance.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":140,"Q_Id":54031676,"Users Score":0,"Answer":"Another solution is to allow commands from a network connection. The script with the \"infinite loop\" will read input from a socket and perform the commands.","Q_Score":2,"Tags":"python","A_Id":54031710,"CreationDate":"2019-01-04T00:29:00.000","Title":"Running infinite loop and getting commands from \"outside\" (e.g. shell or other scripts)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on my Raspberry Pi, that is handling some WS2812B RGB-LEDs. I can control the light and everything with the neopixel library and Python. So fine right now.\nI want this Python script running an infinite loop that only deals with light management. Dimming LEDs, changing color and lots more. But, I want to be able to get commands from other scripts. Let's say I want to type in a shell command that will change the color. In my infinite Python script (LED Handler), I will be able to recognize this command and change the color or the light mode softly to the desired color. \nOne idea is, to constantly look into a text file, if there is a new command. And my shell script is able to insert command lines into this text file.\nBut can you tell me, if there is a better solution of doing it?\nMany thanks in advance.","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":140,"Q_Id":54031676,"Users Score":2,"Answer":"I suggest opening a port with your python script and make it receive commands from that port (network programming). Although this would make your project more complicated, it is a very robust implementation.","Q_Score":2,"Tags":"python","A_Id":54031712,"CreationDate":"2019-01-04T00:29:00.000","Title":"Running infinite loop and getting commands from \"outside\" (e.g. shell or other scripts)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am doing a sentiment analysis project about local people's attitudes toward the transportation service in Hong Kong. I used the Twitter API to collect the tweets. However, since my research target is the local people in Hong Kong, tweets posted from, for instance, travelers should be removed. Could anyone give me some hints about how to extract tweets posted from local people given a large volume of Twitter data? My idea now is to construct a dictionary which contains traveling-related words and use these words to filter the tweets. But it may seem not to work\nAny hints and insights are welcomed! Thank you!","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":42,"Q_Id":54058996,"Users Score":2,"Answer":"There are three main ways you can do this.\n\nLanguage. If the user is Tweeting in Cantonese - or another local language - there is less chance they are a traveller compared to, say, Russian.\nUser location. If a user has a location present in their profile, you can see if it is within Hong Kong.\nUser timezone. If the user's timezone is the same as HK's timezone, they may be a local.\n\nAll of this is very fuzzy.","Q_Score":0,"Tags":"python,twitter,web-crawler,sentiment-analysis,social-media","A_Id":54060976,"CreationDate":"2019-01-06T05:49:00.000","Title":"How to extract tweets posted only from local people?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am a Python developer. I wanted to create some online shopping stores which will be fully customized, Database will Mysql, Redis for caching, mail-gun for mailing, AWS hosting and Theme may be customized. I am confused in both platforms Magento and Shopify. Please Help Which have the best integration with python.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":201,"Q_Id":54103457,"Users Score":0,"Answer":"Yes Rehan is correct to go with the magento framework","Q_Score":0,"Tags":"python,magento,flask,e-commerce,shopify","A_Id":64007871,"CreationDate":"2019-01-09T04:54:00.000","Title":"Magento or Shopify which is best for integration with Python or which provide best APIs for Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"If I was creating a sparse file from scratch and I wanted to make it the size of n I would use bytestream.seek(n-1) to offset the pointer and then write a single null byte at the end. Much quicker than writing a bytestream of n length!\nHowever, if I've opened said file with open(\u2026,'ab'), seek() is no longer an option, as soon as I call write() the position resets to the end of the file, as stated in the documentation.\nIt seems the only option when using python's ammend is to write each individual null byte.\nIs there another way of appending null bytes to a pre-existing file efficiently and quickly?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":201,"Q_Id":54114131,"Users Score":1,"Answer":"It\u2019s true that append mode defeats seek, but part of the purpose of seek is to be more flexible than append mode. Open in update mode ('r+b') and you can seek to or past the end of the file. (You can seek to but not past the end in text mode.)","Q_Score":2,"Tags":"python,python-3.x,bytestream","A_Id":54130712,"CreationDate":"2019-01-09T16:09:00.000","Title":"Appending null bytes to file in python3 using sparse method?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there an interactive, imperative way to manipulate Webots simulations using Python, instead of using the contorller script? E.g. the way you can interact with OpenAI Gym. Thanks!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":104,"Q_Id":54118812,"Users Score":1,"Answer":"No, there is no such a thing available out of the box in Webots. However, it shouldn't be difficult to implement a set of Python commands that could be called from an interactive Python shell. Such commands would communicate with a slave Webots controller via some IPC (Inter Process Communication) to send commands to a running simulation.","Q_Score":1,"Tags":"python,webots","A_Id":54142508,"CreationDate":"2019-01-09T21:44:00.000","Title":"Interactive terminal for Python on Webots?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to always run a Python script in Windows. Every 5 minutes, it is to check if the script is running and if not, run it.\nIn linux, this can be done using flock and cron job. How can this be done in windows?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":80,"Q_Id":54120345,"Users Score":1,"Answer":"You can use the Task scheduler. Create a new basic task with python as the program and your script as the argument.","Q_Score":1,"Tags":"python,windows","A_Id":54120365,"CreationDate":"2019-01-10T00:18:00.000","Title":"Python cron script for windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'd like to make a wheel binary distribution, intstall it and then import it in python. My steps are\n\nI first create the wheel: python .\/my_package\/setup.py bdist_wheel\nI install the wheel: pip install .\/dist\/*.whl\nI try to import the package: python -c\"import my_package\"\n\nThis leads to the error:\nImportError: No module named 'my_package'\nAlso, when I do pip list, the my_package is listed.\nHowever, when I run which my_packge, nothing is shown.\nWhen I run pip install .\/my_package\/ everything works as expected. \nHow would I correctly build and install a wheel?\npython version 3.5\npip version 10.1\nwheel version 0.31.1\nUPDATE: \nWhen I look at the files inside my_package-1.0.0.dist-info, there is an unexpected entry in top_level.txt. It is the name of the folder where I ran \npython .\/my_package\/setup.py bdist_wheel in. I believe my setup.py is broken.\nUPDATE WITH REGARDS TO ACCEPTED ANSWER: \nI accepted the answer below. Yet, I think it is better to simply cd into the package directory. Changing to a different directory as suggested below leads to unexpected behavior when using the -d flag, i.e. the target directory where to save the wheel. This would be relative to the directory specified in the setup.py file.","AnswerCount":4,"Available Count":1,"Score":0.1488850336,"is_accepted":false,"ViewCount":2848,"Q_Id":54145873,"Users Score":3,"Answer":"I had the very same error, but it was due to my setup.py not specifying the entry \"packages=setuptools.find_packages()\".\nEverythings builds nicely without that but you can't import anything even though pip shows it to be installed.","Q_Score":4,"Tags":"python-3.x,pip,python-wheel","A_Id":60125827,"CreationDate":"2019-01-11T11:43:00.000","Title":"python install wheel leads to import error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"While looking at the code for the calculations of extraterrestrial radiation get_extra_radiation() and crosschecking it with literature, I noticed that for both methods 'asce' and 'spencer' the solarposition._calculate_simple_day_angle(doy) function is used. This function basically just calculates (2. * np.pi \/ 365.) * (doy- 1), which is correct for method='spencer'.\nBut I think for method='asce' it should just be (2. * np.pi * doy \/ 365.) - without \"- 1\" - as described on page 9 in \"J. A. Duffie and W. A. Beckman, \"Solar Engineering of Thermal Processes, 3rd Edition\" J. Wiley and Sons, New York (2006)\"","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":95,"Q_Id":54148787,"Users Score":1,"Answer":"I just happen to have this book in front of me, so I checked on page 9, and there is indeed a difference as noted w.r.t. the pvlib-python code. One formula uses n, the other uses n-1. This difference is probably not significant, but perhaps it should be fixed just so it is correct. An issue on github would be the best way to raise this.","Q_Score":0,"Tags":"python,pvlib,solar","A_Id":54153288,"CreationDate":"2019-01-11T14:47:00.000","Title":"Minor mistake in calculation of extraterrestrial radiation (method 'asce')?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have collected a large Twitter dataset (>150GB) that is stored in some text files. Currently I retrieve and manipulate the data using custom Python scripts, but I am wondering whether it would make sense to use a database technology to store and query this dataset, especially given its size. If anybody has experience handling twitter datasets of this size, please share your experiences, especially if you have any suggestions as to what database technology to use and how long the import might take. Thank you","AnswerCount":2,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":729,"Q_Id":54154891,"Users Score":-2,"Answer":"you can try using any NOSql DB. Mongo DB would be a good place to start","Q_Score":1,"Tags":"python,database,twitter","A_Id":54154924,"CreationDate":"2019-01-11T22:29:00.000","Title":"Storing large dataset of tweets: Text files vs Database","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"After I launch Locust without the web UI:\n$ locust -f locust_files\/my_locust_file.py --no-web -c 1000 -r 100\nis it possible to change the number of users or hatch rate programmatically during the execution?","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":1247,"Q_Id":54202932,"Users Score":1,"Answer":"No.. that is not possible.. Locust requires the number of virtual users and hatch rate to be defined at test startup.","Q_Score":1,"Tags":"python,locust","A_Id":54203228,"CreationDate":"2019-01-15T16:25:00.000","Title":"In Locust, can I modify the number of users and hatch rate after I start the test?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"After I launch Locust without the web UI:\n$ locust -f locust_files\/my_locust_file.py --no-web -c 1000 -r 100\nis it possible to change the number of users or hatch rate programmatically during the execution?","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":1247,"Q_Id":54202932,"Users Score":1,"Answer":"Warning: unsupported method\nStart locust in the usual way and investigate the calls made by the browser to the endpoints exposed by locust.\nE.g. the call to update the user count is a simple POST to the \/swarm endpoint with the desired locust count and hatch rate:\ncurl \"http:\/\/localhost:8089\/swarm\" -X POST -H \"Content-Type: application\/x-www-form-urlencoded\" --data \"locust_count=10&hatch_rate=1\"","Q_Score":1,"Tags":"python,locust","A_Id":54782803,"CreationDate":"2019-01-15T16:25:00.000","Title":"In Locust, can I modify the number of users and hatch rate after I start the test?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"After I launch Locust without the web UI:\n$ locust -f locust_files\/my_locust_file.py --no-web -c 1000 -r 100\nis it possible to change the number of users or hatch rate programmatically during the execution?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1247,"Q_Id":54202932,"Users Score":0,"Answer":"1) If we want to increase the number of users during test:\nRun the same test in parallel with additional number of users\n2) If we want to decrease the number of users during test:\na) Run the second test with required number of users \nb) At the same time stop the first test\nBoth options can be automated with python or even bash scripts.\nDirty hack, but I think this will result desirable effect completely.","Q_Score":1,"Tags":"python,locust","A_Id":59071475,"CreationDate":"2019-01-15T16:25:00.000","Title":"In Locust, can I modify the number of users and hatch rate after I start the test?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We are developing an deep learning application on AWS. The automation of model training is quite challenging. The first step is to prepare the data for training which involves generating a huge 3D numpy array (> 100GB) from hundreds of thousands of small 2D numpy arrays. The small numpy arrays are saved in S3 bucket as small files. After the conversion, the big numpy array will saved to another S3 bucket. The training script will pick up the big 3D numpy array before the training. Since lambda function has a memory limit so we will have to launch an EC2 instance manually. \nI wonder what is the best practice to launch a EC2 instance from external and run the python script on the instance to do the data loading and transformation? \nThe whole workflow will probably be automated using AWS step function.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":158,"Q_Id":54260826,"Users Score":0,"Answer":"You can use a Configuration set in a Cloud formation template to define steps where you can perform copies or run scripts or commands upon start up of your EC2 resource. You can even run it transiently so that it shut itself down after all operations are completed.\nYou can then use a script or Lambda function to execute the Cloudformation Stack","Q_Score":1,"Tags":"python,amazon-web-services,numpy,amazon-s3","A_Id":54261008,"CreationDate":"2019-01-18T20:13:00.000","Title":"How to launch a EC2 instance and run a task on-demand","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"We are developing an deep learning application on AWS. The automation of model training is quite challenging. The first step is to prepare the data for training which involves generating a huge 3D numpy array (> 100GB) from hundreds of thousands of small 2D numpy arrays. The small numpy arrays are saved in S3 bucket as small files. After the conversion, the big numpy array will saved to another S3 bucket. The training script will pick up the big 3D numpy array before the training. Since lambda function has a memory limit so we will have to launch an EC2 instance manually. \nI wonder what is the best practice to launch a EC2 instance from external and run the python script on the instance to do the data loading and transformation? \nThe whole workflow will probably be automated using AWS step function.","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":158,"Q_Id":54260826,"Users Score":1,"Answer":"I would go with the most simple solution as this is not that complicated task (from the architectural perspective).\nConfigure S3 event for a bucket, the one where you are storing the new big 3D array, to trigger lambda function once the object has been put into the bucket (you can be more granular and trigger it based on prefix if you are storing all\/different data in the same bucket).\nInside of that lambda function, you simply launch new EC2 instance and pass user data script to it that will download necessary files and run the task (this can be done using boto3 for Python).\nUsing CloudFormation in this case would be overkill (my opinion).","Q_Score":1,"Tags":"python,amazon-web-services,numpy,amazon-s3","A_Id":54265569,"CreationDate":"2019-01-18T20:13:00.000","Title":"How to launch a EC2 instance and run a task on-demand","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"We are developing an deep learning application on AWS. The automation of model training is quite challenging. The first step is to prepare the data for training which involves generating a huge 3D numpy array (> 100GB) from hundreds of thousands of small 2D numpy arrays. The small numpy arrays are saved in S3 bucket as small files. After the conversion, the big numpy array will saved to another S3 bucket. The training script will pick up the big 3D numpy array before the training. Since lambda function has a memory limit so we will have to launch an EC2 instance manually. \nI wonder what is the best practice to launch a EC2 instance from external and run the python script on the instance to do the data loading and transformation? \nThe whole workflow will probably be automated using AWS step function.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":158,"Q_Id":54260826,"Users Score":0,"Answer":"did you consider using Amazon SageMaker? It's easy to configure repeatable training jobs. I'd love to hear your feedback and answer any questions.","Q_Score":1,"Tags":"python,amazon-web-services,numpy,amazon-s3","A_Id":54268333,"CreationDate":"2019-01-18T20:13:00.000","Title":"How to launch a EC2 instance and run a task on-demand","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"This has been asked several ways. No helpful answers found. I'm running Windows, but final build will run on Linux. \nI am creating an RFID reader gate system. I have 2 separate python programs.\nProgram 1 constantly monitors the reader which is connected via serial port (COM27). When the reader reads a badge, looks in database for user, gate opens, records data, closes.\nProgram 2 adds new people to a database. It only reads from the serial port when a new card is being added. (need to scan the card to get the number) for database) \nObviously, program 2 tries to open serial port and fails. Program 1 already has it open.\nI've tried creating a program 3 which handles serial communication, but importing it into the other 2 programs creates separate instances, so same issue. \nHow can I create one instance of the program and have it send the read info to both programs?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":302,"Q_Id":54285516,"Users Score":0,"Answer":"the situation is very strange, but, I think, maybe you can't change your software architecture.\nThe only way that I think could resolve your program is to write a daemon that grabs the serial port and offer 2 files or 2 sockets or something else for each python instance.\nI could do it using c++ but it is not mandatory.","Q_Score":0,"Tags":"linux,python-3.x,windows,serial-port","A_Id":54287126,"CreationDate":"2019-01-21T07:55:00.000","Title":"Reading One Serial Port from With Two Programs : Python 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm attempting to create a back end framework to interact with hardware over a serial connection. I need to be able to specify exactly how these hardware modules will interact without recompilation and running on a system with limited resources.\nI already have the cpp code that is being re-used that interacts with the hardware and has the broad functionality to send messages to the devices. \nRun-time impact is a serious consideration and it is running on a very limited arch distro that we don't want to change too much for hardware reasons.\nIt would make the most sense to me to interface with a scripting language that can be easily generated to have a set of references to the cpp base that can be loaded on command. (Sort of like a plugin system)\nPython - is a really good option but I have almost no experience working with embedded python, I have looked into it and I guess where I might be confused is how the interpreted script would link to functionality in the original program without something like pybind11 and embedded python both working together. Binder certainly has a appeal. No Boost please - maybe a little.\nLUA - is a robust option that is well tested but a little more difficult to generate on command. LuaBridge also has the functionality that I desire. Biggest concern is run time impact but I'm not an expert of course.\nJust make the whole thing in cpp and load libraries like a regular person - solid option but likely the most difficult to generate and run syntax checks on easily.\nMake the entire thing in a scripting language and get rid of the overhead of a compiler - I mean technically this is a option\nThese of course aren't all of the options but this is by far out of my area of expertise and I think it would be beneficial to discuss.\nI would really like to know what I should spend my time researching. I have spent far too much time already looking into pybind and I find myself not being able to sleep easy at night.\nIdeally this workflow would run somewhat like this:\nOn the main Controller :\n\nInterface program is run (cpp)\nInterface program does diagnostics and checks module status (already done)\nInterface checks for run script to execute module functionality\n\nThe Script :\n\nGenerated from some source\nRuns tests to verify generation does not have syntactical mistakes\nGets moved into a folder where the Interface program can grab it (In a \"totally\" safe way) I'm kidding I know the issues with that setup but we aren't considering it at this moment\n\nThat was super long and I'm sorry I'm just very lost and out of my comfort zone.\nYeah I'm sorry I didn't clarify why generated code was important. We built a very simple top level gui to interact with the hardware and that needs to be translated into a script to interact with the main interface for the controller.\nAnother option I came up with last night:\nWrite a very simple custom scripting langauge that I can parse on the cpp side and link that way","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":106,"Q_Id":54285876,"Users Score":0,"Answer":"If you are generating a script, you can probably simplify things to a simple byte code that gets interpreted. Then you don't have to mess with parsing or syntax validation. Each \"instruction\" can be a simple opcode followed by zero or more operands, where each operand will be an integer, float or string (and any other primitive data types that your hardware supports\/needs). You can use something like msgpack for encoding and decoding instructions compactly. \nIf that model works, you can gradually add tools on the developer side, such as a minimal assembler, or even a script interpreter that generates the byte code and thus avoids any complexity within your constrained hardware environment.","Q_Score":1,"Tags":"python,c++,c,lua","A_Id":54352053,"CreationDate":"2019-01-21T08:25:00.000","Title":"What is a good way to generate code to interface with a running cpp application that doesn't require a recompile?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need a simple blockchain in python to be used like bitcoin cryptocurrency but also to be mined with cryptography based algorithms.\nI have searched on GitHub but want to make my own.\nMy simple blockchain app that runs in comand line.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":481,"Q_Id":54290362,"Users Score":1,"Answer":"You can create a list or json in python which contain hash of this block, data you want to store,time stamp,the hash of last block.\nCreate first block with a random last block hash.Now you can create block one by one with data you want to store in block(coins? contract? ...), calculate the hash of this block, to become a chain.\nYou can change your algorithm which create your hash,that will depend how to mine and you can setup some requirements of hash result to limit mining speed.Coins which send to miner can be written into data as public data. \nA P2P network should be setup to enable more people to join in.","Q_Score":1,"Tags":"python-3.x","A_Id":54290977,"CreationDate":"2019-01-21T12:48:00.000","Title":"How to write a simple blockchain in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"We 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.\nRight 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. \nThe 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? \nI 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.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":63,"Q_Id":54299206,"Users Score":0,"Answer":"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.","Q_Score":0,"Tags":"python,html,csv,email","A_Id":54312283,"CreationDate":"2019-01-21T23:31:00.000","Title":"Is it possible to extract an SSRS report embedded in the body of an email and export to csv?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an running with serverless framework and python. I implemented a authentication function and registered it in the serverless.yaml. For testing, I just configured for one lambda function to be called after the authentication function. The authentication function gets called without any error, but the lambda function resolves in a 500 Internal Server Error\nI tried the serverless docs, but a lot of examples regarding my issue are not written in python, so its not helping me\nexpected result: no error when calling lambda function\noutput: 500 Internal Server Error","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":64,"Q_Id":54312422,"Users Score":0,"Answer":"Sorry for not providing any code, but I actually found the solution. I did not generate any policy for the api gateway :D","Q_Score":0,"Tags":"python,amazon-web-services,serverless","A_Id":54401828,"CreationDate":"2019-01-22T16:21:00.000","Title":"Python: Serverless Authentication working, but lambda not getting invoked","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a .python-version file, and when I create a Python repo with github and specify that it should have a .gitignore, it adds the .python-version file to it. It seems to me that that file should NOT be ignored since other people running the code on different machines would want to know what version of Python they need.\nSo why is it .gitignored?","AnswerCount":5,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":8617,"Q_Id":54315206,"Users Score":17,"Answer":"The reason why .python-version should be gitignored is because its version is too specific. Tiny versions of Python (e.g. 2.7.1 vs 2.7.2) are generally compatible with each other, so you don't want to lock down to a specific tiny version. Furthermore, many Python apps or libraries should work with a range of Python versions, not just a specific one. Using .python-version indicates that you want other developers to use an exact, specific Python version, which is usually not a good idea.\nIf you want to indicate the minimum Python version needed, or otherwise a version range, then I believe documenting that in a README is a more appropriate solution.","Q_Score":31,"Tags":"python,github,gitignore,pyenv","A_Id":54368544,"CreationDate":"2019-01-22T19:31:00.000","Title":"Should we gitignore the .python-version file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a .python-version file, and when I create a Python repo with github and specify that it should have a .gitignore, it adds the .python-version file to it. It seems to me that that file should NOT be ignored since other people running the code on different machines would want to know what version of Python they need.\nSo why is it .gitignored?","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":8617,"Q_Id":54315206,"Users Score":1,"Answer":"Old post but still relevant.\nMy answer would be \"it depends\".\nThe name of a virtual env can also be used in .python-version, if it is managed with the help of the virtualenv plugin of pyenv. This makes this file pretty useless it the project is managed on a public Git repo and you can exclude it (but not to do is harmless as told in other answers).\nBut (and I am in this situation) if you manage the project on a private repo and share virtual envs, it can make sense to not exclude it from Git. This allows you to work with a different environment (including the Python version) on an experimental branch of the project. Of course, it would have been far cleaner to fork or clone the original project and experiment with the new env in the copy, but sometimes it easier to just create a new branch.\nAt the end of the day, IMHO there is no universal answer to the question, and it depends on your workflow.","Q_Score":31,"Tags":"python,github,gitignore,pyenv","A_Id":63808471,"CreationDate":"2019-01-22T19:31:00.000","Title":"Should we gitignore the .python-version file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a .python-version file, and when I create a Python repo with github and specify that it should have a .gitignore, it adds the .python-version file to it. It seems to me that that file should NOT be ignored since other people running the code on different machines would want to know what version of Python they need.\nSo why is it .gitignored?","AnswerCount":5,"Available Count":3,"Score":0.1586485043,"is_accepted":false,"ViewCount":8617,"Q_Id":54315206,"Users Score":4,"Answer":"It can also be a bit problematic when using python virtual environments, as people may want to use virtual environment names different than 3.7.2\/envs\/myvenv.","Q_Score":31,"Tags":"python,github,gitignore,pyenv","A_Id":54476106,"CreationDate":"2019-01-22T19:31:00.000","Title":"Should we gitignore the .python-version file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have just started myself with AWS cloud automations and have been using python boto3 for automations. I find boto3 is convenient for me becoz im not good with using AWS CLI commands using inside shell script for automations. My question is for AWS cloud automation, is boto3 superior to AWS CLI commands ? or whats is the advantage that python boto3 i having over AWS CLI commands or vice versa ?","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":1641,"Q_Id":54338549,"Users Score":3,"Answer":"If you can use boto3, then that is the far-superior choice. It gives you much more ability to supplement the AWS API calls with additional logic, such as filtering results with. It is also easier to chain API calls, such as making one call for a list of resources, then making follow-up calls to describe each resources in detail.\nThe AWS CLI is very convenient for one-off commands or simple automation, but things get tricky when using --filter and --query commands.","Q_Score":1,"Tags":"python,amazon-web-services,boto3,aws-cli","A_Id":54340510,"CreationDate":"2019-01-24T02:29:00.000","Title":"Advantage of AWS SDK boto3 over AWS CLI commands","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a sparse large matrix (linear dimension of 2*10^6) for which I want to calculate its trace.\nCalculating it brute force takes 16 seconds to access each diagonal element (hence I could do it in a YEAR!). \nI was thinking of saving it to the disk using scipy.io.mmwrite and reading it with a c++ code which should be much faster. However I cannot find any package that could help me do that.\nAny suggestions would be much appreciated!\nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":476,"Q_Id":54379162,"Users Score":0,"Answer":"The solution was as simple as: np.array(Mat.diagonal()).sum()\nThanks @hpaulj !","Q_Score":1,"Tags":"python,c++,scipy","A_Id":54395217,"CreationDate":"2019-01-26T14:10:00.000","Title":"Calculating the trace of a large sparse matrix","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a question regarding python modules. \nFor example, I have a script which uses netaddr\/paramiko module and now I want to start the script on another linux os where I have no root access. Pip is not installed and the user has no homedir. Virtuelenv is no option. \nSo is there a possibility\/way to 'make' python modules 'portable' and add it to a folder where I can load it in my script??","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":159,"Q_Id":54383381,"Users Score":0,"Answer":"You could use pip install --no-install to list the dependencies of the library you need, then copy the modules \/ packages of all of these libs in your project directory, for example in an \/ext subdirectory.","Q_Score":0,"Tags":"python","A_Id":54383505,"CreationDate":"2019-01-26T22:26:00.000","Title":"\"Standalone\" or \"Portable\" python modules","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can i use paramiko after it give me this error \"paramiko\\kex_ecdh_nist.py:39: CryptographyDeprecationWarning: encode_point has been deprecated on EllipticCurvePublicNumbers and will be removed in a future version. Please use EllipticCurvePublicKey.public_bytes to obtain both compressed and unco\"","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":288,"Q_Id":54385866,"Users Score":0,"Answer":"I had to disable gathering_facts to get past the warning. For some reason Ansible was getting stuck gathering facts.\nAfter disabling gathering facts, I still get this warning, but Ansible is able to continue execution.\nyaml file \ngather_facts: no","Q_Score":2,"Tags":"python-3.x","A_Id":56402605,"CreationDate":"2019-01-27T07:09:00.000","Title":"How can i use paramiko after it give me this error encode_point has been deprecated on EllipticCurvePublicNumbers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way I get can the following disk statistics in Python without using PSUtil?\n\nTotal disk space\nUsed disk space\nFree disk space\n\nAll the examples I have found seem to use PSUtil which I am unable to use for this application.\nMy 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.\nPlease note I am using Python 2.7.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":6715,"Q_Id":54458308,"Users Score":1,"Answer":"You can do this with the os.statvfs function.","Q_Score":0,"Tags":"python,python-2.7,raspberry-pi","A_Id":54458486,"CreationDate":"2019-01-31T10:19:00.000","Title":"How to get disk space total, used and free using Python 2.7 without PSUtil","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have successfully installed flask_bcrypt package using anaconda pip. But I am having a weird problem when I try to import it .Using windows cmd it works well but it fails when I try to do it through anaconda prompt command, jupyter or Spyder ? I tried to restart them and run the command but still having the same problem.Using either jupyter notebook it throws an import error 'cannot import name '_bcrypt'\nbcrypt is required to use Flask-Bcrypt\nImportError Traceback (most recent call last)\n in ()\n----> 1 from flask_bcrypt import Bcrypt\n~\\Anaconda3\\lib\\site-packages\\flask_bcrypt.py in ()\n 25 except ImportError as e:\n 26 print('bcrypt is required to use Flask-Bcrypt')\n---> 27 raise e\n 28 \n 29 from sys import version_info\n~\\Anaconda3\\lib\\site-packages\\flask_bcrypt.py in ()\n 22 \n 23 try:\n---> 24 import bcrypt\n 25 except ImportError as e:\n 26 print('bcrypt is required to use Flask-Bcrypt')\nC:\\python\\Lib\\site-packages\\bcrypt__init__.py in ()\n 23 import six\n 24 \n---> 25 from . import _bcrypt\n 26 from .about import (\n 27 author, copyright, email, license, summary, title,\nImportError: cannot import name '_bcrypt'","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":687,"Q_Id":54540020,"Users Score":0,"Answer":"Have you installed bcrypt? Note flask-bcrypt!= bcrypt.","Q_Score":0,"Tags":"python,bcrypt","A_Id":54544870,"CreationDate":"2019-02-05T17:31:00.000","Title":"import bcrypt fails on anaconda cmd and throws an error \"cannot import _bcrpyt\" but works on windows cmd?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"While running the command pybot --version\nI'm getting the error \n\nfrom robot import run_cli ImportError: No module named robot\n\nI have already installed robotframework 3.0 with python after downloading the module with its setup.py file.\nI tried installing and reinstalling it multiple times.\nAlso I have verified the environment variables for the same which also seems to be inline with what I have installed.\nI checked in the site-packages also where I am able to see robotframework 3.0 present in them.\nI checked in the \/usr\/local\/bin as well as \/home\/.local\/bin folder I can see both robot and pybot available. But for running the command robot --version also it is showing the same error.\nI really don't know what is missing.\nMy Environment:\n\nUbuntu 16.04\npython 2.76\nrobotframework 3.0\n\nThanks in Advance!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3544,"Q_Id":54540608,"Users Score":0,"Answer":"I have little experience on installing the ROBOT Framework in linux machine. But just check whether you have done the following:\n\nHow did you install ROBOT Framework? Is it by pip command or with the downloaded source file? Have you tried with pip command if any?\nSet python path in your environment path\/variables. Example in windows, C:\\Python27\\\nSet python scripts folder in your environment path\/variables. Example in windows C:\\Python27\\Scripts\n\nLast, maybe you can share the output of your 'pip list' command? So, just want to see what are the modules\/packages that you have installed.","Q_Score":0,"Tags":"python,robotframework","A_Id":54610193,"CreationDate":"2019-02-05T18:13:00.000","Title":"Getting the error \"from robot import run_cli ImportError: No module named robot\" even when robotframework was installed in the system using python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is a beginner question but I am using Atom and when I create classes in one file and then import those classes using import file_containing_classes to use them in another file it only sees one of the classes? Does it have something to do with __pycache__. Even after I run the file save the file, the python script that imports the file with classes doesn't recognize it.\nSuggestions?\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":175,"Q_Id":54562635,"Users Score":0,"Answer":"I think the issue has something to do with the fact I have hydrogen installed, once I ran the code like a hydrogen notebook it seems to have worked.","Q_Score":0,"Tags":"python,atom-editor","A_Id":54564044,"CreationDate":"2019-02-06T21:12:00.000","Title":"Atom doesn't recognize classes imported from another file -- python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm writing code (Python 3) that collects data on a small IOT device and uploads it to a database on AWS. Currently the data is sent by parsing it into a json string and sending it via post request. There can be quite a lot of data at times, and I'm wondering if I can send it in compressed form using a post request.\nWhat I don't want to do is take the data, compress it to a file, then read that file's raw data into a string, and place that string in the JSON. It would be a waste to save a file and immediately read from it.\nIs there a way to compress data directly into a string of raw data, and send the compressed string as opposed to compressing into a file and reading it?\nI need a lossless compression format, hopefully something that's not too resource intensive to compress\/decompress. A .npy compression would be especially nice.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":528,"Q_Id":54582085,"Users Score":1,"Answer":"You seem to have binary data since you mention npy.\nJust send the binary data in the POST body.\nIf you need to compress signals then that is a different problem.\nMost measurements are not very compressible losslessly. \nYou might need to lower the precision of your floats or do some signal processing on device like low pass filtering noise, bandpass limit, delta compression.\nFor good results there are powerful lossy quantization algorithms like mp3 is using. But those are complex to understand and get right.","Q_Score":0,"Tags":"python,post,upload,binary-data,http-compression","A_Id":54584614,"CreationDate":"2019-02-07T20:52:00.000","Title":"Compressing data to string for json post without saving files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm writing code (Python 3) that collects data on a small IOT device and uploads it to a database on AWS. Currently the data is sent by parsing it into a json string and sending it via post request. There can be quite a lot of data at times, and I'm wondering if I can send it in compressed form using a post request.\nWhat I don't want to do is take the data, compress it to a file, then read that file's raw data into a string, and place that string in the JSON. It would be a waste to save a file and immediately read from it.\nIs there a way to compress data directly into a string of raw data, and send the compressed string as opposed to compressing into a file and reading it?\nI need a lossless compression format, hopefully something that's not too resource intensive to compress\/decompress. A .npy compression would be especially nice.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":528,"Q_Id":54582085,"Users Score":0,"Answer":"Your not going to POST anything if your device is connecting via MQTT to AWS IoT core I assume? That's normally a lighter weight setup then HTTP and MQTT is preferred in real IoT dev. The best way to handle these things unless you want to program the compression algorithm on the device, is to send your data through AWS IoT Core and connect a Lambda action to that incoming message. Then program the Lambda to do any file manipulation or compression before dispatching the info to DynomoDB or S3 directly from Lambda.","Q_Score":0,"Tags":"python,post,upload,binary-data,http-compression","A_Id":54611972,"CreationDate":"2019-02-07T20:52:00.000","Title":"Compressing data to string for json post without saving files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a script that gathers data from an API, and running this manually on my local machine I can save the data to a CSV or SQLite .db file.\nIf I put this on AWS lambda how can I store and retrieve data?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":6322,"Q_Id":54602932,"Users Score":0,"Answer":"with aws lambda you can use database like dynamo db which is not sql database and from there you can download csv file.\nwith lambda to dynamo bd integration is so easy lambda is serverless and dynamo db is nosql database.\nso you can save data into dynamo db also you can use RDS(Mysql) and use man other service but best way will be dynamo db.","Q_Score":2,"Tags":"python,amazon-web-services,sqlite,aws-lambda","A_Id":54603114,"CreationDate":"2019-02-09T03:39:00.000","Title":"Using AWS Lambda to run Python script, how can I save data?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a script that gathers data from an API, and running this manually on my local machine I can save the data to a CSV or SQLite .db file.\nIf I put this on AWS lambda how can I store and retrieve data?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":6322,"Q_Id":54602932,"Users Score":0,"Answer":"It really depends on what you want to do with the information afterwards.\nIf you want to keep it in a file, then simply copy it to Amazon S3. It can store as much data as you like.\nIf you intend to query the information, you might choose to put it into a database instead. There are a number of different database options available, depending on your needs.","Q_Score":2,"Tags":"python,amazon-web-services,sqlite,aws-lambda","A_Id":54603135,"CreationDate":"2019-02-09T03:39:00.000","Title":"Using AWS Lambda to run Python script, how can I save data?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am in the process of converting my python code from 2.7 to 3 using 2to3. It seems to convert as expected, except that my code always starts with the line #!\/usr\/bin\/python which I expected to change to #!\/usr\/bin\/python3 but it doesn't. Have I missed something? Is there a way to get that to happen?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":170,"Q_Id":54620359,"Users Score":2,"Answer":"#!\/usr\/bin\/python is not a python version-dependent statement, or even python at all. It essentially instructs a shell to execute the script (file) using the python executable (program) located at \/usr\/bin.\nThe intent behind 2to3 it get you along the path of converting your code to python 3, frequently doing all the work for you. It doesn't address issues outside the python code.\nIt's entirely possible for \/usr\/bin\/python to be python 3. The #! line exists let a shell execute a script using what's typically a systems default python.","Q_Score":1,"Tags":"python,python-2to3","A_Id":54622854,"CreationDate":"2019-02-10T19:52:00.000","Title":"Python 2to3 does not change #!\/usr\/bin\/python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an angularjs and a python project. The angularjs for the frontend and the python part is for the trainings made for face recognition. I wanted to know if there is a way that my angular can communicate with python and if it can, how to use the functionalities of python project in the angular.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":133,"Q_Id":54635555,"Users Score":0,"Answer":"Create an API in python console application \ncall http get put etc from angular .","Q_Score":0,"Tags":"python,angularjs","A_Id":54635610,"CreationDate":"2019-02-11T17:01:00.000","Title":"How to create communication between python(not web) and angularjs","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a python script that constantly runs in the background and writes it's output to a file, I have initialized it using Python.h class in c++.\nI want to read from the file when the user make an action, therefore i need to somehow pause or stop the python script.\nI would like to know if there is a way of sending c++ pointers to the python function and stopping the script by changing the object in the c++ code.\nOr maybe force the script to stop.\nThanks, Ori.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":270,"Q_Id":54655895,"Users Score":0,"Answer":"You can force the script to stop using this line of code\nsystem(\"pkill -f name-of-the-python-script\"); in the c++ program.\nYou can also use the c++ program to write in another file and check it in every iteration in the python script. If\nit's empty continue, otherwise: sys.exit() but don't forget to import sys","Q_Score":0,"Tags":"python,c++","A_Id":54656257,"CreationDate":"2019-02-12T17:49:00.000","Title":"How to stop\/pause an python script embedded in c++","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a project where one client needs to take several snapshots from a camera (i.e. it's actually taking a short-duration video, hence a stream of frames), then send all images to a server which then performs some processing on these images and returns a result to the client.\nClient and server are all running Python3 code.\nThe critical part is the image sending one.\nSome background first, images are *640*480 jpeg* files. JPEG was chosen as a default choice, but lower quality encoding can be selected as well. They are captured in sequence by a camera. We have thus approximately ~600 frames to send. Frame size is around 110KiB.\nThe client consists of a Raspberry Pi 3 model B+. It sends the frames via wifi to a 5c server. Server and client both reside in the same LAN for the prototype version. But future deployments might be different, both in term of connectivity medium (wired or wireless) and area (LAN or metro). \nI've implemented several solutions for this:\n\nUsing Python sockets on the server and the client: I'm either sending one frame directly after one frame capture, or I'm sending all images in sequence after the whole stream capture is done.\nUsing Gstreamer: I'm launching a GStreamer endpoint on my client and directly send the frames to the server as I stream. I'm capturing the stream on the server side with OpenCV compiled with GStreamer support, then save them to the disk.\n\nNow, the issue I'm facing is that even if both solutions work 'well' (they get the 'final' job done, which is to send data to a server and receive a result based on some remote processing), I'm convinced there is a better way to send a large amount of data to a server, using either the Python socket library, or any other available tools.\nAll personal researches are done on that matter lead me to solutions similar to mine, using Python sockets, or were out of context (relying on other backends than pure Python).\nBy a better way, I assume:\n\nA solution that saves bandwidth as much as possible.\nA solution that sends all data as fast as possible.\n\nFor 1. I slightly modified my first solution to archive and compress all captured frames in a .tgz file that I send over to the server. It indeed decreases the bandwidth usage but also increases the time spent on both ends (due to the un\/compression processes). It's obviously particularly true when the dataset is large.\nFor 2. GStreamer allowed me to have a negligible delay between the capture and the reception on my server. I have however no compression at all and for the reasons stated above, I cannot really use this library for further development.\nHow can I send a large number of images from one client to one server with minimal bandwidth usage and delay in Python?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1651,"Q_Id":54667373,"Users Score":0,"Answer":"you can restream camera using ffmpeg over network so that client can read it both ways. it will reduce delays.","Q_Score":3,"Tags":"python,image,sockets,opencv,gstreamer","A_Id":71076309,"CreationDate":"2019-02-13T10:02:00.000","Title":"Efficient way of sending a large number of images from client to server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"very simple task:\nsrcdir=\"Q:\/\/Waveforms\/\/Cispr16-1-2\/\/Pk\"\nos.chdir(srcdir)\nthe interpreter says:\nWindowsError: [Error 3] The system cannot find the path specified: 'Q:\/\/Waveforms\/\/Cispr16-1-2\/\/Pk'\nfrom cmd prompt the remote driver is visible:\nVolume in drive Q is USERDATA\nVolume Serial Number is CB9A-E149\nDirectory of Q:\\Waveforms\\Cispr16-1-2\\Pk\n13\/02\/2019 12:21 .\n13\/02\/2019 12:21 ..\n13\/02\/2019 12:21 8.225 F1--Pk--00000.trc\n 1 File(s) 8.225 bytes\n 2 Dir(s) 84.622.512.128 bytes free\nMost likely this is a windows10 security issue, not letting Python access the sahred folder. Has anyone experienced the same issue and has found a solution?\nthanks\nMastro59","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":189,"Q_Id":54671193,"Users Score":1,"Answer":"The double \/\/ should be a single \/. Or \\\\.","Q_Score":0,"Tags":"python-2.7,remote-access","A_Id":54689609,"CreationDate":"2019-02-13T13:19:00.000","Title":"os.chdir can't find remote shared driver","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"very simple task:\nsrcdir=\"Q:\/\/Waveforms\/\/Cispr16-1-2\/\/Pk\"\nos.chdir(srcdir)\nthe interpreter says:\nWindowsError: [Error 3] The system cannot find the path specified: 'Q:\/\/Waveforms\/\/Cispr16-1-2\/\/Pk'\nfrom cmd prompt the remote driver is visible:\nVolume in drive Q is USERDATA\nVolume Serial Number is CB9A-E149\nDirectory of Q:\\Waveforms\\Cispr16-1-2\\Pk\n13\/02\/2019 12:21 .\n13\/02\/2019 12:21 ..\n13\/02\/2019 12:21 8.225 F1--Pk--00000.trc\n 1 File(s) 8.225 bytes\n 2 Dir(s) 84.622.512.128 bytes free\nMost likely this is a windows10 security issue, not letting Python access the sahred folder. Has anyone experienced the same issue and has found a solution?\nthanks\nMastro59","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":189,"Q_Id":54671193,"Users Score":0,"Answer":"I tried with \/ and \/\/ and \\ and \\ none of these worked with windows10, but\nin windows7 this command works:\nos.chdir(\"Q:\/\/Waveforms\")\nfor others having the same problem here is the solution for Windows10.\nit is required to access the share using the ip address and share name.\nthe shared drive was named \"d\"\nin python this syntax works:\nos.chdir(\"\\\\ipaddress\\sharename\\folder\") [ 4 \\ AND 2 \\]\nOR \nos.chdir(\"\/\/ipaddress\/sharename\/folder\")\nthis worked well:\nos.chdir(\"\\\\192.168.147.143\\d\\Waveforms\") [note:IN TEXT MESSAGE I AM TYPING 4\\ AND 2\\ BUT THE POST ONLY SHOWS 2\\ AND 1]\nOR\nos.chdir(\"\/\/192.168.147.143\/d\/Waveforms\") \nresult:\nCurrent Working Directory D:\\products\\MyscopeControl\\src\nDirectory changed to: \\192.168.147.143\\d\\Waveforms","Q_Score":0,"Tags":"python-2.7,remote-access","A_Id":54707237,"CreationDate":"2019-02-13T13:19:00.000","Title":"os.chdir can't find remote shared driver","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Some time ago I ve written a Python script, using poplib library, which retrieves messages from my pop3 email account. Now I would like to use it to retrieve emails from different mail server which works with IMAP. It works well, but only to retrieve messages from Inbox. Is there any way to also get emails from other folders like Spam, Sent etc? I know I could use imaplib and rewrite the script, but my questions is if it's possible to obtain that with poplib.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":554,"Q_Id":54706093,"Users Score":4,"Answer":"No.\nPOP is a single folder protocol. It is very simple and was not designed for multiple folders.\nYou will need to use IMAP or other advanced protocols to access additional folders.","Q_Score":2,"Tags":"python,email,imaplib,poplib","A_Id":54719050,"CreationDate":"2019-02-15T09:21:00.000","Title":"Checking folders different than inbox using poplib in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Was asking if I could do a search on the entire eclipse library which includes my closed projects. I did a file search(Ctrl + H) but they only shows results for projects that are open.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":157,"Q_Id":54724905,"Users Score":0,"Answer":"When a project is closed, it can no longer be changed in the Workbench and its resources no longer appear in the Workbench, but they do still reside on the local file system. Closed projects require less memory. Also, since they are not examined during builds, closing a project can improve build time.\nA closed project is visible in the Package Explorer view but its contents cannot be edited using the Eclipse user interface. Also, an open project cannot have dependency on a closed project. The Package Explorer view uses a different icon to represent a closed project.","Q_Score":0,"Tags":"python,eclipse,search,project","A_Id":54724960,"CreationDate":"2019-02-16T15:55:00.000","Title":"How to search through eclipse closed projects?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been 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.\nNow, 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.\nI 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.\nMy 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.\nThank you!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":24,"Q_Id":54733751,"Users Score":0,"Answer":"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.","Q_Score":0,"Tags":"python,raspberry-pi3","A_Id":54741625,"CreationDate":"2019-02-17T13:30:00.000","Title":"Count number of Triggers in a given Span of Time","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"For my Eclipse Che project, I have to reinstall my python modules every time I load the workspace (blegh). Is there a way to install the modules my team needs to a global folder so they don't have to even install the python modules every time they want to load the project? Thank you!","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":753,"Q_Id":54793121,"Users Score":1,"Answer":"If I understand you question correctly, the best approach would be to build new docker image (based on the one you are using now) with the modules pre-installed and use that image for workspace instead of the default one.","Q_Score":1,"Tags":"python,eclipse,eclipse-che","A_Id":54802762,"CreationDate":"2019-02-20T18:36:00.000","Title":"Have to keep reinstalling python modules (Eclipse Che)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know that you can run multiple scripts by using different terminals, but there's got to be a limit. I can't just run a million of them on one little pi. So the real question... Is there a way I can check how demanding my script is. Thank you in advance!\npi zero w \/ python 3","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":620,"Q_Id":54796505,"Users Score":1,"Answer":"There is no explicitly fixed limit. Just like your desktop or laptop computer, the limit depends on how many resources each running program takes. And just like your computer, the result of consuming too many resources can vary. It can result in the programs just running more slowly or in a complete crash.","Q_Score":1,"Tags":"python,raspberry-pi","A_Id":54796600,"CreationDate":"2019-02-20T22:49:00.000","Title":"How many py script can I run on raspberry pi simultaniously?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How to install libraries like cairomm-devel,pangomm-devel those packages are not in Amazon Linux AMI.\nBut i need those libraries.\nHow do i install those libraries?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":29,"Q_Id":54825688,"Users Score":0,"Answer":"There is no solution Amazon Linux does not have those libraries required.\nI fixed by migrating my server to Docker Instance using AWS Fargate (Serverless Approach).","Q_Score":0,"Tags":"python,amazon-web-services,amazon-ec2,yum","A_Id":58638495,"CreationDate":"2019-02-22T11:03:00.000","Title":"How to install libraries like cairomm-devel, pandomm-devel on Aws Linux AMI","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"i developed a small web APP with CherryPy for Python. I want to run this on a production Server with ubuntu 16.04. My Sysadmin tells me that I shall not use pip or github repository, because of ... something wrong with using anything but apt ... he says. \nIs there a way of getting a recent cherrypy for python3 with apt ?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2257,"Q_Id":54831915,"Users Score":0,"Answer":"The solution on Ubuntu 16.04 with python3 (Python 3.5.2):\nInstall virtualenvironment for python3\nsudo apt-get install python3-venv\nCreate a folder for your environment\nmkdir environment\nCreate the environment\npython3 -m venv environment\nChange into folder\ncd environment\/bin\nActivate environment\nsource activate\nInstall pip within the env\napt install python3-pip\nInstall cherrypy >= 18.1.0\npip3 install cherrypy\nRun program\npython3 .\/my_python_script.py","Q_Score":0,"Tags":"python,ubuntu,cherrypy","A_Id":54922769,"CreationDate":"2019-02-22T17:02:00.000","Title":"Python 3.5.2 Installation of Cherrypy with apt","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"For background, I am somewhat of a self-taught Python developer with only some formal training with a few CS courses in school. \nIn 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. \nMy 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. \nSo my question is, are there more intuitive ways to create tests for parsers? \nThank you in advance for any help!","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":364,"Q_Id":54833354,"Users Score":2,"Answer":"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.","Q_Score":1,"Tags":"python,unit-testing,parsing","A_Id":54833388,"CreationDate":"2019-02-22T18:47:00.000","Title":"How to write unit tests for text parser?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running C# project which use result of python file. I'm using IronPython to run python file in visual studio. But the error above come up. Please help me. Many thanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1617,"Q_Id":54839602,"Users Score":0,"Answer":"Sorry you cant access third party functionalities\/packages (like Pandas here)\nThe reason:\nPandas \/ numpy use great parts of c code, that is a no good for IronPython (.NET).!!!!\nIf you need to use the power of pandas, i suggest you to create a dialog (send\/reveive datas or by file or by calling an external python prog) between your IronPython Project and a program python including pandas.","Q_Score":0,"Tags":"c#,python,pandas","A_Id":54839647,"CreationDate":"2019-02-23T08:18:00.000","Title":"IronPython.Runtime.Exceptions.ImportException: 'No module named pandas'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there an option to use an image uploaded to telegram (file_id couldn't do it) inside InlineQueryResultArticle thumb_url?\nnotes:\nI tried to get the file path using getfile() but it didn't do the trick.\neven tried to upload a very small image size with no luck.\nI'd like to ignore the InlineQueryResultCachedPhoto option since the design is not the same\nany thoughts?\nthank you!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":321,"Q_Id":54859470,"Users Score":0,"Answer":"I also checked that the telegram does not show the uploaded image, I think it is better to give the address of the picture directly.","Q_Score":1,"Tags":"python-telegram-bot","A_Id":69072827,"CreationDate":"2019-02-25T04:24:00.000","Title":"InlineQueryResultArticle - thumb_url uploaded image","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"To be specific,\nPyPi package rarfile has _check_unrar_tool() function that runs on import. I don't want it run while importing, because it throws permission error in certain boxes.\nI cant modify the package at my place due to certain restrictions.\nSo, as in this scenario, is it possible to ignore _check_unrar_tool() call and import successfully.\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":45,"Q_Id":54860427,"Users Score":1,"Answer":"Technically, the rarfile package, more specifically the _check_unrar_tool() just expects a return code of 0 from the unrar command.\nIf you can somehow check if the unrar command works before importing the package, you can substitute it for something else that returns 0 and you can get away without messing with the package.","Q_Score":0,"Tags":"python,python-import,pypi,rar","A_Id":54861080,"CreationDate":"2019-02-25T06:13:00.000","Title":"Is it possible to avoid execution of check function if available in module while importing it","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How do apps like instagram, twitter etc. Know a user is logged on and when next the user starts the app, the user doesn't have to input their credentials all over. Is it by writing and reading from a file, if yes, doesn't it mean a user can find the file that the app reads from, alter it's content and change who's logged on to someone else without authentication","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":61,"Q_Id":54880003,"Users Score":0,"Answer":"Save their token in LocalStorage for web front-end, for other platform \nyou can save in somewhere that can storage.\nToken-Based api. (access with token with any resource)","Q_Score":0,"Tags":"python,session,kivy","A_Id":54880067,"CreationDate":"2019-02-26T07:01:00.000","Title":"How to keep a user logged on","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm having low fps for real-time object detection on my raspberry pi\nI 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 \nHowever 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\ncan 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?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1551,"Q_Id":54881654,"Users Score":0,"Answer":"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 .","Q_Score":0,"Tags":"python,opencv,raspberry-pi,object-detection,yolo","A_Id":55558787,"CreationDate":"2019-02-26T08:57:00.000","Title":"how to increase fps for raspberry pi for object detection","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm having low fps for real-time object detection on my raspberry pi\nI 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 \nHowever 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\ncan 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?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1551,"Q_Id":54881654,"Users Score":0,"Answer":"My detector on raspberry pi without any accelerator can reach 5 FPS.\nI used SSD mobilenet, and quantize it after training.\nTensorflow Lite supplies a object detection demo can reach about 8 FPS on raspberry pi 4.","Q_Score":0,"Tags":"python,opencv,raspberry-pi,object-detection,yolo","A_Id":66489611,"CreationDate":"2019-02-26T08:57:00.000","Title":"how to increase fps for raspberry pi for object detection","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When using the SignedCookieSessionFactory, the documentation states that the sha512 HMAC digest algorithm is used. As a result of this, once session data is serialised, it is signed and sent to the user's client under the session cookie.\nThere is no mention in Pyramid's documentation that sessions are also cached server-side (under this SessionFactory).\nThis presents a contradiction and has also led to authentication confusion when paired with SessionAuthenticationPolicy. If session data cannot be retrieved from the client's session cookie (as it is one-way hashed), how is it that the following is possible?\n\nAuthenticate with the application such that reading Request.authenticated_userid does not return None.\nCopy the session cookie to the clipboard.\nLogout by accessing a view whereby the headers from forget(request) are returned in the Response.\nReplace the session cookie with the copied value.\nThe user is now logged back in.\n\nI understand that simply deleting the cookie client-side is insufficient to completely invalidate the session (without blacklisting), but this then poses the following questions:\n\nHow is it possible to remain secure with browser-scoped sessions unless every session cookie the user has recently been issued is somehow remembered and blacklisted\/invalidated?\nIs the session cookie actually a key\/session ID that's being used to lookup a session in memory? As it's one-way signed, surely this is the only explanation?\nIs it possible then to invalidate sessions server-side, a little more robust than just the headers=forget(request) pattern?\n\nUltimately, I imagine the answer is something along the lines of:\n\"Maintain server-side sessions using an include such as pyramid_redis_sessions\"\nAny explanation would be appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":146,"Q_Id":54887668,"Users Score":3,"Answer":"The cookie contains all of the data. The session content itself is stored in the cookie, alongside an hmac signature of that content. This means that a client may view the content if they try hard enough, but they cannot change it as they cannot create trusted signatures without the server-side secret.\n\nHow is it possible to remain secure with browser-scoped sessions unless every session cookie the user has recently been issued is somehow remembered and blacklisted\/invalidated?\n\nIt depends what you're using the session for - you need to take these issues into consideration before putting data into a session object.\n\nIs it possible then to invalidate sessions server-side, a little more robust than just the headers=forget(request) pattern?\n\nNot unless you store some sort of id in the session and then a server-side table of blacklisted ids. If you did this then you could write your own wrapper session-factory that opened the session, checked the id, and returned an empty one if it was blacklisted. Of course then you might just want to use a server-side session library like pyramid_redis_sessions or pyramid_beaker with one of its server-side-storage backends.","Q_Score":4,"Tags":"python,python-3.x,pyramid","A_Id":54893292,"CreationDate":"2019-02-26T14:23:00.000","Title":"If Pyramid sessions are one-way hashed and not stored server-side, where is the data coming from?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm writing an application in PyQt5 which will be used for calibration and test of a product. The important details:\n\nThe product under test uses an old-school UART\/serial communication link at 9600 baud.\n...and the test \/ calibration operation involves communicating with another device which has a UART\/serial communication link at 300 baud(!)\nIn both cases, the communication protocol is ASCII text with messages terminated by a newline \\r\\n.\n\nDuring 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?\nThe 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.\nThe Desired solution is a GUI which has a nice smooth responsive feel to it, even while it is transmitting and receiving serial data.\nThe 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.\nMy 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.\nI'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.\nAre there any existing architectures or design patterns to use as a starting point for this type of application?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":397,"Q_Id":54898967,"Users Score":0,"Answer":"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:\n\nYes, the best way to solve this is with with PyQt Threads, and using Signals and Slots to communicate between the threads.\nFor basic function (the \"Desired\" solution above) just follow the existing basic design pattern for PyQt multithreaded GUI applications:\n\n\nA GUI thread whose only job is to display data and relay user inputs \/ commands, and,\nA worker thread that does everything else (in this case, including the serial comms).\n\nOne 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.\n\n\nThe 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.\n\nGetting 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.\n\nAll 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.","Q_Score":0,"Tags":"python,pyqt5","A_Id":54964121,"CreationDate":"2019-02-27T05:59:00.000","Title":"How to architect a GUI application with UART comms which stays responsive to the user","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"So i have a python script that automate some checks and send a mail when finished.\nI start the script with windows scheduler every night.\nI want to log if the script ran from the scheduler or if someone ran it manualy from an IDE(PyCharm for my case)\nIs there any os method that returns how a script ran or something else maybe?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":50,"Q_Id":54921887,"Users Score":4,"Answer":"while scheduling from windows scheduler you can send a command line argument, then check it in your code if it is started with specified command line argument then it is run from windows scheduler.","Q_Score":3,"Tags":"python,python-3.x,scheduler","A_Id":54922097,"CreationDate":"2019-02-28T09:04:00.000","Title":"Can my python script know if it started manualy from IDE or automatically from scheduler?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have python script and arm board with android pie.\nI have UART console and adb shell of board. Now i want to run python script on board ? \nHow to add python packages in android build ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":359,"Q_Id":54924609,"Users Score":0,"Answer":"To run python, we need to install QPython apk on the board, which has the necessary python binaries to run python, Download the QPython apk\nStart the adb service on the board and connect to the host PC.\nInstall the qpython apk using the command: adb install \nAfter the apk is successfully installed, verify the installation by checking the org.qpython.qpy directory on the board. the directory contains python binaries.\nBefore running python, we need to source the init.sh script in the bin\/ directory: source init.sh\nYou can now run python by the following command from the bin\/directory as: python-android5 \/path\/to\/python\/file.py","Q_Score":0,"Tags":"android,python,adb,android-9.0-pie","A_Id":55570814,"CreationDate":"2019-02-28T11:25:00.000","Title":"How to run python script on arm board with android pie?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was just wondering, is there any way to convert IUPAC or common molecular names to SMILES? I want to do this without having to manually convert every single one utilizing online systems. Any input would be much appreciated!\nFor background, I am currently working with python and RDkit, so I wasn't sure if RDkit could do this and I was just unaware. My current data is in the csv format. \nThank you!","AnswerCount":7,"Available Count":1,"Score":-0.0285636566,"is_accepted":false,"ViewCount":8612,"Q_Id":54930121,"Users Score":-1,"Answer":"if you change the first line to:\nfrom urllib2 import url open\nit should work for python 2.7","Q_Score":11,"Tags":"python,cheminformatics","A_Id":57932844,"CreationDate":"2019-02-28T16:23:00.000","Title":"Converting molecule name to SMILES?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using a 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","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":213,"Q_Id":54971247,"Users Score":1,"Answer":"You could do either one of the following:\n\nUse a virtual environment (install virtualenv). You can specify\nthe version of Python you want to use when creating the virtual\nenvironment with -p \/opt\/anaconda2\/bin\/python.\nUse an alias:\nalias python=\/opt\/anaconda2\/bin\/python.","Q_Score":0,"Tags":"python,anaconda,gnu-screen","A_Id":54980660,"CreationDate":"2019-03-03T16:50:00.000","Title":"Force screen session to use specific version of python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm starting to learn telegram bot. My plan was to have a bot that daily sends you at a specific time a message, but also I wanted the option to manually poll the bot for getting that daily message, or a random one. Right now I have a bot running on pythonanywhere that can respond to the 2 commands, but what about sending the user the daily message at some time? \nWhat's the way to go, create a channel and then schedule a task on my webhook to daily send the message to the channel, or store all chat-id in my service and talk to them everytime? The first one seems obviously better but I was wondering if there's some trick to make everything works in the bot.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":131,"Q_Id":54981185,"Users Score":0,"Answer":"For now I managed to create a channel, make the bot an admin and scheduled a task on the webhook to daily send a message as admin to the channel","Q_Score":0,"Tags":"python,telegram,telegram-bot","A_Id":55000584,"CreationDate":"2019-03-04T10:22:00.000","Title":"Telegram: Store chat id or Channel with bot inside?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Python 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?\nI have already installed vmprof using \n\npip install vmprof","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":69,"Q_Id":54994853,"Users Score":0,"Answer":"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.","Q_Score":0,"Tags":"python,command-line,profiling,pypy","A_Id":55011625,"CreationDate":"2019-03-05T03:08:00.000","Title":"How do you profile a Python script from Windows command line using PyPy and vmprof?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am using uWSGI to deploy my WSGI application. Are the Python file compiled for every request, or are they precompiled once? I don't see any .pyc files.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":801,"Q_Id":55000167,"Users Score":2,"Answer":"Python caches modules bytecode - directly in the same location for python2.x, under a __pycache__ subfolder for python3 - but scripts (the difference is in usage - if you import it it's a module, if you execute it it's a script) are always recompiled (which is why main scripts are usually very very short an simple).\nIOW, your main wsgi script will be recompiled once for each new server process. Typically a wsgi app is served as a long running process which will handle much more than one single request, so even then the initial compilation overhead is really not an issue (short script + only compiled once per process)...\nAlso, once a Python process is started, imported modules are cached in memory so they are only really imported (loaded) once per process. \nJust note that the user under which the process is running must have write permissions on your app's directory in order to create the .pyc files... and of course read permissions on the .pyc files too.","Q_Score":2,"Tags":"python,uwsgi,wsgi","A_Id":55002715,"CreationDate":"2019-03-05T10:03:00.000","Title":"Does uWSGI use precompiled Python files?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"My organization uses the lambda handler naming convention of:\n lambda.[team_name]-[function_name]\nIn an attempt to deploy a cloud formation template with a few lambda functions that are named in this way, but deployment fails due to a syntax error in the definition of the function.\nI've tried removing the dashes in the handler name, and this removes the syntax error--but now I don't have permission to work with the lambda function as the handler doesn't follow our naming conventions.\nHas anyone dealt with anything like this, what was your workaround?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1358,"Q_Id":55031481,"Users Score":1,"Answer":"Haven't came across this, but if it brakes with that convention your org have to decide on replacing the convention. And who have a period (.) as a function name. That's a flag for me. \nAnd for the immediate issue, it is the IAM role\/group that was assigned to you doesn't have that modified lambda name. So you cannot do anything with it","Q_Score":0,"Tags":"python-3.x,amazon-web-services,aws-lambda","A_Id":55033120,"CreationDate":"2019-03-06T20:14:00.000","Title":"AWS Lambda Handler Naming Convention","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"The context here is simple, there's a lambda (lambda1) that creates a file asynchronously and then uploads it to S3.\nThen, another lambda (lambda2) receives the soon-to-exist file name and needs to keep checking S3 until the file exists.\nI don't think S3 triggers will work because lambda2 is invoked by a client request\n1) Do I get charged for this kind of request between lambda and S3? I will be polling it until the object exists\n2) What other way could I achieve this that doesn't incur charges?\n3) What method do I use to check if a file exists in S3? (just try to get it and check status code?)","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":783,"Q_Id":55031936,"Users Score":0,"Answer":"Let me make sure I understand correctly. \n\nClient calls Lambda1. Lambda1 creates a file async and uploads to S3\nthe call to lambda one returns as soon as lambda1 has started it's async processing. \nClient calls lambda2, to pull the file from s3 that lambda1 is going to push there. \n\nWhy not just wait for Lambda one to create the file and return it to client? Otherwise this is going to be an expensive file exchange.","Q_Score":0,"Tags":"python-3.x,amazon-web-services,amazon-s3,aws-lambda,boto3","A_Id":55032258,"CreationDate":"2019-03-06T20:52:00.000","Title":"Long polling AWS S3 to check if item exists?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've tried the following:\npython -m pytest .\/subfolder -k 'test_common_fields'\nThis doesn't work at all. It finds nothing but this test exists in that subfolder's file of the same name 'subfolder\/test_subfolder.py'\nI tried entering full path: -k 'subfolder\/test_subfolder.py::test_common_fields' and without \"subfolder\" path. Nothing.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":36,"Q_Id":55047163,"Users Score":1,"Answer":"On Ubuntu, I generally use py.test --verbose -k testcase_1 test_xyz.py","Q_Score":0,"Tags":"python,pytest","A_Id":55131558,"CreationDate":"2019-03-07T15:17:00.000","Title":"How do you specify the only test to run with pytest k parameter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have all of my TestCase files in a django app called 'tests'. Running a specific TestCase works just fine with this command:\npython run manage.py test tests.myTestCaseFile\nHowever, when i run the entire set of TestCases in the tests folder this fails:\npython run manage.py test tests\nIn this case many ImportErrors are triggered as well as KeyError: 'en-us'. Essentially every single TestMethod errors out in one way or another.\nAny ideas what could be happening here? \nNOTE: I have already tried to import myapp.urls in the shell and reverse(urlname) works just fine there..","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":682,"Q_Id":55070109,"Users Score":3,"Answer":"I've solved this issue:\n\nKeyError: u'en-us' seems to occur anytime there is an import error in any test module\n\nI had a test file which was testing functionality that did not exist in the current branch. \nSeems that an import error in any test file prevents execution of the entire test suite.","Q_Score":1,"Tags":"python,django,django-nose","A_Id":55961188,"CreationDate":"2019-03-08T19:52:00.000","Title":"Django-nose failure - KeyError: u'en-us'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"So, I'm trying to understand the math involved when trying to translate hexadecimal escape sequences into integers.\nSo if I have the string \"\u00c3\", when I do \"\u00c3\".encode('utf-8') I get a byte string like this \"\\xc3\". ord(\"\u00c3\") is 195. The math is 16*12+3 which is 195. Things makes sense.\nBut if I have the character \"\u00e9\" - then the utf8-encoded hex escape sequence is \"\\xc3\\xa9 - and ord(\"\u00e9\") is 233. How is this calculation performed? (a9 on its own is 169 so it's clearly not addition).\nSimilarly with this '\u012c'.encode('utf-8'). This yields b'\\xc4\\xac'. And ord('\u012c') is 300.\nCan anyone explain the math involved here?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":268,"Q_Id":55085744,"Users Score":0,"Answer":"So, I thought I'd just wrap this one up and post the answers to the math issues I didn't comprehend before receiving a tons of wisdom from SO.\nThe first question regarded \"\u00e9\" which yields \"\\xc3\\xa9\" when encoded with utf8 and where ord(\"\u00e9\") returns 233. Clearly 233 was not the sum of 195 (decimal representation of c3) and 169 (ditto for a9). So what's going on?\n\"\u00e9\" is has the corresponding unicode point U+00E9. The decimal value for the hex e9 is 233. So that's what the ord(\"\u00e9\") is all about.\nSo how does this end up as \"\\xc3\\xa9\"?\nAs J\u00f6rg W Mittag explained and demonstrated, in utf8 all non-ASCII are \"encoded as a multi-octet sequence\".\nThe binary representation of 233 is 11101001. As this is non-ASCII this needs to be packed in a two-octet sequence which according to J\u00f6rg will follow this pattern:\n110xxxxx 10xxxxxx (110 and 10 are fixed leaving room for five bits in the first octet, and six bits in the second - 11 in total). \nSo the 8 bits binary representation of 233 is fitted into this pattern replacing the xx-parts... Since there are 11 bits available and we only need 8 bits we pad the 8 bits with 3 more, 000, (i.e. 00011101001).\n^^^00011 ^^101001 (000 followed by our 8 bits representation of 233)\n11000011 10101001 (binary representation of 233 inserted in a two-octet sequence)\n11000011 equals the hex c3, as 10101001 equals a9- which in other words matches the original sequence \"\\xc3\\xa9\"\nA similar walkthrough for the character \"\u012c\":\n'\u012c'.encode('utf-8') yields b'\\xc4\\xac'. And ord('\u012c') is 300.\nSo again the unicode point for this character is U+012C which has the decimal value of 300 ((1*16*16)+(2*16*1)+(12*1)) - so that's the ord-part.\nAgain the binary representation of 300 is 9 bits, 100101100. So once more there's a need for a two-octet sequence of the pattern 110xxxxx 10xxxxxx. And again we pad it with a couple of 0 so reach 11 bits (00100101100).\n^^^00100 ^^101100 (00 followed by our 9 bits representation of 300)\n11000100 10101100 (binary representation of 300 inserted in a two octet-sequence).\n11000100 corresponds to c4in hex, 10101100 to ac - in other words b'\\xc4\\xac'.\nThank you everyone for helping out on this. I learned a lot.","Q_Score":0,"Tags":"python-3.x,utf-8,hex","A_Id":55093162,"CreationDate":"2019-03-10T08:14:00.000","Title":"How to calculate integer based on byte sequence","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Python. I am currently doing a project which is kind of automation. The overall theme is get input via Chatbot and automate through PythonAutoGUI. I have downloaded one Chatbot. It consisted of AIML. Can we intgrate Python code inside AIML? Is it possible? If it is, How? I can't find relevant tutorials or information regarding this. Cheers!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":115,"Q_Id":55118001,"Users Score":0,"Answer":"Have you tried Program-y it\u2019s 100% python and full aiml 2 compliant and has custom extensions to call python objects","Q_Score":0,"Tags":"python,pyautogui,aiml","A_Id":55191637,"CreationDate":"2019-03-12T09:25:00.000","Title":"How can we integrate Python code in AIML?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a requirement in which I need to automate the start and stop of the AWS EC2 Instances (within Autoscaling group) daily. This is mainly to prevent cost. I have built a Python script to start and stop EC2 instances but it's not working properly as EC2 instances are within an Autoscaling group.\nDoes anybody know any solution for this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":409,"Q_Id":55130327,"Users Score":0,"Answer":"What you need to do is automate the auto scaling parameters, for desired instances, min instances and max instances. Ideally, you want to change the desired instance amount. This will cause the auto scaler to terminate excessive instances, to meet the desired instance amount.","Q_Score":0,"Tags":"python,amazon-web-services,autoscaling","A_Id":55130351,"CreationDate":"2019-03-12T20:41:00.000","Title":"Start and stop AWS EC2 instance","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've been looking into the hyperledger indy framework and I wanted to start to build an app to get started but I noticed that there's the sdk that uses Libindy but there's also the Libvcx that is on top of Libindy but I don't know which one to use since they both seem to do the same.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":918,"Q_Id":55133748,"Users Score":1,"Answer":"The indy-sdk repository is the Indy software that enables building components (called agents) that can interact with an Indy ledger and with each other.\nIn 2019, at a \"Connect-a-thon\" in Utah, USA, developers from a variety of organizations gathered to demonstrate interoperability across a set of independently developed agent implementations. At that time, a further idea developed that led to the creation of Hyperledger Aries. What if we had agents that could use DIDs and verifiable credentials from multiple ecosystems? Aries is a toolkit designed for initiatives and solutions focused on creating, transmitting, storing and using verifiable digital credentials. At its core are protocols enabling connectivity between agents using secure messaging to exchange information.\nLibvcx is a c-callable library built on top of libindy that provides a high-level credential exchange protocol. It simplifies creation of agent applications and provides better agent-2-agent interoperability for Hyperledger Indy infrastructure.\nYou need LibVCX if you want to be interoperably exchange credentials with other apps and agents, in others words if you want to be comply with Aries protocol.\nIn this case LibVCX Agency can be used with mediator agency which enables asynchronous communication between 2 parties.","Q_Score":4,"Tags":"python,hyperledger-indy","A_Id":63579718,"CreationDate":"2019-03-13T03:08:00.000","Title":"What's the difference between hyperledger indy-sdk and Libvcx?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been looking into the hyperledger indy framework and I wanted to start to build an app to get started but I noticed that there's the sdk that uses Libindy but there's also the Libvcx that is on top of Libindy but I don't know which one to use since they both seem to do the same.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":918,"Q_Id":55133748,"Users Score":7,"Answer":"As you've said, LibVCX is built on top of LibIndy. \nLibIndy\nProvides low level API to work with credentials and proofs. It provides operations to create create credential requests, credentials, proofs. It also exposes operations for communication with Hyperldger Indy ledger. \nWhat Libindy doesn't handle is the credential exchange. If you write backend which issues credential and a mobile app which can request and receive credentials using Libindy, you'll have to come up with some communication protocol to do so. Is it gonna be HTTP? ZMQ? How are you going to format messages? This is what LibVCX does for you. You will also have to come up with solution how will you securely deliver messages and credentials from server to client when the client is offline.\nLibVCX\nLibVCX is one of several implementations of Hyperledger Aries specification. LibVCX is built on top of LibIndy and provides consumer with OOP-style API to manage connections, credentials, proofs, etc. It's written in Rust and has API Wrappers available for Python, Javascript, Java, iOS.\nLibVCX was designed with asynchronicity in mind. LibVCX assumes existence of so called \"Agency\" between the 2 parties communicating - a proxy which implements certain Indy communication protocol, receives and forwards messages. Therefore your backend server can now issue and send a credential to someone whom it has talked to days ago. The credential will be securely stored in the agency and the receiver can check whether there's any new messages\/credentials addressed for him at the agency.\nYou can think of agency as a sort of mail server. The message is stored there and the client can pull its messages\/credentials and decrypt them locally.\nWhat to use?\nIf you want to leverage tech in IndySDK perhaps for a specific use case and don't care about Aries, you can use vanilla libindy.\nIf you want to be interoperably exchange credentials with other apps and agents, you should comply with Aries protocol. LibVCX is one of the ways to achieve that.","Q_Score":4,"Tags":"python,hyperledger-indy","A_Id":55600304,"CreationDate":"2019-03-13T03:08:00.000","Title":"What's the difference between hyperledger indy-sdk and Libvcx?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to develop a C# application to monitor a Sick PLC using modbus. I have an example program for talking to the PLC which is written in Python and uses the module pyModbus. Is there a C# nugget package that has the same functionality as pyModbus?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":158,"Q_Id":55159006,"Users Score":0,"Answer":"It's not a Nuget package, but instead a full Visual Studio solution. AdvancedHMI includes a Modbus driver and also has lots of tools that will connect to the driver data without having to write code.\nwww.advancedhmi.com","Q_Score":0,"Tags":"c#,python,plc,pymodbus","A_Id":55191802,"CreationDate":"2019-03-14T09:29:00.000","Title":"C# equivalent for pyModbus","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any way to use the python extension to edit files that reside on a remote server? I have tried NFS and remoteFS, but I do not see any way to get Intellisense working using the remote installation. I normally edit and test on a windows machine, while the target runs on Linux. \nI realise this is not limited to this extension, but is a more general issue.","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":2885,"Q_Id":55189055,"Users Score":1,"Answer":"As a workaround, I'm using a Linux Hosted virtual machine which has a similar setup as the target. This works surprisingly well. It is a shame VMware 12 removed support for unity.","Q_Score":3,"Tags":"python,visual-studio-code","A_Id":55489593,"CreationDate":"2019-03-15T18:52:00.000","Title":"Visual Studio Code use on remote files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to click pictures with picamera and send them to my pythonanywhere...that should run a specific python script and return the output again to my rpi.\nHow is that possible?.. \nI have a hacker account on pythonanywhere.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":88,"Q_Id":55203647,"Users Score":0,"Answer":"You can do that by creating a web app on PythonAnywhere and then have picamera upload the picture. The endpoint on PythonAnywhere could then do the processing that you want and return it's results as the response to the request.","Q_Score":0,"Tags":"python,pythonanywhere","A_Id":55219819,"CreationDate":"2019-03-17T03:42:00.000","Title":"How to connect to pythonanywhere script from my rpi","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to find the latest git issue number for a repository using python for all users rather than an authenticated user.\nIs there any way i could do this? either through the API or any library?\nI looked at the github docs and from my understanding it is not possible to list issues for all users but only authenticated users.\nI looked at pygithub where all i could find was how to create an issue through the library","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":249,"Q_Id":55236480,"Users Score":0,"Answer":"@Kevin Vizalil\nYou can use the Github API's to get the list of issues or single issue\nplease check https:\/\/developer.github.com\/v3\/issues\/#list-issues\nedit:\ne.g. https:\/\/api.github.com\/repos\/vmg\/redcarpet\/issues?sort=created&direction=desc","Q_Score":0,"Tags":"python,git,github,request,github-api","A_Id":55236763,"CreationDate":"2019-03-19T08:30:00.000","Title":"How to find the latest git issue number on github using python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The images that I have gives me inconsistent results. My thought process is: my text is always in white font; if I can switch the pixel of my text to black and turned everything else to white or transparent, I will have better success.\nMy question is, what library or language is best for this? Do I have to turn my white pixel into some unique RGB, turn everything else to white or transparent, then find the unique RGB and make that black? Any help is appreciated.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":501,"Q_Id":55254270,"Users Score":1,"Answer":"Yes, if you could make the text pixels black and all the rest of the documents white you would have better success, although this is not always possible, there are processes that can help.\n\nThe median filter (and other low pass filters) can be used to remove noise present in the image.\nerosion can also help to remove things that are not characters, like thin lines and also noise.\nalign the text is also a good idea, the OCR accuracy can drop considerably if the text is not aligned. To do this you could try the Hough transform followed by a rotation. Use the Hough transform to find a line in your text and then rotate the image in the same angle as the line.\n\nAll processing steps mentioned can be done with opencv or scikit-image.\nIs also good to point out that there are many other ways to process text, too many to mention.","Q_Score":0,"Tags":"python,image,canvas,tesseract","A_Id":55564020,"CreationDate":"2019-03-20T05:46:00.000","Title":"Prepare Image for OCR","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have whole project to convert from Python 2.x to 3.x. So can I go ahead & convert it by just 2to3 module?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":231,"Q_Id":55259840,"Users Score":0,"Answer":"i think you can. maybe there will be some errors but it generly it will be going well","Q_Score":0,"Tags":"python-3.x,python-2.7,module,python-2to3","A_Id":55260344,"CreationDate":"2019-03-20T11:35:00.000","Title":"How much accuracy does 2to3 Python module has to convert files?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need suggestions on how to speed up access to python programs when called from Golang. I really need fast access time (very low latency).\nApproach 1:\nfunc main() {\n...\n...\n cmd = exec.Command(\"python\", \"test.py\")\n o, err = cmd.CombinedOutput()\n...\n}\nIf 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.\nApproach 2:\nThe 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.\nI guess the main reason for this is probably because the python interpretor is already loaded and warm in memory.\nAre 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.\nthanks,","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":235,"Q_Id":55271734,"Users Score":0,"Answer":"Approach 1: Simple HTTP server and client\nApproach 2: Local socket or pipe\nApproach 3: Shared memory\nApproach 4: GRPC server and client\nIn 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.","Q_Score":0,"Tags":"python,go,exec,low-latency","A_Id":55272973,"CreationDate":"2019-03-20T23:43:00.000","Title":"Speed up access to python programs from Golang's exec packaqe","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Im just interested in the debugger, but do not want my plots being altered by pixiedust. Is it possible to use the debugger, without pixiedust having any other effects?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":55,"Q_Id":55286645,"Users Score":0,"Answer":"After 'import pixiedust_node', it just changes the display of cells when you use the library. You can use the debugger without using the rest of pixiedust. Just type '%%pixie_debugger' in the beginning of the cell.","Q_Score":0,"Tags":"python,debugging,jupyter-notebook,pixiedust","A_Id":55953841,"CreationDate":"2019-03-21T18:03:00.000","Title":"Is it possible to use the pixiedust debugger without the rest of pixidust?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a ReactJS project and using Amplify for Signup\/Signin. On signup, I have a post confirmation lambda trigger in Python that stores the user information (username, cognito id, etc.) in an on-prem database. I would like to also store the identity id, but I can't seem to find it in the event or context variable. I can find the identity id by calling Auth.currentCredentials() in React after the user has signed in, but would like to get this information during the signup process. \nAny help on this would be appreciated. Thank you.","AnswerCount":3,"Available Count":2,"Score":-0.1325487884,"is_accepted":false,"ViewCount":1421,"Q_Id":55308723,"Users Score":-2,"Answer":"You can save the identityId in a custom attribute","Q_Score":4,"Tags":"python,amazon-web-services,amazon-cognito,aws-amplify","A_Id":60999641,"CreationDate":"2019-03-22T22:44:00.000","Title":"How to get Cognito Identity Id in Post Confirmation Lambda Trigger in Python using Amplify React?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a ReactJS project and using Amplify for Signup\/Signin. On signup, I have a post confirmation lambda trigger in Python that stores the user information (username, cognito id, etc.) in an on-prem database. I would like to also store the identity id, but I can't seem to find it in the event or context variable. I can find the identity id by calling Auth.currentCredentials() in React after the user has signed in, but would like to get this information during the signup process. \nAny help on this would be appreciated. Thank you.","AnswerCount":3,"Available Count":2,"Score":0.2605204458,"is_accepted":false,"ViewCount":1421,"Q_Id":55308723,"Users Score":4,"Answer":"I had this same issue, and found that it is indeed not available in the auth trigger because the user has to authenticate to retrieve it, as you said. There is also not a way (that I could find) to grab this information using the AWS admin SDK.\nI resorted to running a small check after the user logs into the app and doing a call to save the identityId where I needed it. The purpose was to allow other users to access the user's media after logging in, by using the user's own identityId with amplify to pull a profile picture. \nHope this helps.","Q_Score":4,"Tags":"python,amazon-web-services,amazon-cognito,aws-amplify","A_Id":55308853,"CreationDate":"2019-03-22T22:44:00.000","Title":"How to get Cognito Identity Id in Post Confirmation Lambda Trigger in Python using Amplify React?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to set some pylint settings globally but I don't know if there is an global pylint configuration or where it is...\nI know there is an .pylintrc file but it's not a global configuration.\nSo my question is how to set pylint settings globally.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":753,"Q_Id":55323189,"Users Score":2,"Answer":"pylint is meant to be set up per python module, so it is always suggested to have it per module, instead of having it globally, so that you can track these files in git.","Q_Score":1,"Tags":"python,windows,pylint,pylintrc","A_Id":55323214,"CreationDate":"2019-03-24T11:11:00.000","Title":"Is there a global pylint configuration?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a Project in Raspberry Pi Zero, with apache as web server. The website is in PHP and based on user inputs, it updates a XML file in the server.\nThere is also a python program program running parallely with the web server. This python program contantsly reads the XML and grabs the values from XML, stores them locally and checks for changes in them and if there is any changes it performs some UART communications with external devices, sometimes based on these external communication from the devices, python also updates the XML.\nPython reads the XML every 2 seconds, and the problem is sometimes, when the python is doing the read operation, if the user prodives input and if PHP inserts the new value to the same XML, python crashes. The client wants to reduce the 2 second delay to .1 second, which means Python will be reading fastly and any changes from PHP will crash it.\nIs there a way to get somekind of file lock between python and PHP so that, when Python is reading or writing PHP waits and if PHP is writing Python waits. Priority goes to Python above PHP.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":65,"Q_Id":55328712,"Users Score":0,"Answer":"Would be better to have an api call first which would suggest if the data is being changed currently and when was the last data changed.\nThis way you can avoid the crash which is happening due to sharing of the resource","Q_Score":0,"Tags":"php,python,xml,file-handling,file-locking","A_Id":55329011,"CreationDate":"2019-03-24T21:23:00.000","Title":"Handling a common XML file between PHP and Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to run python test cases through Jenkins, it has the git clone command with ssh key. \nCommand : git clone -v ssh:\/\/user@host:29418\/project folder_to_clone\nGetting the error like :\nWarning: Permanently added '[host]:29418,[100.64.42.4]:29418' (RSA) to the list of known hosts.\nPermission denied (publickey).\nfatal: Could not read from remote repository.\nPlease make sure you have the correct access rights\nand the repository exists.\nBut while running locally everything fine, On Jenkins only getting this issue.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":417,"Q_Id":55351246,"Users Score":0,"Answer":"You need to add create a shh key using ssh-key , add it to both jenkins credentials and the git repository you are trying to fetch the code from.","Q_Score":0,"Tags":"python-3.x,git,jenkins","A_Id":55352738,"CreationDate":"2019-03-26T06:46:00.000","Title":"Jenkins job fails with git \"git clone\" using ssh key","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I followed Python i18n and l10n process to externalize and translate text message in Python app. But when I package Python code into a wheel package, I can't find any guidance in setuptools docs.\nBecause the localized messages files can be treated as data files. Perhaps, I could use package_data parms to include those files. However, it doesn't seem to be right way to do this. Because the deployed localized messages files should be either in system default locale location \/usr\/share\/locale or user-specific location. In either way, I find it difficult to connect pkg_resources package to gettext package without messing with real physical path hacking.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":557,"Q_Id":55365356,"Users Score":3,"Answer":"Here is what I did. I verified that the wheel package deployed and loaded localized *.mo message catalog file properly in Linux, Mac OSX and Windows 10.\n\nMove your locales folder under your top level Python package folder. For example, let say your package name pkg1 and you have my_msg.mo catalog file for French locale. Move your *.mo file to pkg1\/locales\/fr\/LC_MESSAGES\/my_msg.mo\nIn your setup.py, add:\n\n...\npackage_data={'pkg1': ['pkg1\/locales\/\/LC_MESSAGES\/.mo']},\ninclude_package_data=True,\n...\n\nIn your Python script, use the following way to load without hard code any physical path:\n\n...\nlocale_path = pkg_resources.resource_filename('pkg1', 'locales')\nmy_msg = gettext.translation(domain='my_msg', localedir=locale_path, fallback=True)\n_T = my_msg.gettext\nprint(_T(\"hello world!\"))\n...","Q_Score":1,"Tags":"python,localization,internationalization,setuptools","A_Id":55498913,"CreationDate":"2019-03-26T20:00:00.000","Title":"How to include localized message in Python setuptools?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python code which I want to deploy on firebase as my Application database is firebase realtimeDB.\nA part of this APP is developed on python so I want to integrate in with my App. Which can be done by deploying python piece of code on firebase.\nI am unable to find a way to deploy a python code via firebase hosting.\nAnyone have any solution I would really appreciate it.\nI have tried to deploy it with firebase CLI tools. But I think it supports Javascript","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1824,"Q_Id":55369357,"Users Score":1,"Answer":"You can't deploy any backend code with Firebase Hosting. It only serves static content. You will have to look into other ways of running your backend, such as Cloud Functions or App Engine.","Q_Score":0,"Tags":"python,firebase,firebase-hosting","A_Id":55369376,"CreationDate":"2019-03-27T03:31:00.000","Title":"How to deploy a python code on firebase server","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"On Windows I can run py test.py having Python 3 installed.\nBut on Ubuntu, py is not recognized as command, but python3 is.\nIs there anyway I can make py the same command as python3?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":126,"Q_Id":55375436,"Users Score":3,"Answer":"You could always add alias py='python3' to your .bashrc file.","Q_Score":1,"Tags":"python,python-3.x","A_Id":55375458,"CreationDate":"2019-03-27T10:52:00.000","Title":"Cannot run py as command","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"On Windows I can run py test.py having Python 3 installed.\nBut on Ubuntu, py is not recognized as command, but python3 is.\nIs there anyway I can make py the same command as python3?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":126,"Q_Id":55375436,"Users Score":1,"Answer":"To add Up , If the script wants to call the interpreter\n\nMake sure the first line of your file has #!\/usr\/bin\/env python.\nMake it executable - chmod +x .py.\nAnd run it as .\/.py","Q_Score":1,"Tags":"python,python-3.x","A_Id":55375523,"CreationDate":"2019-03-27T10:52:00.000","Title":"Cannot run py as command","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have these scripts that perform a lot of expensive computations. One optimization I do is to evaluate the expensive function on a grid, cache the grid, and interpolate for calls within the grid. It is important that the files be written out to disk so that future sessions can benefit from the cache. When this script was just for my own personal use, I could put the cache wherever. Now that I want to incorporate it into a package for wider distribution, I find that I need to have some way to know where is it kosher to store cache files for a package? Do I just need to make some decisions, or are there some procedures I should follow (e.g. let the user modify the directory at install time, at run-time, etc)?\nEdit: this code will also have functions based on interpolating data from other sources. So I will need a place to store those, too, but need to know where it is standard to do so and how to detect where that is on a particular install (something hard coded at install time, or can Python modules detect where they're installed at runtime?). Point being, this location needs to be persistent in a way that I understand temporary directories not to be. Therefore, this would ideally be done inside of the package's directory structure or somewhere in the user's home directory. If in the package's directories, it is acceptable if I have to do shenanigans with permissions to make a directory that the user can modify.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2191,"Q_Id":55395893,"Users Score":0,"Answer":"I found some cached files here\nC:\\Users\\User_Name\\AppData\\Local\\pip\\cache\nIt is the folder where pip is installed and cache files\/libraries are present.\nIf you uninstall and reinstall python, then these cached libraries will be used, instead of downloading new ones.","Q_Score":3,"Tags":"python,caching,packaging,memoization","A_Id":72181715,"CreationDate":"2019-03-28T10:58:00.000","Title":"Is there a standard location to store function cache files in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was working on a decentralized python chat room. I was just wondering, if you don't open up a port, you can't receive messages. But, if you open up a port, you are vulnerable to getting hacked or something. So, is there a way to communicate with Python between a server and a client without opening up ports?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":39,"Q_Id":55399309,"Users Score":0,"Answer":"At least one of the client or the server should have an open port (typically, the server). As soon as a TCP connection is established (typically, by the client), a random (= chosen by the operating system) port will be used by the client to be reachable by the server.","Q_Score":0,"Tags":"python,sockets","A_Id":55399380,"CreationDate":"2019-03-28T13:52:00.000","Title":"Is there a way to communicate between server and client in Python without opening up ports?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a flow graph with lower and upper bounds and my task is to find any feasible solution as fast as possible. I found many algorithms and approaches to maximum\/minimum flow and so on (also many times uses feasible solution as start point) but nothing specific for any feasible solution. Is there any algorithm\/approach that is specific for it and fast?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":861,"Q_Id":55400911,"Users Score":1,"Answer":"So I finally got time to sum this up. The solution I used is to take the initial graph and transform it in these steps.\n(Weights are in this order: lower bound, current flow, upper bound.)\n1. Connect t to s by edge of (0, 0, infinity).\n2. To each node of the\n initial graph add balance value equal to: (sum of lower bound of\n incoming edges - sum of lower bound of outgoing edges).\n3. Set upper\n bound of every edge to (upper bound - lower bound). Set lower bound\n and current flow of each edge to 0.\n4. Now make new s (s') and new t (t') which will be our new start and end (DO NOT DELETE s and t already in the graph, they just became\n normal nodes).\n5. Create edge from s' to every vertex with positive balance with (0,\n 0, vertex.balance) bounds.\n6. Create edge from every vertex with negative balance to t' with (0,\n 0, abs(vertex.balance)).\n7. Run Ford-Fulkerson (or other maximum flow algorithm of your choice)\n on the new graph.\n8. For every edge of initial graph sum value of the\n edge with the initial old lower bound before transformation and you have your\n initial flows for every edge of the initial graph.\nThis problem is actually a bit harder than to maximize flow when feasible flow is provided.","Q_Score":1,"Tags":"python,graph,network-flow","A_Id":55557061,"CreationDate":"2019-03-28T15:05:00.000","Title":"Finding any feasible flow in graph as fast as possible","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I do side work writing\/improving a research project web application for some political scientists. This application collects articles pertaining to the U.S. Supreme Court and runs analysis on them, and after nearly a year and half, we have a database of around 10,000 articles (and growing) to work with.\nOne of the primary challenges of the project is being able to determine the \"relevancy\" of an article - that is, the primary focus is the federal U.S. Supreme Court (and\/or its justices), and not a local or foreign supreme court. Since its inception, the way we've addressed it is to primarily parse the title for various explicit references to the federal court, as well as to verify that \"supreme\" and \"court\" are keywords collected from the article text. Basic and sloppy, but it actually works fairly well. That being said, irrelevant articles can find their way into the database - usually ones with headlines that don't explicitly mention a state or foreign country (the Indian Supreme Court is the usual offender).\nI've reached a point in development where I can focus on this aspect of the project more, but I'm not quite sure where to start. All I know is that I'm looking for a method of analyzing article text to determine its relevance to the federal court, and nothing else. I imagine this will entail some machine learning, but I've basically got no experience in the field. I've done a little reading into things like tf-idf weighting, vector space modeling, and word2vec (+ CBOW and Skip-Gram models), but I'm not quite seeing a \"big picture\" yet that shows me how just how applicable these concepts can be to my problem. Can anyone point me in the right direction?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":336,"Q_Id":55403920,"Users Score":1,"Answer":"There are many many ways to do this, and the best method changes depending on the project. Perhaps the easiest way to do this is to keyword search in your articles and then empirically choose a cut off score. Although simple, this actually works pretty well, especially in a topic like this one where you can think of a small list of words that are highly likely to appear somewhere in a relevant article. \nWhen a topic is more broad with something like 'business' or 'sports', keyword search can be prohibitive and lacking. This is when a machine learning approach might start to become the better idea. If machine learning is the way you want to go, then there are two steps:\n\nEmbed your articles into feature vectors\nTrain your model\n\nStep 1 can be something simple like a TFIDF vector. However, embedding your documents can also be deep learning on its own. This is where CBOW and Skip-Gram come into play. A popular way to do this is Doc2Vec (PV-DM). A fine implementation is in the Python Gensim library. Modern and more complicated character, word, and document embeddings are much more of a challenge to start with, but are very rewarding. Examples of these are ELMo embeddings or BERT. \nStep 2 can be a typical model, as it is now just binary classification. You can try a multilayer neural network, either fully-connected or convolutional, or you can try simpler things like logistic regression or Naive Bayes.\nMy personal suggestion would be to stick with TFIDF vectors and Naive Bayes. From experience, I can say that this works very well, is by far the easiest to implement, and can even outperform approaches like CBOW or Doc2Vec depending on your data.","Q_Score":1,"Tags":"python,machine-learning,nlp,data-science","A_Id":55404739,"CreationDate":"2019-03-28T17:45:00.000","Title":"Concepts to measure text \"relevancy\" to a subject?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The requirement is that I have to trigger a SageMaker endpoint on lambda to get predictions(which is easy) but have to do some extra processing for variable importance using packages such as XGBoost and SHAP.\nI am able to hit the endpoint and get variable importance using the SageMaker Jupyter notebook. Now, I want to replicate the same thing on AWS lambda.\n1) How to run python code on AWS lambda with package dependencies for Pandas, XGBoost and SHAP (total package size greater than 500MB). The unzipped deployment package size is greater than 250 MB, hence lambda is not allowing to deploy. I even tried using lambda function from Cloud9 and got the same error due to size restrictions. I have also tried lambda layers, but no luck.\n2) Is there a way for me to run the code with such big packages on or through lambda bypassing the deployment package size limitation of 250 MB\n3) Is there a way to trigger a SageMaker notebook execution through lambda which would do the calculations and return the output back to lambda?","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":1517,"Q_Id":55463916,"Users Score":1,"Answer":"I found the 250MB limitation on AWS lambda size to be draconian. Only one file ibxgboost.so from xgboost package is already around 140 MB which leaves only 110Mb for everything else. That makes AWS lambdas useless for anything but simple \"hello world\" stuff.\n As an ugly workaround you can store xgboost package somewhere on s3 an copy it to the \/tmp folder from the lambda invocation routine and point your python path to it. The allowed tmp space is a bit higher - 500MB so it might work. \nI am not sure though if the \/tmp folder is not cleaned between the lambda function runs though.","Q_Score":6,"Tags":"python,amazon-web-services,aws-lambda,xgboost,amazon-sagemaker","A_Id":58662399,"CreationDate":"2019-04-01T21:36:00.000","Title":"How to run python code on AWS lambda with package dependencies >500MB?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"tl;dr: does anyone know any better way to accomplish basically the same thing as aliases since mine don't work?\nhey and thanks for reading,\nI have a raspberry pi where I'm trying to run a bot that only works on python 3.6 and up. Python only officially supports up to 3.5 on Raspberry Pi, so I had to manually compile it.\nAnyway, the bot I use calls \"python3\" in its coding, however Raspberry Pis come with 3.5, so calling \"python3\" actually calls Python 3.5, not 3.7. I tried deleting Python 3.5, but it then rather than calling Python 3.7, it just said that nothing named python3 exists.\nI tried using aliases to call it, but they don't work at all for some reason. I know I'm using the right syntax, and I did the update command for the file, but they just don't work.\nI know that's kind of a lot, but does anyone know any better way to accomplish basically the same thing as aliases since mine don't work? Or can anyone help me figure out what's wrong with my current coding for aliases?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":628,"Q_Id":55465936,"Users Score":1,"Answer":"It's not advisable to install an out-of-distribution Python version, and you can't expect system libraries to work with it.\nYour best bet is to upgrade to Raspbian Buster, as it comes with Python 3.7 as standard. Buster is still in testing phase and not due for release until the summer, but I've been using it for a while and it seems to work ok. I have had success upgrading the Lite image but not Desktop.\nTo upgrade, edit \/etc\/apt\/sources.list and replace stretch with buster, then run apt update; apt dist-upgrade and wait for it to do the upgrade, then reboot and you'll have python3 pointing at Python 3.7.","Q_Score":0,"Tags":"python,python-3.x,raspberry-pi,alias,aliases","A_Id":55492603,"CreationDate":"2019-04-02T02:04:00.000","Title":"How to get the python command to call python3.7?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"tl;dr: does anyone know any better way to accomplish basically the same thing as aliases since mine don't work?\nhey and thanks for reading,\nI have a raspberry pi where I'm trying to run a bot that only works on python 3.6 and up. Python only officially supports up to 3.5 on Raspberry Pi, so I had to manually compile it.\nAnyway, the bot I use calls \"python3\" in its coding, however Raspberry Pis come with 3.5, so calling \"python3\" actually calls Python 3.5, not 3.7. I tried deleting Python 3.5, but it then rather than calling Python 3.7, it just said that nothing named python3 exists.\nI tried using aliases to call it, but they don't work at all for some reason. I know I'm using the right syntax, and I did the update command for the file, but they just don't work.\nI know that's kind of a lot, but does anyone know any better way to accomplish basically the same thing as aliases since mine don't work? Or can anyone help me figure out what's wrong with my current coding for aliases?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":628,"Q_Id":55465936,"Users Score":2,"Answer":"Use a full path to your new python version to run it.\n\/full\/path\/to\/3.7\/python3.7\nWhat the path is will depend on the directions you followed and options picked when compiling the new python version.\nif you want it to work by simply typing python or python3 you will have to change the symbolic links to point to the new python version.","Q_Score":0,"Tags":"python,python-3.x,raspberry-pi,alias,aliases","A_Id":55466257,"CreationDate":"2019-04-02T02:04:00.000","Title":"How to get the python command to call python3.7?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a twisted web application which uploads files and encrypts them, returning the url+key to the user.\nI've been tasked with scaling this application. At the moment when there are more than 3-4 concurrent upload requests the performance will drop off significantly.\nI'm no Twisted expert but I assume this is due to it running in a single python process, being a high cpu application and the GIL?\nHow could I go about scaling this?\nIf this was a different framework such as Flask I would just put uwsgi in front of it and scale the number of processes. Would something similar work for Twisted and if so what tools are generally used for this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":259,"Q_Id":55483727,"Users Score":0,"Answer":"If you think you could throw uwsgi in front of the application, I suppose it is pretty close to shared-nothing. So you can run multiple instances of the program and gain a core's worth of performance from each.\nThere are a couple really obvious options for exactly how to run the multiple instances. You could have a load balancer in front. You could have the processes share a listening port. There are probably more possibilities, too.\nSince your protocol seems to be HTTP, any old HTTP load balancer should be applicable. It needn't be Twisted or Python based itself (though certainly it could be).\nIf you'd rather share a listening port, Twisted has APIs for passing file descriptors between processes (IReactorSocket) and for launching new processes that inherit a file descriptor from the parent (IReactorProcess).","Q_Score":1,"Tags":"python,twisted,scaling","A_Id":55485152,"CreationDate":"2019-04-02T21:19:00.000","Title":"How to scale a CPU bound Twisted application?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I use ...\\pserve development.ini --reload in my dev environment to restart my API when code change.\nThe doc says:\n\nAuto-template-reload behavior is not recommended for production sites\n as it slows rendering slightly; it\u2019s usually only desirable during\n development.\n\nBut the doc has no proposition for a production environment. What's the recommendation to reload, do I have to make it manually every time?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":167,"Q_Id":55495879,"Users Score":2,"Answer":"Yes, you will need to restart the service if you change anything in your config file.\nIf you know that you'll be changing things and don't want to restart it every time that happens, move some of your configs to a database and refactor your app to read from that. This won't be possible for everything, and you'll need to be careful that when an update happens it is applied correctly, but it can be done for some things.","Q_Score":1,"Tags":"python,pyramid","A_Id":55496324,"CreationDate":"2019-04-03T13:01:00.000","Title":"Deploy\/Reload code from python pyramid project in production","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've been getting a lot of spam emails from various colleges. I wrote a simple Python program to go through my emails, and find all the ones whose sender ends in .edu.\nThen, to delete it, I though I was supposed to add the \\\\Deleted flag to those emails using: Gmail.store(id, \"+FLAGS\", \"\\\\Deleted\"). This did not work, and some of them didn't even disappear from the inbox. \nAfter more research, I found that instead I had to use Gmail.store(id, \"+X-GM-LABELS\", \"\\\\Trash\"). \nSo I updated the program to use that, but now it doesn't see any of the emails that I previously added the \\\\Deleted flag to.\nIs there any way I can reset all those emails and then trash them afterward?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":371,"Q_Id":55525410,"Users Score":1,"Answer":"They should be in your All Mail folder. Use the WebUI and search for them and trash them, or select the \"[Gmail]\\All Mail\" folder (watch out for localization, this can change name for non-English users).","Q_Score":0,"Tags":"python,email,gmail,imaplib","A_Id":55544626,"CreationDate":"2019-04-04T21:47:00.000","Title":"Python imaplib recover emails with \\\\Deleted flag and move to trash","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to build python 64 bit from source on solaris10.\nAfter searching in net for a while. I tried using CFLAGS=-m64 LDFLAGS=-m64 while executing .\/configure.But getting errors like wrong ELFCLASS32\nTried the below \n.\/configure CFLAGS=-m64 LDFLAGS=-m64\nBut no luck. And make is throwing errror like \"make: Fatal error: Command failed for target `libinstall'\"\nI am suspecting this is regarding gcc\nTIA","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":210,"Q_Id":55557223,"Users Score":1,"Answer":"The problem is you are linking your 64-bit program with 32-bit libraries. That is what the WRONGELFCLASS error is all about.\nUnfortunately, the default on Solaris tends to be to generate 32-bit libraries. Make sure you generate 64-bit libraries with -m64 and use the file command on the generated .o files to verify they are 64-bit libraries. The 64-bit libraries are in subdirectory 64\/ for each library directory (such as \/usr\/lib\/64\/).","Q_Score":1,"Tags":"python,gcc,x86-64","A_Id":55858182,"CreationDate":"2019-04-07T08:53:00.000","Title":"How to build 64 bit python from source on solaris","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to backup a remote directory with a lot of files, and because of that, I need to compress it before downloading it. I can access this folder through SSH or FTP. The host is running on Linux.\nI have covered the downloading part with aioftp. I was using paramiko and tar Linux command for compressing the directory in the remote host, but instead, I want to use Python modules (from standard library or not) and avoid using Linux commands. Maybe a combination of paramiko to open the session, urllib to create the remote object and tarfile to compress it can make the job, but I haven't found the way.\nIn the end, I want a directory-backup.tar.gz in my localhost.\nHow can I accomplish that?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":565,"Q_Id":55564316,"Users Score":1,"Answer":"You have to compress the directory using tools on the server. \nUsing local Python code makes no sense. To compress the files locally, you would have to download the uncompressed files, compress them (with your local Python code), and upload the compressed archive, only to download it then again. That defies the purpose of the compression, right?\nIf you want to use Python code for compression, you would have to run the Python code on the server. Either by uploading the script and executing it on the server or by feeding the code to remote python process. I do not see much advantage of doing that over using ready-made tar command.","Q_Score":1,"Tags":"python,ssh,urllib,paramiko,tarfile","A_Id":55567385,"CreationDate":"2019-04-07T22:42:00.000","Title":"Pythonic way to compress a remote directory using SSH or FTP","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"using pip I installed new version of HtmlTestRunner in python 3.6, but while I run python file through command prompt its throws error. \n\nTraceback (most recent call last):\n File \"seleniumUnitTest.py\", line 3, in \n import HtmlTestRunner\n ModuleNotFoundError: No module named 'HtmlTestRunner'","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1410,"Q_Id":55565407,"Users Score":2,"Answer":"Using python program.py instead of python3 program.py fixed my problem in Windows 10.","Q_Score":2,"Tags":"python,python-3.x,selenium,selenium-webdriver","A_Id":65629114,"CreationDate":"2019-04-08T02:11:00.000","Title":"Already installed Html test runner but it shows error \"ModuleNotFoundError: No module named 'HtmlTestRunner' \"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to 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.\nI 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. \nNow 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.\nThanks in Advance.","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":330,"Q_Id":55575277,"Users Score":-1,"Answer":"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.\nAs 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.","Q_Score":0,"Tags":"python,raspberry-pi,deep-learning,iot","A_Id":55578897,"CreationDate":"2019-04-08T14:03:00.000","Title":"Is there any way to hide or encrypt your python code for edge devices? Any way to prevent reverse engineering of python code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Our package has a few example scripts that show how the package can be used.\nWhenever we make a breaking change in my package, the examples may need to be updated. Right now I need to manually keep track of this, by checking whether the example scripts still run. Is there some way to add a test_examples function to my unit testing setup that doesn't assert the return value of a specific function, but simply runs all (or specific) files in the examples folder and checks that these scripts complete without error?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":27,"Q_Id":55593421,"Users Score":0,"Answer":"This was much easier than I thought it would be. I simply needed to add a test function to my pytest setup that imported the example scripts. Since these scripts aren't protected by a, if __name__ == \"__main__\": statement, all content is run. If there are errors along the way, the import, and therefore the test, will fail.","Q_Score":0,"Tags":"python,python-3.x,pytest","A_Id":55594481,"CreationDate":"2019-04-09T12:54:00.000","Title":"Add automatic test to package examples","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I tried all combinations and nothing made import geohash work:\n\npip install geohash\npip3 install geohash\napt-get install python-dev\npip3 install python-geohash\n\nthe 4th one isn't even installing but threw an error on me saying:\nsrc\/geohash.cpp:538:20: fatal error: Python.h: No such file or directory\n #include \n ^\n compilation terminated.\n error: command 'x86_64-linux-gnu-gcc' failed with exit status 1","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1378,"Q_Id":55596971,"Users Score":1,"Answer":"Thanks @William D. Irons. The issue got fixed when I did sudo apt-get install libpython3.7-dev","Q_Score":0,"Tags":"python-3.x,geohashing","A_Id":55605164,"CreationDate":"2019-04-09T16:05:00.000","Title":"error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 while doing pip3 install python-geohash","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I hope you are all having an amazing day. So I am working on a project using Python. The script's job is to automate actions and tasks on a social media platform via http requests. As of now, one instance of this script access one user account. Now, I want to create a website where I can let users register, enter their credentials to the social media platform and run an instance of this script to perform the automation tasks. I've thought about creating a new process of this script every time a new user has register, but this doesn't seem efficient. Also though about using threads, but also does not seem reasonable. Especially if there are 10,000 users registering. What is the best way to do this? How can I scale? Thank you guys so much in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":292,"Q_Id":55602143,"Users Score":1,"Answer":"What is the nature of the tasks that you're running?\nAre the tasks simply jobs that run at a scheduled time of day, or every X minutes? For this, you could have your Web application register cronjobs or similar, and each cronjob can spawn an instance of your script, which I assume is short-running, to carry out a the automated task one user at a time. If the exact timing of the script doesn't matter then you could scatter the running of these scripts throughout the day, on seperate machines if need be.\nThe above approach probably won't scale well to 10,000 users, and you will need something more robust, especially if the script is something that needs to run continuously (e.g. you are polling some data from Facebook and need to react to its changes). If it's a lot of communication per user, then you could consider using a producer-consumer model, where a bunch of producer scripts (which run continously) issue work requests into a global queue that a bunch of consumer scripts poll and carry out. You could also load balance such consumers and producers across multiple machines.\nOf course, you would definitely want to squeeze out some parallelism from the extra cores of your machines by carrying out this work on multiple threads or processes. You could do this quite easily in Python using the multiprocessing module.","Q_Score":0,"Tags":"python,web-services,automation,httprequest,scale","A_Id":55603470,"CreationDate":"2019-04-09T22:21:00.000","Title":"How to serve a continuously running python script to multiple users (Social Media Bot)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Guies:\nI used python with netmiko module to save the configuration from our h3c switch,but it stopped at the \"NO MORE\" status, and the script stopped until timeout.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":113,"Q_Id":55647524,"Users Score":0,"Answer":"line vty 0 4\n screen-length 0\n^_^","Q_Score":0,"Tags":"python","A_Id":55648921,"CreationDate":"2019-04-12T08:31:00.000","Title":"using python netmiko to save h3c switch config and meet the no more","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm implementing an application that tracks the locations of Australia's sharks through analysing a Twitter dataset. So I'm using shark as the keyword and search for the Twitts that contains \"shark\" and a location phrase. \nSo the question is how to identify that \"Airlie Beach at Hardy Reef\" is the one that is correlated to \"shark\"? If it's possible, can anyone provide a working code of Python to demonstrate\u200b? Thank you so much!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":67,"Q_Id":55649003,"Users Score":1,"Answer":"If you've already used NER to extract a list of locations, could you then create a table of target words and assign probabilities of being the correct location? For example, you are interested in beaches not hospitals. If beach is mentioned within the location, the probability of being the correct location increases. Another hacky way of doing it might be determining the number of characters or tokens between the word shark and the location - hoping that the smaller the distance, the more likely the word is to be related to the actual attack.","Q_Score":0,"Tags":"python,nlp","A_Id":55653869,"CreationDate":"2019-04-12T09:53:00.000","Title":"Extract the most relevant location corresponding to a keyword","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Top Level Problem\nOur team has inherited a very large and brittle python 2 (and C,C++, few others) codebase that is very difficult and costly to update. Tons of dependencies. Very few tests. Adding behavior improvement and converting to python 3 both have appeared to be monumental tasks. Even making small changes for a new release we've had to revert many times as it's broken something.\nIt's a story of insufficient testing and its major technical debt.\nStill, the project is so big and helpful, that it seems a no brainer to update it than re-invent everything it does.\nSub Problem\nHow to add a massive amount of missing small tests. How can we automatically generate even simple input\/output acceptance unit tests from the high level user acceptance tests?\nAttempted Solution\nThere are about 50 large high level behavioral tests that this codebase needs to handle. Unfortunately, it takes days to run them all, not seconds. These exercise all the code we care the most about, but they are just too slow. (Also a nerdy observation, 80% of the same code is exercised in each one). Is there a way to automatically generate the input\/output unit tests from automatic stack examination while running these? \nIn other words, I have high level tests, but I would like to automatically create low level unit and integration tests based on the execution of these high level tests.\nMirroring the high level tests with unit tests does exactly zero for added code coverage, but what it does do is make the tests far faster and far less brittle. It will allow quick and confident refactoring of the pieces.\nI'm very familiar with using TDD to mitigate this massive brittle blob issue in the first place as it actually speeds up development in a lot of cases and prevents this issue, but this is a sort of unique beast of a problem to solve as the codebase already exists and \"works\" ;).\nAny automated test tool tips? I googled around a lot, and I found some things that may work for C, but I can't find anything for python to generate pytests\/unittest\/nose or whatever. I don't care what python test framework it uses (although would prefer pytest). I must be searching the wrong terms as it seems unbelievable a test generation tool doesn't exist for python.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":51,"Q_Id":55671363,"Users Score":0,"Answer":"I've taken a very lazy and practical imperfect solution, and it took me about 40hrs: 20 of which was wrapping my head around the C part enough to write unit tests for it and fix it, which amounted to about 30 lines -- the other 20 was fixing mostly trivial bytes\/strings issues that futurize couldn't possbly handle and setting up CI.\n\nRun futurize\nRun the most desirable use case as an E2E test and fix issues, complete with new critical unit tests\nCI w\/ tox on 2.7\/3.x for these \n\nEnd result is an unchanged 2.7 codebase and a minimally working beta 3.7 codebase, the long tail 3.7 support for secondary use cases to be solved over time, see Dirk's long term answer.","Q_Score":1,"Tags":"python,unit-testing,testing,automated-tests","A_Id":56344375,"CreationDate":"2019-04-14T01:57:00.000","Title":"Automatic low level testing generation based on high level desired behavioral examples","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Top Level Problem\nOur team has inherited a very large and brittle python 2 (and C,C++, few others) codebase that is very difficult and costly to update. Tons of dependencies. Very few tests. Adding behavior improvement and converting to python 3 both have appeared to be monumental tasks. Even making small changes for a new release we've had to revert many times as it's broken something.\nIt's a story of insufficient testing and its major technical debt.\nStill, the project is so big and helpful, that it seems a no brainer to update it than re-invent everything it does.\nSub Problem\nHow to add a massive amount of missing small tests. How can we automatically generate even simple input\/output acceptance unit tests from the high level user acceptance tests?\nAttempted Solution\nThere are about 50 large high level behavioral tests that this codebase needs to handle. Unfortunately, it takes days to run them all, not seconds. These exercise all the code we care the most about, but they are just too slow. (Also a nerdy observation, 80% of the same code is exercised in each one). Is there a way to automatically generate the input\/output unit tests from automatic stack examination while running these? \nIn other words, I have high level tests, but I would like to automatically create low level unit and integration tests based on the execution of these high level tests.\nMirroring the high level tests with unit tests does exactly zero for added code coverage, but what it does do is make the tests far faster and far less brittle. It will allow quick and confident refactoring of the pieces.\nI'm very familiar with using TDD to mitigate this massive brittle blob issue in the first place as it actually speeds up development in a lot of cases and prevents this issue, but this is a sort of unique beast of a problem to solve as the codebase already exists and \"works\" ;).\nAny automated test tool tips? I googled around a lot, and I found some things that may work for C, but I can't find anything for python to generate pytests\/unittest\/nose or whatever. I don't care what python test framework it uses (although would prefer pytest). I must be searching the wrong terms as it seems unbelievable a test generation tool doesn't exist for python.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":51,"Q_Id":55671363,"Users Score":1,"Answer":"First, good you have already some higher level test running. Parallelize their execution, run each on different hardware, buy faster hardware if possible - as the refactoring task you are about to handle seems to be huge, this will still be the cheapest way of doing it. Consider breaking down these higher level tests into smaller ones.\nSecond, as lloyd has mentioned, for the components you plan to refactor, identify the component's boundaries and during execution of the higher level tests record input and output values at the boundaries. With some scripting, you may be able to transform the recorded values into a starting point for unit-test code. In only rare cases this will end up being useful unit-tests immediately: Normally you will need to do some non-trivial architectural analysis and probably re-design:\n\nWhat should be the units to be tested? Single methods, groups of methods, groups of classes? For example, setter methods can not sensibly be tested without other methods. Or, to test any method, first a constructed object will have to exist, and thus some call to the constructor will be needed.\nWhat are the component's boundaries? What are the depended-on-components? With which of the depended-on-components can you just live, which would need to be mocked? Many components can just be used as they are - you would not mock math functions like sin or cos, for example.\nWhat are the boundaries between unit-tests, that is, at which points in the long-running tests would you consider a unit-test to start and end? Which part of the recording is considered setup, which execution, which verification?\n\nAll these difficulties explain to me, why some generic tooling may be hard to find and you will probably be left to specifically created scripts for test code generation.","Q_Score":1,"Tags":"python,unit-testing,testing,automated-tests","A_Id":55778415,"CreationDate":"2019-04-14T01:57:00.000","Title":"Automatic low level testing generation based on high level desired behavioral examples","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm migrating a python application from an ubuntu server with locale en_US.UTF-8 to a new debian server which comes with C.UTF-8 already set by default. I'm trying to understand if there would be any impact but couldn't find good resources on the internet to understand the difference between both.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":44376,"Q_Id":55673886,"Users Score":0,"Answer":"I can confirm there is effect on different locales (C.UTF8 vs en_US.UTF8). I recently deployed one python program into a new server, and it performed differently. The old and new servers are both Ubuntu 18 servers, and the only difference is the locale (C.UTF8 vs en_US.UTF8). After setting the locale in new server as C.UTF8, they behave the same now.\nIt is easy to set the locale for a single application in Linux environment. You just need to add export LANG=C.UTF8; before your application. Assume you execute you application as python myprogram.py, then you type:\nexport LANG=C.UTF8; python myprogram.py","Q_Score":45,"Tags":"python,linux,docker,debian,locale","A_Id":68593911,"CreationDate":"2019-04-14T09:42:00.000","Title":"What is the difference between C.UTF-8 and en_US.UTF-8 locales?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm migrating a python application from an ubuntu server with locale en_US.UTF-8 to a new debian server which comes with C.UTF-8 already set by default. I'm trying to understand if there would be any impact but couldn't find good resources on the internet to understand the difference between both.","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":44376,"Q_Id":55673886,"Users Score":42,"Answer":"In general C is for computer, en_US is for people in US who speak English (and other people who want the same behaviour).\nThe for computer means that the strings are sometime more standardized (but still in English), so an output of a program could be read from an other program. With en_US, strings could be improved, alphabetic order could be improved (maybe by new rules of Chicago rules of style, etc.). So more user-friendly, but possibly less stable. Note: locales are not just for translation of strings, but also for collation (alphabetic order, numbers (e.g. thousand separator), currency (I think it is safe to predict that $ and 2 decimal digits will remain), months, day of weeks, etc.\nIn your case, it is just the UTF-8 version of both locales.\nIn general it should not matter. I usually prefer en_US.UTF-8, but usually it doesn't matter, and in your case (server app), it should only change log and error messages (if you use locale.setlocale(). You should handle client locales inside your app. Programs that read from other programs should set C before opening the pipe, so it should not really matter.\nAs you see, probably it doesn't matter. You may also use POSIX locale, also define in Debian. You get the list of installed locales with locale -a.\nNote: Micro-optimization will prescribe C\/C.UTF-8 locale: no translation of files (gettext), and simple rules on collation and number formatting, but this should visible only on server side.","Q_Score":45,"Tags":"python,linux,docker,debian,locale","A_Id":55693338,"CreationDate":"2019-04-14T09:42:00.000","Title":"What is the difference between C.UTF-8 and en_US.UTF-8 locales?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm migrating a python application from an ubuntu server with locale en_US.UTF-8 to a new debian server which comes with C.UTF-8 already set by default. I'm trying to understand if there would be any impact but couldn't find good resources on the internet to understand the difference between both.","AnswerCount":4,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":44376,"Q_Id":55673886,"Users Score":7,"Answer":"There might be some impact as they differ in sorting orders, upper-lower case relationships, collation orders, thousands separators, default currency symbol and more.\nC.utf8 = POSIX standards-compliant default locale. Only strict ASCII characters are valid, extended to allow the basic use of UTF-8\nen_US.utf8 = American English UTF-8 locale. \nThough I'm not sure about the specific effect you might encounter, but I believe you can set the locale and encoding inside your application if needed.","Q_Score":45,"Tags":"python,linux,docker,debian,locale","A_Id":55676870,"CreationDate":"2019-04-14T09:42:00.000","Title":"What is the difference between C.UTF-8 and en_US.UTF-8 locales?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am using libclang in Python to construct the AST of some source code. It occurs segmentation fault(core dumped) error for few files. Then I try the command in terminal clang -fmodules -fsyntax-only -Xclang -ast-dump + file. The error occurs, too. I believe clang crashed. (I do not know why, If you know how to solve it, please tell me). Because only few files cause this error. I want to ignore them and use try...except statement in python, but this statement does not work, this error still occurs and code running interrupts directly instead of running code in except. How can I delete the source file which causes error and continue to construct the AST for other files?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":271,"Q_Id":55685941,"Users Score":0,"Answer":"segmentation fault (core dumped) means that the python interpreter has completely stopped (because of a bug in libclang probably). try...except will not catch this.\nYour best bet is to create a bug report for libclang, and attach a file which causes the error.\nThe only other options is to run libclang in a separate process for each file, and ignore any results if the process terminates.","Q_Score":1,"Tags":"python,segmentation-fault,clang","A_Id":55686031,"CreationDate":"2019-04-15T09:13:00.000","Title":"Python & clang: try...except statement not working for segmentation fault(core dumped)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to know the equivalent of the julia type \"symbols\" in Python because i am trying to translate a code that i am working on, from julia to Python.\nThank you","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":702,"Q_Id":55694376,"Users Score":0,"Answer":"Use strings instead. What do symbols do that strings don't do?","Q_Score":1,"Tags":"python,julia","A_Id":55694480,"CreationDate":"2019-04-15T17:21:00.000","Title":"Symbols and its equivalent in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Jupyter notebook called \"Visual Magnitude.ipynb\" on my Windows box. I've used this notebook for several years. It's under CM control (perforce is our CM tool). Normally I don't have it checked out, so it's marked as read-only on the file system. Sometimes I open it up (knowing it's read-only), add a few cells, look at some results, and close it out, knowing the new cells won't be saved. This is ok. \nBut lately I've run into a situation where I forgot to check it out of perforce first, then added\/modified some cells. When I went to save it Jupyter complained it was read-only. So I checked it out (thus removing the read-only status on the file system). Jupyter still doesn't recognize this. So I quit Jupyter all together and restart it with the notebook (which is now writable). But Jupyter refuses to recognize this and still treats it as if it were locked. Almost as if it's caching the file status in some location.\nI've rebooted and still have the same problem. What am I missing to convince Jupyter that this notebook is now writable?\nI'm using Jupyter 4.4.0.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":143,"Q_Id":55697454,"Users Score":0,"Answer":"It turns out that there was a hidden file .~Visual Magnitude.ipynb in the same folder that was still marked read only. Once I deleted that everything was fine.","Q_Score":1,"Tags":"python-3.x,jupyter-notebook","A_Id":55748769,"CreationDate":"2019-04-15T21:24:00.000","Title":"Jupyter notebook won't let me save itself","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to programming. I think I'm close to solving my issue, but it finally broke my brain and I need help. \nI am running a pygame script as a scheduled task in crontabs. I have one code that executes successfully and does what it should. I have another code that executes, but when it does the screen goes blank, usually displaying some lines that I usually see when the Linux boots up, and it just stays stuck there.\nI have gone through both codes and absolutely everything is similar and correct. I have #!\/usr\/bin\/env python at the start of each script.\n(Elsewhere it was recommended that I give the exact version, because I use dictionaries in my script and apparently crontab could get confused with the dictionary stuff that pygame uses. I don't fully understand, I tried it but it didn't work on my raspberry pi so I don't think that's the solution.)\nEach script runs fine in the terminal.\nI have set the PATH variable to the one that the python script uses and also set the SHELL to \/bin\/bash. In the task I also have \"export DISPLAY=:0\" (e.g. 12 21 * * * export DISPLAY=:0 && ...). I have found this was the magic trick that got the other code to work. Which made me wonder if there is another environment variable that I need to set in the task? \nThe difference between the first code and the second code: The second code uses pygame.mixer and plays sound files. In the script, the sound files are in dictionaries (e.g. sound = {\"word\" : \"\/absolute\/path\/to\/file.wav\", \"word2\" : ...etc} As I said this code runs fine in terminal.\nSo why does the one script work and not the other. Both use pygame. The other just uses sound, dictionaries instead of strings, and pygame.mixer as well. My reasoning is that there is an issue with crontab getting stuck on one of these things.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":412,"Q_Id":55698386,"Users Score":0,"Answer":"I fixed it. I was running it out of root. When I ran the crontab in the user it worked. It must be because the root couldn't get at the files.\nImportant tips is to add 'import os' and at some point in the script add 'print(os.environ)' to check all the environment variables when it runs in terminal.\nThen copy the $PATH variables to the top of the crontab jobs.\nSame with $SHELL.\nThe $DISPLAY variables need to be put in the line, so for example '* * * * * export DISPLAY=:0 && \/usr\/bin\/python \/home\/user\/file.py'\nSee how I put absolute paths for both the command and the path to file. I also set absolute paths to files in the script, even if the files are in the same folder as the script. I'm not sure if this is necessary I will check that next. I've seen a lot of people struggle with this issue and the advice usually comes down to these things.","Q_Score":0,"Tags":"python,dictionary,cron,pygame","A_Id":55755005,"CreationDate":"2019-04-15T23:08:00.000","Title":"Crontab executes python script but something is wrong","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to keep reports in different directory every time the execution is done, but it should be done dynamically in automation execution itself\nspecifying the reports directory path in command line execution is not the one I am looking for, that is there but it needs manual input to place the reports in particular directory.","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":803,"Q_Id":55705787,"Users Score":2,"Answer":"Once the test starts running you cannot change the location of the outputs. Your only solution is to use a command line option.","Q_Score":0,"Tags":"python,python-2.7,robotframework","A_Id":55708405,"CreationDate":"2019-04-16T10:15:00.000","Title":"How to make reports dynamically categorised in robot framework?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'd like to use eclipse and PyDev as my Python development environment. I have downloaded the eclipse installer (2019-03 version), however this presents options for \"Java Developers\", \"C\/C++ Developers\", \"PHP Developers\", etc., with no option for Python developers.\nI'm thinking each of the available options may include large amounts of functionality I don't need, leading to a bloated install. So, which is the most stripped-back minimum install that I can install the PyDev plugin over?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":833,"Q_Id":55709550,"Users Score":0,"Answer":"There are a couple of options for using Eclipse as an IDE for a Python interpreter. It is worth pointing out the following points with respect to PyDev, the plugin that may be used in Eclipse...\n\nYou can use the latest version of Eclipse. You don't need Eclipse Neon, for example.\nYou need to install a working version of Python, I used 3.8.1.\nWhen opening your new Eclipse workspace be sure to click on the marketplace link so that you can search and install PyDev, the plugin you will be using within Eclipse.\nOnce PyDev is successfully installed, be sure your preferences acknowledge that the interpreter is in fact Python in Eclipse: Eclipse >> PyDev >> Interpreter - Python\nFrom here you can create and build applications using .py file extension where right clicking your code results in running the selected code.","Q_Score":0,"Tags":"python,eclipse,pydev,eclipse-installer","A_Id":59812927,"CreationDate":"2019-04-16T13:37:00.000","Title":"What is the most lightweight eclipse install for PyDev project?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a testing file in \/dev\/shm\/testing.ini and a dev file in \/etc.\nIf I create two paster applications and trigger my tests, the **settings used in main method is getting overwritten by the 2nd one i.e. the dev one. How to overcome this?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":37,"Q_Id":55724789,"Users Score":1,"Answer":"They aren't overwriting each other - the main function is just called twice, each time with the settings from the respective ini file. If you want your testing.ini file to inherit some settings from the dev.ini file then you need to look at the include syntax supported by pastedeploy, but I'd recommend just defining each file separately and using the correct one at the appropriate time instead of setting up an inheritance hierarchy of settings.","Q_Score":0,"Tags":"python,pyramid","A_Id":55732625,"CreationDate":"2019-04-17T09:51:00.000","Title":"How to read 2 different ini files via paster get_app function in pyramid?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been given access to an Ubuntu machine running Apache 2.4.18 for the purpose of hosting a small web application I've developed in Flask. I'm a user without root privileges. The system administrator has kindly installed mod_wsgi for me, but this module is linked against the system python, which is version 2.7, and I'd like to use python >= 3.6. I've therefore compiled my own python 3.7 and my own mod_wsgi on this machine, and am having trouble getting Apache to use it. Is this possible?\nI've tried adding a LoadModule wsgi_module ...\/mod_wsgi-py37.cpython-37m-x86-64-linux-gnu.so line to var\/www\/html\/whatever\/.htaccess, but have learned that this is not allowed at the Directory level of the configuration. I've also tried using WSGIDaemonProcess user python-home=..., but this also causes Apache to return an Internal Server Error.\nTo make matters worse, I do not have permissions on var\/log\/apache2, so I can't see any Apache output except what it's serving.\nIs it possible to point Apache to my own mod_wsgi and python binaries without having access to the root configuration of Apache or the system? If not, are there any workarounds?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":93,"Q_Id":55728668,"Users Score":1,"Answer":"AFAIK you can only run Apache with a single version of mod_wsgi at any one time. This means that all apps must use the same version of Python, which is a problem I have run into before. I think your options are:\na) Persuade the sysadmin to switch to your version. It is fine to use a version of Python that is different to system Python.\nb) Have a look at something like Gunicorn. That is more separated from Apache, so will allow apps to use different versions of Python on the same server.","Q_Score":1,"Tags":"python,apache,mod-wsgi","A_Id":55728980,"CreationDate":"2019-04-17T13:27:00.000","Title":"Use custom mod_wsgi and python with limited access to a shared server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a RHEL system which by default was running Python2.7 and Python3.4 \nI needed Python3.6 for a project I wanted to work on and so I downloaded it and built it from source. I ran make and make install which hindsight may have been the wrong decision. \nNow I do not seem to have any internet connectivity. Does anyone know what I may have over written to cause this or at least where specifically I can look to track this issue down? \nNote: I can Putty into the Linux machine but it doesn't seem to have any other connectivity, specifically HTTPS","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":66,"Q_Id":55733530,"Users Score":0,"Answer":"It's a bit weird that this would break network connectivity. One possible explanation is that the system has networking scripts or a network manager that relies on Python, and it got broken after make install replaced your default Python installation. It may be possible to fix this by reinstalling your RHEL Python packages (sorry, cannot offer more detailed help there, as I don't have access to a RHEL box).\nI guess the lesson is \"be careful about running make install as superuser\". To easily install and manage different Python versions (separate from the system Python), the Anaconda Python distribution would be a good solution.","Q_Score":0,"Tags":"python-3.x,makefile,centos,redhat","A_Id":55734315,"CreationDate":"2019-04-17T18:01:00.000","Title":"RHEL 7.6 - Built Python3.6 from Source Broke Network","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a RHEL system which by default was running Python2.7 and Python3.4 \nI needed Python3.6 for a project I wanted to work on and so I downloaded it and built it from source. I ran make and make install which hindsight may have been the wrong decision. \nNow I do not seem to have any internet connectivity. Does anyone know what I may have over written to cause this or at least where specifically I can look to track this issue down? \nNote: I can Putty into the Linux machine but it doesn't seem to have any other connectivity, specifically HTTPS","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":66,"Q_Id":55733530,"Users Score":0,"Answer":"So after a lot of time slamming my head against the wall I got it worked out. My best guess is that the system (RHEL 7) relied on something from its default Python2.7 installation to handle SSL negotiations. Installing 3.6 alongside must have overwritten some pointer. Had I done this correctly, with altinstall all would have likely been fine.\nThe most frustrating part of this is that there were no error messages, connections just timed out. \nTo fix this, I had to uninstall all Python versions and then reinstalled Python2.7 - Once Python2 was back in the system it all seemed to work well.","Q_Score":0,"Tags":"python-3.x,makefile,centos,redhat","A_Id":55763685,"CreationDate":"2019-04-17T18:01:00.000","Title":"RHEL 7.6 - Built Python3.6 from Source Broke Network","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"While I was reading aiohttp server documentation, I came across this \nWarning\nUse add_static() for development only. In production, static content should be processed by web servers like nginx or apache.\nWhy cant we use aiohttp to serve static files?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":813,"Q_Id":55749618,"Users Score":4,"Answer":"Why cant we use aiohttp to serve static files?\n\nYou can use aiohttp to serve static, but you shouldn't.\nWeb frameworks like aiohttp are specialized in providing convenient API to create dynamically generated responses (like web pages). They aren't specialized in serving responses with most efficiency and security.\nServers like NGINX on the other hand are specialized in serving things. They can do it more efficiently (C code speed, multiple cores utilization, caching) and secure (protection from common attacks, IP filtering, etc.).\nSince static files aren't dynamically generated there's no need to involve aiohttp in serving them. Specialized server will handle their serving much better. It's a common practice to delegate this job to them.","Q_Score":2,"Tags":"python-3.x,python-asyncio,aiohttp","A_Id":55750115,"CreationDate":"2019-04-18T15:47:00.000","Title":"why cant we use aiohttp to serve static files for production?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I receive data with an Raspberry Pi3 from another device with an ATMEGA 8 Chip via serial port, what I receive should look like : #00 341 341 332 13123 R-? ...\nBut what I receive on my Raspberry is:\nb'\\xff\\xfa\\xfd\\xff\\xff\\xff\\xff\\xff\\xff\\xfd\\xff\\xea~\\xf8\\xff\\xfe\\xfe\\xff\\xd5\\xff\\xfe\\xfd\\xff\\xff\\xfd\\xff\\xff\\xff'\nMy port config:\nport = serial.Serial(\"\/dev\/ttyAMA0\", baudrate=115200, timeout=3.0)\nHow do I decode this or do you have any other suggestions?\nI already tried to encode to utf-8, ascii etc. \nI also tried codecs.\nI just got errors or some more disturbing data. Nothin I can work with.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":337,"Q_Id":55760510,"Users Score":0,"Answer":"Your baudrate is big, try it with a regular value like 9600, also verify you have the same baudrate on both side.","Q_Score":0,"Tags":"python,raspberry-pi,serial-port,decode,uart","A_Id":55760785,"CreationDate":"2019-04-19T10:35:00.000","Title":"Why do I receive unreadable data via serial Port on Raspberry Pi?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"what is best and easy way for convert maya py (python) to pyd ? \nI had explored in this field, but unfortunately none of them was effective and after convert to pyd I can't import my code into Maya.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":190,"Q_Id":55769570,"Users Score":0,"Answer":"pyd files contain native binary python extensions, usially developped using Python C API and some native language.\ncython might be the simplest tool that might help you creating pyd by compiling a subset of Python source code.\nWhat are you trying to achieve ?","Q_Score":0,"Tags":"python,maya","A_Id":55935788,"CreationDate":"2019-04-20T01:49:00.000","Title":"what is best way for convert maya py (python) to pyd?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to extract audio track information (specifically language of the audio) from a live stream that i will be playing with libVLC . Is it possible to do this in javascript or python without writing new code for a wrapper?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":74,"Q_Id":55780457,"Users Score":0,"Answer":"Not sure about javascript, but the Python wrapper will let you do this.","Q_Score":0,"Tags":"javascript,python,node.js,libvlc","A_Id":55788853,"CreationDate":"2019-04-21T06:29:00.000","Title":"Is it possible to get audio track data from libVLC by using javascript\/python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to use a python module in a C++ project I'm developing in VS2019 and seem unable to link it. I've added my Python37-32\/Includes directory to the Additional Include Directories, added my Python37-32\/Libs folder to my Additional Library Directories and Python37-32\/Libs to my Additional Dependencies yet still get an error. The error is LNK1181: cannot open input file 'C:\\Python37-32\\libs.obj'. I've tried numerous fixes including : deleting configurations and removing the libs directory from Additional Dependencies however this often results in numerous undefined Python functions which obviously indicate the library isn't being linked.\nHow would I go about linking this correctly?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":650,"Q_Id":55785768,"Users Score":0,"Answer":"I've found the solution. My configuration was correct without Additional Dependencies however my version of Python being referenced was 32-bit on a 64-bit build.","Q_Score":0,"Tags":"python,c++,visual-studio","A_Id":55786603,"CreationDate":"2019-04-21T18:56:00.000","Title":"How to link Python3.7 to VS2019 C++ Project","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My use case needs to store the data on a disk immediately when the data is available. I'm using Raspberry PI and few lasers. Once the laser is activated\/deactivated timestamp is taken and it should be stored on the disk. Data is only stored when lasers are \"armed\". They can also be in \"idle\" state (they're still working, but timestamps are ignored). Also, lasers can be armed\/disarmed multiple times. \nWhat would be the most efficient way of doing this? Using plane csv\/xml\/txt or something else? Actual SD card that is used in RPI is limited to 8GB. \nAnother question, when using open() method, should i close() the file once i executed write() method or should I keep it open as long as the script itself is running (script is running all the time until user decides to quit)?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":33,"Q_Id":55791341,"Users Score":0,"Answer":"Sounds like python?\nIf so, you can write to your file using with:\n\nwith open('\/path', 'w') as f:\n f.write('stuff')\n\nand the file descriptor will close automatically when execution exits the block.\nHowever, regarding your other questions it depends on your use case. Why does it need to be available immediately? Will another process be reading it? How quickly will this be happening? Are there any other bits of data you need to save along with the timestamp - presumably whether the laser is on or off at that time?\nLikely, a good solution for you would be a lightweight database such as SQLite. The storage on disk is approximately what it would be in a \"flat\" file, such as the .txt or .csv you reference. It will be fast. And it eliminates concern about managing the actual writing.","Q_Score":0,"Tags":"python-2.7,persistence","A_Id":55791537,"CreationDate":"2019-04-22T08:22:00.000","Title":"Persistent storage of data?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to run a Selenium Script (Using PHP) using a Webserver.\nI'm working on Kali and to simulate the Webserver I use Xampp.\nI tried to run the selenium script on Xampp by the following steps:\n-Download the Php Webdriver Bindings, put them in the folder 'htdpcs' of xampp and edit the 'example.php' file following the settings of my own device.\n-Download and execute the Selenium Server Standalone, on port :4444.\nIn the end, I download the geckodriver and I execute the file, but I got the this error:\nOSError: [Errno 98] Address already in use\nHow to fix it in order to run the php-selenium script?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":269,"Q_Id":55816936,"Users Score":0,"Answer":"The Selenium Server will fork a geckodriver as soon as it needs one to start a new browser session. You should not start a geckodriver yourself. If you want to use its Webdriver API yourself you can start it with the --webdriver-port argument.","Q_Score":0,"Tags":"python,selenium,selenium-webdriver","A_Id":55820106,"CreationDate":"2019-04-23T17:59:00.000","Title":"Selenium Servers and Geckodriver don't run at same port","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"When we import a module in a Python script, does this copy all the required code into the script, or does it just let the script know where to find it?\nWhat happens if we don't use the module then in the code, does it get optimized out somehow, like in C\/C++?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":830,"Q_Id":55819621,"Users Score":2,"Answer":"None of those things are the case.\nAn import does two things. First, if the requested module has not previously been loaded, the import loads the module. This mostly boils down to creating a new global scope and executing the module's code in that scope to initialize the module. The new global scope is used as the module's attributes, as well as for global variable lookup for any code in the module.\nSecond, the import binds whatever names were requested. import whatever binds the whatever name to the whatever module object. import whatever.thing also binds the whatever name to the whatever module object. from whatever import somefunc looks up the somefunc attribute on the whatever module object and binds the somefunc name to whatever the attribute lookup finds.\nUnused imports cannot be optimized out, because both the module loading and the name binding have effects that some other code might be relying on.","Q_Score":1,"Tags":"python,python-3.x,import,module,sys.path","A_Id":55819684,"CreationDate":"2019-04-23T21:25:00.000","Title":"Does Python import copy all the code into the file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm building a event detector for Twitter and it's being extremely affected by spam tweets, so I'm planning to filter tweets a little bit with a text similarity algorithm.\nThe approach I have thinked about is to have a set of tweets where I will store the different tweets. First of all I will clear links and mentions from the tweets, and check if the tweet I'm processing has a similarity value with any of the tweets of the set greater than a threshold (0.7-0.8 for example). If that's the case, I will continue the iteration and ignore that tweet; otherwise I will add that tweet to the set and work with it.\nI have been reading different answers to related questions but they were only for small corpuses of text, while this will work with a dataset of at least 15.000 tweets more or less, so the algorithm will be comparing between every tweet and the set of tweets 15.000 times.\nAlso other questions are a bit old, and new algorithms may have been created or better implementations of older ones may have appeared.\nIn conclusion, what do you think is the best way to afront this spam problem? Would it be a Python native one or an extern one?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":502,"Q_Id":55827975,"Users Score":1,"Answer":"to find similarity you can use tf-idf vectors and then calculate cosine similarity between them, but it's a large number of vectors to compare so you can cluster your data and find a center vector for each cluster, so you just need to compare your new tweet with center vectors not all of them.","Q_Score":0,"Tags":"python,string,text,twitter,similarity","A_Id":55828138,"CreationDate":"2019-04-24T10:32:00.000","Title":"Get similarity between text and the texts of a set in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Flask python app running on IBM cloud. The app needs some configuration parameter which it gets from a configuration file. I need to encrypt the configuration file using a symmetric key. How can I do that and where I can store my decrypt key? Ideally I don't want to hard code it into my code.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":24,"Q_Id":55838341,"Users Score":0,"Answer":"12 Factor question. Embed it in the app's deployment environment variables and read the value at runtime.","Q_Score":0,"Tags":"python,ibm-cloud,encryption-symmetric","A_Id":55838704,"CreationDate":"2019-04-24T20:48:00.000","Title":"How to secure a configuration file in IBM Cloud","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to run only the which tests are marked as pytest.mark.skip\nIn my Test class i had marked few test cases are marked as skip. Now i want to run those tests only","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":929,"Q_Id":55872637,"Users Score":3,"Answer":"You could switch to using skipif conditioned on some environment variable.\ni.e.\n@pytest.mark.skipif(os.getenv('FORCE2RUN_SKIPPED_TEST')!='1')","Q_Score":1,"Tags":"python,pytest","A_Id":55873475,"CreationDate":"2019-04-26T17:44:00.000","Title":"How to run a test marked skip in pytest","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I made python script using Selenium webdriver. I use that script to login onto system of my faculty and looking on posts. Script refresh page every 60s to see if there is any new post, if there is new post I would recieve Telegram message on my phone. There is no problem with that, problem is that I have to run that script on my laptop 24h to get notifications, which is not possible since I carry it around. \nQuestion is, how can I run that script 24h? Is there any better solution to monitor that page and send messages if there is new post? \nI tried pythonanywhere but I don't have too much experience in that field so I didn't manage to make it work since always some module is missing...","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":905,"Q_Id":55889195,"Users Score":1,"Answer":"I'd just use a Windows virtual machine from AWS\/Microsoft Azure\/Google\/etc. This may be a bit overdoing it in your situation, but you could have one VM connected to another VM that'd be running your script, if it's something that requires an always-on user interface and can't be run in a Linux headless browser. \nInstalling something like AppRobotic personal macro edition on any of the above cloud services would work great. The pro version that's on AWS Marketplace would also work great, but it'd be overdoing it in your use case.","Q_Score":1,"Tags":"python,selenium,webautomation","A_Id":55889276,"CreationDate":"2019-04-28T10:09:00.000","Title":"How to run python script with selenium all the time but not on my PC","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I made python script using Selenium webdriver. I use that script to login onto system of my faculty and looking on posts. Script refresh page every 60s to see if there is any new post, if there is new post I would recieve Telegram message on my phone. There is no problem with that, problem is that I have to run that script on my laptop 24h to get notifications, which is not possible since I carry it around. \nQuestion is, how can I run that script 24h? Is there any better solution to monitor that page and send messages if there is new post? \nI tried pythonanywhere but I don't have too much experience in that field so I didn't manage to make it work since always some module is missing...","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":905,"Q_Id":55889195,"Users Score":1,"Answer":"Welcome !\nThe best way for you would be to use a server so you don't have to run it locally on your computer.\nYou can use an online VPS on which you install your software or you may even try to run it locally on something like a Raspberry Pi.\nIn both case, you will have to deal with linux commands.\nGood luck","Q_Score":1,"Tags":"python,selenium,webautomation","A_Id":55889236,"CreationDate":"2019-04-28T10:09:00.000","Title":"How to run python script with selenium all the time but not on my PC","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to program a Raspberry Pi to take a single keyboards inputs in one USB port and then output through the Pi's two other USB ports in order to control two Macs at once with one keyboard.\nI'm very new to Python. Which functions and commands do I need in order to program this function to my Pi?\nI've been searching for the proper command, but I came here for help.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":55892458,"Users Score":0,"Answer":"This isn't exactly something easily done with Python. This is because you're delving into developing device drivers on your Macs' side. Please allow me to explain:\nAssuming you're using Raspbian on the Raspberry Pi (a flavor of Linux, and thus a Posix system onto itself), you would need to read the appropriate \/dev\/tty* file which maps to your keyboard first, and then appropriately convert and write out to the appropriate \/dev\/usb* files. Do note, most computers also send handshakes back and forth to the USB devices (for example, to register them on their own USB busses).\nTo be frank, you'd probably have better luck splicing wires from your keyboard, and connecting it to another USB male-socket, and then plugging both male-socket ends into your Macs.","Q_Score":0,"Tags":"python","A_Id":55892585,"CreationDate":"2019-04-28T16:44:00.000","Title":"Raspberry Pi Keyboard Splitter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I try to check appium version with 'appium -v' I receive command not found. What can I do? \nI tried different options but it's not working","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2575,"Q_Id":55902054,"Users Score":1,"Answer":"If you are on Mac OS try\n\nappium --version","Q_Score":0,"Tags":"python-appium","A_Id":69764939,"CreationDate":"2019-04-29T11:06:00.000","Title":"When I try to check appium version with 'appium -v' I receive command not found. What can I do?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have forked a project in Gitlab to my own namespace. I want to create a new branch of that project that mirrors the original repo's master but I do not want to set a remote in my forked repo nor do I want to track that branch. Is there any way I can do it?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":117,"Q_Id":55905036,"Users Score":3,"Answer":"git checkout -b my_branch --no-track \/master","Q_Score":0,"Tags":"git,gitpython","A_Id":55905117,"CreationDate":"2019-04-29T14:03:00.000","Title":"Checkout a remote branch without tracking it","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been working on a projects and I'm trying to use as minimal modules as I can (only basics like Numpy). I want to get accurate GPS data, I'm pretty sure that my computer has location service because I can turn int on in my settings. I know it possible if you use an arduino with gps shield and communicate with it over the serial connection but I would like to have just a script instead of a bunch of hardware. \nIn Short I'm using python 3. How can I retrieve my location using a python script?","AnswerCount":3,"Available Count":1,"Score":-0.0665680765,"is_accepted":false,"ViewCount":839,"Q_Id":55905298,"Users Score":-1,"Answer":"you can use the google geolocation API for this!!","Q_Score":0,"Tags":"python,python-3.x,gps","A_Id":55905401,"CreationDate":"2019-04-29T14:18:00.000","Title":"How to get data from your internal gps with python 3?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In C++ there are .h and .cpp files for design and implementation of code respectively. Is there a similar way to structure files in Python? Can I define my class in one file, and then put all the code for that class in another?\nI feel like the answer is \"no\". I've tried looking up the answer, but the closest results were just how to merge c++ and python.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":548,"Q_Id":55910940,"Users Score":0,"Answer":"It would be much less worthwhile to do than in c++ because as AlexG mention python is not a compiled language. However, you could achieve a \"similar\" effect by linking to another python file. For example, if you wanted to have all of your functions created in a single file, and all of your logic done using those functions in another you would simply use import filename and you could reference your functions in the second file like you would in a .h and .cpp file.","Q_Score":0,"Tags":"python,c++","A_Id":55911047,"CreationDate":"2019-04-29T21:19:00.000","Title":"Is there a Python version of .h and .cpp files?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Do I need an actual mailbox and verified email to send email with SES?\nI own the domain I am trying to send from, but I do not have an account or mailbox setup (this is just a test domain, and I don't want to setup a gmail mailbox) \nIs there a better way to be doing this in a test environment?\nI am using the django-ses package, and sending email like this:\nsend_mail('Test subject', 'This is the body', 'mypersonalemail@yahoo.com',['info@mydomain.com'])\nI very well may have a fundamental misunderstanding of sending email, so any help is appreciated!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":455,"Q_Id":55912101,"Users Score":1,"Answer":"In the test environment, you can send messages e-mail only to address registered in sandbox.","Q_Score":0,"Tags":"python,django,email,amazon-ses","A_Id":55912134,"CreationDate":"2019-04-29T23:40:00.000","Title":"Send email via SES","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to write a simple Python application to manage muted words for Twitter. The interface in the browser and the application are cumbersome to use.\nLooking through the API documentation, it seems that it is possible to create and destroy muted users but not words. Am I missing something, or is this simply not possible?\nI have been trying the python-twitter library but the functionality is missing there too. I realise this is probably an API limitation as opposed to the library.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":404,"Q_Id":55916527,"Users Score":3,"Answer":"No, this is not possible. The API only has methods for muting users, not words.","Q_Score":4,"Tags":"python,twitter","A_Id":55918277,"CreationDate":"2019-04-30T08:11:00.000","Title":"Is there a way to create and destroy muted words using the Twitter API","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created a simple python script which can give what kind of operating system it is using. But I want this script to run multiple remote machine at a same time without installing it on other machine on the same network. Is it possible to run this script on remote machine without installing this script on remote machine? . I saw with ssh python can do this .","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":771,"Q_Id":55927505,"Users Score":1,"Answer":"Based on the way your question is worded, I think the answer is no.\nIf you want to run a python script on a remote machine, you will need to have a python interpreter of some kind available on the remote machine to execute the code.","Q_Score":0,"Tags":"python,python-3.x,sockets,ssh","A_Id":55927622,"CreationDate":"2019-04-30T19:25:00.000","Title":"How to run python script on multiple remote machine? without installing the script?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a test case needed to access a .sh file. I used \nRun Process ${filename},but it threw the error OSError: [Errno 13] Permission denied . I tried to put chomod 777 before Run Process, but robot could not recognize it and robot took it as part of file path. Robot Anyone could help?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":676,"Q_Id":55938777,"Users Score":3,"Answer":"When you trying to run external commands via the Run process keyword,you have missed tab space.\nRun process chmod -R 777 yourfileName","Q_Score":0,"Tags":"python,automated-tests,robotframework","A_Id":55945288,"CreationDate":"2019-05-01T15:35:00.000","Title":"How to give .sh file read and write permission while use command \"run process\" in robot framework","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have to execute a .py file (python file) saved on my local machine (say @C:\\User\\abc\\dosomething.py) from postman from its pre-request section.\nEssentially I need to call the .py file from javascript code but from postman only.\nHow do I do that ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2506,"Q_Id":56002752,"Users Score":0,"Answer":"Unfortunately this is not possible. The Pre-request and test-scripts are executed in a sandbox environment.","Q_Score":1,"Tags":"python-2.7,postman","A_Id":56004157,"CreationDate":"2019-05-06T09:52:00.000","Title":"How to execute python script from postman?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I wish to have a touchsensor on the end of a moving arm. However, through the Python API, getDevice('touch_sensor') only returns sensors that are directly under the Robot parent. \nIs there a way I can either get a sensor that is nested (under a joint), or instead make a sensor that is under parent move in tandem with another joint?\nI have tried setting the bounding box of the sensor to a shape\/transform nested under the moving joint, but it simply takes on the original position of the shape and doesn't update when the joint moves.\nI have also tried putting the sensor directly under the joint, in which case it does indeed move, but then I cannot access it from the python API. (Using get device returns None)","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":143,"Q_Id":56022689,"Users Score":2,"Answer":"Found the problem, I should have used getTouchSensor instead of getDevice!!\nNow it works fine.","Q_Score":0,"Tags":"python,sensors,webots","A_Id":56023750,"CreationDate":"2019-05-07T12:29:00.000","Title":"How to get TouchSensor nested under joint in Webots (Python API)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Requirement:\n\nSending mail via SMTP(only via SMTP for specific reason) to the user which is read through event \"RunInstances\" from cloud-trail.\nAs SMTP code is not working with lambda I will have to kept inside EC2 and trigger it through lambda.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":512,"Q_Id":56025709,"Users Score":1,"Answer":"There are few options:\n\nUse SQS: Use Lambda to send messages to SQS, add workers in your EC2s to consume the messages.\nCreate a server in EC2 that listens to traffic from a port, for example: 80. Use Lambda to send HTTP requests to the EC2 server.\n(Not recommended for this case): Use Step Function Activity. Lambda to call step function, passes the input which is email content. The step function will run and create an activity. The EC2 instance will then have a worker implemented that keep polling activities from the Step function.","Q_Score":0,"Tags":"python,amazon-ec2,aws-lambda,boto3","A_Id":56031606,"CreationDate":"2019-05-07T15:15:00.000","Title":"Is there any way to trigger code inside EC2 from Lambda?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm evaluating test framework, lint and code coverage options for a new Python project I'll be working on. \nI've chosen pytest for the testing needs. After reading a bunch of resources, I'm confused when to use Sonarcube, Sonarlint , pylint and coverage.py.\nIs SonarLint and Pylint comparable? When would I use Sonarcube?\nI need to be able to use this in a Jenkins build. Thanks for helping!","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1964,"Q_Id":56045813,"Users Score":1,"Answer":"Sonarlint and pylint are comparable, in a way.\nSonarlint is a code linter and pylint is too. I haven't used sonarlint, but it seems that analyzes the code a bit deeper that pylint does. From my experience, pylint only follows a set of rules (that you can modify, by the way), while sonarlint goes a bit further analyzing the inner workings of your code. They are both static analyze tools, however.\nSonarcube, on the other hand, does a bit more. Sonarcube is a CI\/CD tool that runs static linters, but also shows you code smells, and does a security analysis. All of what I'm saying is based purely on their website.\nIf you would like to run CI\/CD workflows or scripts, you would use Sonarcube, but for local coding, sonarlint is enough. Pylint is the traditional way, though.","Q_Score":7,"Tags":"python,python-3.x,lint","A_Id":66343876,"CreationDate":"2019-05-08T17:07:00.000","Title":"Python - Difference between Sonarcube Vs pylint","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm evaluating test framework, lint and code coverage options for a new Python project I'll be working on. \nI've chosen pytest for the testing needs. After reading a bunch of resources, I'm confused when to use Sonarcube, Sonarlint , pylint and coverage.py.\nIs SonarLint and Pylint comparable? When would I use Sonarcube?\nI need to be able to use this in a Jenkins build. Thanks for helping!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1964,"Q_Id":56045813,"Users Score":0,"Answer":"Nicholas has a great summary of Pylint vs Sonarlint.\n(Personally I use the Sonarlint)\nAlthough the question is older, I thought I'd answer the other part of your question in case anyone else has the same question; internet being eternal and all.\nCoverage.py as it sounds, runs code coverage for your package. SonarQube then uses the report that coverage.py makes and does things with it and formats it in a way that the Sonar team decided was necessary. Coverage.py is needed if you want to use SonarQube for code coverage. However, if you just want the code smells from SonarQube, it is not needed.\nYou were also asking about when to use SonarQube, coverage.py, and Jenkins.\nIn Jenkins, you would create a pipeline with several stages. Something along the following lines:\n\nCheck out code (automatically done as the first step by Jenkins\nBuild code as it is intended to be used by user\/developer\nRun Unit Tests\nrun coverage.py\nrun SonarQube","Q_Score":7,"Tags":"python,python-3.x,lint","A_Id":69052886,"CreationDate":"2019-05-08T17:07:00.000","Title":"Python - Difference between Sonarcube Vs pylint","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wrote a python program which uses a module (pytesseract, specifically) and I notice it takes a few seconds to import the module once I run it. I am wondering if there is a way to initialise the module before running the main program in order to cut the duration of the actual program by a few seconds. Any suggestions?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":47,"Q_Id":56045872,"Users Score":0,"Answer":"One possible solution for slow startup time would be to split your program into two parts--one part that is always running as a daemon or service and another that communicates with it to process individual tasks.\nAs a quick answer without more info, pytesseract also imports (if they are installed) PIL, numpy, and pandas. If you don't need these, you could uninstall them to reduce load time.","Q_Score":0,"Tags":"python,python-3.x,python-2.7","A_Id":56046054,"CreationDate":"2019-05-08T17:11:00.000","Title":"Is it possible to initialise a module before running a python program?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wrote a python program which uses a module (pytesseract, specifically) and I notice it takes a few seconds to import the module once I run it. I am wondering if there is a way to initialise the module before running the main program in order to cut the duration of the actual program by a few seconds. Any suggestions?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":47,"Q_Id":56045872,"Users Score":0,"Answer":"I presume that you need to start your application multiple times with different arguments and you don't want to waste time on imports every time, right?\nYou can wrap actual code in while True: and use input() to get new arguments. Or read arguments from the file.","Q_Score":0,"Tags":"python,python-3.x,python-2.7","A_Id":56046145,"CreationDate":"2019-05-08T17:11:00.000","Title":"Is it possible to initialise a module before running a python program?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Just like the title says, I would like to turn on my raspberry pi and have it automatically open a terminal and that terminal would automatically start a python script. Preferably in a way where I can run 4 different terminals each running a different .py file.\nI have done the rc.local approach but the programs do not open in a terminal and that is essential for the functionality of the code. \nAny suggestions?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":149,"Q_Id":56048691,"Users Score":0,"Answer":"Edit the file found here:\n\/etc\/xdg\/lxsession\/LXDE\/autostart\nadd your commands to it\n@python PathToScript\/script.py\nEdit: I realize you want the terminal open. I believe this will work\n@lxterminal --command \"python pathToScript\/script.py\"","Q_Score":0,"Tags":"python,linux,raspberry-pi","A_Id":56048758,"CreationDate":"2019-05-08T20:37:00.000","Title":"How can I open a terminal and run a program in it automatically on my raspberry pi?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"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.\nMy 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)?\nI have thought about RDP, but I wanted to have your opinions also.\n(PS: FREE Service if it's possible, otherwise the lowest cost)\nThank you!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":724,"Q_Id":56056794,"Users Score":1,"Answer":"I would suggest you to setup AWS EC2 instance with whatever OS you want. \nFor beginner, you can get 750 hours of usage for free where you can run your script on.","Q_Score":0,"Tags":"python,web-services,monitoring,network-monitoring","A_Id":56057837,"CreationDate":"2019-05-09T09:52:00.000","Title":"How to make a python script run forever online?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In my CTF environment, if I want to access an application in a server, I have to perform SSH. Here's what it looks like:\n\n(my terminal) ssh username@ssh_ip\nenter password\n\nThe steps start to annoy me because if I have to access the same application more than once, I have to perform these steps multiple times.\nThus, I want to create a script that does this automatically, like '.\/run_everything', which will autorun everything and immediately brings me to the application CLI instantly.\nWhat kind of python library that can do this? I'm not asking for someone to make it for me, but more like asking for advice like what libraries to use and stuff.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":251,"Q_Id":56086866,"Users Score":1,"Answer":"Try python api of iTerm2 or use some packages like paramiko.","Q_Score":1,"Tags":"python,python-3.x","A_Id":56087036,"CreationDate":"2019-05-11T03:12:00.000","Title":"Script for SSH OverTheWire","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a script that reads from a google sheet and uses the information to create tickets using the Jira python api. In my situation it won't work to have the script be triggered at a certain time, the script has to be triggered through the sheet. Is there some way to detect a button press or a cell change which runs my local python file?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":948,"Q_Id":56107330,"Users Score":1,"Answer":"I had a similar problem. \nthere is a tool set call 'gspread', which can read from python data from your Google sheets.\nWhat I did is a script in the spread sheet, what filled a cell with \"Start + time\". You can trigger script with this with a button.\nNow the python program read this cell every minute. If the cell contains the start trigger, if fires the python script. \nNot the nicest solution, but it works for a few years now.","Q_Score":2,"Tags":"python,python-3.x,google-sheets","A_Id":56109784,"CreationDate":"2019-05-13T07:11:00.000","Title":"Is it possible to run a python script from google sheets on a button press?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Visual Studio Code by default has sensible pylint settings that limits the number of pylint messages that are output.\nIs there any way to easily trigger a \"pylint run\" including the tests that are disabled by vscode by default either on all modules or on an individual module without messing with the vscode settings every time?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":28,"Q_Id":56108631,"Users Score":1,"Answer":"Unfortunately there isn't a way to temporarily flip the linting cap for just a single lint check.","Q_Score":0,"Tags":"python,visual-studio-code,pylint","A_Id":56194093,"CreationDate":"2019-05-13T08:41:00.000","Title":"Temporarily enable exhaustive pylint messages in vscode","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am developing a simple web server that runs on a raspberry pi zero and lights up an LED when a request is received on the POST route (with a given color, intensity, blink timing and other informations contained in the request data) and shuts it down when a request is received on the DELETE route.\nI wanted to have a sort of backup of the requests i do to the server so that they can be \"redone\" (in whatever order) when the server restarts so that the LEDs will turn on without having to redo all of them by hand.\nRight now (since it was the easiest and fasted way for me to do it as a proof of concept) every time i make a POST request i save the color in a dict using as key the serial of the LED and then write the dict to a json file.\nWhen i receive a DELETE request i read the file, delete the entry and write it again with the other information that it may contain (if more than one LED was connected), if the server loses power or gets shut down and restarts it reads the file and restores the LEDs statuses.\nI was wondering what would be the best way to have a system like this (either using a file, DB or other possible solutions) in a way that would use the lowest amount of RAM possible since I already have other services running on the rpi that use quite a bit of it.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":30,"Q_Id":56132088,"Users Score":0,"Answer":"Depending on how many LEDs there are it sounds like what you are doing will be a JSON file of only a few bytes, right? There are ways you could compress that, but unless you have a huge number of LEDs I doubt it will be a significant saving compared to everything else.","Q_Score":0,"Tags":"python,database,raspberry-pi,ram","A_Id":56133167,"CreationDate":"2019-05-14T13:51:00.000","Title":"Saving data using less RAM possible","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to narrow down some potential issues in Maximo. Can Python help me get all queries certain users run while they are logged in? If Python can do this can someone please provide an example I can work with?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":122,"Q_Id":56134963,"Users Score":0,"Answer":"The direct, simple answer to your question is, No.\nIf you don't want to log SQL for all users, as you would get with @JPTremblay's excellent answer, then you should investigate the Configure Custom Logging action of the Logging application. In the associated dialog, on the Thread Logger tab, you should be able to configure UI logging for your particular user, and add the SQL logger in the Thread Logger Details.","Q_Score":1,"Tags":"python,tsql,maximo","A_Id":56448163,"CreationDate":"2019-05-14T16:38:00.000","Title":"Can I get with a python script what queries users run while logged into Maximo?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using the following code which works fine on python2.7. This code returns me error 'Unicode objects must be encoded before hashing' on python 3.7. Can someone please tell me the equal of this in python3.7 version.\nbase64.encodestring(hashlib.sha256(any_string).digest()).strip()\nA lot of downstream code depends on this so I cannot change this algo. I want the same output in python3.7.\nAny pointers would be appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":260,"Q_Id":56139582,"Users Score":0,"Answer":"base64.encodestring(hashlib.sha256(any_string.encode('UTF-8')).digest()).strip()\nIn Python 3+ unicode objects (strings) and bytes are handled differently than in Python 2. The sha256 function seems to require bytes and not unicode which is why the error is appearing. Adding .encode('UTF-8') to the string will give the correct format for the sha256 function. I have tested this in both python 2.7 and 3.7 and both work correctly and give the same output.","Q_Score":0,"Tags":"python-3.x,python-2.7,base64,encode","A_Id":56140725,"CreationDate":"2019-05-14T22:45:00.000","Title":"base64.encodestring returns error Unicode objects must be encoded before hashing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have successfully implemented google assistant on rpi using gassistpi and added agent on dialogflow also. The issue is that if multiple users invoke google assistant on different raspberry pi I am not able to identify which user has invoked the action as request from webhook on dialogflow doesn't have any user identity information. Thus, I am facing issues while retrieving data for particular user.\nI tried using account linking on actions on google using google signup over voice but I am unable to implement that.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":174,"Q_Id":56150206,"Users Score":1,"Answer":"The Google Assistant SDK does not have voice match as a feature, so you would be unable to use it to identify individual users of the Action on that surface.","Q_Score":0,"Tags":"python-3.x,dialogflow-es,actions-on-google,google-assistant-sdk","A_Id":56153506,"CreationDate":"2019-05-15T13:09:00.000","Title":"check identity of multiple users on actions on google","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"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.\nHowever 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.\nIt 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.\nI 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.\nI'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.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":930,"Q_Id":56159051,"Users Score":0,"Answer":"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.\nFor the project-wide add \/Users\/${USER}\/.pyenv\/shims: to the start of the \"Project properties > C\/C++ Build > Environment > PATH\".\nI 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.","Q_Score":2,"Tags":"python,eclipse,makefile,virtualenv,pyenv","A_Id":61663567,"CreationDate":"2019-05-15T23:51:00.000","Title":"How to use a Pyenv virtualenv from within Eclipse?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"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.\nHowever 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.\nIt 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.\nI 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.\nI'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.","AnswerCount":3,"Available Count":3,"Score":-0.0665680765,"is_accepted":false,"ViewCount":930,"Q_Id":56159051,"Users Score":-1,"Answer":"Typing CMD+SHIFT+. will show you dotfiles & directories that begin with dot in any Mac finder dialog box...","Q_Score":2,"Tags":"python,eclipse,makefile,virtualenv,pyenv","A_Id":59180632,"CreationDate":"2019-05-15T23:51:00.000","Title":"How to use a Pyenv virtualenv from within Eclipse?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"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.\nHowever 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.\nIt 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.\nI 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.\nI'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.","AnswerCount":3,"Available Count":3,"Score":-0.0665680765,"is_accepted":false,"ViewCount":930,"Q_Id":56159051,"Users Score":-1,"Answer":"For me, following steps worked ( mac os 10.12, eclipse photon version, with pydev plugin)\n\nProject -> properties\nPydev-Interpreter\/Grammar \nClick here to configure an interpreter not listed (under interpret combobox)\nopen interpreter preference page \nBrowse for python\/pypy exe -> my virtualenvdirectory\/bin\/python\nThen 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)\n\nIn the bottom libraries section, you should be able to see the site-packages from your virtual env\nExtra 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","Q_Score":2,"Tags":"python,eclipse,makefile,virtualenv,pyenv","A_Id":57618150,"CreationDate":"2019-05-15T23:51:00.000","Title":"How to use a Pyenv virtualenv from within Eclipse?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"When I run my Qt application I get the message \n\nQt WebEngine seems to be initialized from a plugin. Please set\n Qt::AA_ShareOpenGLContexts using QCoreApplication::setAttribute before\n constructing QGuiApplication.\n\nThe app runs fine regardless of the fact that this is getting dumped to the terminal. I cant seem to find the root cause or really understand what this message is trying to tell me. What is this message saying and how can I fix it?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":7357,"Q_Id":56159475,"Users Score":0,"Answer":"Using PySide6 instead of PySide2 solved my problem with python 3.9 and QT 5.15 if it can help","Q_Score":9,"Tags":"python,pyside2,qtwebengine","A_Id":67457543,"CreationDate":"2019-05-16T01:06:00.000","Title":"Qt WebEngine seems to be initialized","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I have a node.js server running on a Raspberry Pi 3 B+. (I'm using node because I need the capabilities of a bluetooth library that works well). \nOnce the node server picks up a message from a bluetooth device, I want it to fire off an event\/command\/call to a different python script running on the same device.\nWhat is the best way to do this? I've looked into spawning child processes and running the script in them, but that seems messy... Additionally, should I set up a socket between them and stream data through it? I imagine this is done often, what is the consensus solution?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":149,"Q_Id":56178165,"Users Score":1,"Answer":"Running a child process is how you would run a python script. That's how you do it from nodejs or any other program (besides a python program).\nThere are dozens of options for communicating between the python script and the nodejs program. The simplest would be stdin\/stdout which are automatically set up for you when you create the child process, but you could also give the nodejs app a local http server that the python script could communicate with or vice versa. \nOr, set up a regular socket between the two. \nIf, as you now indicate in a comment, your python script is already running, then you may want to use a local http server in the nodejs app and the python script can just send an http request to that local http server whenever it has some data it wants to pass to the nodejs app. Or, if you primarily want data to flow the opposite direction, you can put the http server in the python app and have the nodejs server send data to the python app.\nIf you want good bidirectional capabilities, then you could also set up a socket.io connection between the two and then you can easily send messages either way at any time.","Q_Score":0,"Tags":"python,node.js,raspberry-pi","A_Id":56192507,"CreationDate":"2019-05-17T00:38:00.000","Title":"Get nodejs server to trigger a python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"In the Telegram app, you can send photos that self-destruct and can't be screenshotted by clicking on the clock icon before sending them. Is there any way to reproduce this behavior using the Telegram Bot API?\nI'm using python-telegram-bot and couldn't find anything in its docs, but i'm not even sure if the API allows it. I could delete the messages after some time using bot.delete_message, however, the important part here is that the images shouldn't be screenshottable.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1906,"Q_Id":56187603,"Users Score":1,"Answer":"I'm using python-telegram-bot and couldn't find anything in docs, but i'm not even sure if the API allows it.\n\nTelegram Bot API does not support such method yet. \n\nI could delete the messages after some time using bot.delete_message, however, the important part here is that the images shouldn't be screenshottable.\n\nYes, bot can delete messages \"manually\" but there's no way to control the ability of making screenshots.","Q_Score":4,"Tags":"telegram,telegram-bot,python-telegram-bot","A_Id":56189665,"CreationDate":"2019-05-17T13:38:00.000","Title":"How to send photos with self-destruct timer using Telegram Bot API?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"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.\nI use Ubuntu 18.04 and I'm usng telepot library.\nWhat is wrong and how to fix it?\nEdit: 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.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1148,"Q_Id":56220056,"Users Score":1,"Answer":"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.\nThe 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.","Q_Score":2,"Tags":"python,python-3.x,ssl,telegram-bot,telepot","A_Id":56220074,"CreationDate":"2019-05-20T11:26:00.000","Title":"\"SSL: CERTIFICATE_VERIFY_FAILED\" error in my telegram bot","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How do I add an additional CA (certificate authority) to the trust store used by my Python3 AWS Lambda function?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":6930,"Q_Id":56225178,"Users Score":5,"Answer":"If you only need a single CA, then get your crt file and encode it into a pem using the following command in linux:\n\nopenssl x509 -text -in \"{your CA}.crt\" > cacert.pem\n\nIf you need to add CA's to the default CA bundle, then copy python3.8\/site-packages\/certifi\/cacert.pem to your lambda folder. Then run this command for each crt:\n\nopenssl x509 -text -in \"{your CA}.crt\" >> cacert.pem\n\nAfter creating the pem file, deploy your lambda with the REQUESTS_CA_BUNDLE environment variable set to \/var\/task\/cacert.pem. \n\/var\/task is where AWS Lambda extracts your zipped up code to.","Q_Score":6,"Tags":"python,python-3.x,amazon-web-services,aws-lambda,ssl-certificate","A_Id":59638101,"CreationDate":"2019-05-20T16:51:00.000","Title":"Python AWS Lambda Certificates","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I 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.\nI 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.\nI 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.\nI'm running on macOS Mojave 10.14.5","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1220,"Q_Id":56233672,"Users Score":1,"Answer":"Items can't be recovered when you perform rm -rf. However, you can try the following:\ncp \/usr\/local\/bin\/python* \/usr\/bin \nThis would copy user local python to usr bin and most probably will bail you out.\nDon't worry, nothing will happen to your OS. It should work fine :)","Q_Score":0,"Tags":"python,macos,terminal","A_Id":56233846,"CreationDate":"2019-05-21T07:54:00.000","Title":"Accidentally deleted \/usr\/bin\/python instead of \/usr\/local\/bin\/python on OS X\/macOS, how to restore?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a 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?\nIt 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.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":129,"Q_Id":56265812,"Users Score":0,"Answer":"Twilio developer evangelist here.\nFirst up, I don't believe that you can enable add-ons for voice services that are served through Twilio SIP trunking.\nUnless 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.\nInstead 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.\nDoes that help at all?","Q_Score":0,"Tags":"twilio,ibm-cloud,cloudant,python-cloudant,ibm-voice-gateway","A_Id":56334855,"CreationDate":"2019-05-22T22:30:00.000","Title":"Can I connect my IBM Cloudant Database as the callback URL for my Twilio IBM STT add-on service?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm working on an assignment where i have to assign 1 up to 10 distribution centers to all US states. I have made a model in excel to calculate all the costs, and clearly the goal of the assignment is to find the cheapest way. I have 50 rows (for each state) and 10 columns (for all possible DC locations). My model is based on this matrix, and if I change the matrix, the costs will instantly display. The only constraint is that each state is supplied by exactly 1 DC.\nIts clear I cant make all possible combinations by hand, I have tried to translate my model into an optimization program (AIMMS), but it'l take allot of time witch I already put in the excel model. I was thinking if I had all possible matrices (generated in R, Matlab, or Python, dont care witch one) i can loop over my spreadsheet them and let a program read the cost, to determine the best choice. Its theoretically possible to supply all state by 1 DC, and at most 10, so every possible 1x50, 2x50, 3x50 ... 10x50 matrix is needed to determine the best one.\nSo again in short, is it possible to generate every nxm binary matrix with a sum total of 1 on each row in preferably R, or otherwise in Matlab or Python?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":149,"Q_Id":56358243,"Users Score":2,"Answer":"TLDR: No.\n\nLet's look at the simpliest example: 2 DC. Your possible rows will be:\n\n(1,0)\n(0,1)\n\nNow you want to construct all possible 2x50 matrices. Their number is 2^50 (2 possible rows in 50 rows). It is equal to:\n1125899906842624\nWe suppose that each matrix stores 100 bytes. That all 2x50 matrices will store:\n(2**50) * 100 \/ 1024 \/ 1024 \/ 1024 \/ 1024 = 102400 terabytes of data.\nAnd to process all of them (in the most optimistic results for normal computers) will spend time equal to:\n(2**50) \/ 10**9 \/ 60 \/ 60 = 312 hours.\nAnd 10x50 will be even more...","Q_Score":1,"Tags":"python,r,matlab,matrix","A_Id":56358796,"CreationDate":"2019-05-29T10:18:00.000","Title":"How to generate all posible binary nxm matrices, where the sum of each row is 1","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"There is a table with a list of users and their email on a webpage. At the top of the page, is a search\/filter input field that allows the user to type an email or username and filter for the result as he\/she is typing. \nThe problem: However, when I use the send_keys() method instead of doing this manually, nothing is filtered in the table view.\nThis is happening on the Safari browser on the iPhone 7 Plus (real device, not simulator). Some other information:\n\niOS version: 12.2\nAppium version: 1.13.0-beta.3\nSelenium version: 2.53.1\nProgramming language: Python 2.7.15\n\nIn addition to send_keys(), i've tried to use set_value(), i've also tried to execute JS and setting the attribute value, and also tried to send key for each character (in a for loop with a delay between each character).\nI'm expecting for example, element.send_keys(\"test1000@test.com) to filter the table view on the web page so that the only user that is displayed has the associated test1000@test.com email as it does when I go through the site manually.\nIn actuality, send_keys() does not do that and nothing in the table view gets filtered.\nAny help or guidance would be appreciated!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":288,"Q_Id":56382223,"Users Score":0,"Answer":"Explicit wait for table to get populate in DOM\nsendKeys search String and additional key Tab\ntextbox.sendKeys(\"test1000@test.com\"+Keys.TAB)\nExplicit Wait for filter to get applied and table to get refreshed.\nfind elements for the newly populated table with applied filters.","Q_Score":0,"Tags":"selenium,appium,appium-ios,python-appium","A_Id":56395049,"CreationDate":"2019-05-30T16:37:00.000","Title":"Using send_keys() on a search\/filter input field does not filter results in table","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Say I define a list object and only want it to be read-only in a function I define. In C++, you'd do this with a const reference. Is there any way to do this with a python function? Does this make sense with respect to writing \"pythonic\" code or am I just trying to apply a C++ paradigm incorrectly?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":181,"Q_Id":56387866,"Users Score":1,"Answer":"In Python, all variables are references, so having an equivalent of C's const wouldn't really do anything. If the pointed-to object is mutable, you can mutate it; if it's immutable, you can't.\nHowever, there are some types that are mutable, and some that aren't. Lists are mutable, but tuples are not. So if you pass your data as a tuple, you're guaranteed the function can't do anything to it.\nTo use a C metaphor, a list of integers is somewhat like an int[], and a tuple of integers is a const int[]. When you pass them to a function, it doesn't matter if you're passing a const reference or a non-const reference; what matters is whether the thing it references is const or not.","Q_Score":3,"Tags":"python,immutability","A_Id":56387957,"CreationDate":"2019-05-31T02:14:00.000","Title":"Is it possible to force data immutability in a python function?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to redirect mysite.com\/index.php to mysite.com\/clientarea.php using .htaccess does not work for me help out.\nwith simple code.\nI have tried several time and finally the site is not available \n\nTry running Windows Network Diagnostics.\n DNS_PROBE_FINISHED_NXDOMAIN","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":46,"Q_Id":56420275,"Users Score":0,"Answer":"Based on that error, it appears you're redirecting to a different hostname than mysite.com - I assume unintentionally. \nIf you can post your .htaccess code, the solution may be easy to provide.","Q_Score":0,"Tags":"django,python-3.x,.htaccess,whmcs","A_Id":56420311,"CreationDate":"2019-06-03T01:49:00.000","Title":"How Can i redirect url to another url with the .htaccess in cpanel","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have two simple lambda functions. Lambda 1 is invoking lambda 2 (both do a simple print for text).\nIf both lambdas are outside of a VPC then the invocation succeeds, however as soon as I set them both in to access a VPC (I need to test within a VPC as the full process will be wtihin a VPC) the invocation times out.\nDo I have to give my lambda access to the internet to be able invoke a second lambda within the same VPC?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":648,"Q_Id":56425420,"Users Score":1,"Answer":"If your lambda functions are inside a VPC you need to configure your both lambda functions into private subnet not public subnet. That is the AWS recommended way.","Q_Score":0,"Tags":"python,python-3.x,aws-lambda","A_Id":56448070,"CreationDate":"2019-06-03T10:27:00.000","Title":"Unable to invoke second lambda within VPC - Python AWS Lamba Function","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to use python-gitlab projects.files.create to upload a string content to gitlab.\nThe 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.\nI'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.\nThanks for your help.\nEDIT---\nSorry, I'm using python 3.7 and the string is actually a csv content, so it's basically like:\n',col1,col2\\n1,data1,data2\\n'\nSo when I upload it the gitlab file I want it to be:\n,col1,col2\n1,data1,data2","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":101,"Q_Id":56442415,"Users Score":0,"Answer":"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.\nI'm not sure if there's other of doing this but just for someone that encounters a similar situation.","Q_Score":0,"Tags":"python,gitlab","A_Id":56462585,"CreationDate":"2019-06-04T10:52:00.000","Title":"how to use python-gitlab to upload file with newline?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am researching a way to send out a PWM-ed IR pulse from an xBee3 device. I couldn't find any IR related libs, so I guess I'll have to \"brute\" force it by \"waiting\" X many microseconds and setting digital I\/O pins ON and OFF. \nAny ideas\/pointers\/references would be much appreciated!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":106,"Q_Id":56464137,"Users Score":0,"Answer":"MicroPython on the XBee3 RF products won't be capable of the microsecond timing you're looking for, and the PWM output only allows for setting the duty cycle, not the frequency.\nYou would need to add extra hardware to convert (for example) the I2C interface to IR transmission. The XBee3 RF products don't support a secondary UART like the XBee Cellular products do, but if they add that feature you would could have a UART->IR interface via a secondary microprocessor.","Q_Score":0,"Tags":"xbee,pwm,infrared,micropython,transmission","A_Id":56483498,"CreationDate":"2019-06-05T15:59:00.000","Title":"How can one achieve an arbitrary frequency and duty cycle PWM-ed IR transmission in an xBee3 using MicroPython?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can I synchronise the front-end and back-end to get the data in the real-time than periodically making a request to the back-end API?\nI have been using an angular 7.2 framework at the front-end and python as a back-end. I want a technique so that the changes in the back-end and the database can be listened by the front-end and the browser becomes up to date.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":163,"Q_Id":56473272,"Users Score":0,"Answer":"Use web sockets : real time communication between web servers and clients is possible with the help of this protocol.","Q_Score":0,"Tags":"python,angular","A_Id":56474506,"CreationDate":"2019-06-06T08:02:00.000","Title":"How to fetch the data using angular 7 from the server (python) in the real-time to keep UI updated?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm using a C++ DLL with python which makes use of COM objects. \nI'm loading it with cdll.LoadLibray.\nMy application was working fine with python 2.7. Now that I'm moving to Python 3.7 my C++ DLL fails when I call: CoInitializeEx(NULL,COINIT_MULTITHREADED)\n with error 0x80010106: Cannot change thread mode after it is set. \nBy googling a bit I found some references on sys.coinit_flags = pythoncom.COINIT_MULTITHREADED but this pieces of code does not solve the issue.\nIt seems Python 3 is initializing COM by itself and now I cannot change the COM concurrency model.\nHow can I enable COINIT_MULTITHREADED?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":357,"Q_Id":56473850,"Users Score":0,"Answer":"Ok... for whoever will have this issue, after googling and trying to understand how to get Python 3 not to initialize COM or initialize it for MTA (i.e. COINIT_MULTITHREADED) I gave up and simply put CoUninitialize() in my C++ code just before calling CoInitializeEx(NULL,COINIT_MULTITHREADED) needed by my DLL.","Q_Score":0,"Tags":"python,python-3.x,com,dynamic-dll-import","A_Id":56478216,"CreationDate":"2019-06-06T08:39:00.000","Title":"My DLL using COM objects with COINIT_MULTITHREADED is no more working on Python 3.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python script that loops through all of the AWS accounts we have and lists the EC2 instances in each one. \nI want to turn it into an AWS Lambda function. But I can't figure out how to pull the AWS credentials that would allow me to list the servers in all the accounts.\nHow can I achieve this in AWS Lambda?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":316,"Q_Id":56496230,"Users Score":0,"Answer":"When you create lambda you have so specify a role\nIn IAM you can attach required permission to a lambda role. \nIf you want to use some specific set of credentials in a file, you can utilize AWS Systems Manager to retrieve credentials. \nThough, I would recommend role on lambda","Q_Score":0,"Tags":"python,aws-lambda","A_Id":56496798,"CreationDate":"2019-06-07T14:28:00.000","Title":"Loop through AWS Accounts in Lambda Python Function","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python script that loops through all of the AWS accounts we have and lists the EC2 instances in each one. \nI want to turn it into an AWS Lambda function. But I can't figure out how to pull the AWS credentials that would allow me to list the servers in all the accounts.\nHow can I achieve this in AWS Lambda?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":316,"Q_Id":56496230,"Users Score":1,"Answer":"Create a role with cross account permissions for ec2:ListInstances\nAttach the role to the lambda function","Q_Score":0,"Tags":"python,aws-lambda","A_Id":56501963,"CreationDate":"2019-06-07T14:28:00.000","Title":"Loop through AWS Accounts in Lambda Python Function","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have set up a Raspberry Pi connected to an LED strip which is controllable from my phone via a Node server I have running on the RasPi. It triggers a simple python script that sets a colour.\nI'm looking to expand the functionality such that I have a python script continuously running and I can send colours to it that it will consume the new colour and display both the old and new colour side by side. I.e the python script can receive commands and manage state.\nI've looked into whether to use a simple loop or a deamon for this but I don't understand how to both run a script continuously and receive the new commands.\nIs it better to keep state in the Node server and keep sending a lot of simple commands to a basic python script or to write a more involved python script that can receive few simpler commands and continuously update the lights?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":302,"Q_Id":56504180,"Users Score":1,"Answer":"IIUC, you don't necessarily need to have the python script running continuously. It just needs to store state, and you can do this by writing the state to a file. The script can then just read the last state file at startup, decide what to do from thereon, perform action, then update the state file.\nIn case you do want to actually run the script continuously though, you need a way to accept the commands. The simplest way for a daemon to accept command is probably through signal, you can use custom signal e.g. SIGUSR1 and SIGUSR2 to send and receive these notifications. These may be sufficient if your daemon only need to accept very simple request.\nFor more complex request where you need to actually accept messages, you can listen to a Unix socket or listen to a TCP socket. The socket module in the standard library can help you with that. If you want to build a more complex command server, then you may even want to consider running a full HTTP server, though this looks overkill for the current situation.\n\nIs it better to keep state in the Node server and keep sending a lot of simple commands to a basic python script or to write a more involved python script that can receive few simpler commands and continuously update the lights?\n\nThere's no straightforward answer to that. It depends on case by case basis, how complex the state is, how frequently you need to change colour, how familiar you are with the languages, etc.","Q_Score":0,"Tags":"python,node.js,command-line,raspberry-pi","A_Id":56504287,"CreationDate":"2019-06-08T06:50:00.000","Title":"How to run a Python script continuously that can receive commands from node","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have collected many unique JPEG files and compiled them into a single ~1000-page PDF file via Python. Each unique image occupies a single page within the PDF file. \nNow, I would like to go back and add functionality to my Python script so that each image has an integer stamped onto it and is searchable via ctrl+f after processing. For example, after processing via Python, page 15 within the PDF file has image 345 stamped to it. If I open the PDF file and searched for number 345, page 15 would be found.\nWhat is Pythonic method to accomplish this task?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":74,"Q_Id":56532567,"Users Score":1,"Answer":"You can add a text, or a label to the image in the same page, so you can find it when you search for it using Ctr+F","Q_Score":0,"Tags":"python,image,pdf,jpeg,ctrl","A_Id":56532604,"CreationDate":"2019-06-10T19:37:00.000","Title":"Finding image via ctrl+f via Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I RMB on a single Python unittest in PyCharm (in the gutter on the green arrow) Pycharm insists on running all the tests in the file. Am I missing something in the configuration?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":183,"Q_Id":56533155,"Users Score":0,"Answer":"It seems to have corrected itself after I renamed the test case class","Q_Score":0,"Tags":"pycharm,python-unittest","A_Id":56561245,"CreationDate":"2019-06-10T20:32:00.000","Title":"PyCharm Python not running single unit test","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can I control exactly when MXNet should run performance tests?\nI have an MXNet application that is about to go to production. It is running ok, but it has a variable batch size and it causes MXNet to perform autotune often.\nAlthough the batch size is variable, it is typically 1. I'm fine with performance loss on bigger sizes (it is still better than interrupting it all the time to autotune).\nIf I disable autotune with export MXNET_CUDNN_AUTOTUNE_DEFAULT=0 the network runs considerably slower.\nSo my question: is there a way to run autotune only once, preferably at my call?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":461,"Q_Id":56550179,"Users Score":3,"Answer":"There is currently no way to run autotune only once. When autotuning is enabled MXNet will run performance tests to find the best algorithm to run for Convolution\/DeConvolution operators. The best algorithm is cached with the specific input shape, output shape. So as long as you have the same input\/output shape, the performance tests should not re-run. However, if the shape changes then it would trigger the algorithm to re-run.","Q_Score":2,"Tags":"python,mxnet","A_Id":56566460,"CreationDate":"2019-06-11T18:58:00.000","Title":"MXNet CuDNN Autotune management","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We have an application that invokes a Python interpreter from within a C++ code. The C++ code is parallelized with mpi. The interpreter is used to run Python scripts (these may involve message passing via mpi4py or not). Here's the problem: When we run the code as a serial code, if the Python scripts contains an error, on stderr we get the message that the interpreter generates with the usual diagnostic information (line where error occurs, type of error,...). If, however, we run the code in parallel over multiple cores, we do not get any diagnostic info from the interpreter. On the C++ side, we know that an error occurred in the script, but that is all. Of course, this makes debug much harder, since some of the errors may only occurs when running in parallel. So my question is how to redirect error messages from the interpreter to a file, or other ideas to deal with this situation.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":107,"Q_Id":56581003,"Users Score":0,"Answer":"The problem had to do with how we exit the code after an error on the Python side occurred. \nOriginally, we used MPI_Abort(). Switching to std::exit(0) solves the issue. \nNow, when a script generates an error, the Python interpreter messages are correctly displayed (from every process!).","Q_Score":0,"Tags":"python-3.x,runtime-error,mpi","A_Id":56600285,"CreationDate":"2019-06-13T12:54:00.000","Title":"How to deal with python interpreter run-time errors when running python within an mpi code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am comparing design choice of wrapping either each \"vector\" into Object, or each whole \"matrix\" of vectors into Object. \nI realize there will be more overhead if I try to wrap up each path by a class object, but it would make the system a lot easier to understand and implement.\nHowever, I thought this might cost us the performance.\nWhat would be a convention when it comes to loading big data as attributes?\nI appreciate your thoughts in advance,\nq","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":20,"Q_Id":56605145,"Users Score":1,"Answer":"It seems you want to \"wrap paths\" and store many attributes for those paths, and there are lots of \"paths\".\nInstead of defining classes that require lots of custom objects creation just for the paths themselves, store the paths (strings I suppose) as keys in a dict, and the attributes in any appropriate form inside.","Q_Score":0,"Tags":"python,performance,oop","A_Id":57694779,"CreationDate":"2019-06-14T21:09:00.000","Title":"Design Choice: how to wrap up large files with 100k+ vectors","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to get the path of invoked (top-level) Python script. Actually it is a package and I am running it with python3 -m . I researched web and Stack Overflow but couldn't find a proper solution. __file__ and __path__ are not working, os.getcwd() doesn't work if the package is invoked from another location, sys.argv[0] is not guaranteed to have the full path. The way import __main__ is not a good way I think since I import the top-level script into a dependent script.","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":250,"Q_Id":56620387,"Users Score":-1,"Answer":"I encountered the problem of open(\"xyz.dat\",\"r\") not finding xyz.dat in the same folder as the .py file\nSolved my problem by adding \"working_dir\": \"$file_path\" to my Sublime Text 3 build script.\nHowever, I wondered how python libraries did it. For example, Kivy's AsyncImage has a \"source\" parameter to its constructor that successfully finds image files in the same folder as the top-level py file.\nAfter some digging, I discovered the method that Kivy uses:\n\nimport kivy.resources as kr\nfull_path = kr.resource_find(\"image.png\")\n\nI do not like to rely on a setting in a build script to find files in the same folder, so this is the method I'm going to follow in future Kivy projects.\nBTW, resource_find does rely on sys.argv[0] to \"know\" the full path of the top-level python script.","Q_Score":2,"Tags":"python","A_Id":67192928,"CreationDate":"2019-06-16T15:47:00.000","Title":"Getting path of the top-level Python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know that pytest is integratabtle with Jenkins. Is pytest-benchmark integratabtle with Jenkins?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":112,"Q_Id":56642698,"Users Score":-2,"Answer":"yes both pytest and pytest-benchmark are integratable with Jenkins ( source: comment )","Q_Score":0,"Tags":"python,jenkins,continuous-integration,pytest","A_Id":56659711,"CreationDate":"2019-06-18T06:12:00.000","Title":"pytest-benchmark integration with Jenkins","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a script working with multiple modules that include loggers (lets assume modules A and B).\nWhen executing, functions of A will automatically create a logger, but to keep things tidy I would like messages from module B only to be displayed in my stdout. \nIs there a convenient way to disable all print statements for every function \/ class coming from module A, without explicitly referring to the function that prints? Im thinking about something like a line of code at the start of the script handling that.\nMany thanks!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":70,"Q_Id":56667055,"Users Score":0,"Answer":"There are two approaches:\n\nYou can monkey patch the print function\/logger object in module A's namespace and replace it with your own. This is quick and dirty, but would not require any modifications in module A. I'd highly recommend against doing this if possible, you'll just get into trouble. \nIf you can modify module A, the proper way to do this is to ensure that module A use the python logger for all its output, and that it sets a logger name. In your logging configuration, you can then specify a LoggerFilter or LoggerAdapter to selectively suppress log entries based on logger name prefix or other attributes of the LogEntry.","Q_Score":1,"Tags":"python,python-3.x,stdout,global","A_Id":56667385,"CreationDate":"2019-06-19T11:52:00.000","Title":"Globally silence the stdout for one whole module","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What all inbuilt function call happen after creating a object from class? I know init() get called any other functions get called automatically ?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":43,"Q_Id":56672093,"Users Score":1,"Answer":"I don't think anything occurs after init() unless you define it to, before init(); however a call to the class' __new__() function will occur BEFORE the call to init()","Q_Score":0,"Tags":"python-3.x","A_Id":56672404,"CreationDate":"2019-06-19T16:21:00.000","Title":"automatically called functions while Object creation in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am given a network packet whose last 64 bytes (128 hex characters) are the RSA-512 digital signature of the SHA-256 hash of the packet. I take a truncated version of this packet (everything except the last 64 bytes) and calculate the hash myself, which is working fine, however I need a way to get back the hash that generated the signature in the first place\nI have tried to do this in Python and have run into problems because I don't have the RSA private key, only the public key and the Digital Signature. What I need is a way to take the public key and signature and get the SHA-256 hash back from that to compare it to the hash I've generated. Is there a way to do this? Any crypto libraries would be fine. I am using hashlib to generate the hash","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":902,"Q_Id":56676828,"Users Score":0,"Answer":"The original hash was signed with the private key. To get the original hash, you need to decrypt the signature with the public key, not with the private key.","Q_Score":1,"Tags":"python,rsa,digital-signature","A_Id":56679386,"CreationDate":"2019-06-19T22:44:00.000","Title":"How to get the original hashed input to an RSA digital signature?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've done a php page index.php which uses some python scripts to retrieve some informations and copy them from a file A to a file B. My problem is that if I have more than one user that access index.php, B is modified from both the users. How can I make the second user wait until the first user has finished to modify B?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":414,"Q_Id":56682737,"Users Score":0,"Answer":"You can make one file in parallel xyz.txt.in_use and check for it every time from other location that the file is exists OR not then wait till it got deleted then after the writing completion, delete the xyz.txt.in_use, so that other can take charge on xyz.txt","Q_Score":0,"Tags":"php,python,concurrency","A_Id":56684754,"CreationDate":"2019-06-20T09:16:00.000","Title":"Prevent multiple users write on file at the same time","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I automated the Test Suite using Robot Framework-Selenium base on PYTHON 27. This same Test Suite needs to execute on client side. \nBut Company do not want to share code base with client. \nIs there anyway that I can create binary file of Robot Framework and share the same binary file with client instead of sharing a actually code ?\nlike in Java we create .jar file.\nKindly help me I am looking for solution from last three days.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":343,"Q_Id":56709077,"Users Score":0,"Answer":"I don't think there's anything you can do. Robot doesn't have the ability to parse binary files, so any solution would have to include converting your binary files to text files on the client machine.","Q_Score":1,"Tags":"python,robotframework,executable,robotium","A_Id":56709784,"CreationDate":"2019-06-21T19:00:00.000","Title":"How to hide robot framework code base and share only binary file to client?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"So i have this homework, i need to do a email client that sends emails, notifies when a new email arrives,etc.\nOne of my problems is verifying a domains reputation if the user writes an url in the body or subject of the email, if the domain can be danger i shouldn't send the email. I tried mywot.com api, but i can't get a key to try coding.\nI searched for other apis like domaintools, whoisxml, urlvoid but they have a ton of documentation, and i just get lost reading all of it, also they services are limited to free users.\nIs there another api that i can try? o there's another way to valid user urls?\nThanks for your answers.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":276,"Q_Id":56711961,"Users Score":0,"Answer":"most of them are free until a certain number of queries are hit (like 1000 month). \nFor a fully free API you'll probably need to implement it yourself, since indexing domain lists takes a lot of effort.\nCheck the free intervals of senderbase and virustotal","Q_Score":0,"Tags":"python,json,xml,url,dns","A_Id":61699316,"CreationDate":"2019-06-22T01:39:00.000","Title":"How to see Domains reputation with python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I can successfully convert my .py files to .exe files through the auto-py-to-exe program. \nHowever is there a way to do it completely from a script?\nfor example:\nimport auto-py-to-exe\ncontained file\nconsole type\nauto-py-to-exe.convert(fileorigin.py,filedest.exe)\nMy goal is to have a script constantly running that converts my code then it uploads it to my server. I have the code to upload to the server on timer though i currently have to manually convert my files through the auto-py-to-exe program which is very time consuming and annoying. \nIf there is another way to do achieve this without auto-py-to-exe I am interested. \nThank you heaps :)\nIve tried googling however i could not find anything.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1381,"Q_Id":56712682,"Users Score":0,"Answer":"Using pyinstaller instead. Will post the code when im back on this pc.","Q_Score":1,"Tags":"python-3.x,exe,file-conversion,auto-py-to-exe","A_Id":56712762,"CreationDate":"2019-06-22T04:51:00.000","Title":"Use Auto-py-to-exe from python script?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"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?\nI 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.\nI 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?","AnswerCount":5,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2227,"Q_Id":56743561,"Users Score":5,"Answer":"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.\nWhat about building a full Python application but running it all from Docker? \nThat 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'.\nThere are base docker images out there that are specifically for Building Python and .NET Project and also for running.","Q_Score":7,"Tags":"c#,python,.net,ironpython,python.net","A_Id":56885931,"CreationDate":"2019-06-24T20:31:00.000","Title":"Running Python Code in .NET Environment without Installing Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I found upload_from_file and upload_from_filename, but is there a function or method to upload an entire folder to Cloud Storage via Python?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2959,"Q_Id":56759262,"Users Score":0,"Answer":"I don't think directly in the Python API, no, but there is in the commandline tool gsutil. You could do a system call from the python script to call out to the gsutil tool as long as you're authenticated on commandline in the shell you're calling the Python from.\nThe command would look something like:\ngsutil -m cp -r gs:\/\/","Q_Score":3,"Tags":"python,directory,google-cloud-platform,upload","A_Id":56762660,"CreationDate":"2019-06-25T17:31:00.000","Title":"Upload a folder to Google Cloud Storage with Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I found upload_from_file and upload_from_filename, but is there a function or method to upload an entire folder to Cloud Storage via Python?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2959,"Q_Id":56759262,"Users Score":0,"Answer":"Google Cloud Storage doesn't really have the concept of \"directories\", just binary blobs (that might have key names that sort of look like directories if you name them that way). So your current method in Python is appropriate.","Q_Score":3,"Tags":"python,directory,google-cloud-platform,upload","A_Id":56780840,"CreationDate":"2019-06-25T17:31:00.000","Title":"Upload a folder to Google Cloud Storage with Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Pycharm-community 2016 0.3 on Ubuntu 16.04. \nI'm coding in Python 2.7, the problem is that the functions which are defined by me are not being syntax-highlighted. For example, before using Pycharm I was using Atom, in it the functions are highlighted making it very easy to debug.\nI have turned on Semantic highlighting and i'm using the theme 'Dracula'.\nI tried to re install Pycharm-communty, tried installing the latest edition, but none if it is working.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":21,"Q_Id":56789819,"Users Score":0,"Answer":"I found a work-around foe this problem,\nIf you install the 'onedark' theme and enable it, the local functions are also highlighted.\nTo install,\ngo to settings > plugins > search for 'onedark', and install","Q_Score":0,"Tags":"python-2.7,pycharm","A_Id":56794227,"CreationDate":"2019-06-27T11:14:00.000","Title":"Functions are not being highlighted in Python2.7 in Pycharm-community","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a recipe that needs to know the version string\/information of another recipe. Basically I want to expand the PV variable of a different recipe. What would be the easiest way to do this? I was thinking maybe there is a bb python function I can use in my recipe to parse the other recipe and find it's PV.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":320,"Q_Id":56794981,"Users Score":0,"Answer":"Easily, you can't. Can you explain what you actually need to do?","Q_Score":0,"Tags":"python,linux,yocto,bitbake","A_Id":56795346,"CreationDate":"2019-06-27T16:07:00.000","Title":"How can I reference\/find the ${PV} of one recipe in another recipe in Yocto\/Bitbake?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Problem\nI have a Lambda function in Account 1, which retrieves EC2 instance status.\nSimilarly, I want to retrieve EC2 instance status in other 4 accounts.\nWhat I did\nI Created trust relationship with the other 4 account by updating the IAM role.\nQuestion:\nWill my python code (residing in my lambda function in account 1) is enough to retrieve ec2 instance status from the other 4 accounts? or should I do something more ?\nPlease suggest!\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":22,"Q_Id":56809483,"Users Score":1,"Answer":"Each AWS Account is separate. You cannot access details of one AWS Account from another AWS Account. However, you can temporarily assume an IAM Role from another account to gain access.\nInstead, you will need to:\n\nCreate an IAM Role for the central Lambda function (Lambda-Role) and grant it permission to call AssumeRole\nCreate an IAM Role in each account that you wish to access, grant it permission to call DescribeInstances and configure it to trust Lambda-Role\nThe Lambda function can then loop through each account and:\n\n\nCall AssumeRole for that account, which will return temporary credentials\nUse those credentials to call DescribeInstances","Q_Score":0,"Tags":"python-3.x,amazon-web-services,aws-lambda","A_Id":56813988,"CreationDate":"2019-06-28T15:23:00.000","Title":"Is my python code enough to retrieve ec2 instance status from other accounts?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So it seems like Buster comes default with 2.7 on load and an alternate 3.7 version of Python. However, I am using this Raspberry Pi 3 B+ just for an application that is only compatible with Python 3.5. How do run Python 3.5 as default version or remove 3.7 entirely from Buster?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":14894,"Q_Id":56814302,"Users Score":1,"Answer":"I truly believe that you can just install python3.5 from the source repos.\nIf you want to install python 3.5.4 : \nsudo apt-get install python3.5\nIf you want to install python 3.5.3 (Debian Stretch) :\nEdit as root \/etc\/apt\/source.list and add the following repos,\ndeb http:\/\/mirrordirector.raspbian.org\/raspbian\/ stretch main contrib non-free\nrpi firmware deb http:\/\/archive.raspberrypi.org\/debian\/ stretch main ui\nThen install the specific package version from the target repo using the following command : \nsudo apt-get install python3.5 -t stretch\nIf want to install pip3.5 (which i guess you would need) : \nwget https:\/\/bootstrap.pypa.io\/get-pip.py\npython3.5 .\/get-pip.py","Q_Score":3,"Tags":"python,python-3.x,raspberry-pi3,raspbian,debian-buster","A_Id":56842605,"CreationDate":"2019-06-29T00:32:00.000","Title":"Downgrade Python 3.7 to 3.5 on Raspbian Buster","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So it seems like Buster comes default with 2.7 on load and an alternate 3.7 version of Python. However, I am using this Raspberry Pi 3 B+ just for an application that is only compatible with Python 3.5. How do run Python 3.5 as default version or remove 3.7 entirely from Buster?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":14894,"Q_Id":56814302,"Users Score":0,"Answer":"just need to follow 1 step\ndo not remove python3.7 directly it will cause problems \ninstall 3.5 and directly start using it.\nafter 3.5 install you can remove python 3.7\nkeep it simple. :)","Q_Score":3,"Tags":"python,python-3.x,raspberry-pi3,raspbian,debian-buster","A_Id":57602834,"CreationDate":"2019-06-29T00:32:00.000","Title":"Downgrade Python 3.7 to 3.5 on Raspbian Buster","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to setup a server to run on startup (Raspberry Pi) - the server calls a script which calls a script...except they're not firing.\n\nadd the cron job using crontab -e and writing @reboot python3 \/path\/to\/my_server.py (also tested with & at end of line)...this works fine.\nmy_server.py uses httpd.server_forever() to listen at a few endpoints...this works fine.\nOne of the server endpoints runs subprocess.Popen(['python3', '\/path\/to\/my_script.py']).\nmy_script.py then runs subprocess.Popen(['qgis']) (also tried with shell=True).\n\nHowever, QGIS isn't starting.\nThis is only happening when trying to run everything on boot with the cron job. If I manually open a terminal and run python3 \/path\/to\/my_server.py then everything works as expected. I'm thinking it has to do with...things not being run in a shell\/terminal - maybe a behavior of Popen?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":82,"Q_Id":56816358,"Users Score":0,"Answer":"The issue is that QGIS requires x server to be running, and cron won't have that by default.\nFix: change cron entry to be @reboot export DISPLAY=:0; python3 \/path\/to\/my_server.py and everything works!","Q_Score":0,"Tags":"python,shell,cron,subprocess,qgis","A_Id":56821316,"CreationDate":"2019-06-29T09:07:00.000","Title":"Python subprocess.popen from within a cron job","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"My setup:\nI am using python3 and the socket module to setup a socket using ipv4 and tcp, listening and receiving data via an open port. I have a simple server and client where the client sends a request and the server responses. \nMy problem:\nI did some research and many people suggest that an open port is like an open door so how can I lock it? My goal is to secure my server and my client and not the data that is transmitted (which means the data shouldn't be altered but it does not matter if somebody reads it). I just want to make sure that neither the server nor the client receives wrong data or can be hacked in any way. If both the server and the client are normal computers with build-in firewalls are those sufficient?\nQuestions:\n\nHow can I make sure that the data I transmit can't be altered?\nIs the firewall (normal firewall that every computer has built-in) of the server sufficient when listening, receiving and sending data via an open port? If not what can I do to make sure the server can't be hacked in any way (obviously not entirely but as good as possible)?\nSame as question 2. just for a client (which as far as I am concerned does use an open port or at least not like the server)\n\nPS: If possible using python.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":412,"Q_Id":56816388,"Users Score":0,"Answer":"A Basic level of security for the server side would be to send a random key along with the data for verification of trusted client. If the list of clients that are going to send data are known you can just whitelist the IP addresses which accept data only from a specific list of IP addresses.","Q_Score":1,"Tags":"python,sockets,security,tcp,server","A_Id":56816527,"CreationDate":"2019-06-29T09:15:00.000","Title":"How to secure a python socket listening, sending and receiving on an open port?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How do you make cplex use a greedy optimization solution as opposed to the optimal solution? Are there parameters you can set or is this not possible?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":99,"Q_Id":56822596,"Users Score":2,"Answer":"What you can do is to compute the greedy solution yourself and then submit this as a warmstart\/MIP start.\nThere are no parameters to force CPLEX to use a greedy algorithm to construct a solution since it is not clear how weights for a greedy algorithm should be chosen for an arbitrary MIP. So for a general MIP, it is not clear what a greedy algorithm should do exactly and whether it would have a chance to succeed or not.\nIf a model is suitable for a greedy approach then it frequently is easy to implement the greedy approach in an external tool and just warm start CPLEX with that solution.","Q_Score":0,"Tags":"python,cplex","A_Id":56831000,"CreationDate":"2019-06-30T05:22:00.000","Title":"Making CPLEX use a greedy solution","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am 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?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":467,"Q_Id":56822722,"Users Score":0,"Answer":"Use message.embeds instead to get the embed string content","Q_Score":1,"Tags":"python,bots,embed,message,discord","A_Id":56823113,"CreationDate":"2019-06-30T05:53:00.000","Title":"Using a Discord bot, how do I get a string of an embed message from another bot","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"For each of my tests in a unittest.TestCase suite, I need to do some setup: run a function that returns a different value for each test (depending on some properties of each test that are passed as arguments to the setup function).\nThere is the setUp() hook that I could use, but it does not return a value and does not accept arguments. But let's say arguments aren't important in this case.\nWhat strategy is recommended? \n\nCreating a custom setup function to use inside each test case\nUsing setUp() with global variables\nUsing setUp() with class or instance variables","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2493,"Q_Id":56840887,"Users Score":0,"Answer":"Note my destinction between setup and Setup below: Each test has to so some setup activities, but these are not necessarily put into the Setup method.\nMy preference is that each test function should be easily understood by itself. I don't want to look at test code wondering \"where does this value suddenly come from\" or the like. Which means, I avoid a common Setup method but instead use helper functions \/ methods that also have descriptive names. To be more precise:\n\nIf a test case needs a specific setup, I normally embed it directly into the test.\nIf a subset of the test cases have an identical or similar setup, I consider creating a helper method to extract the common parts. The name of that helper method should be descriptive, like makeTrafficLightInGreenState for a helper factory to produce a specific type of traffic light object. In this example I could then also have makeTrafficLightInRedState for a different group of tests. I find this preferrable over a common Setup method which just creates both the green and the red traffic light: In the end you get confused which part of Setup is relevant for which test. Certainly, when writing your helper methods, you are also free to give them parameters, which could in the traffic light example result in 'makeTrafficLightInState(green)'. But, which approach to choose here is situation specific.\nEven if all tests have something in common, like the creation of a certain object, I prefer putting this in a descriptively named helper method rather than relying on the implicit call to Setup.\nSometimes I also use Setup, but only for activities that are not necessary for understanding the logic of the test cases. For example, if there is some original state that needs to be preserved at the beginning of the test cases and to be restored afterwards, this could be put into Setup without any negative impact on the readability of the individual test cases.\n\nIn your case, you seem to already have a function with parameters that is suited to deliver test case specific data. I would simply call that function from each test case that needs it. Or, if calling that function is not simple (you have to create additional objects as arguments for it or the like), again put it into a helper method.","Q_Score":0,"Tags":"python,unit-testing,python-unittest","A_Id":56879061,"CreationDate":"2019-07-01T18:44:00.000","Title":"How to properly use a per-test setup function that returns a value in unittest?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have written code in Python. In the import section i have the following:\nimport snappy\nimport xlrd\nThe xlrd is a library that can only be used by Python 3.6. The snappy is a libary that can only be used by Python 2.7. How i can use both Python 2.7 and 3.6?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":49,"Q_Id":56871135,"Users Score":0,"Answer":"You cannot run a program with various versions of Python at once.","Q_Score":0,"Tags":"python","A_Id":56871183,"CreationDate":"2019-07-03T13:19:00.000","Title":"Import from various version of python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have written code in Python. In the import section i have the following:\nimport snappy\nimport xlrd\nThe xlrd is a library that can only be used by Python 3.6. The snappy is a libary that can only be used by Python 2.7. How i can use both Python 2.7 and 3.6?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":49,"Q_Id":56871135,"Users Score":0,"Answer":"Sadly you can't, you have to use a compatible version of the library you need.\nYou can use python-snappy","Q_Score":0,"Tags":"python","A_Id":56871195,"CreationDate":"2019-07-03T13:19:00.000","Title":"Import from various version of python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am getting only upto 10000 members when using telethon how to get more than 10000 \nI 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\nExpected greater than 10000\nbut actual is 10000","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":131,"Q_Id":56884669,"Users Score":0,"Answer":"there is no simple way. you can play with queries like 'a*', 'b*' and so on","Q_Score":0,"Tags":"python,telegram,telethon","A_Id":56884748,"CreationDate":"2019-07-04T09:21:00.000","Title":"how to get the memebrs of a telegram group greater than 10000","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In what environment should I write the code for the telegram bot so that it works even when the console is not running?\nI tried to write code in an online environment, but when I turn it off, the bot does not work.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":47,"Q_Id":56886030,"Users Score":0,"Answer":"This depend from the OS you are using (es. Windows, Ubuntu 18.04 etc.), and also from which programming language and which version of it you are using (es. \"python 3.6\"). \nIf you want to have the code always available to be executed, you need to put the script or the scripts in a server (a dedicated computer) always turned on,you can rent one online or you can do it and set up one by yourself , but this need some knowledge before, and depends on which kind of things you want from your server.\nIf you're still in the early stage of the bot-development i suggest you to use your localhost or local environment in general to test your work, in this way you can focus to one thing at time , useful especially in your first experiences in developing and coding. If it's not strictly necessary i would focus at one thing at time to learn better step by step.","Q_Score":0,"Tags":"bots,telegram,python-telegram-bot","A_Id":56930372,"CreationDate":"2019-07-04T10:32:00.000","Title":"In what environment should I write the code for the telegram bot so that it works even when the console is not running?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"sshpass -P mysshpass ssh root@127.0.0.1 \".\/myscript.py\"\nAbove is the command that I execute from shell, it asks me for a password as \"myscript.py\" is scripted to ask for it. But when I execute the same command from python, it doesn't prompt me for password. \nmy python code\nos.system(sshpass -P mysshpass ssh root@127.0.0.1 \".\/myscript.py\")","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":92,"Q_Id":56899164,"Users Score":0,"Answer":"you might consider paramiko module, or by specifiying a key file (rsa private key) with ssh -i (see authorized_keys if you are not familiar with ssh auth","Q_Score":0,"Tags":"python","A_Id":56899185,"CreationDate":"2019-07-05T08:15:00.000","Title":"How to provide a password over ssh using python script?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm am running my tests on Azure Pipelines (but the same thing applies to Travis and Appveyor). I have a Python package, let's call it calculator which contains cython extensions. When I push to my repository, the CI servers clone my package and install it using python setup.py develop, then run pytest to run the tests. Running python setup.py develop builds the extensions inplace, so the shared objects are in the actual directory. So when my unittests run import calculator, the cwd is the source directory, so the actual copies of the python scripts are used, which contain the shared object files right there, so everything works fine.\nNow, I want to replace python setup.py develop with python setup.py install. Now, the extensions are no longer built in the current source directory, but are packaged and installed into the python path. However, when pytest is called after installation, python can still find the calculator module in the working directory, and (I guess) ignores the properly installed calculator module. And because the extensions weren't built inplace, the tests fails saying the extension module is not found.\nThe reason I want to do this is because I also have wheels set up to be built on the CI servers. When I build a wheel, I would also like to make sure nothing went wrong and install that wheel and run tests on it. Similarily to python setup.py install, I suppose the calcualtor module in the working directory takes precedence over my installed wheel, and results in extension import errors.\nHow do people typically deal with this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":456,"Q_Id":56908227,"Users Score":1,"Answer":"I've read up quite a bit on this since posting this question and the problem stems from the fact that Python automatically prepends the working directory to sys.path. Since CI servers have their working path set to the source directory, the actual source files take precedence over the installed library. There are two solutions:\n\nWe can switch the package over to a src layout, which just means renaming the typical convention of my calculator package containing source files from calculator to src. This requires that setup is then properly adjusted, and that the src directory contains a single directory called calculator. This, in my opinion, is ugly, so I went with the much simpler option\nsimply remove or rename the source directory on the CI server, so that the package can't be found in the working directory. In my specific case, I just ran mv calculator src before running my tests.","Q_Score":2,"Tags":"python,cython,setuptools,python-wheel","A_Id":56912627,"CreationDate":"2019-07-05T19:15:00.000","Title":"How to test Python wheels on CI","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently started used Atom IDE. It feels good. The only thing that I find difficult is to setup a project profile to run. In pycharm there is Run configuration, is there something similar to it in Atom ?\nI have a project with multiple classes. When ever I want to run my script,I have to go to the main.py to launch 'ctrl + i'.\nCould any one help me to setup the project in a such a way, when I execute 'ctrl + i' it automatically launch's main.py instead of the py file I am calling from.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":811,"Q_Id":56913965,"Users Score":1,"Answer":"In the top bar, under \"packages\", go to \"script\", and select \"configure script\".\nThere put in the directory in which the program is, what command to run (python3 main.py), and select \"save as profile.\" The window explains itself.\nThen, you should be able to run from that profile with Alt+Ctrl+Shift+B, from whatever tab you're on.","Q_Score":0,"Tags":"python-3.x,ide,atom-editor","A_Id":56914347,"CreationDate":"2019-07-06T12:10:00.000","Title":"How to configure Atom script to run main.py","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"The title clearly says it, \nHow do I go about dragging the message author into the voice channel the bot is currently in?\nSay my bot is in a voice channel alone. A command is called to play sound to the author only. \nBut the author isn't in a voice channel, so I can't use the move_to(*) method, hence the word drag.\nI scrounged the API reference for connections, but I can't seem to find any.\nIs it even possible to drag users into a voice channel?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":179,"Q_Id":56924550,"Users Score":2,"Answer":"Of course you cannot forcibly connect a client to a voice channel - this would directly violate user privacy. Your idea is akin to 'dragging people into phone calls' unexpectedly.","Q_Score":0,"Tags":"python,discord,discord.py,python-3.7,discord.py-rewrite","A_Id":57067105,"CreationDate":"2019-07-07T17:35:00.000","Title":"discord.py rewrite - dragging message author to a voice channel","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I understand that the LaunchInstanceDetails method in oci.core.model has a parameter -> metadata , wherein one of the metadata key-names that can be used to provide information to Cloud-Init is -> \u201cuser_data\u201d , which can be used to run custom scripts by Could-Init when provided in a base64-encoded format.\nIn my Python code to create a Windows VM,while launching the instance, I have a requirement to run 2 custom scripts:\n\nScript to login to Windows machine via RDP \u2013 this is absolute(needs to be executed every time a new Windows VM is created without fail) \u2013 Currently , we have included this in the metadata parameter while launching the instance, as below:\ninstance_metadata['user_data'] = oci.util.file_content_as_launch_instance_user_data(path_init)\nBootstrap script to Install Chef during the initialization tasks - this is conditional ( this needs to run only if the user wishes to Install Chef and we internally handle it by means of a flag in the code) \u2013 Yet to be implemented as we need to identify if more than one custom script (conditional in this case) can be included.\n\nCan someone help me understand if and how we can achieve to include multiple scripts(keeping in mind the conditional clause) in a single metadata variable or can we have multiple metadata or some other parameter in this service that could be utilised to run the Chef Installation script","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":66,"Q_Id":56933571,"Users Score":0,"Answer":"I'd suggest combining these into a single script and using the conditional in a if statement to install Chef as required.","Q_Score":1,"Tags":"windows,python-2.7,chef-infra,oracle-cloud-infrastructure","A_Id":56974975,"CreationDate":"2019-07-08T11:05:00.000","Title":"use of multiple custom scripts in metadata parameter of the LaunchInstanceDetails method in oci.core.model","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know it is possible to fetch then use checkout with the path\/to\/file to download that specific file.\nMy issue is that I have a 1 MB data cap per day and git fetch will download all the data anyway even if it does not save them to disc until I use git checkout. I still used my data\nIs my understanding of how git fetch\/checkout correct? is there a way to download a specific file only to see if there is a new version before proceeding with the download.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":28491,"Q_Id":56943327,"Users Score":0,"Answer":"This works for me on a local gitlab:\ncurl http:\/\/mylocalgitlab\/MYGROUP\/-\/raw\/master\/PATH\/TO\/FILE.EXT -o FILE.EXT","Q_Score":14,"Tags":"python,linux,git","A_Id":70557243,"CreationDate":"2019-07-08T22:39:00.000","Title":"How to download a single file from GitLab?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm purposefully modifying every locally synced files (although directory name is unique and unmodified), which makes the sync method try to redownload the whole bucket, taking an excess of time.\nCopying the local files (to preserve their timestamp + size) isn't really an option since the bucket size is so big, and AWS sync docs don't seem to have an option to exclude modified files.\nI was hoping there's a way to prevent attempting to redownload a directory if it exists locally.\nAny ideas?\nThanks a lot","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":416,"Q_Id":56960781,"Users Score":0,"Answer":"Would aws s3 sync --size-only work for you?\n\n--size-only (boolean) Makes the size of each key the only criteria used to decide whether to sync from source to destination.\n\n(Emphasis mine.)","Q_Score":2,"Tags":"python,amazon-web-services,amazon-s3","A_Id":56960874,"CreationDate":"2019-07-09T21:33:00.000","Title":"AWS S3 sync method- possible to ignore modified files completely?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"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.\nI'm starting to get the hang of abstract classes and how to use them as blueprints for subclasses I'm creating.\nWhat I don't understand though, is the purpose of concrete methods in abstract classes.\nIf 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?\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":526,"Q_Id":56960959,"Users Score":1,"Answer":"This question is not Python specific, but general object oriented.\nThere 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.","Q_Score":1,"Tags":"python-3.x,oop,abstract-class","A_Id":56961464,"CreationDate":"2019-07-09T21:53:00.000","Title":"What is the purpose of concrete methods in abstract classes in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to determine why I would have the need to use Python in UiPath vs invoking VB.Net code. If someone could provide specific examples about why using Python would be more beneficial, it would be very much appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":201,"Q_Id":56975724,"Users Score":0,"Answer":"Python has a larger user community than VB.Net, therefore it is more likely to get help with Python in case you need to find out how to do something or have a problem.\nIt would be more comfortable if UIPath allowed writing the expressions in Python, but it's not dramatic either. You can always call a thread written in your favorite language and get the results to continue with the UIPath flow. Actually the expressions that one writes in UIPath are not so complex.","Q_Score":2,"Tags":"python,uipath","A_Id":57183394,"CreationDate":"2019-07-10T17:22:00.000","Title":"What are example cases in which I should use Python in UiPath?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently using python to write some appium test. Because I am behind a corporate firewall my traffic needs to go via a proxy. \nI have set my http_proxy and https_proxy variables, but it seems like this is not being picked up by python during execution.\nI tried the exact same test using javascript and node and the proxy get picked up and everything works so I am sure the problem is python not following the proxy settings.\nHow can I make sure python is using correct proxy settings?\nI am using python 2.7 on macos mojave\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":154,"Q_Id":56987653,"Users Score":0,"Answer":"So I figured out that appium currently does not support options to provide a proxy when making a remote connection. As temporary solution I modified the remote_connection module of selenium that appium inherits forcing it to use a proxy url for the connection.\nMy python knowledge is not that good but I think it shoudnt take much effort for someone to make a module that wraps\/override the appium webdriver remote connection to include a proxy option.","Q_Score":0,"Tags":"python","A_Id":57199327,"CreationDate":"2019-07-11T10:56:00.000","Title":"python ignores environmet proxy settings","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new in drone, can you please explain one thing:\nIs it possible to have RC controller programmed by python?\nAs I understood using telemetry module and DroneKit, it is possible to control the drone using python.\nBut usually telemetry module supporting drones are custom drones and as I understood telemetry module does not work as good as RC.\nSo to have cheaper price, can someone suggest me solution about how to control RC drone using python?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":268,"Q_Id":56990495,"Users Score":0,"Answer":"You can use tello drones .These drones can be programmed as per your requirement using python .","Q_Score":0,"Tags":"python,dronekit-python","A_Id":58305698,"CreationDate":"2019-07-11T13:34:00.000","Title":"Drone control by python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to remove Appium session and all Appium resources on the device, but leave an app opened on a real iOS device?\nThe thing is that I need to execute driver.quit to clean all Appium resources, but leave the app itself opened","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":291,"Q_Id":57011110,"Users Score":0,"Answer":"The best way I've found is to update deleteSession method in node_modules\/appium\/node_modules\/appium-xcuitest-driver\/build\/lib\/driver.js to remove await this.proxyCommand(\/session\/${this.sessionId}, 'DELETE');","Q_Score":0,"Tags":"ios,appium,python-appium","A_Id":57065414,"CreationDate":"2019-07-12T16:50:00.000","Title":"Is it possible to remove Appium session (and all Appium resources on device), but leave app opened on iOS (real device)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have written api using nodejs and calling those api's from Python code. I always have to make sure that my nodejs is running before I execute my python code. Can we make nodejs start running automatically while start executing python file.\nFor Example: we can achieve this in the angular just by including some code in package.json file, so that when I start angular server that will automatically run my node script as well.\nI saw about \"Python-Shell\" package but \"It is a simple way to run Python scripts from Node.js\".\nThis is very important. Please help me!!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":71,"Q_Id":57016359,"Users Score":0,"Answer":"In the package.json file, you will find a start property which define commands the console should run when the server is started.","Q_Score":1,"Tags":"node.js,python-3.x","A_Id":57016622,"CreationDate":"2019-07-13T05:13:00.000","Title":"How to make nodejs run automatically when we start running python code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"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.\nI already had code in Sublime Text 3 file, how can I run it without this error? \nFor example: \n\n'ModuleNotFoundError: No module named 'matplotlib'. \n\nI think it should be run by cmd but I don't know how.","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5433,"Q_Id":57038252,"Users Score":2,"Answer":"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. \nThen, 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.\nIf 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.","Q_Score":3,"Tags":"python,sublimetext3","A_Id":57038467,"CreationDate":"2019-07-15T10:55:00.000","Title":"[How to run code by using cmd from sublime text 3 ]","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In my raspberry pi, i need to run two motors with a L298N.\nI can pwm on enable pins to change speeds. But i saw that gpiozero robot library can make things a lot easier. But \nWhen using gpiozero robot library, how can i alter speeds of those motors by giving signel to the enable pins.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":503,"Q_Id":57038494,"Users Score":1,"Answer":"I have exactly the same situation. You can of course program the motors separately but it is nice to use the robot class.\nLooking 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. \nSo here is my line of code:\n Initio = Robot(left=(4, 5, 12), right=(17, 18, 13))\nHope it works for you!\nI have some interesting code on the stocks for controlling the robot's absolute position, so it can explore its environment.","Q_Score":1,"Tags":"python-3.x,raspberry-pi2,robotics,gpiozero","A_Id":59144212,"CreationDate":"2019-07-15T11:09:00.000","Title":"how can I use gpiozero robot library to change speeds of motors via L298N","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Python script that contains a plain text password used to bind Mac to AD.\nI need to deploy this script to few Macs.\nHow can I secure password which is in plain text, so that no one can see the password?\nI don't want to use base64, I'd need something stronger than base64.","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":1177,"Q_Id":57039385,"Users Score":-1,"Answer":"Try storing the password in a variable in a separate Python script. \npass.py\npassword = 'PASSWORD'\nImport the variable from this script separately.\nmain.py\nfrom pass import password\nThis will create a bytecode file named pass.pyc. Now you can delete pass.py and continue using pass.pyc, which isn't human-readable and much harder to decompile.\nEdit: If somebody has access to your source code, they can still see the password with a print statement!\nEdit 2: As Giacomo Alzetta commented, the password is still human-readable here, but it comes down to the \"attack model\" here. If someone really wants to, they can still dig around and find it. Other alternatives are encryption algorithms available in OpenSSL. Symmetric key algorithms might still not be useful for you since you'd probably have to store the encryption key within the source code. Asymmetric key algorithms might work.","Q_Score":1,"Tags":"python,macos","A_Id":57039581,"CreationDate":"2019-07-15T12:04:00.000","Title":"How to secure plain text Password in python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've got a 10K+ line log file that I'm using to debug an issue. I'm looking for 'aberrant' log lines that occur infrequently relative to the other lines in the file to hopefully extract interesting happenings that may be occurring. These log lines are highly variable and diverse.\nMy initial approach was to do a fuzzy comparison of each line against the remaining lines in the file, get an average of those ratios and assign it to each line, sort those ratios and return the smallest N items in that set.\nHowever, this takes a very, very long time on my machine when using Python (I'm using fuzzywuzzy).\nAny alternative suggestions?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":31,"Q_Id":57047521,"Users Score":0,"Answer":"Instead of that comparison, make one pass of the file to categorize the lines by their distinctive features. Store a reference to each line in a dict, keyed by category.\nThen make a pass over the dict, eliminating any keys with too many references (i.e. boring categories). The remaining categories are the interesting ones.\nThis is an O(N) process, rather than the O(N^2) process with which you started.","Q_Score":0,"Tags":"python,string,algorithm,search,fuzzy-search","A_Id":57047650,"CreationDate":"2019-07-15T21:40:00.000","Title":"Finding least commonly occurring fuzzy string","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm doing a project that consists of an RPi and an ESP8266. My RPi acts as the broker. I send data from my ESP to RPi through MQTT by subscribing. When I don't subscribe and run my code the data is lost until the point I subscribe. Is there a way to save the data values in the RPi as a file and when I subscribe, the previous data isn't lost as it is saved?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":50,"Q_Id":57059553,"Users Score":0,"Answer":"There needs to be a subscriber for the broker to not discard messages. If you want to keep all of them, you will need to have a subscriber that records messages and can play them back later or otherwise allow you to process the data.","Q_Score":0,"Tags":"python,mqtt","A_Id":57059943,"CreationDate":"2019-07-16T14:25:00.000","Title":"How to save data values without subscribing through MQTT?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python script that is called from a java program \nThe java program feeds data to the python script sys.stdin and the java program receives data from the python process outputstream . \nWhat is know is this .\nrunning the command 'python script.py' from the java program on 10MB of data takes about 35 seconds.\nHowever running the commands 'python script.py > temp.data ' and then cat temp.data is significantly faster. \nThe order of magnitude of performance is even more drastic as the data gets larger.\nIn order to address this , I am thinking maybe there is a way to change the sys.stdout to mimic what I am doing.\nOr maybe I can pipe the python script output to a virtual file .\nAny recommendations ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":169,"Q_Id":57067260,"Users Score":0,"Answer":"This is probably a buffering problem when you have the Java program writing to one filehandle and reading from another filehandle. The order of those in the Java and the size of the writes is suboptimal and it's slowing itself down.\nI would try \"python -u script.py\" to see what it does when you ask python to unbuffer, which should be slower but might trick your calling program into racing a different way, perhaps faster.\nThe larger fix, I think, is to batch your code, as you are testing with, and read the resulting file, or to use posix select() or filehandle events to handle how your java times its writes and reads.","Q_Score":0,"Tags":"python,bash,sys","A_Id":57068701,"CreationDate":"2019-07-17T01:13:00.000","Title":"receiving data from java program that calls python script is too slow","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"Using Red Hat, apache 2.4.6, worker mpm, mod_wsgi 4.6.5, and Python 3.7 When I start httpd I get the above error and: \nModuleNotFoundError: No module named 'encodings'\nIn the httpd error_log.\nI'm using a python virtual environment created from a python installed from source under my home directory. I installed mod_wsgi from source using --with-python= option pointing to the python binary in my virtual environment, then I copied the mod_wsgi.so file into my apache modules directory as mod_wsgi37.so\nI ran ldd on this file, and have a .conf file loading it into httpd like this:\nLoadFile \/home\/myUser\/pythonbuild\/lib\/libpython3.7m.so.1.0\n LoadModule wsgi_module modules\/mod_wsgi37.so\nThen within my VirtualHost I have:\nWSGIDaemonProcess wsgi group=www threads=12 processes=2 python-path=\/var\/\n www\/wsgi-scripts python-home=\/var\/www\/wsgi-scripts\/wsgi_env3\nWSGIProcessGroup wsgi\nWSGIScriptAlias \/test \/var\/www\/wsgi-scripts\/test.py\n\nfrom my virtual environment:\nsys.prefix:'\/var\/www\/wsgi-scripts\/wsgi_env3'\nsys.real_prefix:'\/home\/myUser\/pythonbuild'\nWhen I switch to the system-installed mod_wsgi\/python combo (remove python-home line from WSGIDaemonProcess, and change the .conf file to load the original mod_wsgi.so) it works fine. It seems like some path variables aren't getting set properly. Is there another way to set variables like PYTHONHOME that I'm missing? How can I fix my install?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2265,"Q_Id":57082540,"Users Score":1,"Answer":"I had a very similar issue and I found that my manually specified LoadModule wsgi_module \"\/path_to_conda\/\" was being ignored because the previously apache-wide wsgi mod was being loaded. You can check if wsgi.* is present in \/etc\/apache2\/mods-enabled.\nIf that is the case, consider a2dismod wsgi to disable the apache wsgi that loads the wrong python.","Q_Score":2,"Tags":"python,apache,redhat,wsgi","A_Id":68673425,"CreationDate":"2019-07-17T18:56:00.000","Title":"mod_wsgi - Fatal Python error: initfsencoding: unable to load the file system codec","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I know I can use testzip or just try to uncompress the file and catch the exception.\nMy issue is that I might have .msg files which have attachments that are zipfiles.\nIn that case the ZipFile will just skip over the first few bytes, open the attached zip file and not raise an exception.\nThe only way I can come up with this is manually opening the file and check the first two bytes to see if it's PK, but I'd just like to have a more \"strict\" check.\nIs this possible with either ZipFile or another library?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":205,"Q_Id":57095466,"Users Score":2,"Answer":"What is \"actually a zipfile\" for you?\nA file marked as such with PK?\nA valid \"header\" at the end of the file?\nThere are files in the wild that work as PE executable, ZIP, and PDF at the same time.\nThe most strict you can get would probably both the PK and reading the header. You already answered your own question.","Q_Score":1,"Tags":"python,python-zipfile","A_Id":57095530,"CreationDate":"2019-07-18T13:18:00.000","Title":"Check if file is actually a zipfile","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I made a chatbot in AWS Lex and deployed it to facebook. However, I want the chat to display a typing animation before the bot replies. Right now the bot just replies instantly. I want there to be a typing animation to make the bot been more human like. \nIs there some setting in FB Developer I can turn on? I can't seem to find it anywhere. All I see are things for the API call but I am not using any REST calls in my chatbot.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":25,"Q_Id":57096570,"Users Score":0,"Answer":"What if you wait 1 second before sending the message?","Q_Score":0,"Tags":"python,amazon-web-services","A_Id":57096707,"CreationDate":"2019-07-18T14:12:00.000","Title":"AWS Lex and Facebook typing animation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing a c extension (called my_ext) and I successfully compiled the source code to a .so file. However, my_ext depends another dynamic library installed by pip. So the link directory looks like \/lib\/python3.6\/site-packages\/foo. And my link command looks like this g++ -fPIC -L\/lib\/python3.6\/site-package\/foo\/ -lfoo ... and I am able to link successfully. However, my question is that since my link_directory is hard-coded according to path in my laptop. When I package my python package and ship to customer, how will that extension load libfoo.so? I assume it will look for the path hard-coded by me right? In this case, customer might not be able to load libfoo.so. How can I resolve this issue?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":58,"Q_Id":57102081,"Users Score":0,"Answer":"However, my question is that since my link_directory is hard-coded according to path in my laptop\n\nIt shouldn't be. How did you come to conclusion that it is?\nRun readelf -d my_ext.so, and see if there is a reference to the path on your laptop. If there is (unlikely), update your question with the output from readelf -d, and a better answer may come.","Q_Score":0,"Tags":"python,dynamic-linking,python-extensions","A_Id":57212325,"CreationDate":"2019-07-18T20:19:00.000","Title":"Ship Python Extension that required dynamic linking","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wrote a Python script which scrapes a website and sends emails if a certain condition is met. It repeats itself every day in a loop.\nI 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.\nIs there a specific website I can host my Python code on which will allow it to always run?\nMore 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?\nThanks in advance!","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":1140,"Q_Id":57126697,"Users Score":3,"Answer":"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.\ni did this with my telegram bot","Q_Score":1,"Tags":"python,cloud,hosting","A_Id":63171389,"CreationDate":"2019-07-20T16:40:00.000","Title":"How to host a Python script on the cloud?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wrote a Python script which scrapes a website and sends emails if a certain condition is met. It repeats itself every day in a loop.\nI 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.\nIs there a specific website I can host my Python code on which will allow it to always run?\nMore 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?\nThanks in advance!","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":1140,"Q_Id":57126697,"Users Score":2,"Answer":"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.","Q_Score":1,"Tags":"python,cloud,hosting","A_Id":57130698,"CreationDate":"2019-07-20T16:40:00.000","Title":"How to host a Python script on the cloud?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to tweet something by talking to Alexa. I want to put my code on AWS Lambda, and trigger the function by Alexa.\nI already have a Python code that can tweet certain string successfully. And I also managed to create a zip file and deploy it on Lambda (code depends on the \"tweepy\" package). However, I could not get to trigger the function by Alexa, I understand that I need to use handlers and ASK-SDK (Alexa Service Kit), but I am kind of lost at this stage. Could anyone please give me an idea about how the handlers work and help me see the big picture?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":195,"Q_Id":57134770,"Users Score":0,"Answer":"For your question about capturing user's input for tweeting, use AMAZON.SearchQuery slot type. You may run into limitations about how much text can be collected and the quality of the capture but SearchQuery slot is the place to start.","Q_Score":0,"Tags":"python,handler,alexa,alexa-skills-kit","A_Id":57210572,"CreationDate":"2019-07-21T15:53:00.000","Title":"How to integrate Lambda, Alexa, and my code (Python - Tweepy)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Something I've noticed is that when there is an error in our script (regardless of the programming language), it often takes longer to \"execute\" and then output the error, compared to its execution time when there are no errors in our script. \nWhy does this happen? Shouldn't outputting an error take less time because the script is not being fully run? Or does the computer still attempt to fully run the script regardless of whether there is an error or not?\nFor example, I have a Python script that takes approximately 10 seconds to run if there are no errors. When there is an error, however, it takes an average of 15 seconds. I've noticed something similar in NodeJS, so I'm just assuming that this is the case for many programming languages? Apologies if this is a bad question - I'm relatively new to programming and still lack some fundamental understandings.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":41,"Q_Id":57136776,"Users Score":1,"Answer":"The program doesn't attempt to run the script fully in case of an error, the execution is interrupted at the point where an error happens. This is by default but you can always set up your own exception handlers in your scripts which will execute some code.\nAnyway, raising and handling (logging) exceptions also requires some code execution (internal code of the programming language) thus this also takes some time.\nIt's hard to tell why your script execution takes longer in case of an error without looking at your script though, I personally never noticed such differences in general but maybe I just didn't pay attention...","Q_Score":1,"Tags":"python,node.js,performance,time,error-handling","A_Id":57137376,"CreationDate":"2019-07-21T20:29:00.000","Title":"Why do errors take longer than the script itself?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Let me start off by saying I know this issue has already been discussed, but I could not find a solution that was similar to my case.\nI have a directory structure like the following:\n\nproject\/\n\n\ntools \n\n\nmy_tool\n\n\ntool_name.py\n\n\ntests\n\n\nlib\n\n\nconstants.py\nmy_test.py\ncommon\/\n\n\ncheck_lib.py\n\n\n\n\n\nI need to import constants.py, check_lib.py, and tool_name.py into my_test.py using relative paths. Is there a way to do this even though several of my modules are in various depths within different directories in my project? I am trying to do this directly in the code with a \"from module.path import module\" type of import. Any help is greatly appreciated!\nMY solution was the following:\ntool_name.py\n\nprint(\"tool_name.py imported\")\n\nconstants.py\n\nprint(\"constants.py imported\")\n\ncheck_lib.py\n\nprint(\"check_lib.py imported\") \n\nmy_test.py\n\nimport constants\n import common.check_lib \nimport sys\n import os\n sys.path.append(os.path.abspath('test_project\/tools\/my_tool')) \nimport tool_name \n\noutput : \n\nconstants.py imported\n check_lib.py imported\n tool_name.py imported\n my_test.py is running","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":54,"Q_Id":57150623,"Users Score":0,"Answer":"Using PYTHONPATH=., go to the directory one level up from \"project\".\nInvoke your code with somewhat long names, e.g. $ python -m project.tools.my_tool.tool_name.\nThat way \"tools\" code will be allowed to access \"tests\", since it's still within \"project\".","Q_Score":1,"Tags":"python-3.x","A_Id":57150714,"CreationDate":"2019-07-22T16:59:00.000","Title":"Import module using relative paths","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to sift through a Word document and complete some quick grammar checks. I currently have code that splits the document into words using python-docx and then I run my grammar checks on the words\/sentences based on specific criteria. I then past the correct grammar back into the document using the .add_run function.\nThe issue I'm having is when I past the correct grammar back into the document, it doesn't save the font style (Bold and Italics), so when I paste words in, it just shows up as text without the Bold and Italics when I want to keep it. \nMy question is, is there any way in python (using python-docx or any other package) to save the font details (mainly bold and italics) for each word so that I can use code to bold or italicize words accordingly?\nI've already tried using the .style function for paragraphs and runs, but the issue that arises is that the style per paragraph is unclear on what is being bolded and italicized, and I don't want to paste a whole paragraph, just the wrong words.\nI've also tried looking at the .style for each run, but it is unreliable since runs often splits a word into 2 when it shouldn't. (\"Mario\" might become 2 different runs \"M\" and \"ario\" even when there isn't any style change).\nI've also tried looking at other packages but haven't found anything helpful.\nif the input is \"Stack Overflow is a question and answer site for professional and enthusiast programmers.\"(with \"question\" and \"answer\" is bold and italicized),\nthe expected output is same sentence with the word \"question\" and \"answer\" bold and italicized\nthe actual output is the same sentence but no bold or italics in it whatsoever.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":141,"Q_Id":57169973,"Users Score":0,"Answer":"This is a challenging problem in the general case:\n\nCharacter-formatting can be applied at various levels (directly, style, document-default, etc.) and determining the effective character formatting for a particular run is therefore not a single-step process.\nA given word can partly appear in more than one run and not all parts of the word are guaranteed to be complete runs, for example a sequence of five r|uns could ab|so|lut|ely be split like this\"\n\nSo you have your work cut out for you. A general-case solution might have a Word object for each word, with a sequence of (run, offset, length) tuples for each which, with the proper processing, could give you the information you need. You would probably assume that the formatting of the first character of the word could safely be applied to the whole word. In that case, you could just have a sequence of (word, run) pairs, where the run item is the one in which the first character of word appears in.\nAs a start I would look at run.bold and run.italic to get the most common formatting and then work your way up from there.","Q_Score":0,"Tags":"python,python-docx","A_Id":57172882,"CreationDate":"2019-07-23T18:10:00.000","Title":"How to use python-docx or any other similar package to save font style (bold and italic) from Word document","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been successfully using the Python Tweepy library to download data (tweets) from Twitter. I had substantial help with my code using Tweepy. For the next stage of my research, I need to access the Premium Search API, which I cannot do using Tweepy. Twitter recommends using TwitterAPI for premium search, available from @geduldig on GitHub. The problem is I'm new to Python and it would be a steep learning curve for me to learn TwitterAPI. Am I able to use TwitterAPI just to access the premium search API, but use Tweepy for other tasks (implement search query, etc)?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":69,"Q_Id":57186757,"Users Score":0,"Answer":"I do not know specifics about the libraries you asked, but of course, you could use both the libraries in your program. \nYou need to spend a little bit more time grokking the TwitterAPI library. I do not think that amounts to a steep learning curve.","Q_Score":0,"Tags":"python,github,twitter,tweepy,twitterapi-python","A_Id":57186922,"CreationDate":"2019-07-24T15:45:00.000","Title":"Python Novice: where to start with Python and TwitterAPI","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to transfer an image saved to a raspberry pi from the rpi to an android application to display it. I am treating the raspberry pi as the server and the android app as the client. My server side is implemented using python. I am using pylab to save a figure to the raspberry pi and then later open the image and read the contents as a byte array. This byte array is then passed to the android app, written in java. \nI can view the image on the rpi when I open it, but once it is sent to the android, something is happening to it that causes the incorrect number of bytes to be read and the image to be corrupted. I realized that java reads big endian while the raspberry pi byte order is little endian. I am not sure if this is what is causing the problem in transferring the image? \nSo, I am wondering if there is a way to either encode the byte array as big endian when it is sent from python or a way to decode the byte array as little endian when it is received by java. I tried simply reversing the image byte array in python but that did not work. Any suggestions would be very helpful!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":448,"Q_Id":57197445,"Users Score":0,"Answer":"I am not an expert in hardware differences between a Pi and other platforms, but this process can be performed using ByteBuffer.\nYou can get an instance of ByteBuffer using ByteBuffer.wrap(byteArray) or ByteBuffer.allocate(capacity).\nYou can then set the endian-ness of the buffer using buffer.order(ByteOrder.BIG_ENDIAN); or buffer.order(ByteOrder.LITTLE_ENDIAN);\nThe data can then be returned with buffer.get().","Q_Score":0,"Tags":"java,python,tcp,raspberry-pi,endianness","A_Id":57197538,"CreationDate":"2019-07-25T08:24:00.000","Title":"Convert Image from Little to Big Endian","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a consumer application written in python. It consume the rabbitmq messages through multiprocessing. But when I try to process or validate those messages with in the on_message callback function then the consumption is bit slow. I am opening an excel mapping file to validate those incoming messages through a separate message class. Any help? Thanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":222,"Q_Id":57214978,"Users Score":0,"Answer":"since I can't comment yet I ll write to you here what I think about the pub. I think your Question is not clear. Besides I think you should show some Code and explain further what you are trying to achieve. what is meant by consumption is a bit slow ? like how exactly ? and which Pika version are you using etc.. this can be Important to look up what can provoque this \"slow\" Error that you have. Besides I think Pika is buggy for the 0. version, while using it I had some issues sometimes and it is not thread safe.","Q_Score":0,"Tags":"python,rabbitmq,producer-consumer,xlrd,pika","A_Id":57218571,"CreationDate":"2019-07-26T07:18:00.000","Title":"Pika message consumption is slow while processing messages in callback function","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm want to remove the chinese characters of a text or any other any character that isnt Latin\ni tried using encoding='UTF-8' but dont works\nText Example: \nUm olhar maligno que s\u00f3 desejava a destrui\u00e7\u00e3o!\n\u201cParem-o!\u201d\nEle ordenou os dem\u00f4nios.\nOs dem\u00f4nios abriram suas asas, seguraram suas armas e lan\u00e7aram magia.\n\u03a3? ?\u0393\u03b1\u03c0? \u2026\u2026. \u201d\n\u0393\u03b5\u03b9? !!\nI want that return\nUm olhar maligno que s\u00f3 desejava a destrui\u00e7\u00e3o!\n\u201cParem-o!\u201d\nEle ordenou os dem\u00f4nios.\nOs dem\u00f4nios abriram suas asas, seguraram suas armas e lan\u00e7aram magia.\n? ?? \u2026\u2026. \u201d\n? !!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1280,"Q_Id":57232963,"Users Score":0,"Answer":"Try to use this extension of Latin encoding:\nISO 8859-2 (Latin 2)","Q_Score":0,"Tags":"python,unicode-string","A_Id":57233039,"CreationDate":"2019-07-27T14:16:00.000","Title":"Remove chinese characters","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know this has been questioned before, but no real solution was proposed and I was wondering if there any new ways nowadays.\nIs there anyway to hook an event using any AWS service to check if a lambda has timed out? I mean it logs into the CloudWatch logs that it timed out so there must be a way.\nSpecifically in Python because its not so simple to keep checking if its reaching the 20 minute mark as you can with Javascript and other naturally concurrent languages.\nIdeally I want to execute a lambda if the python lambda times out, with the same payload the original one received.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":5966,"Q_Id":57258980,"Users Score":1,"Answer":"Two options I can think of, the first is quick and dirty, but also less ideal:\n\nrun it in a step function (check out step functions in AWS) which has the capability to retry on timeouts\/errors\na better way would be to re-architect your code to be idempotent. In this example, the process that triggers the lambda checks a condition, and as long as this condition is true, trigger the lambda. That condition needs to remain true unless the lambda finished executing the logic successfully. This can be obtained by persisting the parameters sent to the lambda in a table in the DB, for example, and have an extra field called \"processed\" which will be modified to \"true\" only once the lambda finished running successfully for that event.\n\nUsing method #2 will make your code more resilient, easy to re-run on errors, and also easy to monitor: basically all you have to do is check how many such records do you have which are not processed, and what's their create\/update timestamp on the DB.","Q_Score":5,"Tags":"amazon-web-services,aws-lambda,python-3.7","A_Id":57259095,"CreationDate":"2019-07-29T17:46:00.000","Title":"How to handle timeouts in a python lambda?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to implement very simple authentication for updating values on my server. Here's the situation:\nI have a door sensor hooked up to a raspberry pi. Every time the sensor is triggered ('Opened' or 'Closed'), I send a POST request out to my Digital Ocean droplet at 'api.xxxxxx.com' which points to a restify server. The POST request body contains the sensor state, a time-stamp, and an API key. The RESTify server also has a file called 'constants.js' that contains the same API key. If the API key sent from the RPi is the same as the one in the constants file on my droplet, it allows values to update (latest state\/time). If not, it just sends back an error message.\nThe API key is a password sent through SHA3-256.\nIs this scheme okay for what I'm doing? The only thing I could think of is if someone found the endpoint, they might be able to spam requests to it, but nothing else. The API key (on my local raspberry pi and on the droplet) are kept in different files and excluded from git, so viewing git files would not reveal anything.\nI don't expect anyone to have access to my droplet or raspberry pi either, so if I set up SSH correctly I don't see how it (the API key in the files) could be leaked either.\nEDIT: Forgot to say that I'm using Python on the Raspberry Pi to send out POSTs. The droplet is running a RESTify server (JS).","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":48,"Q_Id":57262893,"Users Score":1,"Answer":"Well, you are vulnerable to network snooping. If anyone can snoop either of the network links, then they can steal the API key and are free to use your service with it. \nHTTPS on both links would prevent that. HTTPS could also prevent any sort of DNS hijack that could trick the Pi into sending the APIKey to a false host (thus stealing it that way).\nOther than that, your API key is your secret that controls access so as long as it is secured in storage at both ends and secured in transit and it's sufficiently hard to guess, you are OK.","Q_Score":0,"Tags":"javascript,python,node.js,authentication,restify","A_Id":57263175,"CreationDate":"2019-07-30T00:41:00.000","Title":"Very simple authentication on my own server, is this okay?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Getting intermediate result, while PuLP is trying to find the optimal and feasible solution.\nAs you know, solving Mixed integer Linear programming (MILP) cases may take a long time. I'm trying to get intermediate results from PuLP optimization package, while it is running. I know it is possible to do that in Gurobi, which is a commercial optimization package.\nI'm not sure about the code I can use in PuLP package to get that information. Any advice would be appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":126,"Q_Id":57289142,"Users Score":1,"Answer":"Pulp doesn't really have this interface (though if you use gurobi you can access the underlying solver object).","Q_Score":0,"Tags":"python-3.x,optimization,pulp,mixed-integer-programming","A_Id":57299336,"CreationDate":"2019-07-31T10:55:00.000","Title":"Getting intermediate info. from PuLP","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have 10 Beacons and I can see there are different rssi values published using python file.\nhowever, when i try to use the phone\/pc to find the beacons, sending different \"rssi\" value for unique mac address.\nI need to understand that is there any function to find value of rssi for unique mac address? Below is my output and should I get value of rssi in one array for one mac address?\nFor Example\nMessage Recieved from Beacon: {\n \"uuid\": \"uuid\",\n \"major\": 1,\n \"minor\": 2,\n \"txPower\": 216,\n \"RSSI\": -76,\n \"MAC_ADDRESS\": \"ca:83:81:d8:f4:2f\"\n}\nMessage Recieved from Beacon: {\n \"uuid\": \"uuid\",\n \"major\": 1,\n \"minor\": 2,\n \"txPower\": 216,\n \"RSSI\": -77,\n \"MAC_ADDRESS\": \"ca:83:81:d8:f4:2f\"\n}\nI expect the output \nIn one minute duration\nMac address : [ca:83:81:d8:f4:2f]\nRSSI : [-76,-77,-78]","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":164,"Q_Id":57294957,"Users Score":0,"Answer":"Each \"message received\" is an advertising data packet. It contains the signal strength of that particular packet as the RSSI value. The advertisements come in random order and aren't requested for by the receiver. If you want to query a particular address for the last few RSSI values, then you need to have the program record all the advertising RSSI values it's previously seen and then you query that.","Q_Score":0,"Tags":"python,bluetooth-lowenergy,rssi","A_Id":57313194,"CreationDate":"2019-07-31T16:06:00.000","Title":"How to store iBeacon RSSI values till one minute in an array using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have written a simple test code in python to toggle two of the I\/O pins on and off every few seconds. I would like to be able to run this code whenever the board powers on so that I don't need to bring a keyboard, mouse, and monitor everywhere I want to run the simple test. How do I do this on Mendel OS on a google coral?","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":656,"Q_Id":57302900,"Users Score":1,"Answer":"Using crontab has been working consistently for me, you may want to add a time.sleep in the beginning of your python file\nedit crontab \ncrontab -e\nselect nano editor\nadd\n@reboot sudo python3 ","Q_Score":2,"Tags":"python-3.x,google-coral","A_Id":58123872,"CreationDate":"2019-08-01T06:22:00.000","Title":"How do I run a python script on boot on Google Coral?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to save an image\/an array as an OIB File.\nI have tried using the oiffile library. I am able to open and read OIB files, but I want to save an image as an OIB File.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":78,"Q_Id":57311998,"Users Score":0,"Answer":"Since oiffile uses cv2 structure for opening\/closing images (via numpy arrays), so you might be opening the image using imread(). Then you can use imwrite() for saving\/writing the image file to a destination path.","Q_Score":0,"Tags":"python,image,save","A_Id":57314256,"CreationDate":"2019-08-01T15:06:00.000","Title":"Saving an Image as an OIB File in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"A few months ago I had Visual Studio IDE then uninstalled it and(stupidly) uninstalled all the Visual C++ Redistributables along with it. I managed to install all the versions from 2005 up to 2013, but I can't seem to get the 2015 version running. I get stuck on \"processing: windows81_x64\" and \"processing: windows81_x86\" screens.\nI'm trying to use python in command prompt \"C:>python\" and I get this error \"The program cant start because api-ms-win-crt-runtime-l1-1-0.dll is missing from your computer\". I'm also getting similar error messages with other software, python is just an example.\nI've tried manually deleting and reinstalling the packages , which obviously hasn't worked. I've also tried using the \"major geeks\" installer (I know its a 'use at my own risk' software) but it only installed up to 2010 files. \nOn a side note, Windows update isn't working for me either, not sure if that has anything to do with the issue or not\nAny help appreciated","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":387,"Q_Id":57314714,"Users Score":0,"Answer":"I really don't know what the issue was, but I reinstalled windows 10 and everything now works fine.","Q_Score":1,"Tags":"python,visual-studio,visual-c++,installation,command-prompt","A_Id":59240615,"CreationDate":"2019-08-01T18:06:00.000","Title":"Visual C++ Redistributable 2015 Deleted and can't reinstall","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"1) I have a script (calling python), that runs perfectly on local\n2) The same scripts crashes on cron\n3) I know it's related to environment as: env reproduces the error exactly\n4) I have no .bash, .profile or any of those common files. They do not exist but its clear the env is setup somehow.\nI tried printenv and tried to copy-paste into my script, it didnt work. \nAny ideas into where to look next?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":194,"Q_Id":57331096,"Users Score":0,"Answer":"A simple way to troubleshoot cron is to redirect the stdout and stderr to a log file\n\n5 * * * * path_to_yourscript > \/tmp\/cron_output.log 2>&1\n\nLet cron run and then take a look at the log file","Q_Score":0,"Tags":"python,cron","A_Id":57331834,"CreationDate":"2019-08-02T17:28:00.000","Title":"Simulate local run for cron job","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'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?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":99,"Q_Id":57340091,"Users Score":0,"Answer":"Sorry, it turns out that program arguments aren't highlighted (the test I was using)","Q_Score":0,"Tags":"python-sphinx,pygments","A_Id":57341047,"CreationDate":"2019-08-03T16:17:00.000","Title":"I can not get pigments highlighting for Python to work in my Sphinx documentation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was trying something when I came across this problem. I have a hashed password stored in a file on my computer. However the way my code detects whether or not a password has already been set is it checks if that file exists. If it does than it will ask you for the password that has been set. If the file does not exist than it will ask you to set a new password. But this also means that theoretically if someone wanted to break in they could just delete that file and enter a new password.\nHow do you go about solving this? I am not sure if this is a totally stupid question or not but I have no clue how to solve this.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":40,"Q_Id":57343272,"Users Score":0,"Answer":"You don't have to ask for a password at all.\nJust deny all other users access to your script by settings permissions.\nIf you are sharing your user account consider someone could simply remove the password prompt from your script.","Q_Score":0,"Tags":"python,file,security,hash,passwords","A_Id":57345674,"CreationDate":"2019-08-04T02:00:00.000","Title":"How to properly save one hashed password","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"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.\nI 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.","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":303,"Q_Id":57373489,"Users Score":-1,"Answer":"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. \nFor instance, \nimage_dimensions = [1800, 2400] # width, height\npdf_page_dimension = [595, 841] # these are coordinates of the specific page of the pdf\nAssuming, 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\nx_scale = pdf_page_dimension[0] \/ image_dimensions[0]\ny_scale = pdf_page_dimension[1] \/ image_dimensions[1]\nscaled_coordinates = [400*x_scale, 700*y_scale, 450*x_scale, 720*y_scale]\nPdf page dimensions can be obtained from any of the packages: poppler, pdfparser, pdfminer, pdfplumber","Q_Score":0,"Tags":"python,opencv,nlp,ocr,tesseract","A_Id":61167395,"CreationDate":"2019-08-06T09:58:00.000","Title":"Showing text coordinate from png on raw .pdf file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm looking for the best way to preform ETL using Python.\nI'm having a channel in RabbitMQ which send events (can be even every second). \nI want to process every 1000 of them.\nThe main problem is that RabbitMQ interface (I'm using pika) raise callback upon every message.\nI looked at Celery framework, however the batch feature was depreciated in version 3.\nWhat 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.\nIt sounds like a very simple use-case, however I didn't find any good best practice for it.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":5901,"Q_Id":57378832,"Users Score":1,"Answer":"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. \nIf 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. \nThis is better than keeping a list in memory, because if your service dies, the messages will still be persisted in the database. \nNote : 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.","Q_Score":3,"Tags":"python-3.x,rabbitmq,etl","A_Id":57414807,"CreationDate":"2019-08-06T14:54:00.000","Title":"Best Practice for Batch Processing with RabbitMQ","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Suppose that I need some functionalities for my class(C) which are currently available in both A and B classes. So I decided to inherit from A or B in my class (C). A is more complete and includes some additional methods and variables which I will never use them. However, I prefer to use A since it seems to make my code more unified in a joint project.\nMy question is that does inheritance from A, in comparison with B, affect the code speed or not?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":57,"Q_Id":57387487,"Users Score":0,"Answer":"In CPython, changing the class from which a class inherits has little or no impact on its speed so long as each method\/attribute used comes from the corresponding class in the new hierarchy. (The \u201clittle\u201d case pertains when there are additional hash table collisions.) Adding additional bases that must be searched (because they appear in the method resolution order before the class that satisfies a lookup) will add a dictionary lookup per attribute search.\nFor many __magic__ methods, no inheritance ever matters: the function to call for each is precalculated and resolved in constant time thereafter.","Q_Score":1,"Tags":"python,python-3.x","A_Id":57388719,"CreationDate":"2019-08-07T05:27:00.000","Title":"Effect of additional inheritance on execution speed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to have a file which contains the path variable (my system's python path here will be F:\/Python\/python.exe) which is mentioned on the top of every python file stored in the www folder of wamp in Windows. Then I want to import that file to all the other files so that I don't need to mention the path on top of the file every time. Is this possible?\nI have tried creating a function and creating a variable that stored the variable but obviously that can't be done. So how to create such a file which can be imported in other files. Or is there any other solution for what I want to achieve?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":31,"Q_Id":57388129,"Users Score":0,"Answer":"You can try this way \nMaybe this can help you to solve the problem\n\nCreate a file main.py\nIn that particular file do all the import statements\n\nThis will reduce the repentance of the import statements \nFrom your file:\nfrom main import *","Q_Score":1,"Tags":"python,python-3.x,wamp","A_Id":57389030,"CreationDate":"2019-08-07T06:24:00.000","Title":"How to create a file containing path and import that file into another python file in the so that the path does not need to be explicitly mentioed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I 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'!\nI'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\n\nModuleNotFoundError: No module named 'nose'\nProcess finished with exit code 1\nEmpty suite\n\nI 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!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":112,"Q_Id":57389351,"Users Score":0,"Answer":"I found the solution: I can run without nosetests from the 'Run' dropdown options in the toolbar, or Alt+Shift+F10.","Q_Score":1,"Tags":"python,pycharm","A_Id":57389395,"CreationDate":"2019-08-07T07:44:00.000","Title":"Pycharm is not letting me run my script 'test_splitter.py' , but instead 'Nosetests in test_splitter.py'?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to create a clone\/copy of an existing web application on pythonanywhere. I have access to the pythonanywhere account. The application is active and is not mine - a friend is allowing me to make a copy so that I can learn how web applications work. Thus, it is important that I can make a copy without messing up or updating anything in the current web application. \nAll of the tutorials I am finding are about deploying an application via git to github to pythonanywhere (which I have done before) but never the other way around. \nI created an empty github repository and thought about going to the python bash console and adding it as a remote server, then pushing the code to github. But, I don't know if this makes a new connection that will mess up the application. I want to just download the application once and be done. \nI would really appreciate step-by-step instructions on how to download a copy of the web application to my local server and\/or github. If you provide code, please assume I know nothing and tell me where I should run it (command prompt, pythonanywhere bash console, etc).","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1080,"Q_Id":57401599,"Users Score":2,"Answer":"I just did this the following way. In a bash console on pythonanywhere, navigate to the app with $cd yourapp. Then create a git repository there with git init. Once its done add the folders in the app to the repo with git add . Then you need to commit to update the empty repository: git commit -m \"your comment\". \nOnce the repo is created on pythonanywhere, move to the local folder in your local machine's terminal where you want to copy the app. Then clone the repo on pythonanywhere with entering the following command to your local terminal: git clone yourusername@ssh.pythonanywhere.com:\/home\/yourusername\/yourapp \nSince its not a bare repository, you won't be able to push any code changes to the pythonanywhere app, by default. This can be changed though, but I understand that is not what you want. If you want to make sure that no changes are applied back, just delete the .git folder from pythonanywhere which was created by the git init \nMy concern though is, that if your friend's app is database backed, you might be able to send data to the live database from your local instance of the app. So, definitely double check on that with him\/her.","Q_Score":1,"Tags":"git,github,pythonanywhere","A_Id":59017818,"CreationDate":"2019-08-07T20:03:00.000","Title":"How to clone an existing web application from pythonanywhere to github\/local","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I'm wondering if there is a way to detect physical disconnection of a device while serial communication is open? Is the only way to write try-except code whenever data is sent?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":526,"Q_Id":57420789,"Users Score":0,"Answer":"Use pyserial isopen() which return a Boolean value if it is open or not.\n Import serial\nser = Serial.Serial(\"your serial info\")\n Ser.isOpen()","Q_Score":2,"Tags":"python,pyserial","A_Id":57422708,"CreationDate":"2019-08-08T21:23:00.000","Title":"How to detect when a device is disconnected while serial communication is open?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm wondering if there is a way to detect physical disconnection of a device while serial communication is open? Is the only way to write try-except code whenever data is sent?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":526,"Q_Id":57420789,"Users Score":1,"Answer":"There is no standard way to detect if a serial device is connected to say RS-232, RS-422, and other serial interfaces - there could be exceptions, which I don't know about though. For a RS-232 the minimum required wires to be able to receive and send are ground, TX, and RX. For a differential serial interface like RS-422 or RS-485 the ground isn't needed. If you know something about the behaviour of the device connected, then you could use this. Like if you expect certain responses to commands sent, or the RS-232 flags to be set in a certain way.","Q_Score":2,"Tags":"python,pyserial","A_Id":57434486,"CreationDate":"2019-08-08T21:23:00.000","Title":"How to detect when a device is disconnected while serial communication is open?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have python installed through windows store and I can install programs using pip, but when I try to run said programs, they fail to execute in powershell.\nHow can I make sure that the necessary \"scripts\" folder is in my path? I never faced these problems when installing from executable.\nFor example, \"pip install ntfy\" runs successfully in Powershell.\nThe command \"ntfy send test\" fails telling me the term is not part of a cmdlet, function, etc. etc.\nThe 'ntfy' program is located here \/mnt\/c\/Users\/vlouvet\/AppData\/Local\/Packages\/PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\/LocalCache\/local-packages\/Python37\/Scripts\/ntfy.exe\nWhat is the recommended way of editing my path so that programs installed via pip are available across windows store updates of the Python language?","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":10355,"Q_Id":57421669,"Users Score":7,"Answer":"The above answer is good but I managed to get it to work by doing the following.\n\nFind your installation under C:\\Users\\\"your user\"\\AppData\\Local\\Packages it will be named something like PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\nOpen your windows settings in the start menu\nIn search type Environment variables. Edit environment variables for your account should pop up. Click it\nIn the top box find Path, click it\nOn the right Click new and enter C:\\Users\\\"your user\"\\AppData\\Local\\Packages\\\"python install directory name from 1. here\"\\LocalCache\\local-packages\\Python37\\Scripts inside the little box under the last item in the list\nopen a new cmd prompt and type the script you wanted it should work.","Q_Score":10,"Tags":"python,windows,pip","A_Id":61709201,"CreationDate":"2019-08-08T23:05:00.000","Title":"Question about pip using Python from Windows Store","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Does anyone know of a solution for checking if a tweet has replies or not, without checking the reply_count field of the JSON response? \nI'm building a crawler and already have a method for scraping a timeline for tweets as well as replies to tweets. In order to increase efficiency I want to find out if a tweet has any replies at all before calling my reply method. I have a standard developer account with Twitter so I do not have access to reply_count.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":123,"Q_Id":57436251,"Users Score":0,"Answer":"Looking for this as well. Only way I found was scraping the page (which is against the Terms of Service)\nreply-count-aria-${tweet.id_str}.*?(\\d+) replies","Q_Score":0,"Tags":"twitter,tweepy,twitterapi-python","A_Id":61215841,"CreationDate":"2019-08-09T19:44:00.000","Title":"Is there a workaround for non-premium Twitter developers for getting reply_count?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently using page objects in my Appium and Python project to run the tests only on the iOS platform. Now I need to implement the same tests for Android (the app is the same).\nI know the locators are different for each platform, but the functions I created I can use for both platforms.\nIn java the @iOSXCUITFindBy and @AndroidFindBy annotations make design easier for this purpose, but so far I haven't found anything similar to use with Appium and Python.\nWhat strategy can I use to reuse the same functions for both platforms (Android and iOS)?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":1462,"Q_Id":57438847,"Users Score":2,"Answer":"I used Robot Framework (python) to create test suites for testing the development of an iOS and Android app. Same app and started at the same time. Automation was done in sprint. Automated tests as the app was being developed.\nInitially we created automated tests for both platforms at the same time. Similar ideas to above...If\/Else etc...\nWe ran into issues after a few months. I wasn't as simple as If\/Else. Functionality of the SAME APP across two mobile platforms changed during the development. Differences in what you can do (development\/technical wise) on iOS vs Android platforms differs in some points.\nThey essentially were the same app but they had differences created by some technical limitations. Allot of tests were simply not applicable across both platforms and would have required allot of effort and ugly tests to shoehorn them to be.\nOne platform then became a priority over the other. But laying the groundwork for test functionality for both platforms has an overhead which the business didn't want\/need as one platform was a priority (with option for he other to become the priority at a later date).\nDropped dual test suites after six months in favour of Android Test Suite separate to iOS Test Suite.\nSure there was some overlap but it became allot easier to manage.\nIf I were to start over I would have kept them separate at the start.\ntldr :) Keep them separate (folder\/suite structure and functionality wise).","Q_Score":2,"Tags":"python,appium,python-appium","A_Id":57673908,"CreationDate":"2019-08-10T02:30:00.000","Title":"Appium - Design page object to reuse same function with iOS and Android","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"So, I'm not a test expert and sometimes, when using packages like DRF, I think what should I test on the code...\nIf I write custom functions for some endpoints, I understand I should test this because I've written this code and there are no tests for this... But the DRF codebase is pretty tested.\nBut if I'm writing a simple API that only extends ModelSerializer and ModelViewSet what should I be testing?\nThe keys in the JSON serialized?\nThe relations?\nWhat should I be testing?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":630,"Q_Id":57455468,"Users Score":1,"Answer":"Even if you're only using automated features and added absolutely no customization on your serializer and viewset, and it's obvious to you that this part of the code works smoothly, you still need to write tests.\nCode tends to get large, and some other person might be extending your code, or you might go back to your code a few months later and not remember how your implementation was. Knowing that tests are passing will inform other people (or yourself in the distant future) that you're code is working without having to read it and dive into the implementation details, which makes your code reliable.\nThe person using your API might be using it at a service and not even be interested in what framework or language you used for implementation, but only wants to be sure that the features he\/she requires work properly. How can we ensure this? One way is to write tests and pass them.\nThat's why it's very important to write complete and reliable tests so people can safely use or extend your code knowing that the tests are passing and everything is OK.","Q_Score":0,"Tags":"python,django,testing,django-rest-framework","A_Id":57456241,"CreationDate":"2019-08-12T03:55:00.000","Title":"What to test in a simple DRF API?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"There are so many documentation about running OpenEDX on Ubuntu, but there is not any clear documentation how to run OpenEDX on CentOS specially with cPanel.\nAnyone can help me regarding this case?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":353,"Q_Id":57495379,"Users Score":0,"Answer":"I took \"tutor\" distribution which is in docker form, so it just ran smoothly over CentOS 7 of mine.","Q_Score":0,"Tags":"python,django,centos,cpanel,openedx","A_Id":62251687,"CreationDate":"2019-08-14T13:08:00.000","Title":"How to run OpenEDX on Centos 7 with cPanel","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I wish to do the following: \nfrom aienvs.Sumo.SumoGymAdapter import SumoGymAdapter\nbut python goes to the following path and imports it:\n\/home\/azlaan\/.local\/lib\/python3.6\/site-packages\/aienvs\/Sumo\nI don't want it to import from the sites packages but from this directory:\n\/home\/azlaan\/..\/..\/aienvs\/aienvs\/Sumo\nI added inside the .bashrc the pythonpath as follows:\nexport PYTHONPATH=\"\/home\/azlaan\/PycharmProjects\/otherprojects\/aienvs:$PYTHONPATH\"\nThere is also another PYTHONPATH defined before this line in the bashrc file, I dont know if it affects it or not.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":429,"Q_Id":57498199,"Users Score":0,"Answer":"Python scans the paths present under sys.path list to import the modules.\nBy default site-packages path will be present under sys.path list and since your module is present under site-packages directory, python will import the module from here.\nIf you want to import from \/home\/azlaan\/..\/..\/aienvs\/aienvs\/Sumo, insert this path to sys.path list at the 0th index. Add below lines to your script, this should make it work.\nimport sys\nsys.path.insert(0, \"\/home\/azlaan\/..\/..\/aienvs\/aienvs\/Sumo\")\nfrom SumoGymAdapter import SumoGymAdapter","Q_Score":0,"Tags":"python-3.x,import,python-import,pythonpath","A_Id":57563325,"CreationDate":"2019-08-14T15:56:00.000","Title":"How to prevent Python from looking into the site packages for a module?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to use CP-SAT solver with some variables: x,y. I want to maximise an objective function of the form x**2-y*x with some constraints. I'm getting\n\nTypeError: unsupported operand type(s) for ** or pow(): 'IntVar' and\n 'int'\n\nerror messages. Am I correct in assuming I cannot use nonlinear objective function for CP-SAT, as I couldn't find any documentation or examples that did employ nonlinear objectives? Or is there some way to do this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":671,"Q_Id":57524316,"Users Score":3,"Answer":"You have to create an intermediate variable using AddMultiplicationEquality(x2, [x, x])","Q_Score":1,"Tags":"python,or-tools,cp-sat-solver","A_Id":57524523,"CreationDate":"2019-08-16T12:02:00.000","Title":"Using CP-SAT Solver for non-linear objective function","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In Python, we have two widely used methods for taking user input. First input() method and second, readline() method defined as sys.stdin.readline(). I would like to know if there are any situations when input() method is preferred over readline() method.\nAs I understand, readline() is faster than input(). Both of these return string value and we have to typecast them according to our needs. There is also a readlines() method to read user inputs on multiple lines. Is it better to use readlines() when reading multiple lines from user?\ninput() method does not require any import, where as readline() requires an import of sys.stdin. Still input() is slower. Does this mean time required for importing is negligible?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":66,"Q_Id":57537890,"Users Score":2,"Answer":"TLDR Speed is not a factor.\nIf your program is designed to read data from standard input, the like of a Unix filter, you won't use input but you will use the methods of sys.stdin, exactly because you have different methods to match the data flow of your program.\nOn the other hand, if your program is designed to interact with a user then input is clearly the way to go. Because the speed of the program is not the infinitesimal difference in speed of the two calls but the speed of the user interaction and the extra convenience provided by the optional prompt string is a very strong argument in favour of input.","Q_Score":0,"Tags":"python,input,stdin,readline,readlines","A_Id":57538548,"CreationDate":"2019-08-17T16:07:00.000","Title":"Is there any situation when input() is preferred over sys.stdin.readline()?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to debug (and get an understanding of what is happening) a Python script that runs on a Raspberry Pi and uses Pygatt to communicate with a BLE peripheral device. I am trying to make it work using Visual Studio Code (because I use it for JavaScript) on a Linux Mint PC. My Python experience is minimal.\nThe script works fine on the Linux Mint PC with a CSR 4.0 dongle. I open a terminal and enter:\n$ \/usr\/local\/bin\/python3.6 -i \/home\/rob\/python-test\/BLETestTool.py\nThe script runs, sets up the BLE adapter, and I get the >>> prompt. From there I can issue commands to connect and communicate with the device. The key to this is the \"-i\" argument. If I leave it out, the script just sets up the BLE adapter, which flashes a bit, and then terminates.\nWhen I try to debug using VS Code the script starts without the \"-i\" argument and terminates. I have tried numerous settings in launch.json and I have been searching for hours.\nIs it possible to invoke the -i argument when debugging Python in VS Code, or any other IDE? Alternatively, is there an alternative way to get the interactive command line experience working?\nAny clues would be greatly appreciated.\nThanks in advance,\nRob","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":207,"Q_Id":57538204,"Users Score":0,"Answer":"The -i argument tells Python to exit into the REPL when the script is done running. It doesn't make sense to do that with the debugger. Instead, set a breakpoint in the script that gets hit before it exits. Then if you need to do interactive exploration you can use the debug console.","Q_Score":2,"Tags":"python,debugging,command-line,visual-studio-code","A_Id":57564723,"CreationDate":"2019-08-17T16:49:00.000","Title":"Debugging Python with an interactive terminal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm connected to a Raspberry Pi running Raspbian lite, using PuTTY with SSH. To execute a Python script, I'm navigating to the script's directory and using python3 scriptname.py, (this script is always running, unless being modified) after doing this, all I can see is the script's console log, and I don't think I'm able to do anything else with the Pi, unless if I stop the scripts execution.\nIs there anyway that I can send that process to the background, and continue to use the interface to do other things","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":283,"Q_Id":57547605,"Users Score":0,"Answer":"I appreciate the different solutions. I don't know why it didn't occur to me that opening a new terminal session would truly act as a new session, I would've guessed it would essentially clone the output, but thanks Mark. Thanks coderasha, I might use Linux Screen sometime. Also, thanks Dinko, I wasn't aware I could append executions using &!","Q_Score":0,"Tags":"python,raspberry-pi,raspbian","A_Id":57547830,"CreationDate":"2019-08-18T19:12:00.000","Title":"How can I have a Python script run in the background. I'm using terminal and SSH","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm developing a discord bot using discord.py (rewrite branch) for my servers and I need to invite the bot to multiple servers and use it simultaneously. \nMy question is: \nDo I need to set up a new thread for every server or does the bot queue events and handle them one by one? if it does queue them, should I just use that or use separate threads?\nSorry if this is a noobish question but I'm fairly new to discord.py and I don't really understand how it works just yet.\nThanks for reading","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":8081,"Q_Id":57550170,"Users Score":-1,"Answer":"Multiprocesses, threads or queues can all be used to approach this issue each with their respective advantages and disadvantages . Personally I would use threads as the events that need to take place on each server are independent of each other mostly.","Q_Score":3,"Tags":"python,discord.py-rewrite","A_Id":57550391,"CreationDate":"2019-08-19T03:32:00.000","Title":"How does a discord bot handle events from multiple servers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using paramiko to create a SFTP server. I have succeeded in uploading and downloading files to and from server on client request.But, I need to send a file from server to client whenever I need without client request. So, instead of breaking my head on making server send a file to client I want to make both machines act as both server and client in different ports so that when I need to send a file from machine A to B I can just Upload it to the SFTP server running on that port. Is this hypothesis possible?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":450,"Q_Id":57615144,"Users Score":0,"Answer":"You already know that you cannot send a file from an server to a client:\nCan I send a file from SFTP Server to the Client without any request from it?\n(The question on Server Fault has been deleted)\n\nTo answer your port question:\nYou do not care about client's port. It is automatically assigned to any available port, without you ever needing to know its value. In general, that's true for any TCP\/IP connection, not only SFTP.\nSo you can just run SFTP server on both machines on the standard port 22. And use your client code on the other machine to connect to it.","Q_Score":0,"Tags":"python,windows,sftp,paramiko","A_Id":57616068,"CreationDate":"2019-08-22T18:23:00.000","Title":"Is it possible to run both SFTP server and client in a same machine on different ports?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wanted to upload a zipped build folder to my linux machine and unzip and deploy.. My issue here is the zip file itself 400MB takes 2 hour to upload, is there any way, I can compress file more to reduce like 100MB or some and upload? Anyother help also welcome.. Am doing it with Jenkins and python\nI tried to make it as tar or gzip which results same size","AnswerCount":2,"Available Count":2,"Score":-0.1973753202,"is_accepted":false,"ViewCount":33,"Q_Id":57620675,"Users Score":-2,"Answer":"you can use Uharch programm to compress your file","Q_Score":0,"Tags":"python,file-upload,ftp","A_Id":57620769,"CreationDate":"2019-08-23T06:09:00.000","Title":"I wanted to upload a zipped build folder to my linux machine and unzip and deploy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I wanted to upload a zipped build folder to my linux machine and unzip and deploy.. My issue here is the zip file itself 400MB takes 2 hour to upload, is there any way, I can compress file more to reduce like 100MB or some and upload? Anyother help also welcome.. Am doing it with Jenkins and python\nI tried to make it as tar or gzip which results same size","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":33,"Q_Id":57620675,"Users Score":0,"Answer":"There is nothing which can magically compress 400 MB to 100 MB, especially not if these are already compressed data like (usually) when you have a ZIP file. \nHow much data can be compressed depends very much on the data - for normal text 50% is not unusual but for binary data it is much less. And it usually will not be able to compress already compressed data any further - otherwise you could just compress again and again until you only have a single byte.\n\nI tried to make it as tar or gzip which results same size\n\nThis is expected. While different compression algorithms might slightly differ in the compression they can achieve these differences are only in a few percent and not in the several factors you need here. Lossless compression is essentially compacting information and data can only be compacted up to some size since the original information somehow needed to by retained. This is different to compression of images or audio where loss of information is often acceptable (and results in loss of quality) and thus much higher compression factors are possible.","Q_Score":0,"Tags":"python,file-upload,ftp","A_Id":57621158,"CreationDate":"2019-08-23T06:09:00.000","Title":"I wanted to upload a zipped build folder to my linux machine and unzip and deploy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"When I install a python module using pip -t . pip downloads the module into a specific folder in the current directory. Python then searches the current directory for the module when it is imported and all is well.\nWhat is the best practise for whether to add the module folders into GIT?\nIt seems to me that checking in these folders is not a good idea, instead the build process should download them from the requirements file rather than get them from SCM.\nHowever adding each folder into .gitignore seems overly burdensome. \nI was expecting the python modules to go into some special directory such as python_modules which I could then add to .gitignore however this does not appear to be the case. Or is there some kind of hook that I can use to get pip to update the .gitignore file automatically when installing new modules?\nSo what do people do to manage these files? My googling has so far not revealed much and I am not at a loss as to what to do?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":276,"Q_Id":57678337,"Users Score":2,"Answer":"One option would be to create a directory called python_modules, and then when you install a new module, install it with pip install -t python_modules .... This way you can add python_modules to your .gitignore.\nThat being said, what's your rationale behind installing them inside your project rather than letting the build process install them in the usual location on your system?","Q_Score":2,"Tags":"python,git,pip","A_Id":57678421,"CreationDate":"2019-08-27T15:52:00.000","Title":"How to handle python modules in GIT","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to use Raspberry Pis to communicate collected Data via Python (Modbus TCP and RTU) scripts to a Database. These scripts are constantly running on the Pi and are connected to the Products where the data is coming from.\nConsequently, we have to ship the already set up Raspberry Pi to the Customer. Now the Problem occurs, that the Database Credentials are stored in the Python Scripts running on the Raspberry Pi.\nIs there a possibility to overcome this Problem?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":57,"Q_Id":57705953,"Users Score":1,"Answer":"Naive solution: Store database credentials on your server (or somewhere on internet) so every time Raspberry Pi run the script, it connect to the server to get the credentials first.\nMy recommended solution: Create an API (may be web API) to communicate with database and Rasp Pi only work with this API. By this way, the client side doesn't know about database's credentials and some private things you want to hide also.","Q_Score":0,"Tags":"python,raspberry-pi3,raspbian","A_Id":57706159,"CreationDate":"2019-08-29T08:19:00.000","Title":"Hide Database Credentials in Python Code on Raspberry Pi","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to profile a script to see why it's taking so long and I'm wondering if I'm not seeing what's taking the most time.\nThe call (python -m profile scpt.py) takes 27671 seconds to run according to my own timing of the script, but when I sum the tottime column of the output, I get 13410.423 seconds. That's a little shy of half the total runtime.\nCan I rest assured that all that can be optimized is what's reported and that I'm not missing anything significant? Where is the rest of the time taken up? Is it the profiler code which is doubling the actual time it takes to run the script without the profiler? If not, is there a way to obtain running time stats that I'm missing?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":65,"Q_Id":57761630,"Users Score":0,"Answer":"The missing time is time when the program was blocked on IO.\nThe profile module only measures CPU time. It is not an IO profiler.\nThis is the difference between wall time and CPU time.","Q_Score":0,"Tags":"python,profile","A_Id":57762055,"CreationDate":"2019-09-02T18:58:00.000","Title":"Why doesn't the sum of tottime in `python -m profile scpt.py` come close to the total running time?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to send Confidential emails via gmail, although I am not sure it is supported. Via the gmail API, the User.messages fields do not seem to indicate whether an email is confidential or not. I retrieved a confidential and regular email via the v1 gmail api get method and the messages are identical. Is there a way send a confidential gmail email, either with the official api or other service?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":319,"Q_Id":57782111,"Users Score":1,"Answer":"To my knowlage you can't send messages with \"Confidential mode\" through the Gmail API. This is not currently supported.","Q_Score":0,"Tags":"python,google-api,gmail-api,google-api-python-client","A_Id":57782321,"CreationDate":"2019-09-04T05:41:00.000","Title":"Send Confidential email through gmail api","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am creating an experiment in python. It includes the presentation of many mp4 videos, that include both image and sound. The sound is timed so that it appears at the exact same time as a certain visual image in the video. For the presentation of videos, I am using psychopy, namely the visual.MovieStim3 function.\nBecause I do not know much about technical sound issues, I am not sure if I should\/can take measures to improve possible latencies. I know that different sound settings make a difference for the presentation for sound stimuli alone in python, but is this also the case, if the sound is embedded in the video? And if so, can I improve this by choosing a different sound library?\nThank you for any input.\nJuliane","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":82,"Q_Id":57790029,"Users Score":0,"Answer":"Ultimately, yes, the issues are the same for audio-visual sync whether or not they are embedded in a movie file. By the time the computer plays them they are simply visual images on a graphics card and an audio stream on a sound card. The streams just happen to be bundled into a single (mp4) file.","Q_Score":0,"Tags":"python,audio,video,latency,psychopy","A_Id":57807337,"CreationDate":"2019-09-04T13:56:00.000","Title":"Improving sound latencies for video presentation in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I used eclipse+pydev as my python ide. I can't find the similar option like java debugger's \"hot code replace\". \nThat is when debugging a python file, I updated the code, and then save the code, it should trigger the hot code replace. Such that, I can see the changes without stop and restart debugging.\nConsidering a=2, b=102,When I debugging at the line \"c=a+b\", I changed the line \"b=102\" to \"b=100\", and then save the code. I expect now the \"b\" should be 100 and c should be 102. But, the b is still 102 and c is still 104.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":141,"Q_Id":57815306,"Users Score":1,"Answer":"For Eclipse+PyDev, the hot code replace happens automatically too, but it doesn't affect the function you're currently executing (you need to get out of it and then get back in).\nThis is a shortcoming of Python itself (it's not possible to change the code for the frame that's currently executing and there's no way to drop the execution of the current frame either).\nAs a note, you can use the set next statement action to help you get to some place in the current function to exit it sometimes...","Q_Score":2,"Tags":"python,pydev,hot-code-replace","A_Id":57824262,"CreationDate":"2019-09-06T03:23:00.000","Title":"How can I set \"hot code replace\" when debugging python by pydev","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an url of tweet and want to get texts of tweet from the url in Python. But I have no idea. I searched about Tweepy, But I think It's for search, upload tweets not to get texts from url.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":183,"Q_Id":57824627,"Users Score":0,"Answer":"You could probably use Beautiful Soup to grab the info you need via cURL. They have decent documentation. Does Twitter have an API you could use?","Q_Score":0,"Tags":"python,twitter,tweets","A_Id":57824762,"CreationDate":"2019-09-06T15:13:00.000","Title":"How to get texts from an url of tweets in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is a rather general question:\nI am having issues that the same operation measured by time.clock() takes longer now than it used to.\nWhile I had very some very similar measurements\n\n1954 s\n1948 s\n1948 s\n\nOne somewhat different measurement\n\n1999 s\n\nAnother even more different\n\n2207 s\n\nIt still seemed more or less ok, but for another one I get\n\n2782 s\n\nAnd now that I am repeating the measurements, it seems to get slower and slower.\nI am not summing over the measurements after rounding or doing other weird manipulations.\nDo you have some ideas whether this could be affected by how busy the server is, the clock speed or any other variable parameters? I was hoping that using time.clock() instead of time.time() would mostly sort these out...\nThe OS is Ubuntu 18.04.1 LTS.\nThe operations are run in separate screen sessions.\nThe operations do not involve hard-disk acccess.\nThe operations are mostly numpy operations that are not distributed. So this is actually mainly C code being executed.\nEDIT: This might be relevant: The measurements in time.time() and time.clock() are very similar in any of the cases. That is time.time() measurements are always just slightly longer than time.clock(). So if I haven't missed something, the cause has almost exactly the same effect on time.clock() as on time.time().\nEDIT: I do not think that my question has been answered. Another reason I could think of is that garbage collection contributes to CPU usage and is done more frequently when the RAM is full or going to be full.\nMainly, I am looking for an alternative measure that gives the same number for the same operations done. Operations meaning my algorithm executed with the same start state. Is there a simple way to count FLOPS or similar?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":50,"Q_Id":57857413,"Users Score":0,"Answer":"As a result of repeatedly running the same algorithm at different 'system states', I would summarize that the answer to the question is:\nYes, time.clock() can be heavily affected by the state of the system.\nOf course, this holds all the more for time.time().\nThe general reasons could be that\n\nThe same Python code does not always result in the same commands being sent to the CPU - that is the commands depend not only on the code and the start state, but also on the system state (i.e. garbage collection)\nThe system might interfere with the commands sent from Python, resulting in additional CPU usage (i.e. by core switching) that is still counted by time.clock()\n\nThe divergence can be very large, in my case around 50%.\nIt is not clear which are the specific reasons, nor how much each of them contributes to the problem.\nIt is still to be tested whether timeit helps with some or all of the above points. However timeit is meant for benchmarking and might not be recommended to be used during normal processing. It turns off garbage collection and does not allow accessing return values of the timed function.","Q_Score":3,"Tags":"python,time,python-2.x,clock,wall-time","A_Id":57884855,"CreationDate":"2019-09-09T15:56:00.000","Title":"Can time.clock() be heavily affected by the state of the system?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to setup a cron job to run a python script every hour, but it has to be run with python3.\nI've tried setting up the cron to point to the python 3.6 libraries, but this doesn't seem to work.\nThis is how I've set it up\n\n0 * * * * \/usr\/local\/lib\/python3.6\/python3 \/mnt\/dietpi_userdata\/python\/main.py\n\nI suspect it's something simple, but it's beyond my own (googling) skills.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":73,"Q_Id":57894681,"Users Score":0,"Answer":"Are you sure that your python3 path is correct? If you are not using a virtual environment you could try this:\n0 * * * * $(which python3) \/mnt\/dietpi_userdata\/python\/main.py\nAdditionally you could manually run which python3 to verify your python3 path.","Q_Score":0,"Tags":"python-3.6,raspbian","A_Id":57894826,"CreationDate":"2019-09-11T18:12:00.000","Title":"How do I setup a cron to run specifically with python3?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an API (in python) which has to alter files inside an EC2 instance that is already running. I'm searching on boto3 documentation, but could only find functions to start new EC2 instances, not to connect to an already existing one.\nI am currently thinking of replicating the APIs functions to alter the files in a script inside the EC2 instance, and having the API simply start that script on the EC2 instance by accessing it using some sort of SSH library. \nWould that be the correct approach, or is there some boto3 function (or in some of the other Amazon\/AWS libraries) that allows me to start a script inside existing instances?","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2456,"Q_Id":57896987,"Users Score":3,"Answer":"Unless you have a specific service running on that machine which allows you to modify mentioned files. I would make an attempt to log onto EC2 instance as to any other machine via network. \nYou can access EC2 machine via ssh with use of paramiko or pexpect libraries.","Q_Score":1,"Tags":"python,amazon-web-services,amazon-ec2,boto3","A_Id":57897084,"CreationDate":"2019-09-11T21:24:00.000","Title":"Running Python Script in an existing EC2 instance on AWS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using php to run a python script and fetching its output using json.dump and showing on my php page. I feel its slower than when I run it through python idle.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":59,"Q_Id":57916771,"Users Score":0,"Answer":"If I understand your question correctly it's no surprise that it feels slower because calling your Python script from PHP, instead of calling it from CLI, increases the operations your PC has to execute. Consider this: first PHP has to create a shell to call your script, then wait for it to finish (e.g. wait for an exit code appearing in the buffer), grab everything from the buffer and then push it into the output buffer and then flush the output buffer, so the data is actually displayed on your page. And besides all of that your output data is transported twice, first from Python to PHP and then from PHP to your browser.\nFurthermore, the processing speed depends on the method you use to call your Python script - there are a couple of ways to achieve this and some have more overhead than others.","Q_Score":0,"Tags":"php,python","A_Id":57922170,"CreationDate":"2019-09-13T02:58:00.000","Title":"Is it a bad idea to run a python script and fetch its output via PHP?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I want to be able to input a username into my Python program and then it checks how many followers that account has (if it's not private) and displays the number. I'm sure it has something to do with APIs.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":379,"Q_Id":57964704,"Users Score":1,"Answer":"first idea that came to my mind is to scrape it with beautifulsoup.","Q_Score":0,"Tags":"python,api,instagram","A_Id":57964909,"CreationDate":"2019-09-16T21:35:00.000","Title":"How can I check how many followers someone has on Instagram with Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Python to create an RSA encoding system but I have to follow some conditions: \n\nBoth of private and public keys have to be encoded in 16 values.\nThe keys has to be encoded in 64 bits.\n\nI wanted to used PyCryptodome, but since it limit you to use a size of 1024 bit, or more and for my case I just want to encode them in 16 values.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":68,"Q_Id":57997340,"Users Score":0,"Answer":"As mentioned in the comments by me: 16 x 64 = 1024, and 1024 is an often used RSA key size.\nI strongly suggest that you are misunderstanding the question. It seems you have to perform 1024 bit modular exponentiation using machine words of 64 bit internally for the calculations. How the keys are encoded is an entirely other matter; during the calculations you'd use the modulus and exponent as an unsigned number after all, not the encoded key.\nWith RSA there are three distinct key \"sizes\" possible:\n\nthe key size, which is just the size of the modulus as unsigned number in bits;\nthe encoded key size of the public and private key, which can be any size but is commonly larger than the key size mentioned above;\nthe key strength, which is the strength of the key compared to e.g. an AES key.\n\nNote that RSA with a key size of 1024 has a comparative strength of 80 bits, which is considered on the low side of things.","Q_Score":1,"Tags":"python,cryptography,rsa","A_Id":58026626,"CreationDate":"2019-09-18T16:21:00.000","Title":"can I generate a fixed encrypted message of 16 values in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"After succesfull instalation message from anaconda3 2019.07 installer, I cannot find the scripts file in the installation directory (\"C:\\Users...\\Anaconda3\"). \nI found many fixes to installing anaconda and many of those consist of including the scripts file path to the environment variables path. Then I noticed that I could not find this file whatsoever.\nI've been uninstalling and installing it but the \"scripts\" file seems to not be set during install procedure.","AnswerCount":2,"Available Count":2,"Score":-0.0996679946,"is_accepted":false,"ViewCount":826,"Q_Id":58002769,"Users Score":-1,"Answer":"Please check whether you have Scripts folder inside anaconda3. \nYou can set the path to Scripts folder in the \"Path\" Environment variable inside control panel(Control Panel\\System and Security\\System -> Advanced system settings -> Environment Variables) as \nC:\\Users.....\\anaconda3\\Scripts\nHope this helps.","Q_Score":2,"Tags":"python,anaconda,conda","A_Id":58005733,"CreationDate":"2019-09-19T02:06:00.000","Title":"Anaconda not setting Scripts file when installing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"After succesfull instalation message from anaconda3 2019.07 installer, I cannot find the scripts file in the installation directory (\"C:\\Users...\\Anaconda3\"). \nI found many fixes to installing anaconda and many of those consist of including the scripts file path to the environment variables path. Then I noticed that I could not find this file whatsoever.\nI've been uninstalling and installing it but the \"scripts\" file seems to not be set during install procedure.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":826,"Q_Id":58002769,"Users Score":0,"Answer":"From the FAQ:\n\nIn what folder should I install Anaconda on Windows?\nWe recommend installing Anaconda or Miniconda into a directory that contains only\n7-bit ASCII characters and no spaces, such as C:\\anaconda. Do not\ninstall into paths that contain spaces such as C:\\Program Files or\nthat include Unicode characters outside the 7-bit ASCII character set.\nThis helps ensure correct operation and no errors when using any\nopen-source tools in either Python 3 or Python 2 conda environments.\n\nIn my case, I reinstalled Miniconda3 in a folder located at a \"shorter\" path (D:\\Miniconda3) and the Scripts folder were created.","Q_Score":2,"Tags":"python,anaconda,conda","A_Id":66674142,"CreationDate":"2019-09-19T02:06:00.000","Title":"Anaconda not setting Scripts file when installing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is [Setup] purposes in Robot Framework? Is it a built in keywords or we can extend it?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":336,"Q_Id":58039370,"Users Score":0,"Answer":"So, I use mostly two Setup i.e. Suite Setup and Suite Teardown.\nA suite setup is executed before any test cases or sub test suites in that test suite, and similarly a suite teardown is executed after them.","Q_Score":0,"Tags":"python,robotframework","A_Id":58051551,"CreationDate":"2019-09-21T10:25:00.000","Title":"Robot Framework: What is [Setup] purposes?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is [Setup] purposes in Robot Framework? Is it a built in keywords or we can extend it?","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":336,"Q_Id":58039370,"Users Score":2,"Answer":"The setup and teardown statements in a test ([Setup] and [Teardown], or the setup and teardown options in the settings table) are themselves not keywords, though they are used in a similar manner. They take a keyword as their first argument, and that keyword is run before the body of the test ([Setup]) or after the body of the test has finished running ([Teardown]). The keyword you provide can do anything you want, so in that sense you can extend them.\nA test typically has four phases (though the second and third can sometimes be intermixed):\n\nsetup - prepare the system for test\nexercise - perform actions on the system being tested\nverify - do verifications on the outcome of the exercise\nteardown - free up resources used by the tests\n\nBy using [Setup], or the global Suite Setup or Test Setup in the settings section, helps you identify which code is preparing the test and which code is related to the actual test. \nOne of the aspects of good test design is that failure should tell you something useful. If a test fails during setup, that is going to tell you something different from failure during the test itself. A failure in the body of the test signals a failure in the product being tested, a failure in the setup or teardown usually means there is a problem with infrastructure or the implementation of the test itself.\nAs a useful side-effect, using setup and teardown helps to document your test cases. The setup says \"this isn't what this test is testing, it's simply preparing the test\". The body of the test says \"this is what I'm actually testing\". And the teardown says \"I'm done testing, now it's time to clean up\".","Q_Score":0,"Tags":"python,robotframework","A_Id":58041646,"CreationDate":"2019-09-21T10:25:00.000","Title":"Robot Framework: What is [Setup] purposes?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running a python application which is running inside a docker container using Beanstalk in a private subnet, and I want to get the Private\/Local IP of the EC2 instance. Is it possible to get the Local IP address without using curl http:\/\/169.254.169.254\/latest\/meta-data\/local-ipv4 inside a docker container.\nAlthough I tried docker run --net=host but still its not accessible.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":404,"Q_Id":58064056,"Users Score":0,"Answer":"You can get the local ip of a Linux instance with this command:\nhostname -I | awk '{print $1}'\nFor EB, use .ebexentions and write a bash script in a script_name.config to run: export HOST_IP=$(hostname -I | awk '{print $1}')","Q_Score":1,"Tags":"python-3.x,amazon-web-services,docker,amazon-ec2,amazon-elastic-beanstalk","A_Id":58065828,"CreationDate":"2019-09-23T13:54:00.000","Title":"How to get EC2 instance private IP in a private subnet?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to Automate Web App testing using Selenium and PyTest and I am new to both. So here is the structure of my project folder: \nParent Folder\nLocator.py\nSection 1(Folder) -> test_sectionone.py\nLocator.py contains all my Xpaths. Now when I try to import Locator.py by typing import Locator and then fetching the xpath using Locator.xpathElement1 in the test_sectionone.py, pytest fails with the following error: \nHint: make sure your test modules\/packages have valid Python names.\nTraceback:\ntest_mailboxProvisioning.py:5: in \n import Locator\nE ModuleNotFoundError: No module named 'Locator'\nIs there something I am missing? Is there a naming convention because of which I am facing the issue?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":67,"Q_Id":58069050,"Users Score":0,"Answer":"Convert Parentfolder into a python package by including an empty file __init__.py\nConvert sub folder \"Section1\" into a python package by including an empty file __init__.py\nIn test_sectionone.py now either import ParentFolder.Locator (using absolute path) or from ..Locator import function using relative path.\nBoth should work.","Q_Score":0,"Tags":"python,selenium,pytest","A_Id":58069402,"CreationDate":"2019-09-23T19:32:00.000","Title":"Unable to import .py file in Pytest","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently running regressions with Panel data, and was wondering which Panel Regression model is the best. I ran the PooledOLS and Fixed Effect Model using the Panel OLS (with entity effect and time effect being true).\nI am trying to understand what one of the outputs of the model mean, more specifically, the F-Test for Poolability. On conducting my research I found some vague answers, nothing really concrete. So, anybody from here can help me out?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":399,"Q_Id":58077033,"Users Score":2,"Answer":"The Poolability F-test tests how well the indexes you have on the panel pool the data. As a rule of thumb, you should have at least 3 observations per panel group. The F-test, similar to the two other F-tests in PanelOLS tests against the null that the pooling effect is not significant.","Q_Score":1,"Tags":"python,panel-data,linearmodels","A_Id":71139660,"CreationDate":"2019-09-24T09:21:00.000","Title":"What is F-Test for Poolability in the Fixed Effect Model?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using dht22 sensor and arduino uno. I am able to get the output of the serial reading and I have communicated it with python through pyserial. So now, my sensor data are appearing on python. I have also created an HTML gui of a thermometer which displays random data. NOW THE PROBLEM IS, I CAN'T FIGURE OUT HOW TO COMMUNICATE MY PYTHON TO THE HTML FILE. Any help would be appreciated.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":222,"Q_Id":58112600,"Users Score":1,"Answer":"Due to security reasons with browsers, this is supposedly impossible without any frameworks... But try flask as mentioned above, should get your project up and going!","Q_Score":1,"Tags":"html,python-3.x,arduino","A_Id":58114257,"CreationDate":"2019-09-26T08:29:00.000","Title":"How to input data from arduino serial monitor to html file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"i am able to see below path created in my html report , i am able to open this path from html when it is a local job , but when i run in jenkins ,this link wont work , i am able to see metadata have url and workspace info , can i use this meta data to generate proper links in html file , so that i will be able to open them from jenkins page . \n\nhref=\"file:\/\/\/space\/scratch\/jenkins\/navarro\/workspace\/coverage_regression\/dut\/python\/.simtest\/NavarroSimTestSystem\/default\/TestJaxi\/test_py_jaxi_read_version_reg_ss\/TestJaxi.test_py_jaxi_read_version_reg_ss-2458081572_simulate.log\" type=\"text\/plain\">TestJaxi.test_py_jaxi_read_version_reg_ss-2458081572_simulate.log","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1119,"Q_Id":58124694,"Users Score":0,"Answer":"Are you trying to show test results in Jenkins job? I have found it easier to generate junit.xml using --junitxml switch and point Jenkins to the Junit XML path. It shows all test results data. Or have you tried the 'html-publisher-plugin'.","Q_Score":0,"Tags":"python,jenkins,jenkins-pipeline,pytest","A_Id":58132551,"CreationDate":"2019-09-26T20:57:00.000","Title":"Pytest : How to update jenkins url in pytest html report instead of local path","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to extract all Twitter feeds of a specific language only. (to extract Sinhala language tweets) How can I do that using python?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":57,"Q_Id":58143644,"Users Score":2,"Answer":"regex is useful.\nSinhala language use codes U+0D80\uff5eU+0DFF in utf-8. First, try extracting tweets that contain Sinhala characters with regex.","Q_Score":1,"Tags":"python,tweepy,tweets","A_Id":58143708,"CreationDate":"2019-09-28T05:30:00.000","Title":"How to extract all Twitter feeds of sinhala language language only using python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Recently I researched python language and so many people complain about the speed of the language. I was wondering can this language be made faster?","AnswerCount":1,"Available Count":1,"Score":0.761594156,"is_accepted":false,"ViewCount":336,"Q_Id":58217310,"Users Score":5,"Answer":"It doesn't make sense to ask talk about the speed of a programming language. A programming language is a set of abstract mathematical rules and restrictions. It is a specification. A piece of paper, essentially.\nA piece of paper doesn't have a speed in the sense we are talking about here.\nIn order to execute some program written in the programming language, the language needs to be implemented. Furthermore, you need to write a program which you can execute. And you need to execute this program in some specific environment (CPU, RAM, OS, machine architecture, \u2026)\nThen, and only then can you measure how long it takes to run.\nBut now you are measuring many variables:\n\nthe program\nthe environment\nthe implementation\nthe specific version of the implementation\nthe language\n\nSince you have so many variables and only one datapoint, it is impossible to tell which variable contributed which amount to the result.\nMany Python benchmarks I see use CPython running on Linux on an Intel AMD64 CPU. This benchmark is a little unfair, however:\n\nCPython is actually a very simple implementation. It does not use any of the optimizations that are typically used in high-performance language engines, such as adaptive optimizations, speculative inlining, polymorphic inline caching, dynamic type feedback, de-virtualization, escape detection, to name just a few.\nLinux, like almost all modern operating systems, is not specially optimized for running Python-like languages. It is more optimized for C-like languages. For example, Linux has virtual memory, which is known to have a negative performance impact on garbage collection.\nIntel AMD64 CPUs are not specially optimized for running Python-like languages. They are more optimized for C-like languages. For example, they contain optimizations which don't really help Python, when that die space and those transistors could be better spent on Python-specific optimizations.\n\nCheck out, for example, the design of the Azul Vega-3 CPU and the corresponding Operating System, both of which were specially designed for running memory-safe, pointer-safe, type-safe languages with garbage collection, dynamic dispatch, and a high degree of runtime polymorphism.\nIf you want a fair comparison between, for example Python and C, you need to run your Python code on a Python implementation that has the same amount of research, engineering, development, man-power, money, and resources poured into it as a C implementation (such as Microsoft Visual C, Clang\/LLVM, GCC, etc.) on an Operating System that is equally optimized for running Python, on a CPU that has the same amount of research, engineering, development, man-power, money, and resources poured into it for making Python run fast and is produced using the same advanced processes that e.g. Intel Xeons are produced with.\nIf you spend enough research, engineering, development, man-power, money, and resources on making Python fast, then it will be fast.\nThere are lots of historical examples: there was a Lisp and Smalltalk hype in the 70s-90s, and people spent tons of money on Lisp and Smalltalk compilers and VMs, and lo and behold, those implementations became much faster. When the Self VM came out, it was competitive with many C++ implementations of the time. Then, Sun cut funding for the Self project, and during that time there was also a C++ hype, so money was spent on C++ compilers, and those became fast.\nAfter that, there was a Java hype, where people spent money on JVMs. (Funnily enough, the developers of Self, after Sun cut funding, founded their own company and built a Smalltalk VM, and after realizing that Java and Smalltalk were very similar, they built a JVM. This JVM was so fast that Sun bought the company to get access to the JVM technology that they would have had for free, if they hadn't pushed the developers out of the company in the first place.) Oracle HotSpot is still based on the codebase of the Animorphic Smalltalk VM written by the former Self developers.\nNow, we are currently in an ECMAScript hype, and as soon as companies started pouring money into ECMAScript engines, those became literally ten times faster in the span of just a few years. (One of the drivers of this was Google with its V8 engine, which was actually designed by some former Self developers who had left Oracle to form their own company.)\nThere are some quite fast Python execution engines out there. I personally am looking forward to GraalPython. And I suspect if people started throwing money at Python implementations, they would also find that there is still a lot of potential for improvement. For example, TruffleRuby (built by the same people) has shown that it can beat C in some cases, and the team working on it is actually tiny compared to e.g. Microsoft Visual C or Clang\/LLVM.","Q_Score":0,"Tags":"python","A_Id":58217425,"CreationDate":"2019-10-03T10:35:00.000","Title":"Can Python language be the fastest language in future?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to make something like this: I will have list of email and password of a certain website. I want to check that email and password work for that website. I want it to go put that email and password in email and password box of certain website. If that logged in then it will say Logged in else not logged in.\nCan I built it with Python module called Scrapy?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":80,"Q_Id":58222912,"Users Score":0,"Answer":"Yes, you can.\nWhether Scrapy is the best choice for your use case depends on the details you have not shared.","Q_Score":0,"Tags":"python-3.x,scrapy","A_Id":58410314,"CreationDate":"2019-10-03T15:59:00.000","Title":"Can Python Scrapy module help us to make an account checker?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"My problem is that I want to be able to upload a PHP file to my pythonanywhere server and then get its public url and use it to get notifications from a webhook to that url or specifically to the file responsible for processing those notifications. But I can't find a way to get this url and being honest is the first time I find myself using this server. Thank you and excuse my ignorance.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":65,"Q_Id":58236668,"Users Score":1,"Answer":"PythonAnywhere does not support PHP.","Q_Score":0,"Tags":"pythonanywhere","A_Id":58268294,"CreationDate":"2019-10-04T12:42:00.000","Title":"How to get the public url of a file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new to WMI(Windows management instrumentation) and trying to get files from a remote host.Seeing the wmi docs it says that WMI allows copying files, but never saw an example of it.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":186,"Q_Id":58238120,"Users Score":0,"Answer":"I don't know much about WMI but you can serve your files from remote host with python using simply:\npython2\npython -m SimpleHTTPServer\nor python3\npython3 -m http.server","Q_Score":0,"Tags":"python,wmi","A_Id":58238207,"CreationDate":"2019-10-04T14:14:00.000","Title":"How to copy files from remote computer and storing them in local one using WMI and Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"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?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":942,"Q_Id":58259708,"Users Score":1,"Answer":"Do you have a directory with \"telegram\" name? If you do,rename your directory and try it again to prevent import conflict.\ngood luck:)","Q_Score":0,"Tags":"telegram-bot,python-telegram-bot","A_Id":58888596,"CreationDate":"2019-10-06T17:33:00.000","Title":"ModuleNotFoundError: No module named 'telegram'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to set a variable in my Python code to different values, according to whether it is running in unit tests or in production.\nAssuming we can't pass additional parameters to the test runners, or we don't have any environment variables set in production environment.\nA_LOCAL_VARIABLE = 1 if is_running_by_pytest() else 0\nMy expectation is that by checking whether the code is running under the pytest runner, I can change the value of the variable.\nIdeally, if the code is ran by the pytest runner, there're some pre-defined environment variables that we can use to identify it. But I cannot find documentations, or I was using the wrong keywords.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":201,"Q_Id":58280200,"Users Score":0,"Answer":"You can use a configuration variable. Each of our executable environments have its own configuration file. Some of our tests use different values for different environments like Single Sign On tests.","Q_Score":0,"Tags":"python,pytest","A_Id":58280376,"CreationDate":"2019-10-08T04:28:00.000","Title":"Any way to determine whether the code is running under pytest or not (i.e. in production)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Need to sudo su - diffuser after connection via SSHClient function.\nI cannot login with ssh directly to the required user id in order to run commands owned by that required user. When at the local cli of the target ssh system, I simply run sudo su - diffuser, and then run the required commands.\nIs there anyway to simulate this using the Paramiko SSHClient commands?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":67,"Q_Id":58307003,"Users Score":1,"Answer":"I was able to resolve this using the SSHClient's invoke_shell method and associated methods (x.send, x.recv, etc.)","Q_Score":0,"Tags":"python","A_Id":58310387,"CreationDate":"2019-10-09T14:57:00.000","Title":"paramiko SSHClient sudo to new user","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I can open my ESP32 Vroom32 device made by Espressif with a cp2101 chip on Ubuntu. I used Ubuntu to flash Micropython onto it, however when I try to connect with Putty, MPFshell or anything else on Windows 10 it will not work. I downloaded and installed the recommended drivers for it and also updated Windows which was supposed to load the driver as well. I can see the device and COM port in device manager but when I attempt to connect I get blocked. For example on MPFshell I get the message \"Cannot connect to COM17\"","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":201,"Q_Id":58307073,"Users Score":0,"Answer":"It is a common reason for boards to show the \"Cannot Connect to COM\" error because of a bad USB cable.\nAlways check with another cable first, before getting deeper to the problem.","Q_Score":0,"Tags":"esp32,micropython","A_Id":58327904,"CreationDate":"2019-10-09T15:01:00.000","Title":"Cannot open COM port on ESP32 device. Using Windows10 and MPFShell","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am working on a project in which I need to implement a functionality wherein a folder or directory is protected using a password. As in, when someone tries to open that particular folder, a password prompt is presented to them. If correct password is entered, then folder access is granted or else not.\nIs this possible using python or Java ? Is yes then how ? And if not then which language can be used ?\nI tried searching a lot but nothing helpful came out of it.","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":129,"Q_Id":58321548,"Users Score":-1,"Answer":"If you mean folders on the file system then you could mimick this behavior by storing files in a password protected zip file. \nIf you mean conceptual folders within your application then you are free to implement authentication any way you want. Normally this involves a user logging in to your application to gain access to the protected resources.","Q_Score":0,"Tags":"java,python,python-3.x","A_Id":58321590,"CreationDate":"2019-10-10T11:11:00.000","Title":"Password protecting folder or directory in java or python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have Fico Xpress solver installed in my mac. I can run my optimization model from command line. Before doing so, I run . \/Applications\/FICO\\ Xpress\/xpressmp\/bin\/xpvars.sh which runs a number of commands such as CLASSPATH=${XPRESSDIR}\/lib\/xprs.jar:${CLASSPATH}, export CLASSPATH etc. \nThe issue is when I want to run the model in Pycharm. Pycharm doesn't seem to be able to find Xpress. The the 'optimizer' executable of Xpress cannot be found. In fact, I cannot even import xpress. \nAs a potential solution, I would like to be able to launch the xpvar.sh script before I run Pycharm. \nI have been trying to use External Tool option in Pycharm, but get the error message Source this script by running 'source \/Applications\/fico\/xpressmp\/bin\/xpvars.sh'\nHere are the parameters I set in my External Tool:\nProgram: \/Applications\/fico\/xpressmp\/bin\/xpvars.sh\nArguments: source\nWorking Directory: \/Applications\/fico\/xpressmp\/bin\/ \nAny other potential solutions are also very welcome. Thanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":193,"Q_Id":58346046,"Users Score":1,"Answer":"The problem seems to be that PyCharm is a GUI application and does not read the .bash_profile or .bashrc files where most environment variables are set. What worked for me is using the EnvFile plugin for PyCharm (I'm using the Community Edition 2019.2):\n\nUnder Preferences->Plugin, search for EnvFile;\nInstall the plugin, then restart PyCharm;\nCreate a .env file (e.g. myvars.env) containing all variables you need, one per line, in the format VARNAME=VALUE\nLoad your project, then under Run->Edit configurations, select the EnvFile tab;\nClick on the \"+\" to add your myvars.env;\nMaybe restart PyCharm again.\n\nAt this point your variables should be available to your Python application.","Q_Score":0,"Tags":"python,bash,macos,pycharm,pyomo","A_Id":58602968,"CreationDate":"2019-10-11T17:33:00.000","Title":"Launch a bash script before running my optimization model in Pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"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. \nIn Depth Explanation:\nI 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. \nI 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.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":36,"Q_Id":58380298,"Users Score":0,"Answer":"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.\nThis 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. \nUsing this way you'd learn some key services:\n\nS3 + Static website Hosting\nAPI Gateway \nLambdas \nSecrets Manager\n\nYou 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.\nHowever there are hundreds of different ways to also design it. And this is only one of them!","Q_Score":2,"Tags":"python,amazon-web-services,amazon-s3,amazon-ec2,aws-lambda","A_Id":58380658,"CreationDate":"2019-10-14T15:59:00.000","Title":"Dynamically Injecting User Input Values into Python code on AWS?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using Appium version V1.15.0 and have already start the server successfully with the default Host: 0.0.0.0 and Port: 4723\nBut now when i try to start the server it shows me this error \"Error Starting Appium server: listen EADDRINUSE 0.0.0.0:4723\"\nI have tried to solve this issue by changing the port but could not find any solution.\nSuggest me if you guys have any better solution.","AnswerCount":4,"Available Count":3,"Score":0.1488850336,"is_accepted":false,"ViewCount":3805,"Q_Id":58424717,"Users Score":3,"Answer":"I have found the solution. After restarting my computer, i could successfully run the Appium server.\nIf anyone face the same problem. Please follow below steps:\n1. Check if the port is listening to any other services.\n Open command prompt: Type netstat -a -b\n\nEither kill that service or try with different port.\nIf both not working then restart your machine.\n\nThis way i have solved this problem.","Q_Score":3,"Tags":"python-appium,appium-desktop","A_Id":58444163,"CreationDate":"2019-10-17T04:00:00.000","Title":"Could not start Appium server. It's showing [Error Starting appium server: listen EADDRINUSE 0.0.0.0:4723]","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am using Appium version V1.15.0 and have already start the server successfully with the default Host: 0.0.0.0 and Port: 4723\nBut now when i try to start the server it shows me this error \"Error Starting Appium server: listen EADDRINUSE 0.0.0.0:4723\"\nI have tried to solve this issue by changing the port but could not find any solution.\nSuggest me if you guys have any better solution.","AnswerCount":4,"Available Count":3,"Score":0.1488850336,"is_accepted":false,"ViewCount":3805,"Q_Id":58424717,"Users Score":3,"Answer":"If EADDRINUSE, Address already in use is the issue, \ndo\nps aux | grep node\nto get the process ids.\nThen:\nkill -9 PID\nDoing the -9 on kill sends a SIGKILL.","Q_Score":3,"Tags":"python-appium,appium-desktop","A_Id":60395724,"CreationDate":"2019-10-17T04:00:00.000","Title":"Could not start Appium server. It's showing [Error Starting appium server: listen EADDRINUSE 0.0.0.0:4723]","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am using Appium version V1.15.0 and have already start the server successfully with the default Host: 0.0.0.0 and Port: 4723\nBut now when i try to start the server it shows me this error \"Error Starting Appium server: listen EADDRINUSE 0.0.0.0:4723\"\nI have tried to solve this issue by changing the port but could not find any solution.\nSuggest me if you guys have any better solution.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":3805,"Q_Id":58424717,"Users Score":0,"Answer":"The following solution on windows worked for me\nC:\\Users\\username> taskkill \/F \/IM node.exe\nSUCCESS: The process \u201cnode.exe\u201d with PID 13992 has been terminated.","Q_Score":3,"Tags":"python-appium,appium-desktop","A_Id":71693131,"CreationDate":"2019-10-17T04:00:00.000","Title":"Could not start Appium server. It's showing [Error Starting appium server: listen EADDRINUSE 0.0.0.0:4723]","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I was using the following code cmd \/c $hash > $in 2>&1 to run a specific executable file using powershell. Here are the issues i face \n\nThis commands works in PC but not servers.\nThis commands can run perfectly in manually way in server, but when schedule, it hit into error as following \n\nUnicodeEncodeError: 'charmap' codec cant encode characters in position 33-35: character maps to undefined\nKindly help.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":94,"Q_Id":58425334,"Users Score":7,"Answer":"As I know that I have faced same kind of issue when developing script in python & after lot of search I have found that I am facing charmap issue because of encoding issue.\nWhat I need to do is set utf-8 as default encoding & after setting it in my python script I am able to solve above issue.\nTry to set proper encoding while reading file or opening file & hope you will find solution for your problem.","Q_Score":2,"Tags":"python,powershell,server","A_Id":58425422,"CreationDate":"2019-10-17T05:16:00.000","Title":"Powershell Error when run the script automatically","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a simple task I want to perform over ssh: return all files from a given file list that do not exist.\nThe way I would go about doing this would be to wrap the following in an ssh session:\nfor f in $(files); do stat $f > \/dev\/null ;done\nThe stdout redirect will ignore all good files and then reading the stderr will give me a list of all non found files.\nI 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. \nI try to understand why and when native python is better than subprocessing bash\n\nComputability with different OS (not an issue for me as the code is pretty tightly tied to Ubuntu)\nError 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\n\nThe 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\nAre there any guidelines for when and how to choose bash over python?\nThis 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","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":105,"Q_Id":58426347,"Users Score":1,"Answer":"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).\nThe reason is that it\u2019s 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\u2019t 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 \u201cdoubly escaped\u201d) so as to have the local shell\u2019s interpretation be the desired multi-word command for the remote shell.\nSo 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\u2019s .ssh\/config if it is not designed with this automated use case in mind.\nIn 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.","Q_Score":1,"Tags":"python,python-3.x,bash,subprocess","A_Id":58442463,"CreationDate":"2019-10-17T06:41:00.000","Title":"File related operations python subprocess vs. native python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to configure my vim editor in Ubuntu 18.04 to automatically run a python file inside the editor. The problem seems to be that, on my Dell Inspiron, the function keypresses are being captured by the GUI. For example, pressing F9 brings up a display of all my open windows. \nI've also tried setting a-F9 as well, but with no luck. The command itself works manually, but vim won't run it when I press the key that's mapped to the command. \nHere's an example of the lines in the .vimrc that I've tried...\nautocmd filetype python nnoremap :exec '!clear; python' shellescape(@%, 1)\nand...\nautocmd filetype python nnoremap :exec '!clear; python' shellescape(@%, 1)\nI've also tried this:\nimap :w:!clear;python %\nNone of them seem to work. Pressing the key doesn't run the command. \nAny help appreciated. \nThanks","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":201,"Q_Id":58427032,"Users Score":2,"Answer":"You can insert the literal key inside a buffer (here: your .vimrc) by pressing followed by the key (e.g. ). If that function key correctly arrives in Vim, the literal string (4 characters) should be inserted. If that's not the case, you first need to remove the interference by the surrounding system. It may be some bloatware (less likely on Linux though) that captures the function keys (uninstall it then), but I've also seen notebooks being configured with special functions (also volume \/ brightness up \/ down) on the function keys, and the actual function key is only sent via a combination with a special Fn key; that usually can be toggled in the BIOS. You can test other applications (e.g. the browser should react to with reload and with full-screen) to see if this indeed is a global problem. As you're on Linux, you can also use the xev tools for this.\nYour key mappings in itself are fine. I would recommend putting any settings, mappings, and filetype-specific autocmds into ~\/.vim\/ftplugin\/{filetype}_whatever.vim (or {filetype}\/whatever.vim (for Python mappings, I'd choose python_mappings.vim); cp. :help ftplugin-name) instead of defining lots of :autocmd FileType {filetype}; it's cleaner and scales better; requires that you have :filetype plugin on, though. Settings that override stuff in default filetype plugins should go into ~\/.vim\/after\/ftplugin\/{filetype}.vim instead.\nFunction keys itself should also work in terminals, in combinations with modifier keys like Shift and Alt often not. Therefore, another approach (for maximum portability, e.g. when you're working through SSH) would be to skip the function keys altogether and go for mappings.","Q_Score":0,"Tags":"python,vim","A_Id":58427935,"CreationDate":"2019-10-17T07:22:00.000","Title":"Trying to set up an autocmd in .vimrc to map a key to a command, but having problems","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a Microservice written in python flask and I will be hosting it soon.\nI want to send one file (example.txt) to My Microservice as a part of Bamboo Task. \nThe microservice will use this file and extract some useful information.\nThe bamboo is connected with Bitbucket.\nQuestions:\n\nHow do I achieve this in Bamboo?\nAre there any changes required at my Micreservice.\n\nI newbie in all these technologies. Any help is appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":69,"Q_Id":58455612,"Users Score":0,"Answer":"There are few steps to acheive this.\n\nSetting up the microservice to accept file.\nMake sure your micro-service is able to accept the file. If yes, perfect. Then we only need to work on the below steps.\nExtracting the file from the build plan. \nCreate the build plan and add the build task, this task should produce your artifact file \"example.txt\", You need to choose the build task which is suitable for your mircoservice client project(Node, maven). The artifact cannot be persisted if you don't mark it as a shared artifact. Describe the shared artifact in task settings. The artifact is shown when the build completes that would confirm that the build is working properly and producing the required artifact.\nSending the file from a deployment plan.\nOnce the artifact is available. You need to create the deployment plan, which can be a script in python or bash to do a REST call for transferring the file. Make sure the location of the file is correct in the script.","Q_Score":0,"Tags":"python,bitbucket,microservices,bamboo,data-exchange","A_Id":58692339,"CreationDate":"2019-10-18T17:29:00.000","Title":"How to send a file from Bamboo task to a our python Microservice","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to write 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.\nDoes anyone know how to do it?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":289,"Q_Id":58458098,"Users Score":0,"Answer":"I solved putting a while loop inside the function on_message.\nSo I need to send only a message and then my bot can write as many messages as he wants","Q_Score":0,"Tags":"python,python-3.x,discord.py","A_Id":58462241,"CreationDate":"2019-10-18T20:56:00.000","Title":"How to write in discord with discord.py without receiving a message?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So e.g. you are working @ Google in the YouTube team and you want to modify how the search bar looks like, or just want to change the font size, or work on a major project like the recommender system etc., does making a Git branch copy over ALL of the backend code for YouTube on your machine? So if there are 100 engineers working from their laptops in the YouTube team, are there 100 copies of YouTube code on their tiny laptops in circulation? Because as I understand Git, when you branch off, you create a copy of the source code, which you merge back into the production branch, which merges into the master branch.\nPlease correct me if I am wrong as I have only worked on MUCH smaller projects which use Git (~100 files, ~15k lines of code).\nYour support will be much appreciated.\nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":903,"Q_Id":58479776,"Users Score":2,"Answer":"Creating a branch in Git copies nothing.\nOK, this is a bit of an overstatement. It copies one hash ID. That is, suppose you have an existing repository with N branches. When you create a new branch, Git writes one new file holding a short (currently 40-byte long, eventually to be 64-byte long) hash ID. So if your previous disk usage was 50 megabytes, your new disk usage is ... 50 megabytes.\nOn the other hand, cloning a repository copies everything. If the repository over on Server S is 50 megabytes, and you clone it to Laptop L, the repository on Laptop L is also 50 megabytes.1 There are ways to reduce the size of the clone (by omitting some commits), but they should be used with care. In any case, these days 50 megabytes is pretty small anyway. :-)\nThere's a plan in the works for Git to perform a sort of mostly-delayed cloning, where an initial clone copies some of the commits and replaces all the rest with a sort of IOU. This is not ready for production yet, though.\nThe way to understand all of this is that Git does not care about files, nor about branches. Git cares about commits. Commits contain files, so you get files when you get commits, and commits are identified by incomprehensible hash IDs, so we have branch names with which to find the hash IDs. But it's the commits that matter. Creating a new branch name just stores one existing commit hash ID into the new branch name. The cost of this is tiny.\n\n1This isn't quite guaranteed, due to the way objects stored in Git repositories get \"packed\". Git will run git gc, the Garbage Collector, now and then to collect and throw out rubbish and shrink the repository size, and depending on how much rubbish there is in any given repository, you might see different sizes.\nThere have been various bugs in which Git didn't run git gc --auto often enough (in particular, up through 2.17 git commit neglected to start an auto-gc afterward) or in which the auto-gc would never finish cleaning up (due to left-over failure log from an earlier gc, fixed in 2.12.2 and 2.13.0). In these cases a clone might wind up much smaller than the original repository.","Q_Score":1,"Tags":"python,git,github","A_Id":58480189,"CreationDate":"2019-10-21T04:23:00.000","Title":"Does creating a Git branch copy ALL of the source code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am tried to solve a MILP problem using python pulp and The solution is infeasible. So, I want to find where infeasibility is coming and want to relax it or remove it to find feasible solution. it is difficult to check manually in the LP file bcz large number of constraints are present. So How I can handle this issue?\nI went through some articles they mentioned that check manually in the LP file but it is very difficult to do manually for a huge number of variables\/constraints.\nIt is giving just infeasibility","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2029,"Q_Id":58481385,"Users Score":0,"Answer":"I use some rule of thumbs to check infeasibility.\n\nAlways start with a small data set that you can inspect more manually.\nAfter relax all integer variables. If this relaxation is infeasible, your problem is linear infeasible. You might have constraints saying stuff like x > 3 and x < 2;\nIf the linear relaxation is feasible, then deactivate each constraint once. Frequently you find some obvious constraints being infeasible, such as sum(i,x_i) = 1. But if you deactivate one by one, you may find that another more complex constraint set is causing infeasibility, and there you might investigate better.","Q_Score":1,"Tags":"python,mathematical-optimization,pulp,mixed-integer-programming","A_Id":58506705,"CreationDate":"2019-10-21T07:10:00.000","Title":"Identifying infeasibility constraint and relaxing\/removing it in Python using Pulp?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am tried to solve a MILP problem using python pulp and The solution is infeasible. So, I want to find where infeasibility is coming and want to relax it or remove it to find feasible solution. it is difficult to check manually in the LP file bcz large number of constraints are present. So How I can handle this issue?\nI went through some articles they mentioned that check manually in the LP file but it is very difficult to do manually for a huge number of variables\/constraints.\nIt is giving just infeasibility","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":2029,"Q_Id":58481385,"Users Score":2,"Answer":"In general, this is not so easy. Some pointers: \n\nIf you can construct a feasible but not necessarily optimal solution for your problem, plug this in and you will find the culprits very easily.\nSome advanced solvers have tools that can help (IIS, Conflict refiner). They may or may not point to the real problem.\nNote that the model can be LP infeasible or just integer infeasible.\nIn some cases it is possible just to relax a suspect block of constraints and see what happens.\nA more structural approach I often use is to formulate an elastic model: allow constraints to be violated but at a cost. This often makes some economic sense: hire temp workers, rent extra capacity, buy from 3rd parties etc.","Q_Score":1,"Tags":"python,mathematical-optimization,pulp,mixed-integer-programming","A_Id":58491280,"CreationDate":"2019-10-21T07:10:00.000","Title":"Identifying infeasibility constraint and relaxing\/removing it in Python using Pulp?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My aim is to force the docker build to fail if the Unittests have not all passed. I'm using the following line in my DockerFile:\nRUN python3 -m unittest discover test\nMy unit tests are in classes in the test directory. The tests are run, but a failed test does not result in a failed build. \nI know that a non-zero exit code is how to stop a build, but that does not seem to occur using this command.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1973,"Q_Id":58484542,"Users Score":2,"Answer":"Had the same problem : Fail the docker build if unittest fails in azure pipeline \nI put the below code in my build.yml file. \nerrors=$(docker logs careplan-tests-1 2>&1 | grep \"FAILED\" -c)\n if [ $errors > 0 ]; then\n echo -e \"unittest tests failed\"\n docker rm apiunittest\n exit 1\n fi\nGives the output as \"##[error]Bash exited with code '1'.\" in docker build and fails the azure pipeline.","Q_Score":8,"Tags":"python,unit-testing,docker","A_Id":62270037,"CreationDate":"2019-10-21T10:38:00.000","Title":"Stop\/fail docker build if tests fail","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm working on a Python script that connects to the Twitter API to pull in some tweets into an array, then pushes this to a mysql database. It's a pretty basic script, but I'd like to set it up to run weekly.\nI'd like to know the best way to deploy it so that it can automatically run weekly, so that I don't have to manually run it every week.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":46,"Q_Id":58512952,"Users Score":0,"Answer":"This depends on platform where you intend to run your python code. As martin says, this is not a python question and more of scheduling related question.","Q_Score":0,"Tags":"python,cloud","A_Id":58513538,"CreationDate":"2019-10-22T22:14:00.000","Title":"How to run Python code periodically that connects to the internet","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a Python script that connects to the Twitter API to pull in some tweets into an array, then pushes this to a mysql database. It's a pretty basic script, but I'd like to set it up to run weekly.\nI'd like to know the best way to deploy it so that it can automatically run weekly, so that I don't have to manually run it every week.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":46,"Q_Id":58512952,"Users Score":0,"Answer":"You can create a batch file that can activate python and run your script and then, use task scheduler to schedule youe batch file execution weekly","Q_Score":0,"Tags":"python,cloud","A_Id":58513008,"CreationDate":"2019-10-22T22:14:00.000","Title":"How to run Python code periodically that connects to the internet","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a file with a function. I want to import the file and when doing that I get No module named ex25.\nimport ex25\nI have checked some tutorials and the offial documentation.\n\n\n\nimport ex25\n No module named ex25","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":26,"Q_Id":58515227,"Users Score":0,"Answer":"First, check if the file is .py file and in the same folder with the file that you are currently working on, there shouldn't be any problem at all. \nIf not in the same folder, but in a different folder and make sure that your file is .py file, you need to make that folder (which contains the file) to a package by adding a file name __init__.py","Q_Score":0,"Tags":"python-3.x,file,import","A_Id":58515616,"CreationDate":"2019-10-23T03:53:00.000","Title":"How do I import a file to execute a function","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using pytest-bdd and want to generate a test report where the Given, When, Then steps are clearly shown and in the case of a failure, it shows you the error. \nI have installed pytest-html and successfully created a report but it doesn't support the Given, When, Then steps.\nI have also tried outputting the report as json using the --cucumber-json option but am unsure what I can do with that. \nAllure reporting is another avenue I have explored but it requires extra decorations on steps which I would like to avoid, but maybe it is the best\/only way. \nSomething similar to the robot framework test report for example would be a great start!","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":1698,"Q_Id":58545137,"Users Score":4,"Answer":"Use allure-pytest-bdd==2.8.10 plugin and generate allure reports.","Q_Score":2,"Tags":"python,pytest,reporting,bdd,test-reporting","A_Id":60333188,"CreationDate":"2019-10-24T16:02:00.000","Title":"How to generate a useful pytest-bdd test report?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to create a support telegram bot using pytelegrambotapi. While I was making it, I met a problem. There a lot of global variables appeared in my code and I want to systematize it. I searched about this in internet and found few solutions: to make a json serializable class and save all data in json file or to make a database of all users using MySql. But I don't know what is better. The amount of users, who will use a bot will be about 100-150, so what is the better solution for my telegram bot? thnx in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":153,"Q_Id":58583279,"Users Score":0,"Answer":"Both solutions are ok, but if you want to increase the number of users you have to use database for integrity and consistency","Q_Score":0,"Tags":"mysql,python-3.x,telegram-bot","A_Id":58675828,"CreationDate":"2019-10-27T20:53:00.000","Title":"Use MySql vs json file for user database for python telegram bot","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have this code related with the download, unzip, search and upload to a AWS S3. \nI have a function to download, another to unzip, another to make the searches and another function to upload the found files; to finally call all this functions into one function. \nThe problem it's that at some point (specifically in the last function) the execution gets an error. \nThe code has 1684 lines of code, and could take even 4 hours to execute. \nIf an error is found in a function, the try\/catches guarantee the final return. \nI've tried to call every function sequentially and they work. \nIf trying to call all the functions, except the last one it still works. \nIf trying to call the last function (the upload to S3), it works. \nI believe it could be related with the RAM \nTrust me, it's huge","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":37,"Q_Id":58613422,"Users Score":1,"Answer":"Basically, my problem was solved through the creation of a \".sh\" format script that calls all the functions sequentially.","Q_Score":0,"Tags":"python,python-3.x,amazon-web-services,amazon-s3","A_Id":58718308,"CreationDate":"2019-10-29T18:28:00.000","Title":"Two functional functions when called together creates an error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Manim noobie here. \nI 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. \nAny advice on how to do so? Warm thanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3318,"Q_Id":58625414,"Users Score":16,"Answer":"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.","Q_Score":11,"Tags":"python-3.x,manim","A_Id":60919095,"CreationDate":"2019-10-30T12:29:00.000","Title":"Display two animations at the same time with Manim","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've written multiple unit tests using python unit test module in multiple directories\nHow to run all the tests from a single file\nI have to integrate this file to a jenkins job and am using django","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":250,"Q_Id":58626393,"Users Score":1,"Answer":"Your folders will need to contain an __init__.py file in each of them, then you should be able to instantiate the unit test runner and pass it the parent directory, unit test discovery should pick up the sub-folders automatically.","Q_Score":0,"Tags":"python,python-2.7,python-unittest","A_Id":58626505,"CreationDate":"2019-10-30T13:24:00.000","Title":"Running multiple python unit test cases which are in different directories","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"For some unknown reason my pycharm has stopped successfully running unittests. Before I could simply right click a file of tests and hit Debug unittests in.. \nor in the file itself call for debugging on the TestCase subclass itself or on any test_ method thereof. Now it just finishes immediately with nothing and creates an artifact in configurations that seems to be treating the unitest file as a simple python file. If I delete that I sometimes get in a weird state where it fails a bunch of assertions immediately and tries to user my path to the file as a module somehow by the error it puts out.\nI don't understand. I have used pycharm for years and never seen this problem previously. \nLooks to be the 2019.2 version running on Ubuntu. Did something change?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":23,"Q_Id":58634220,"Users Score":0,"Answer":"Ah ha! The project having the problem was opened via a soft link directory. When I opened the same thing using the direct directory the problem disappeared. Bizarre.","Q_Score":0,"Tags":"python,pycharm,python-unittest","A_Id":58649931,"CreationDate":"2019-10-30T21:59:00.000","Title":"pycharm running unittests stopped working","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"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.\nI 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.\nIs there a way to accomplish this in Python without external databases\/files?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":611,"Q_Id":58653864,"Users Score":0,"Answer":"Generally speaking, it's better (and easier) to use the external database or file. But, if you absolutely need it you could also:\n\nModify the script itself, e.g. store the date of the last run in commented out last line of the script. \nStore 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.\nChange the \"modified date\" of the script itself and use it as a reference.","Q_Score":0,"Tags":"python,python-3.x,praw","A_Id":58654034,"CreationDate":"2019-11-01T03:45:00.000","Title":"In a Python bot, how to run a function only once a day?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm in the process of implementing an algorithm that requires connectivity between somewhere around 10 Raspberry Pi's over a LAN and could use some help in figuring out a means to get them to talk between each other. \nFor some background on what I'll be using this for, I'll be connecting individual RaspPi's to SEL relays to gather metered data for a scale model microgrid of my school's actual power grid. With that metered data, I'd like to be able to send sampled data from each relay to other random relays in the testbed as part of a consensus algorithm (like hashgraph) to try and reduce an ICS-focused attack on our power grid like what happened to Ukraine a few years ago. The idea is that a byzantine fault tolerance system would work well for a power system spanned over a large geographical area.\nAs this is only a test to determine whether or not such an implementation would be beneficial for use in power substations, I've only been using python scripts for gathering the aforementioned data from the relays. As such, I'm looking for a python-based means of communication between these computers. I've looked into sockets, but I'm not sure whether or not that's an effective means for 10 computers trying to communicate with one another.\nThe ideal end-goal would be to simulate a man-in-the-middle attack on this testbed to see if the system would be able to correct and detect the threat in a timely manner.\nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":42,"Q_Id":58665473,"Users Score":1,"Answer":"Any single system (Raspberry PI) can listen for incoming connections and use them in some specific way. \nThings to consider which might be of use:\n\nDo you absolutely need all data?\nIt data sent often or rarely?\nWill connections be randomly sending data?\nAre the systems required to speak to one another?\n\nHigh volume data with occasional loss might be a good solution using UDP.\nIf you really need all the data, use TCP and random connections to ensure data capture.\nWould you need to send them to eachother or just to one or two sources? This might make your issue easier.\nRegardless, systems are capable of handling much more than 10 connections so you should be ok. \nNot sure how else to help.","Q_Score":3,"Tags":"python,raspberry-pi,communication","A_Id":58665724,"CreationDate":"2019-11-01T20:24:00.000","Title":"What's the best way to implement full communication between many RaspPis over a network?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an audio file sampled at 44 kbps and it has a few hours of recording. I would like to view the raw waveform in a plot (figure) with something like matplotlib (or GR in Julia) and then to save the figure to disk. Currently this takes a considerable amount of time and would like to reduce that time. \nWhat are some common strategies to do so? Are there any special circumstances to consider on approaches of reducing the number of points in the figure? I expect that some type of subsampling of the time points will be needed and that some interpolation or smoothing will be used. (Python or Julia solutions would be ideal but other languages like R or MATLAB are similar enough to understand the approach.)","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":144,"Q_Id":58667844,"Users Score":1,"Answer":"Assuming that your audio file has a sample rate of 44 kHz (which is the most common sampling rate), then there are 60*60*44_000 = 158400000 samples per hour. This number should be compared to a high-resolution screen which is ~4000 pixels wide (4k resolution). If you would print time series with a 600 dpi printer, 1 hour would be 60*60*44_000 \/ (600 * 2.54 * 100) = 1039 meters long if every sample should be resolved. (so please don't print this :-))\nInstead have a look at PyPlot.jl functions psd (power spectral density) and specgram (spectrogram) which are often used to visualize frequencies present in an audio recording.","Q_Score":0,"Tags":"python,matplotlib,audio,plot,julia","A_Id":58717599,"CreationDate":"2019-11-02T02:40:00.000","Title":"How to plot a very large audio file with low latency and time to save file?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I thought it might be time to start using PowerShell instead of cmd. I currently run Python scripts from Notepad++ with the following commnad:\ncmd \/c cd "$(CURRENT_DIRECTORY)" &python -i "$(FILE_NAME)"\nHow should I modify this to get the same behaviour in PowerShell please?\nI tried\npowershell -noexit cd "$(CURRENT_DIRECTORY)" &python -i "$(FILE_NAME)"\nbut I got an error about ampersands. I know very little about PowerShell or cmd in general - I just use them to run my Python scripts.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":58,"Q_Id":58678730,"Users Score":0,"Answer":"After a bit more digging I found a solution:\npowershell -noexit cd '$(CURRENT_DIRECTORY)'; python -i '$(FILE_NAME)'\nPowerShell seems to prefer single quotes for paths so I wrapped $(CURRENT_DIRECTORY) and $(FILE_NAME) in single quotes.\nAlso, & is replaced by ; for multiple commands.\nIf there is a more \"correct\" way of doing this, please let me know.","Q_Score":1,"Tags":"python,powershell,cmd","A_Id":58679344,"CreationDate":"2019-11-03T09:06:00.000","Title":"Calling PowerShell from Python using Notepad++","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Which one is more suitable for my project? I want to build a human gesture mimicking Robotic arm. The application is to be built using an open source PYNQ framework. It requires me to choose either one of the kits Ultra96 or PYNQ-Z2 kit for my project so that they can provide me with it. I am unable to find the exact difference between the functionalities of the two, and when to use which? Please help me.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":127,"Q_Id":58681419,"Users Score":0,"Answer":"I have been using the Z2 board and it would seem to work just fine for your project. Although I can't speak for the ultra96 it's worth noting that it is a community board and so is not officially supported by Pynq.","Q_Score":0,"Tags":"python,arm,iot,robotics","A_Id":61090911,"CreationDate":"2019-11-03T15:02:00.000","Title":"Ultra96 or Pynq-Z2 kit?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"How to do that the best way?\nHow to autostart and run the script every 5 seconds? (i read something from a rs232 device)\nI want to write some values every 5 seconds to a postgresql database and for this is it ok to open the database connection every 5 seconds and close it or can it be stay opend?\nthanks in advance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":193,"Q_Id":58684337,"Users Score":0,"Answer":"I think the best way is to have a constantly running script that reads the value, sends to db, and sleeps for the remainer of the interval and keep the connection open. This way you can monitor and react if a read, write or both take too long for example. And then to have a separate script just to check if the main one is alive and notify you or restart the main one. I had some success with this model when reading from a bitcoin exchange api and inserting into mariadb every 6 seconds","Q_Score":0,"Tags":"python,python-3.x,postgresql,raspberry-pi,raspbian","A_Id":58684649,"CreationDate":"2019-11-03T20:30:00.000","Title":"Best and most efficient way to execute a Python script at Raspberry Pi (Raspbian Buster) every 5 seconds and store in PostgreSQL?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an script in Python to test login on a web page.\nMy question : What are the alternatives to Behat compatible with Python?.\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":300,"Q_Id":58696651,"Users Score":1,"Answer":"Edit: This question got heavily edited after I answered so I am copying my out of scope comment into the answer: \"It seems popular enough => github.com\/behave\/behave\" \nBehat is a PHP library written in PHP. It would be too hard to get it to interface with your tests in Python.\nOn the other hand, I suggest looking up a Python-native BDD framework.","Q_Score":0,"Tags":"python,selenium,behat","A_Id":58697982,"CreationDate":"2019-11-04T15:40:00.000","Title":"What are the alternatives to Behat for Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We have our admin team setup PYENV so that we can run against multiple versions of python.\nwe have two versions of python Python 2 and Python 3. How do I run my scripts against python 3?\nFor example, when I just run like Python test.py it always run against python2 but I want to run my script with Python3.\nThank you for your help.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":463,"Q_Id":58715579,"Users Score":0,"Answer":"if you are using mac in terminal write ( python3 (name of the file).py","Q_Score":0,"Tags":"python,python-3.x","A_Id":58715612,"CreationDate":"2019-11-05T16:27:00.000","Title":"How to run python code if pyenv is setup to run against multiple versions of python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"We have our admin team setup PYENV so that we can run against multiple versions of python.\nwe have two versions of python Python 2 and Python 3. How do I run my scripts against python 3?\nFor example, when I just run like Python test.py it always run against python2 but I want to run my script with Python3.\nThank you for your help.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":463,"Q_Id":58715579,"Users Score":0,"Answer":"That depends.\nIf you want to use python3.x globally, you can run pyenv global 3.x to set the specific python version you want as your global version.\nHowever, if you want to use python3.x for that specific script only, run \npython3.x path\/to\/specific\/script.py","Q_Score":0,"Tags":"python,python-3.x","A_Id":58715677,"CreationDate":"2019-11-05T16:27:00.000","Title":"How to run python code if pyenv is setup to run against multiple versions of python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a telegram bot , i have a code in python the publish links to different channels.\nIs there any way to know who press the link , i tried with get_updates , but it only shows messages.\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":157,"Q_Id":58728252,"Users Score":0,"Answer":"Text and InlineKeyboardButton link clicks are not tracked by Telegram. You can try using third-party services (url-shorteners) to track your links.\nNOTE: this feature is not declared by Telegram. In my experience, Telegram did not send Update about the same actions.","Q_Score":1,"Tags":"python-3.x,api,telegram","A_Id":58731036,"CreationDate":"2019-11-06T10:42:00.000","Title":"Telegram API get updates in a channel","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wrote several xslt files. Within each file, I have multiple templates to modify strings, so I am trying to find a way to create unit tests for these templates. Is there is a way to test xslt files in PyCharm with pytest?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":51,"Q_Id":58737917,"Users Score":0,"Answer":"Answering this for anyone else who wants to test xslt files in python using pytest: I am using lxml.etree to parse the a sample XML file and the xslt file I have, then using lxml.etree.XSLT and transform() to transform the html output into an etree object. I can compare what I expect to be within certain tags to what is actually there based on the xslt transformation.","Q_Score":0,"Tags":"python,unit-testing,xslt,pycharm,pytest","A_Id":58882233,"CreationDate":"2019-11-06T20:21:00.000","Title":"Unit testing XSLT files in pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created script to upload data in every 10 minutes. it works but after uploading several times, there is 1 minute gap.\n It starts like that\n2019\/10\/01 10:00 2019\/10\/01 10:10\nAfter running script several times it show below result\n2019\/10\/01 19:01 2019\/10\/01 19:11\nHow to modify it always record and upload exactly in 10:00 minutes?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":22,"Q_Id":58741173,"Users Score":0,"Answer":"Please post here your actual code (just the part which triggers the 10 to 10 min thing), you may be missing something","Q_Score":0,"Tags":"python,file,file-upload","A_Id":58741223,"CreationDate":"2019-11-07T02:35:00.000","Title":"Script time leakage","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed libboost_python3 and am trying to link it to my program but get this error:\n\/usr\/bin\/ld: cannot find -lboost_python3\nCan anyone help me link to lboost_python3?\nThanks","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":965,"Q_Id":58771549,"Users Score":1,"Answer":"I could find a solution to this problem in ubuntu. Just add in terminal:\nsudo ln -s \/usr\/lib\/x86_64-linux-gnu\/libboost_python-py35.so \/usr\/lib\/libboost_python3.so","Q_Score":1,"Tags":"python-3.x,caffe,pycaffe","A_Id":58771606,"CreationDate":"2019-11-08T17:51:00.000","Title":"\/usr\/bin\/ld: cannot find -lboost_python3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Sorry if this is a silly question, I'm still a beginner in Android and couldn't find an answer to my question. I'm making an Android application that sends an input to a server and executes a Python script on that server to process the given input and generates an output. I was successful in sending data from Android client to Python server using SSH. \nI can also use SSH to retrieve the output back to the Android client. However, the Python script takes some time to generate the output, and I can't seem to find a way for the Android client to wait for the Python script to finish generating the output. I was able to do this on internet connection with using Firebase database and have the Python script upload the output into Firebase database and have the Android client listen for changes in database. But I'm looking for a way to do this locally without internet (i.e. Firebase).\nSo is there a way to make my Android application wait for a message from Python to know it has finished with generating the output so it can retrieve it back using SSH or any other way?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":63,"Q_Id":58776295,"Users Score":0,"Answer":"Was a protocol what was send a code what was suppost to say if that 2 files are the same. but i do not remember the name. For u will be more easy to send the storage information's in bits (to the device) and after to start that important transfer. when the device will lost the connection will need to compare the real storage memory with the first information's send it and if has not match to ask the user to reconnect to internet or something like that. Maybe is helping until some one will give u the answer.","Q_Score":0,"Tags":"java,python,android","A_Id":58776390,"CreationDate":"2019-11-09T04:01:00.000","Title":"How to make Android app wait for a message from Python on a local server without internet?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I noticed the other day that generating keys with GPG on a server takes forever which suggests bad entropy? This server is combining RSA and AES encryption with quite large RSA keys (generated elsewhere).\nThe AES key I RSA encrypt (and that is used to encrypt the actual message) are generated with calls to Crypto.Random.new().read(). If the entropy is bad on this server isn't there a risk for compromised encryption? Or is a 32 byte AES and a large RSA key \"good enough\"? (whatever that means)\nI'm using the Crypto python module but can switch to cryptography or GnuPG if that effort improves security. Changing server is also an option.\nIs SSL affected by bad entropy?\nos.urandom() vs Crypto.Random?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":96,"Q_Id":58794533,"Users Score":0,"Answer":"It's unlikely that your server has \"bad entropy\" or insufficient amounts of entropy; especially if your machine is running any other tasks, or has any human input (such as keypresses or mouse movement), even the 'blocking' entropy should be more than sufficient, unless you're asking for extraordinary amounts of random bits.\nI'd check a few other common bottlenecks, including the ping-time to the server, if you have C bindings installed and configured for your python libraries, etc. (In particular, pure python implementations of crypto are notoriously slow.)","Q_Score":0,"Tags":"python,cryptography,aes,rsa,entropy","A_Id":58794550,"CreationDate":"2019-11-11T01:33:00.000","Title":"Handling bad entropy in encryption","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Having multiple languages to deploy under appengine; I wonder if some kind of private approach could be applied; in order to have it all resides only under a single domain\nFor example, given xyz.com domain setup as wildcard; having a default service, services svc1 and svc2; and a dispatch.yaml mapping *\/svc1\/* to svc1 service and *\/svc2* to svc2 service; how to :\n\nhide all the *.appspot domain ?\nhide the automatic setup of svc1.xyz.com and svc2.xyz.com ?\n\nIt could be easy for a given service to check the host and redirect to the desired one; but it would have to be done for every services; feels like there a better way\nIt feels a bit messy to have all those auto enopoints opened and unused, the idea would be to have it all under xyz.com\/\n\n-","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":45,"Q_Id":58797322,"Users Score":1,"Answer":"There is no way of hiding all the routes of the .appspot domain. As you probably are aware the dispatch.yaml, only works as a redirect. Probably, you cannot just disable the default domain, since there are a lot of tools like Cloud Tasks, Cron Jobs etc.. that uses that default domain, hitting those endopoints.\nAs for the second question, you cannot hide them, but in case you don't need them, you can overwrite them in the dispatch.yaml to point to some custom made \"not found\" page.","Q_Score":0,"Tags":"google-app-engine,google-app-engine-python,google-appengine-node","A_Id":58798896,"CreationDate":"2019-11-11T07:44:00.000","Title":"Appengine \/ restrict services to only be available under a single domain","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I'm trying to use pysftp on python, although pysftp is installed I get a Bcrypt ImportError \nSo I uninstalled and re-installed bcrypt, checked the location of the directory spyder is referring to for importing packages, bcrypt exists. Also checked that the init.py file exists . Checked inside the init.py file that the module _bcrypt exists. Even tried importing bcrypt separately. \nimport bcrypt\nimport pysftp\nimport pysftp\nTraceback (most recent call last):\nFile \"\", line 1, in \n import pysftp\nFile \"C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda4\\lib\\site-packages\\pysftp__init__.py\", line 12, in \n import paramiko\nFile \"C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda4\\lib\\site-packages\\paramiko__init__.py\", line 22, in \n from paramiko.transport import SecurityOptions, Transport\nFile \"C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda4\\lib\\site-packages\\paramiko\\transport.py\", line 90, in \n from paramiko.ed25519key import Ed25519Key\nFile \"C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda4\\lib\\site-packages\\paramiko\\ed25519key.py\", line 17, in \n import bcrypt\nFile \"C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda4\\lib\\site-packages\\bcrypt__init__.py\", line 25, in \n from . import _bcrypt\nImportError: cannot import name '_bcrypt' from 'bcrypt' (C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda4\\lib\\site-packages\\bcrypt__init__.py)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1462,"Q_Id":58807161,"Users Score":0,"Answer":"Reinstalled Anaconda , and there was no issue. The actual solution is still not found.","Q_Score":0,"Tags":"python,bcrypt,pysftp","A_Id":58942736,"CreationDate":"2019-11-11T18:59:00.000","Title":"bcrypt error while trying to import pysftp or paramiko","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to click on the link from email and download the file in my laptop by using python script. Any one has any idea about this?\nI could see most of the information's which i am seeing in the internet is download the file in linux itself.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":103,"Q_Id":58812527,"Users Score":0,"Answer":"The Instruction to do that:\nWriting a code to do the following:\n\nlogin to your email.\nparse your inbox and locate the specific email.\nparse the html source and locate the url for the download link.\ndownload it by connecting directly to it.","Q_Score":0,"Tags":"python","A_Id":58812603,"CreationDate":"2019-11-12T05:24:00.000","Title":"How to download the file by clicking the link in email by using the python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I 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?\nThank you in advance for your help.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":97,"Q_Id":58820116,"Users Score":1,"Answer":"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.","Q_Score":3,"Tags":"python,c++,eclipse","A_Id":58820608,"CreationDate":"2019-11-12T13:47:00.000","Title":"How I can debug two-language program?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using github3.py library for my remaining code modules.\nSo if possible can we use github3.py lib for cloning a repo or any other python library is also good.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":65,"Q_Id":58821294,"Users Score":1,"Answer":"Normally, you should be able to clone it the same way as a normal repository.","Q_Score":0,"Tags":"python,python-3.x,git,github,github3.py","A_Id":58824019,"CreationDate":"2019-11-12T15:01:00.000","Title":"Clone a Githubenterprise Repo using python libraries","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new using python on kubuntu. I'm writing some simple functions and write also tests on pytest to practise test-driven-development (although I know it's wasted on such easy functions, it's just for the sake of practice).\nBecause I'm beginner, I'm writing the code in an editor and I'm executing it on the terminal, in a next step I'll use an IDE like Thonny. I have installed Python3.7, although Python2.7 seems to be the standard within the system. Nonetheless, the file with the functions works fine. I'm printing some f-strings and it works fine also. The first line of the file is a Shebang which tells the interpreter, to use Python3.7 (#!\/usr\/bin\/env python3.7). However, when I want to execute the tests, I'm writing pytest in console, as indicated by the pytest-introduction. Alas, I get a syntax error, because it seems that pytest is importing Python2.7 which of course doesn't know f-strings.\nI verified that pytest is indeed importing Python2.7 by executing the command pytest --version and I was confirmed.\nMy question is: How can I make pytest to import Python3.7 so the test would pass or at least the Syntaxerror would go away? Replacing the f-string with a normal string makes the test pass, so I'm assuming this is the only problem.\nAny help is highly appreciated. Many thanks in advance. I hope, I gave all the relevant informations. If more information is needed, I'll provide that gladly.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":768,"Q_Id":58826624,"Users Score":0,"Answer":"You can install pytest with pip3. For most libraries, pip3 defaults to python3.x and pip defaults to python2.x","Q_Score":0,"Tags":"python,python-3.x,pytest","A_Id":58826862,"CreationDate":"2019-11-12T21:04:00.000","Title":"import pytest from Python3.7 instead 2.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Python script 'test.py' which has import pymysql. I have installed pymysql using pip and sudo. When I run this .py, it works great.\nI have another Bash script which is used to run the above test.py. When I run this bash script, I get the error:\n\nModuleNotFoundError: No module named 'pymysql'\n\nWhere am I going wrong?\nPyMySQL==0.9.3\nPython=3.7.1","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":47,"Q_Id":58847950,"Users Score":0,"Answer":"It is possible that pymysql's location needs to be in your PATH environment variable. \nWhen you run your bash script, what version of python is it using? Is it using the python \"on which\" you installed pymysql, or another one?\nTo make sure you are using the correct version of Python, I suggest using venv.","Q_Score":0,"Tags":"python,mysql,python-3.x","A_Id":58847980,"CreationDate":"2019-11-14T01:09:00.000","Title":"ModuleNotFound error while running through Bash","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm looking for the equivalent of the linux \"mmap.PROT_EXEC\" method for windows. (Inside mmap module on python)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":221,"Q_Id":58849264,"Users Score":1,"Answer":"Without going down to raw ctypes access to the underlying APIs (CreateFileMapping\/MapViewOfFile), this can't be done. The access arguments (used on Windows, and mapped to equivalent flags\/prot flags on Linux) defined by Python are strictly limited to ACCESS_READ, ACCESS_WRITE, ACCESS_COPY and ACCESS_DEFAULT, and none of them allow the memory to be mapped executable.","Q_Score":0,"Tags":"python,windows,mmap","A_Id":58849362,"CreationDate":"2019-11-14T04:11:00.000","Title":"mmap.PROT_EXEC windows equivalent in mmap python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a python module which is designed to be used by non-programmers, interactively. It is used within iPython, and on load, it asks for a couple of user inputs, prints some ascii art, that sort of thing. This is implemented in the __init__.py of the module.\nThe module also contains a utils file tld(containing setup.py)\/utils.py, with some functions in it. I would like to test these. The utils file does not import anything from the rest of the module, and contains only pure functions. The tests live in tld(containing setup.py)\/tests\/test_utils.pyCurrently, trying to run pytest results in a failure, as the module's __init__ file is run, which hangs whilst awaiting the above mentioned user input.\nIs there a way of getting pytest to run the tests in test_utils.py, without running the __init__.py of the python module? Or some other way of getting around this issue?\nI have tried running pytest tests\/test_utils.py, but that had the same effect.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":135,"Q_Id":58877894,"Users Score":0,"Answer":"I solved this by defining an initialize function inside the __init__.py of the module, which encapsulates all of the user interaction. If module.initialize() is not explicitly called, no user input is requested, so the pytest tests can run as expected.","Q_Score":1,"Tags":"python,pytest","A_Id":58891396,"CreationDate":"2019-11-15T13:17:00.000","Title":"Testing an interactive module with pytest","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Im looking for a way to program using python on an Arduino. Are there any up-to date interpreters available? I looked at some older questions, but there are no up-to date versions. Specifically, I'm looking for a way to program it on an Arduino Uno rev 3.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":52,"Q_Id":58878124,"Users Score":2,"Answer":"You cannot program an Arduino Uno in Python. You need a more powerful MCU to run a Python compiler\/runtime like MicroPython.\nMicroPythons memory requirements exceed Arduinos specs.","Q_Score":0,"Tags":"python,arduino","A_Id":58879477,"CreationDate":"2019-11-15T13:32:00.000","Title":"Can you program python onto an Arduino","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want a reverse proxy (using mitmproxy\/mitmdump) for an insecure site. I want the proxy to run on a non-standard port (not 443) and to be accessible only via https. This is the closest I've gotten:\nmitmdump -p 2112 --mode reverse:http:\/\/localhost:41781 --set block_global=false --certs full.pem\nThis works when I access it via https: https:\/\/localhost:2112. The problem is, it is also accessible via http: http:\/\/localhost:2112.\nHow do I disable that and make it only accessible via https?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2329,"Q_Id":58892960,"Users Score":0,"Answer":"(Obligatory: Use Apache\/nginx\/... if you need a production-grade reverse proxy)\nMitmproxy currently always supports both HTTP and HTTPS to simplify setups (we had lots of bug reports because of misconfigurations). If you want to disable HTTP, you could write an addon that detects flow.request.scheme == \"http\" and then either invokes flow.kill() or sets flow.response = mitmproxy.http.HTTPResponse.make(). Lastly, you can also make sure to set HSTS headers in the response hook in mitmproxy.","Q_Score":1,"Tags":"python,ssl,reverse-proxy,mitmproxy","A_Id":58916214,"CreationDate":"2019-11-16T16:45:00.000","Title":"mitmproxy reverse proxy - want SSL only on non-standard port","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've got an electronic piano that lacks the pitch bend and modulation wheels. I'm looking for a way to simulate them while still giving output through the same MIDI port the device is connected. The rest I'll figure out myself.\nI'm using Windows and Python 3.5. Thank you for your time.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":734,"Q_Id":58904130,"Users Score":2,"Answer":"Using loopMIDI worked for me. What it does is simply puts its Output as its Input, so when sending modulation wheel (or other) events to Output (I had to use output.write_short(0xb0, 1, modulation), Pygame) it will send those events directly to Input and then it'll be possible to use it as a MIDI input device in workstations and etc.","Q_Score":3,"Tags":"python,midi","A_Id":59555400,"CreationDate":"2019-11-17T19:06:00.000","Title":"Connecting to a MIDI Input port and simulating input (Python)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to collect the list of favorite(like) in each tweet for a specific celebrity so that I can get the top three users who like his\/her posts the most in a period. However, I can't find any information using Tweepy(Twitter API) to gather it. Is it the only possible to use Selenium to collect the favorite list for each tweet?\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":36,"Q_Id":58925031,"Users Score":0,"Answer":"Twitter's API does not provide this information. Also note that using Selenium or other web scraping methods is against the Twitter Terms of Service.","Q_Score":0,"Tags":"python-3.x,twitter,tweepy","A_Id":58937988,"CreationDate":"2019-11-19T00:42:00.000","Title":"How to find lists of favorite for each tweet?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created a python package that includes a setup.py file. I need this package to be distributed among some clients, who will import and build their products on top of my package and I want to make the package proprietary as it contains some sensitive information. \nI have added a license header but there are some URLs that I want to hide from my clients.\nHow to achieve this? Thank you","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":43,"Q_Id":58933295,"Users Score":2,"Answer":"You don't. \nSecurity through obscurity is broken from the outset. If you ship it to the client, they own it at some level or another.\nEspecially in the case of python, it makes no sense to hide things, because the interpreter still has to be able to process them - if you encrypt something, you have to ship the decryption tools with it, which means a malicious user already has everything they need to figure out your secrets.\nIf you don't want a user to have access to it, you can't sent it to the user. Period.","Q_Score":0,"Tags":"python,python-3.x","A_Id":58933421,"CreationDate":"2019-11-19T11:40:00.000","Title":"Is it possible to hide code in my importable package?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hope you are doing well.\nI am trying to build a following robot which follows a person.\nI have a raspberry pi and and a calibrated stereo camera setup.Using the camera setup,i can find depth value of any pixel with respect to the reference frame of the camera. \nMy plan is to use feed from the camera to detect person and then using the stereo camera to find the average depth value thus calculating distance and from that calculate the position of the person with respect to the camera and run the motors of my robot accordingly using PID.\nNow i have the robot running and person detection using HOGdescriptor that comes opencv.But the problem is,even with nomax suppression, the detector is not stable to implement on a robot as too many false positives and loss of tracking occurs pretty often.\nSo my question is,can u guys suggest a good way to track only people. Mayb a light NN of some sort,as i plan to run it on a raspberry pi 3b+.\nI am using intel d435 as my depth camera. \nTIA","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":527,"Q_Id":58934308,"Users Score":1,"Answer":"Raspberry pi does not have the computational capacity to perform object detection and realsense driver support, check out the processor load once you start the realsense application. One of the simplest models for person detection is opencv's HOGdescripto that you have used.","Q_Score":0,"Tags":"python,computer-vision,raspberry-pi3,object-detection,robotics","A_Id":58939946,"CreationDate":"2019-11-19T12:37:00.000","Title":"fast light and accurate person-detection algorithm to run on raspberry pi","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like my bot to recover the attachment of a message and send it in another channel with an embed, I make this:\nembed.set_image(url=message.attachments[0].url\nbut it only work with images (or gif, but video doesn't work)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":235,"Q_Id":59007265,"Users Score":0,"Answer":"embed.set_image as the name implies is for settings images. Unfortunately Discord does not let bots send videos inside embeds. Your limited options are to take the url and post it as just the content of the message and let discord embed it.","Q_Score":0,"Tags":"python-3.x,discord,discord.py,discord.py-rewrite","A_Id":59056271,"CreationDate":"2019-11-23T11:46:00.000","Title":"Discord bot recover the attachment of a message and send it in another channel with an embed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I developed a program to interact between Telegram and other 3rd party Software. It's written in Python and I used the Telethon library. \nEverything 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. \nOf 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?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":118,"Q_Id":59032433,"Users Score":1,"Answer":"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. \nYou 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.","Q_Score":0,"Tags":"python,telegram,telethon","A_Id":59032610,"CreationDate":"2019-11-25T12:59:00.000","Title":"Python and Telethon: how to handle sw distribution","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So i 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\nI have tried to compile the obfuscated script with pyinstaller however this does not work either\nWondering what else i can try?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":3221,"Q_Id":59037825,"Users Score":1,"Answer":"I had this problem, fixed by adding --restrict=0\nFor example: pyarmor obfuscate --restrict=0 app.py","Q_Score":1,"Tags":"python-3.x,pyinstaller,py2exe,pyarmor","A_Id":59040654,"CreationDate":"2019-11-25T18:14:00.000","Title":"Pyarmor Pack Python File Check Restrict Mode Failed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can someone brief me on what happens if I didn't use any webserver(NGINX) in front of my Application server (uWSGI or GUNICORN)?\nMy requirement is exposing a simple python script as a web-service. I don't have any static content to render. In that scenario can I go without NGINX?\nBrief me what are the issues I will face if I go with plain app server? Max requests per second would be some 50 to 80(This is the upper limit).\nThanks, Vijay","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":66,"Q_Id":59085500,"Users Score":0,"Answer":"If your script acts like a webserver then it is a webserver and you don't need any layer on top of it.\nYou have to make sure though it acts like one:\n\nlistens for connections\nhandles them concurrently\nwakes up upon server restart, etc\u2026\n\nAlso:\n\nhandles internal connections correctly (eg. to the database)\ndoesn't leak memory\ndoesn't die upon an exception\n\nHaving a http server in front of a script has one great benefit: the script executes and simply dies. No problem with memory handling and so on\u2026 imagine your script becomes unresponsive, ask yourself what then\u2026","Q_Score":0,"Tags":"python-3.x,nginx,uwsgi","A_Id":59085973,"CreationDate":"2019-11-28T09:28:00.000","Title":"What happens if i didn't use NGINX with uWSGI or Gunicorn?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"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.\nI 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?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":570,"Q_Id":59087777,"Users Score":0,"Answer":"There is nothing built-in, instead you should use one of the many integrations like sonarqube, if I don\u2019t want to write a custom script.","Q_Score":4,"Tags":"python,unit-testing,continuous-integration,code-coverage,github-actions","A_Id":65973463,"CreationDate":"2019-11-28T11:25:00.000","Title":"Fail build if coverage lowers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I remember when I save my files in PHP language, it didn't need to restart or reload apache web server.\nIn Python, specialy Django, If I use django webserver with runserver command,it needs to restart django if I change my files. Question is, if I use WSGI in server, Does it behave such as php or runserver command?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":40,"Q_Id":59139472,"Users Score":1,"Answer":"If you modify static files or html template, you should be fine without reloading your server.\n But you will need to reload your apache server if you change any of your python files.","Q_Score":0,"Tags":"php,python,django,mod-wsgi","A_Id":59164319,"CreationDate":"2019-12-02T13:01:00.000","Title":"Does WSGI behave dynamicly?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am writing a cgi script to run on a server, and when I put #!\/bin\/python3 at the top of the file it works fine. The problem is that on my local machine, my Python installation is in \/opt\/local\/bin\/python (and macOS does not allow symlinks in \/bin. So to run the script on my local machine, I need to manually change the path in each cgi file, which is cumbersome.\nIs there a better way to specify my Python path (something like \"try this path first else try this path?\")","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":38,"Q_Id":59162982,"Users Score":0,"Answer":"You can let your system environment choose the path using #!\/usr\/bin\/env python3","Q_Score":0,"Tags":"python,cgi","A_Id":59163022,"CreationDate":"2019-12-03T18:06:00.000","Title":"Specify Python location in cgi script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a Polygon (shapely) and the centroid of this Polygon (with longitude and latitude). Is there any way to count radius of the Polygon?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1145,"Q_Id":59195515,"Users Score":1,"Answer":"There are two cases:\n\nYou have a regular polygon, meaning all sides are equally long and the angles between sides is constant throughout the polygon. In this case you draw the smallest circle that touches all corner points of the polygon. The radius of this circle is said to also be the radius of your polygon.\nFor an irregular polygon it is a bit harder to get a grasp on the radius. Similar to the case above you could take the radius of the smallest circle in which the polygon fits.","Q_Score":0,"Tags":"python,polygon,shapely","A_Id":59195933,"CreationDate":"2019-12-05T12:46:00.000","Title":"How to count a radius of a polygon","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a question so in telegram bot there is a InlineKeyboardMarkup that can have a callback, but its not persistent, does not stick to the botton of the screen, when you write a new message it will go up, like a normal message. And on the other hand there is ReplyKeyboardMarkup that does persist and stay at the botton, but does not have a callback. So is there a way to create a button that stays at the botton but allso accepts a callback that you can catch with callback_query_handler","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":329,"Q_Id":59201308,"Users Score":0,"Answer":"No, there is no way to create a button that you can capture with callback_query_handler in a ReplyKeyboardMarkup.\nWhen you press a KeyboardButton, it sends a message with its text. What you could do is put your bot's commands in the buttons or you can make a message handler that captures non-command messages and execute some code for each text of your buttons.","Q_Score":0,"Tags":"python,telegram","A_Id":59201831,"CreationDate":"2019-12-05T18:32:00.000","Title":"Fixed button for Telegram bot that accepts a callback","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"In Python 3.6, when I attempt to \"open('foobar', \"r+b\") with a file whose permissions are '-r--r--r--' (in CentOS7), I get a permission failure:\n\"builtins.PermissionError: [Errno 13] Permission denied: 'full\/path\/to\/foobar'\"\nIt opens just fine with \"r\", and the \"r+b\" works just fine if the permissions are '-rw-rw-rw-'.\nI do need to open these files read-only, I'd like them to have read-only protections in the directory (so that they aren't inadvertently changed by other code), and I do need to read them as binaries. Is this a feature\/bug of Python 3.6?\nI'd like to know if I'm doing something incorrect, or if there's some work-around if not. I'd really like to avoid upgrading to 3.8 right now.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":228,"Q_Id":59205618,"Users Score":2,"Answer":"You are using the + mode, which is trying to open the file for update. Try without the + and it should work.\nPer the help:\n\n'+' open a disk file for updating (reading and writing)","Q_Score":1,"Tags":"python","A_Id":59205646,"CreationDate":"2019-12-06T01:31:00.000","Title":"Python 3.6 fails to open read-only file using \"r+b\" mode","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"There's a long list of languages that can be compiled into Wasm. Is there any performance gain from writing in something like C or Rust over Python? Or is it all the same since it is being compiled to Wasm?","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":2072,"Q_Id":59206185,"Users Score":3,"Answer":"Compiling to WebAssembly is basically just simulating a special form of assembly targeting virtual hardware. When you read \"can compile language X\" into Wasm, it doesn't always mean the language literally compiles directly to Wasm. In the case of Python, to my knowledge, it means \"they compiled Python interpreters to Wasm\" (e.g. CPython, PyPy), so the whole Python interpreter is Wasm, but it still interprets Python source code files normally, it doesn't convert them to special Wasm modules or anything. Which means all the overhead of the Python interpreter is there, on top of the overhead of the Wasm engine, etc.\nSo yes, C and Rust (which can target Wasm directly by swapping out the compiler backend) will still run faster than Python code targeting CPython compiled to Wasm, for the same reasons. Tools that speed up Python when run natively (e.g. Cython, raw CPython C extensions, etc.) may also work in Wasm to get the same speed ups, but it's not a free \"Compile slow interpreted language to Wasm and become fast compiled language\"; computers aren't that smart yet.","Q_Score":4,"Tags":"python,c,webassembly","A_Id":59206299,"CreationDate":"2019-12-06T02:53:00.000","Title":"Does WebAssembly run faster if written in C as opposed to Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a 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.\nNow, 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.\nThis lead to the following question:\n\nIs this solution data-scientifically feasible?\nDoes exists any other one-class classifier?\n(Most important of all) Are there any other ways to find if a tweet is similar to the ensable of tweets containing activism hashtags?\n\nThanks in advance for your help!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":540,"Q_Id":59238140,"Users Score":1,"Answer":"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.","Q_Score":1,"Tags":"python,twitter,nlp,classification,text-classification","A_Id":59395618,"CreationDate":"2019-12-08T17:44:00.000","Title":"Find how similar a text is - One Class Classifier (NLP)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a webapp that I made using django that I need to deploy to many raspberry pi devices. I'm using ansible to automate the deployment to devices. While developing the app I used pipenv to manage my project dependencies in a virtual environment.\nMy question is, is it necessary to make a virtual environment on the actual raspberry pi devices when deploying or can I just install all my necessary packages on the system environment? What are the advantages of making a virtual environment on the device?\nThank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":78,"Q_Id":59239496,"Users Score":1,"Answer":"Separating your apps' dependencies from systems' is always a good idea. The overhead is minimal and may prevent issues in the future. It makes it much easier to tear down and rebuild your app if you ever need to, rather than potentially having to re-image the raspberry pi if anything goes wrong. It also means you have the ability to run separate apps on the pi that don't need to be running off the same package versions, should you ever want to do that.\nHowever, it's certainly possible not to use one and you might get away with it and not have any issues. But if you want to improve the reliability and maintainability of your app and pi, and considering how easy it is to setup and use, it seems like a poor design decision not to use it.","Q_Score":1,"Tags":"python,django,raspberry-pi,virtualenv","A_Id":59240818,"CreationDate":"2019-12-08T20:12:00.000","Title":"Python virtualenv when deploying webapp to raspberry pi?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've compiled a program I've made with Python using cx_Freeze. I want to upload this program to a GitHub repository and I'm aware that I should use the \"releases\" feature. However, my executable file comes with many other files. Additionally, GitHub doesn't process some of the files(which came with my executable) I try to upload.\nIs there even a way to do such a thing? Or is this not supposed to be done? If so, how else can I distribute my executable programs?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":223,"Q_Id":59258391,"Users Score":2,"Answer":"You should upload your \"distributables\" as a ZIP file. You should also consider building an installer that copies all of the files to their correct location on the user's file system.","Q_Score":1,"Tags":"python,exe,cx-freeze","A_Id":59258426,"CreationDate":"2019-12-10T00:03:00.000","Title":"How do I properly upload a Python executable file to GitHub?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I've compiled a Python program with cx_Freeze. The Python code itself is only 195 lines long. However, my compiled program is 500 MB. I use matplotlib, numpy, and pymsgbox and I don't know if my libraries affect my compiled program size that much.\nWhat is the reason for this unexpected file size and is there a way to reduce the size of my executable?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":892,"Q_Id":59259914,"Users Score":4,"Answer":"Part of the purpose of cx_Freeze is to bundle all the dependencies, so that the end user need not install them. numpy, matplotlib, etc. are not small dependencies, especially because they have large binary (non-Python) components. So what you are asking is not physically possible, not because of cx_Freeze limitations, but because of a contradiction between the following two requirements:\n\nend user should be able to run executable on essentially any Windows machine, including possibly one without Python, numpy, and matplotlib\ndistributed binary size should be small\n\nYou cannot satisfy both these requirements simultaneously. cx_Freeze is appropriate for the first, but not the second. If you can assume your end users already have Python, numpy, matplotlib installed (or can install seperately), and want to distribute your program such that the binary size be small, a wheel is more appropriate.","Q_Score":2,"Tags":"python,exe,cx-freeze","A_Id":59259990,"CreationDate":"2019-12-10T03:46:00.000","Title":"How to reduce cx_Freeze compiled Python executable size?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"It seems the paths are relative to the root package. Should I define the project folder as the source root of the Intellij module, instead of the package folder?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":166,"Q_Id":59269256,"Users Score":1,"Answer":"Yes, Setting the project folder as the root will change the paths to be relative to that folder","Q_Score":1,"Tags":"python-3.x,intellij-idea","A_Id":59269363,"CreationDate":"2019-12-10T14:16:00.000","Title":"How to make Intellij (19.3) to perform absolute auto imports for python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"It seems the paths are relative to the root package. Should I define the project folder as the source root of the Intellij module, instead of the package folder?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":166,"Q_Id":59269256,"Users Score":1,"Answer":"Press Ctrl+Alt+Shift+S.\nClick on Proj. Settings \/ Modules\nClick on \/ Sources tab\nSet as Source only the project root folder and mark as Excluded all folders that should not be considered as source or indexed.","Q_Score":1,"Tags":"python-3.x,intellij-idea","A_Id":59269367,"CreationDate":"2019-12-10T14:16:00.000","Title":"How to make Intellij (19.3) to perform absolute auto imports for python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have several binary files, which are mostly bigger than 10GB.\nIn this files, I want to find patterns with Python, i.e. data between the pattern 0x01 0x02 0x03 and 0xF1 0xF2 0xF3.\nMy 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.\nMy 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?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":367,"Q_Id":59307194,"Users Score":3,"Answer":"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.\nOn 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.","Q_Score":0,"Tags":"python,algorithm,search,binaryfiles","A_Id":59307725,"CreationDate":"2019-12-12T14:51:00.000","Title":"How to search pattern in big binary files efficiently","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm building a telegram bot using pyTelegramBotAPI libraries, I wanted to know if there is a way to know when a user deletes a chat with my bot, so the bot will not send more messages towards that specific id.\nreading the telegram API I found nothing, can you help me?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1203,"Q_Id":59311680,"Users Score":1,"Answer":"As I know, there is no way. When you chat with a friend, is there any way to know that he\/she has deleted the chat page of you? NO.\nTelegram bot is completely similar to simple chat in this case up to\n this date. It doesn't have considered in Telegram Bot API up to this\n date.","Q_Score":0,"Tags":"python,telegram-bot","A_Id":59360428,"CreationDate":"2019-12-12T19:40:00.000","Title":"How to delete a Telegram user id when user delete the chat of the bot","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"My server can run on either Python 3.6 or Python 3.8. The problem seems to be the client.\nIf I run the client on Python 3.6, I get TLSv1.2 working with no error. But if I run the same client code on Python 3.8, I get NO_SHARED_CIPHER on the server and SSLV3_ALERT_HANDSHAKE_FAILURE on the client.\nI suspect it has something to do with server or client certificate.\nUPDATE: I created some new server and client certificates to experiment around with: ed25519, rsa, and secp256k1. From what I've seen, the problem above only shows up when the server certificate is secp256k1 and both the client and server are running Python 3.8 (and therefore with TLSv1.3). The client can use any type of certificate.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":298,"Q_Id":59333458,"Users Score":0,"Answer":"... NO_SHARED_CIPHER ...\n I suspect it has something to do with server or client certificate.\n\nThis is a problem of cipher selection and cipher selection has almost nothing to do with the certificate, at least if the the certificate type is still the same, i.e. ECC vs. RSA. And I assume that you are still using the same certificate or at least the same certificate type in the working and non-working cases.\nIt is more likely that your client tries to use some RC4 or 3DES based cipher which is today considered obsolete and thus is no longer supported by a server when using a newer version of the software stack (i.e. Python+OpenSSL).","Q_Score":0,"Tags":"python-3.x,sockets,ssl,openssl","A_Id":59333535,"CreationDate":"2019-12-14T08:17:00.000","Title":"Python SSL\/TLS - no shared cipher on Python 3.8 but working on Python 3.6","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm developing a 8 Puzzle game solver in python lately and I need a bit of help\nSo far I finished coding the A* algorithm using Manhattan distance as a heuristic function.\nThe solver runs and find ~60% of the solutions in less than 2 seconds\nHowever, for the other ~40%, my solver can take up to 20-30 minutes, like it was running without heuristic.\nI started troubleshooting, and it seems that the openset I use is causing some problems :\n\nMy open set is an array\nEach iteration, I loop through the openset to find the lowest f(n) (complexity : O(n) )\n\nI 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\"\nThank you for your help ! Have a good day\nEDIT: FIXED\nI solved my problem which was in fact a double problem.\nI 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\nThe 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.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":164,"Q_Id":59340795,"Users Score":0,"Answer":"The open set should be a priority queue. Typically these are implemented using a binary heap, though other implementations exist.\nNeither an array-list nor a dictionary would be efficient.\n\nThe 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.\nA 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.","Q_Score":0,"Tags":"python,algorithm,complexity-theory,a-star,sliding-tile-puzzle","A_Id":59342082,"CreationDate":"2019-12-15T02:32:00.000","Title":"8Puzzle game with A* : What structure for the open set?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I try to install librosa in python. Then I got error with llvmlite lite.\nI solved with easy_install llvmlite command.\nAfter that the librosa package is installed successfully.\nThe issue starts when I importing librosa in Jupiter.\nThe errors is -\nOS Error: could not load shared object file libllvmlite.so\nI do not understand this error. The packages are successfully installed but got error when importing.\nAny help, thank you","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":207,"Q_Id":59341518,"Users Score":0,"Answer":"I think in Linux, .so are shared objects. Restart and try opening your jupyter notebook with super user.","Q_Score":0,"Tags":"python,python-import,librosa","A_Id":59341712,"CreationDate":"2019-12-15T05:48:00.000","Title":"Librosa installation in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Case 1: Class is coded in code.py. Say class contains a couple of instance variables and an instance method that does some processing and returns the result. In flask endpoint, I am importing the class from code.py module and instantiating the class and calling the object.mtdname()\nCase 2: in code.py, along with the same class as in case 1, I define a function (do_work) outside the class. The do_work function instantiates the class and calls object.mtdname() method. In flask endpoint, I import only the do_work function from code.py. when do_work is invoked it will create the object and return the result.\nWhat are pro and cons of using case 1 or 2?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":31,"Q_Id":59351107,"Users Score":0,"Answer":"Generally speaking, I would prefer case 1 because case 2 requires an additional test that really doesn't test anything new. So for the purposes of reducing code, I would go with Case 1 unless do_work did something other than just call the one method.","Q_Score":0,"Tags":"python,python-3.x","A_Id":59351193,"CreationDate":"2019-12-16T05:43:00.000","Title":"Instantiate class and call its functions via a function in the same module as class declaration?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am 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().\nDespite 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.\nI 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?\nThank you!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":43,"Q_Id":59372579,"Users Score":0,"Answer":"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.","Q_Score":1,"Tags":"python,numpy,scipy","A_Id":59381955,"CreationDate":"2019-12-17T10:48:00.000","Title":"Can you change the precision globally of a piece of code in Python, as a way of debugging it?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I currently have a python project which basically reads data from an excel file, transforms and formats it, performs intensive calculations on the formatted data, and generates an output. This output is written back on the same excel file.\nThe script is run using a Pyinstaller EXE which basically is packing all the required libraries and the code itself, so every user is not required to prep the environment to run the script.\nBoth, the script EXE and the Excel file, sit on the user's machine.\nI need some suggestion on how this entire workflow could be achieved using AWS. Like what AWS services would be required etc.\nAny inputs would be appreciated.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":98,"Q_Id":59397424,"Users Score":1,"Answer":"One option would include using S3 to store the input and output files. You could create a lambda function (or functions) that does the computing work and that writes the update back to S3.\nYou would need to include the Python dependencies in your deployment zip that you push to AWS Lambda or create a Lambda layer that has the dependencies.\nYou could build triggers to run on things like S3 events (a file being added to S3 triggers the Lambda), on a schedule (EventBridge rule invokes the Lambda according to a specific schedule), or on demand using an API (such as an API Gateway that users can invoke via a web browser or HTTP request). It just depends on your need.","Q_Score":1,"Tags":"python,amazon-web-services","A_Id":59397565,"CreationDate":"2019-12-18T17:37:00.000","Title":"Suggestions to run a python script on AWS","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"my code is very simple python, it stores a \"Hello World\" in a variable, and then calls by my email GMAIL and sends the data stored within the variable, until and all right\nthen I turned it into .exe (with cx_Freeze), and both the .py and .exe files were running perfectly on my computer, and sending me the message via email!\nhowever, after I tried to run the .exe file on another computer (I exported the entire executable folder and installed python on the other computer as a precaution), it simply stops running when it comes to sending the email, and closes the console by itself. ; -;\nit stops executing when calling by smtplib:\nimport smtplib\nHow can I solve this problem, I want to run my files on other machines!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":26,"Q_Id":59419937,"Users Score":0,"Answer":"The two machines may have different OS or CPUS, this could be an issue. Have you tried to transfer the source (python) code, and compile it on the other machine? That should fix the issue, and if you want to run it on many different machines, consider compiling it on the machine you would like to run it on, and then upload that file. Cheers!","Q_Score":0,"Tags":"python,exe,python-3.7,cx-freeze,smtplib","A_Id":59419983,"CreationDate":"2019-12-20T04:45:00.000","Title":"Error executing specific lines of a python library on another computer as exe file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"A website has been developed on a local ubuntu machine using python flask. The website runs fine on ubuntu at 127.0.0.1:5000. This website is supposed to go live on a godaddy server for which there is cpanel access. How to do it?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":348,"Q_Id":59425136,"Users Score":1,"Answer":"If it's a shared hosting solution, Answer to your question is NO, you can't do it. In a shared hosting environment Godaddy using only a PHP Stack. so you won't be able to use python there. Either go with VPS and configure your server. or go with a cloud service provider like Digital ocean, AWS, Linode etc.,","Q_Score":0,"Tags":"python,flask,cpanel,godaddy-api","A_Id":59425216,"CreationDate":"2019-12-20T12:17:00.000","Title":"Flask cpanel godaddy server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am trying to open my python files with a double click. I normally open them in anaconda prompt which uses the powershell file found in C:\\Windows\\System32\\WindowsPowerShell\\v1.0. I tried using open with and navigating to this file, however then the promt window opens and immediately closes... the script should run continuously.\nI also tried opening it with the \"python (command line)\" file which I found in C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\Python 2.7 I cannot open the location of that file for some reason using right click> open file location, however I tried to open my script using this but again the same thing happens.\nIt is frustrating as I need to close and open my scripts often. Each time I have to load up anaconda prompt, type in python and drag the file, and than press enter.\nAny help would be appreciated.\nI have installed Python 3.7 btw that I installed with ana and am trying to avoid reinstalling python as I have so many npm installs done that I did not keep a log of.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":240,"Q_Id":59429783,"Users Score":0,"Answer":"Try to open file\/folder in other IDE like vscode, pyCharm or text editor.\nOpen IDE first after that click on file menu and select open option.Browse the file\/folder and select it.","Q_Score":0,"Tags":"python,anaconda","A_Id":59429837,"CreationDate":"2019-12-20T18:22:00.000","Title":"Cannot open python files with double click","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to use pycurl in my first python project on Raspbian but i have some difficulties installing it. During the installation procces (by pip) everything seemed to go well, nothing errored out but when i try to implement it the ide errors out. I've tried a lot of suggested solutions in other treads but I'm geting nowhere.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":128,"Q_Id":59432583,"Users Score":0,"Answer":"If the error is no module named pycurl, then the most likely reason for that is the package is its not well installed.\nThe common reason for that is that your virtual environment is not well activated, so you didn't install it globally and its withing your environment.\nIf you don't have a virtual environment then you installed your package globally. The most common reason for a no module error is that you installed it in another version of python that you are using in your code.\nDouble check where you are installing the packages and which version your project is using!","Q_Score":0,"Tags":"python,raspbian,pycurl","A_Id":59432790,"CreationDate":"2019-12-21T00:14:00.000","Title":"No module named pycurl error even with pycurl instaled","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have made a bot with BotFather and got the access token. What I want is to add my bot to a number of groups(I will provide the invite link to it) and it should be able to join the group through an API. So, let's say I have a list of 100 public groups with their invite link, then my bot should be able to join them, this process should be automated. \nI tried searching the telegram API docs, but I wasn't able to find there. Also, the questions on StackOverflow mostly helpful when I want to add the bot to my own group, which I don't want. \nI just want a direction, maybe a function from telethon or any other client. I will then be able to do it by myself.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":206,"Q_Id":59442068,"Users Score":0,"Answer":"You can't add bot to the group without corresponding admin permission, also what you're trying to do looks like a spam and leads to account restriction(or full deletion).","Q_Score":0,"Tags":"python,python-3.x,telegram,telegram-bot,telethon","A_Id":59442105,"CreationDate":"2019-12-22T06:18:00.000","Title":"How to add a telegram bot to different groups with python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have made a bot with BotFather and got the access token. What I want is to add my bot to a number of groups(I will provide the invite link to it) and it should be able to join the group through an API. So, let's say I have a list of 100 public groups with their invite link, then my bot should be able to join them, this process should be automated. \nI tried searching the telegram API docs, but I wasn't able to find there. Also, the questions on StackOverflow mostly helpful when I want to add the bot to my own group, which I don't want. \nI just want a direction, maybe a function from telethon or any other client. I will then be able to do it by myself.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":206,"Q_Id":59442068,"Users Score":0,"Answer":"Only an admin of a group or channel can add the bot. The bot itself cannot add it anywhere. Even a user have to initiate the interaction with bot first.","Q_Score":0,"Tags":"python,python-3.x,telegram,telegram-bot,telethon","A_Id":59468608,"CreationDate":"2019-12-22T06:18:00.000","Title":"How to add a telegram bot to different groups with python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently developing a piece of software on a Raspberry Pi. Because I have to control motors very precisely i developed a C script, that does that for me. My current problem is, that I didn't found any solid method to transfer a list of signed floats from a Python3 Script to a C script. It is really important, that the method is fast.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":44,"Q_Id":59447345,"Users Score":0,"Answer":"You could use a socket to send data from one script to the another.","Q_Score":0,"Tags":"python,c,list,char,ipc","A_Id":59447373,"CreationDate":"2019-12-22T19:16:00.000","Title":"Python and C IPC","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been testing some optimisations to a piece of code (specifically, whether elif n in [2,3] is faster than elif n == 2 or n == 3) and noticed something strange. \nUsing timeit.default_timer I did several runs of each version of the function, and the first run was always significantly slower than subsequent ones (values starting off around 0.01 of a second that trailed off to consistently around 0.003). \nIs python doing something behind the scenes to optimise the code on later runs? This isn't really a problem by any means, but I'd be interested to know what is happening (if anything)","AnswerCount":3,"Available Count":1,"Score":-0.0665680765,"is_accepted":false,"ViewCount":467,"Q_Id":59457810,"Users Score":-1,"Answer":"Yes, python caches the pyc file after the first run, so if the code doesn't change it will run faster in next iterations because it won't need to compile it to byte code again. Remember python is an interpreted language, it's just skipping an interpretation step.","Q_Score":3,"Tags":"python,timeit","A_Id":59457857,"CreationDate":"2019-12-23T15:34:00.000","Title":"Why is the first run of timeit usually slower than subsequent ones?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've made a telegram bot, that sends a request to a certain API and returns the answer to the bot.\nwhen I run the app locally, it takes like 2-3 seconds to execute a request and send the answer to the user, but when its webhook to pythonanywhere, it takes 5-10 minutes to execute a request.\nis it really that slow? or something is wrong?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":80,"Q_Id":59458765,"Users Score":1,"Answer":"That really seems like something's wrong. Instrument your code with some timing information so you can see where it's spending it's time. Then you can start to try to work out why there's such a big difference.","Q_Score":0,"Tags":"python-3.x,telegram-bot,pythonanywhere,python-telegram-bot","A_Id":59481625,"CreationDate":"2019-12-23T16:51:00.000","Title":"pythonanywhere - SUPER SLOW?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to find all builds which started some user by his username. Is it possible to do with the help of Python?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":43,"Q_Id":59460430,"Users Score":1,"Answer":"Yes. you could use Python, if you have access to the jenkins master.\nThe userId is in build.xml which is usually in your jenkins jobs\/you_job_name\/builds\/your_build_number\/build.xml\nYou could iterate over all the jobs and their builds and get the answer from there.","Q_Score":1,"Tags":"python,jenkins","A_Id":59465979,"CreationDate":"2019-12-23T19:32:00.000","Title":"Get information about the Jenkins builds related to specified username","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying connect to internal Jira instance use my AWS lambda function. The lambda cannot connect to this web-resource because VPN is required. (all work properly on my local machine under VPN connection).\nPlease any suggestion regarding this issue ?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":166,"Q_Id":59468906,"Users Score":0,"Answer":"Since there is an AWS Direct Connect connection between an Amazon VPC and your corporate network, the AWS Lambda function can be configured to connect to the VPC.\nThe Lambda function can then connect to the JIRA instance on the corporate network by using the private IP address of the JIRA instance.\nYou might be able to configure the VPC to defer to your corporate DNS server to resolve the DNS Name into the IP address, but I would recommend you start by using the private IP address itself to ensure that connectivity is working.","Q_Score":0,"Tags":"python,aws-lambda,python-jira","A_Id":59478372,"CreationDate":"2019-12-24T12:31:00.000","Title":"How connect to internal Jira instance via AWS lambda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying connect to internal Jira instance use my AWS lambda function. The lambda cannot connect to this web-resource because VPN is required. (all work properly on my local machine under VPN connection).\nPlease any suggestion regarding this issue ?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":166,"Q_Id":59468906,"Users Score":0,"Answer":"It would be best to use SQS messaging.\n\nDefine a message format\nFrom your lambda function, publish a message when you want to query something\nHave an app\/worker running inside your network, which is listening to your SQS queue.\nYour app\/worker receives that message and can query to your Jira instance.\nWhen the result is ready, your app\/worker can publish it on other SQS queue\nYou can receive the message in another lambda function, or If you want to receive the response in a same lambda function, you can poll for messages and wait till you get your desired message.\nIf you have multiple such lambda functions, or many requests going on. You can put a request-id in messages. So, when receiving a message, you can come to know which is your desired message and delete that one only.","Q_Score":0,"Tags":"python,aws-lambda,python-jira","A_Id":61316127,"CreationDate":"2019-12-24T12:31:00.000","Title":"How connect to internal Jira instance via AWS lambda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"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.\n\nFor 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.\nBut 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?\n\n(only interested in windows-based apps for now)\nThe aim is of course to create robots able to navigate the apps as a human would do.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":497,"Q_Id":59470191,"Users Score":0,"Answer":"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.\nTo 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.","Q_Score":1,"Tags":"c#,python,windows,blueprism,rpa","A_Id":59556005,"CreationDate":"2019-12-24T14:27:00.000","Title":"Blueprism-like spying and bot development","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am working on a group project which entails generating many reports. We were thinking of using amazon echo. We would ask alexa to fetch the reports from a particular tine period or something like that.\nWe plan on doing so using Python.\nIt is possible using ASK(Alexa Skills Kit) SDK to achieve this goal ? Like, can alexa tap into our application and fetch all that we want. We do not want to use anything else other than Amazon echo.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":31,"Q_Id":59476035,"Users Score":0,"Answer":"I think it's possible you need to create a custom skill for that, there are somethings that you might want to consider though,\n\nHow long is the report: it will work fine if reports are small and giving you some brief overview or some numbers. you don't wanna listen to long report on that robotic voice.\nName of reports: sometimes Alexa will not understand or misunderstood the name you're trying to say if it's complex one.\nmeaning of tap into your application: In Alexa skill you can write custom logic just like you write for a software so If there's API to fetch reports then It can be done. The skill will call API and pass the data that you say to that skill, data like to date, from date etc.","Q_Score":0,"Tags":"python,alexa-skills-kit","A_Id":59519917,"CreationDate":"2019-12-25T07:06:00.000","Title":"Using amazon alexa echo in my application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to build an app through react-native wherein I need to upload a JSON file to my account folder hosted on pythonanywhere.\nCan you please tell me how can I upload a JSON file to the pythonanywhere folder through react-native?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":136,"Q_Id":59479344,"Users Score":2,"Answer":"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.","Q_Score":0,"Tags":"pythonanywhere","A_Id":59481639,"CreationDate":"2019-12-25T14:33:00.000","Title":"How to upload a file to pythonanywhere using react native?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to run a test case using the command below\npipenv run py.test --cov=src --cov-fail-under=85 -vv test\/unit --debug\nIt complains as below\n\\n from requests_aws4auth import AWS4Auth\\nE ModuleNotFoundError: No module named 'requests_aws4auth'\") tblen=7>>\nWhen I run pip list I can notice that requests-aws4auth is there\nPackage Version \n\ncertifi 2019.11.28\nchardet 3.0.4\nelasticsearch 7.1.0\nidna 2.8\npip 19.2.3\npipenv 2018.11.26\nrequests 2.22.0\nrequests-aws4auth 0.9\nsetuptools 39.0.1\nurllib3 1.25.7\nvirtualenv 16.7.9\nvirtualenv-clone 0.5.3 \nPlease let me know in case you have any suggestion.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1259,"Q_Id":59488208,"Users Score":1,"Answer":"l was able to run the below command and after, it was successful.\n$ pip install requests\n$ sudo pip install requests-aws4auth\nGive it a try","Q_Score":1,"Tags":"python,python-unittest","A_Id":64043149,"CreationDate":"2019-12-26T12:04:00.000","Title":"python unit test - unable to import requests_aws4auth","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing a code to run a pi-based robot. It has several sensors and communicates with external computers over wifi as well. Some of the sensor and computer communication data is done over sockets (to other scripts) to keep things modular and simple (for me). As long as I stay at less than 10 sockets, will I come across any problems? I am mostly wondering if there is anything inherently wrong with this coding strategy.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":69,"Q_Id":59490736,"Users Score":0,"Answer":"Q : As long as I stay at less than 10 sockets, will I come across any problems?\n\nMaybe yes, maybe not. The number of ZeroMQ Socket-instances does not matter in this, the configuration of the ZeroMQ Context()-instances and thereof of the underlying operating system's resources do matter.\n\nQ : anything inherently wrong with this coding strategy?\n\nNo, unless you do right things in a wrong way. Particularly \"this coding\" remains magically hidden as an unseen, so far, code, the less the MCVE-formulated code-example and the general answer for such a problem thus suffers from a principal undecidability, until an MCVE-code is let to run in the problem-specific eco-system, with known limits for the control-loops and the robot physical properties ( which is left to the kind readers to review ad-hoc ).\nZeroMQ will have Zero-problems in running on the RPi-platform, given due configuration does not suffocate the Context()-instance(s) by not providing adequate resources.","Q_Score":1,"Tags":"python,websocket,zeromq,pi,sensors","A_Id":59505155,"CreationDate":"2019-12-26T16:03:00.000","Title":"is there such a thing as too many python websockets?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am doing a small project on sentiment analysis using TextBlob. I understand there are are 2 ways to check the sentiment of tweet:\n\nTweet polarity: Using it I can tell whether the tweet is positive, negative or neutral\nTraining 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'.\n\nMy 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 ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":304,"Q_Id":59498416,"Users Score":0,"Answer":"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.\nFor example, a tweet predicted as 80% Positive remains Postive. However, a tweet predicting as 50% Postive could be Neutral instead.","Q_Score":0,"Tags":"python,nltk,sentiment-analysis,naivebayes,textblob","A_Id":59678549,"CreationDate":"2019-12-27T09:10:00.000","Title":"TextBlob Naive Bayes classifier for neutral tweets","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am not able to run the command $ sudo ~\/mininet\/examples\/miniedit.py in mininet.When I type that command to use miniedit the output comes as Traceback (most recent call last):\n File \".\/mininet\/examples\/miniedit.py\", line 63, in \n from mininet.log import info, debug, warn, setLogLevel\nImportError: No module named mininet.log","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2093,"Q_Id":59517716,"Users Score":0,"Answer":"you have to execute miniedit.py from remote terminal \"that has visualization\" using ssh .","Q_Score":1,"Tags":"python,pip,sdn,mininet","A_Id":59662070,"CreationDate":"2019-12-29T07:55:00.000","Title":"How to use miniedit in mininet?. Can anyone suggest the commands","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"So I'm given a TFile that contains two TTree objects, which contain track\/tower pT, eta and phi, divided by events. My goals is to extract each track and tower in the event and then cluster whole event using the FastJet package. Now, if I'm doing this task using pure ROOT my analysis takes 30 minutes at max (with ~100 GB TFile). In the meanwhile, uproot will process only 10,000 events in this time limit... \nIt is apparent that I'm doing something wrongly, so I wanted to ask, what would be the proper way to access track-by-track information to get the same speed as in ROOT?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":98,"Q_Id":59520611,"Users Score":1,"Answer":"Uproot gets its efficiency from operating on many events per Python function call. The FastJet interface, last time I checked, would only accept one particle at a time: a Python function call for every particle in every event. Without even profiling it, I'd I suspect that this is the bottleneck.\nThere's another library called pyjet that improves upon this by feeding FastJet a whole event at a time. All the particles in one event are put into a large, contiguous NumPy array. Then, at least, there's only one Python function call per event.\nTo do multiple events per array would require jagged arrays (to indicate where one event stops and the next event begins). There have been some plans to link Awkward Array to FastJet to supply this functionality, but for now, pyjet is the best you can do. If you have many particles per event, like hundreds, this might be okay.","Q_Score":1,"Tags":"python,numpy,uproot","A_Id":59521505,"CreationDate":"2019-12-29T15:13:00.000","Title":"How to efficiently retrieve tracks in uproot?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm building a web-app with Flask and have an philosophical\/architecture related question for all you with more experience than I.\nThe user enters some basic search criteria in my app, my app then queries multiple 3rd-party APIs for information related to the criteria and aggregates the results. \nUltimately, my app will send the user a bi-weekly email with an HTML-formatted table containing the information gathered by the API queries (as rows in the table). The information doesn't need to be stored long term, it becomes obsolete after a week or so there is really no point in storing it. The 3rd party APIs will always be queried anew each week or so. \nInitially I was thinking that I would need to maintain a database table for each user which would aggregate and store the results of their specific API queries. I was planning to create the contents of the emailed table from the rows in the database. \nI'm now wondering if there is a way to accomplish all of this without using a database to temporarily store the results of the API queries before emailing.\nMy question: What is the most efficient or optimal means for accomplishing what I'm trying to do? Is it possible to do this without a database for storing the results of the API queries?\nTo recap here was the sequence of operation for the initial concept:\nApp queries API for info --> App stores data returned by APIs in DB Table --> App puts info from DB table into formatted HTML table --> App sends HTML table to user in email --> The next time the App queries the APIs the DB tables would be over-written.\nFor context here are the different packages I'm using:\nFlask 1.1.1\nwerkzeug 0.15.5\nApplication server for both development and production.\ngunicorn 19.9.0\nTesting and static analysis.\npytest 5.1.0\npytest-cov 2.7.1\nmock 3.0.5\nflake8 3.7.8\nData and workers.\npsycopg2-binary 2.8.3\nFlask-SQLAlchemy 2.4.0\nSQLAlchemy 1.3.7\nalembic 1.0.11\nredis 3.3.7\ncelery 4.3.0\nForms.\nFlask-WTF 0.14.2\nWTForms-Components 0.10.4\nWTForms-Alchemy 0.16.9\nPayments.\nstripe 2.35.0\nUtils.\nfaker 2.0.0\nExtensions.\nflask-debugtoolbar 0.10.1\nFlask-Mail 0.9.1\nFlask-Login 0.4.1\nFlask-Limiter 1.0.1\nFlask-Babel 0.12.2\nFlask-Static-Digest 0.1.2","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":59521728,"Users Score":0,"Answer":"If you don't need it in a DB, it seems like you could work with the pandas module, and just use it as a DataFrame. The dataframe offers a lot of the easy manipulation of a database without having to actually use a database.","Q_Score":0,"Tags":"python,database,flask,architecture,web-development-server","A_Id":59521810,"CreationDate":"2019-12-29T17:34:00.000","Title":"Can I avoid using a database in this scenario?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Running cplex\/pyomo the solver found a solution and it reported saved somewhere though I closed before taking note, can't find over the web where is it stored.\nrunning windows, anyone?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":174,"Q_Id":59547875,"Users Score":2,"Answer":"I don't know how exactly pyomo invokes CPLEX to store solutions on disk. The default behavior of CPLEX is to store solutions in the current working directory. The solution file will have a suffix of either .sol or .mst.","Q_Score":0,"Tags":"python,cplex,pyomo","A_Id":59607635,"CreationDate":"2019-12-31T19:34:00.000","Title":"What is the default location for saved cplex solutions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am following the Obey the testing goat book and I try to automate some shell command server side using Fabric3\nI have an issue concerning thefab deploy:host=yyy@xxx\nyyy being username\nxxx being folder name of my domain name\nWhenever I run this command, I get Login password for 'xxx': and it just never seem to work even though I enter the correct one\nHere is what I did so far:\n1- did ssh-keygen locally and on the server\n2- added on local side a file named authorized_keys which contains id_rsa.pub generated on server side\n3- did the same operation on server side \nBasically, both sides have a file named authorized_keys \nLocal side (resp. server side) have authorized_keys which is just a copy of id_rsa.pub generated by the ssh-keygen command on server side (resp. local side)\nCould anyone review what I did so far and tell me if I DID understand the problem (or not), and what should I do to resolve this issue\nThank vm","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":63,"Q_Id":59561008,"Users Score":0,"Answer":"I have no clue how I managed to make it work...\nBasically, I deleted the old public key that I had linked to my user in my digitalocean droplet's settings, and generated a new one, on the local terminal using ssh-keygen, then I did the basic configuration by copying this public key server-side on following path ~\/.ssh\/authorized_keys ...\nNow, it does still asks for my password, but does proceed to the execution of my fabfile script after correct password input\nI'm thinking that the 'proper' way to setup a ssh with one's user is to do it manually through command-line ?\nAnyway, problem 'solved'","Q_Score":0,"Tags":"python,django,server,automated-tests,fabric","A_Id":59592322,"CreationDate":"2020-01-02T09:30:00.000","Title":"fabric3 : Intempestive Login for password when trying to run fab command","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am researching on micropython to use for an IoT project for school using nodeMCU esp8266. one of the use cases requires the device to receive IR signal from an Aircon remote control and save it as well as being able to transmit this code using and IR LED. in circuitpython there is a library called pulseio that can do this function, but it is not available in micropython. can this library be imported into micropython?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":934,"Q_Id":59599062,"Users Score":4,"Answer":"In short No. \nIt is very unlikely any CircuitPython library willl work straight over in MicroPython on your board. The main reason for this is that once the library starts to use UART or I2C the underlying implementation in CircuitPython is very dependent on other CircuitPython libraries which do not have equivalents in MicroPython.\nIt may be possible to find all these and re-implement them using standard MicroPython.\nThe decision point is if you can do that faster than finding a MicroPython library or example for your board to do the same thing OR if you should buy a CircuitPython compatible board instead.","Q_Score":3,"Tags":"esp8266,micropython,adafruit-circuitpython","A_Id":60854293,"CreationDate":"2020-01-05T10:46:00.000","Title":"Can circuitpython libraries be imported and used in micropython?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I Have 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.\nCan anyone help how to achieve that?","AnswerCount":3,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":60,"Q_Id":59606906,"Users Score":2,"Answer":"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.\nAnd 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","Q_Score":3,"Tags":"python,python-3.x","A_Id":59606974,"CreationDate":"2020-01-06T05:04:00.000","Title":"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","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I Have 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.\nCan anyone help how to achieve that?","AnswerCount":3,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":60,"Q_Id":59606906,"Users Score":2,"Answer":"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.\nI'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.","Q_Score":3,"Tags":"python,python-3.x","A_Id":59606944,"CreationDate":"2020-01-06T05:04:00.000","Title":"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","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I Have 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.\nCan anyone help how to achieve that?","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":60,"Q_Id":59606906,"Users Score":1,"Answer":"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.","Q_Score":3,"Tags":"python,python-3.x","A_Id":59607089,"CreationDate":"2020-01-06T05:04:00.000","Title":"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","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a python script, let's call it my_script.py. The script is supposed to generate simulated responses to an api call performed on the command line.\nWhat I am looking for is some way to have a custom command line command, e.g. run-my-script execute my_script.py while allowing for my_script.py to accept keyword arguments.\nIt would be great to have a solution that doesn't require external libraries and that allows for keyword arguments to be passed from the command line to that function.\nIs there a way to have a custom command on the command line, like run-my-script trigger my_script.py? \nThough it would be easiest to just run python my_script.py from the command line, for my use case I need to have the python script triggered just by run-my-script alone.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":369,"Q_Id":59620571,"Users Score":2,"Answer":"alias run-my-script=\"python my_script.py\"\nRun this command in terminal and run-my-script will execute my_script.py.\nYou can also add it in ~\/.bashrc so you can access it after you reboot.","Q_Score":0,"Tags":"python,bash,shell,command-line","A_Id":59620775,"CreationDate":"2020-01-07T00:11:00.000","Title":"Mapping a custom a CLI command to a Python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was making an integer to Boolean program and was dealing with some large numbers\nThe test case was - 15921396743627894741911\nWhen I used \nr\/2 the output was 7.960698371813948e+21\nint(r\/2) gave me 7960698371813947736064\nand r\/\/2 gave me 7960698371813947370955\nWhy is the value for the last two cases so vastly different. Thank you","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":62,"Q_Id":59639995,"Users Score":0,"Answer":"In Python 3, \/ does \"true division\", which returns a float, but floats have limited precision.","Q_Score":2,"Tags":"python,python-3.x","A_Id":59640093,"CreationDate":"2020-01-08T05:41:00.000","Title":"Difference between int(r\/2) and r\/\/2 outputs","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have included Python.h in my module header file and it was built successfully. \nSomehow 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.\nI have no clue at the moment what is being wrong.\nCould anyone give a hint? It is for the NS3(Network Simulator 3) framework.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":115,"Q_Id":59650272,"Users Score":0,"Answer":"thanks for writing back to me:).\nI solved the issue by adding the pyembed feature in the wscript within the same folder as my.cc file.\nThanks again:).\nJ.","Q_Score":0,"Tags":"python,c++,compiler-errors,header","A_Id":59666010,"CreationDate":"2020-01-08T16:40:00.000","Title":"NS3 - python.h file can not be located compilation error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Python with the paho-mqtt library for an application where I'll have multiple devices connecting to a broker over 3G constantly sending data that will be stored in a database. For this data is quite important, I needed some kind of confirmation that the MQTT messages from the devices have been successfully delivered to the broker. Is there a way of doing that?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":167,"Q_Id":59664359,"Users Score":0,"Answer":"On the publish method you can set the QoS 1 or 2. QoS level 1 guarantees that a message is delivered at least one time to the receiver. The sender stores the message until it gets a PUBACK packet from the receiver that acknowledges receipt of the message. It is possible for a message to be sent or delivered multiple times. QoS 2 is the highest level of service in MQTT. This level guarantees that each message is received only once by the intended recipients. QoS 2 is the safest and slowest quality of service level. The guarantee is provided by at least two request\/response flows (a four-part handshake) between the sender and the receiver. The sender and receiver use the packet identifier of the original PUBLISH message to coordinate delivery of the message.","Q_Score":0,"Tags":"python,python-3.x,mqtt,mosquitto","A_Id":59664642,"CreationDate":"2020-01-09T12:49:00.000","Title":"Is there a way to assure a message's been delivered to the broker in MQTT with Paho MQTT for Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python code on a server and if I upload a video from mobile to the server,so How can I provide path of that video to the python code if I want every video should prodceed by the python code","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":141,"Q_Id":59671070,"Users Score":0,"Answer":"I have doubts that your explanation has truly reflects what you need. First of all servers accept every thing \"as it is\" as long as the input has the appropriate format for that specific \"server\". In your case, the video might be a stream, binary, or event encoded data in to a \"socket\" in your \"server\". the framework should not matter. So when you have a stream you should be able get it in to your \"server\" to be processed. If you have problem in that sense, you should try to look first how \"servers\" accept input. I assume you're knowledgable for that. Let's say you have a nginx server on a linux machine which also has a python included. So your web server should be configured to run in python (Django or something similar). Once you started to upload your file, the content can be passed as async, or sync process in python (I think I should not mention how RESTFull model work on http). When you have the data (stream or static\/bulk), you should be able to whatever you want to do with that data.","Q_Score":0,"Tags":"python,video,uploading","A_Id":59725643,"CreationDate":"2020-01-09T19:42:00.000","Title":"Uploaded video process by python code on server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have an 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.\nIdeally, I would like something where I could a list a set of variables pairs and run the lambdas on a schedule\nThe only way I see of doing this, is have separate lambdas and setting the environment variables for each manually\nAny Ideas about how to achieve this","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":393,"Q_Id":59673456,"Users Score":2,"Answer":"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.\nOf 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.","Q_Score":1,"Tags":"python-3.x,amazon-web-services,aws-lambda","A_Id":59673562,"CreationDate":"2020-01-09T23:15:00.000","Title":"AWS Lambda - Run Lambda multiply times with different environment variables","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a C++ application which generates a stream of AVFrame objects and I want to pass them in realtime to a Python application for further processing, e.g. using OpenCV.\nWhat is the best way of doing this? Thanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":110,"Q_Id":59696325,"Users Score":0,"Answer":"If you are in a Unix or Linux based system, you can use a pipe. You also can use the local socket to transmit the stream.","Q_Score":0,"Tags":"python,c++,ffmpeg,video-streaming","A_Id":59711018,"CreationDate":"2020-01-11T16:27:00.000","Title":"Best way to stream FFMpeg AVFrame objects from a C++ application to Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"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.\nHow, 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.\nIn 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?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":41,"Q_Id":59698487,"Users Score":1,"Answer":"From RabbitMQ document, I find: \n\nDelivery tags are monotonically growing positive integers and are presented as such by client libraries.\n\nSo 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.","Q_Score":0,"Tags":"python,rabbitmq,pika","A_Id":59702401,"CreationDate":"2020-01-11T20:43:00.000","Title":"How to identify the message in a delivery notification?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing a telegram to the bot. I ran into such a problem. I need the bot to send a message (text) when clicked on which it was copied (as a token from @BotFather)","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":13652,"Q_Id":59713920,"Users Score":1,"Answer":"You can simply by editing the text in following manner\nWrite ``` then write your text then again write that 3 character .\nBingo!!!","Q_Score":4,"Tags":"python,bots,telegram,telegram-bot,py-telegram-bot-api","A_Id":65958439,"CreationDate":"2020-01-13T09:40:00.000","Title":"How to make that when you click on the text it was copied pytelegrambotapi","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The documentation suggests that BytesIO is the new StringIO, because it supports current-relative seeks. \nHowever, this is incorrect. \nBytesIO cannot be used uniformly with TextIOWrappers as they are returned by open() calls. The former returns bytes the later returns text objects when reading. \nTextIOWrapper(BytesIO(...)) also, does not do work as desired, because again, it does not support relative seeks.\nSo what is the best construct to replace the python2 StringIO in python3?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":263,"Q_Id":59729620,"Users Score":1,"Answer":"There is no single uniform replacement, as string handling itself has changed in Python 3.\nThe class for in-memory text files in Python 3 is io.StringIO. Like other text files, it doesn't support current-relative seeks. While io.StringIO could theoretically support efficient current-relative seeks, for consistency with other text files (and to avoid constraining the implementation), it refuses to do so.\nThe class for in-memory binary files in Python 3 is io.BytesIO. There's a good chance that this is what you should be using (and if it is, then you should probably be opening your disk files in binary mode too).\nIf you really need the flexibility of Python 2's StringIO.StringIO.seek handling with an in-memory text file in Python 3, your best bet may be to write your own class.","Q_Score":0,"Tags":"python,stringio,bytesio","A_Id":59730503,"CreationDate":"2020-01-14T08:02:00.000","Title":"What uniformly replaces the StringIO of Python2 in Python3?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently on the steep part of the learning curve with a Linux server and running into a very frustrating issue.\nInitially, I was running python scripts from the root user, then I learned that this was bad and created a new user and am working on migrating everything over to this new user. For some reason, when I set up the new user in exactly the same way that I set up the root I can no longer run the active file. From the root user, I can either click 'run active file' or the small play button in the top right corner but that disappears when I log in as the new user. \nI receive the error message '''only files on disk can be run in the terminal'''\nAny ideas on where I'm going wrong? Like I said still learning this stuff so if any more detail is needed please let me know.\nThanks!!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":292,"Q_Id":59760784,"Users Score":0,"Answer":"Well this was dumb, the Python extension was installed when running the root but had to separately install the extension for the additional user. Fixed the issue.","Q_Score":0,"Tags":"python,linux,visual-studio,linode","A_Id":59773887,"CreationDate":"2020-01-15T23:00:00.000","Title":"Cannot run active file in visual studio when connected to linux server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have to automate certain tests daily using cron job. I specify my shell script in my cron job. First, I have to first start my spring-boot application. I do that using the java -jar spring-boot-app.jar command. Then I need to execute a python script after starting the spring-boot app. I've put both these 2 commands in a shell script. But the problem is the python script is not being run, after starting the spring-boot app from the shell script. How do I start the python script too? I tried opening a new terminal using gnome-terminal in my script, but this command doesn't work in a remote machine. How do I start both the spring-boot app and the python command?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":357,"Q_Id":59763543,"Users Score":1,"Answer":"I think the answer above by UtLox will resolve your problem, because the \"&\" at the end will run your Spring Boot application in the background","Q_Score":1,"Tags":"java,python,shell,cron","A_Id":59763697,"CreationDate":"2020-01-16T05:32:00.000","Title":"how to run both java and python command in a shell script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am looking to send different data types to my arduino via a serial connection using python. I have already managed to send simple data such as strings over the serial line and I parse the data in my arduino code, but now I want to send something similar to a structure containing two integers and a string.\nI was thinking I should just build the data I want to send as strings, concatenate them with a separator token, and parse this long string in my arduino code. Is this the usual way to send more data types at once, or is it better to send the variables separately?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":177,"Q_Id":59794478,"Users Score":1,"Answer":"Yes there is always a risk of loosing bytes. \nBut how you do it is totally dependent on what kind of data you are sending. For example if the values you are sending is between 0 and 255 you can send the value as one byte.\nIf on the other hand you are sending multiple values and or strings it si a good practice to make use of the control characters in the ASCII table to mark the start of a sequence and seperation and identification of values. For example\n\nSTX \"value_id1\" US \"value\" RS \"value_id2\" US \"value\" ... ETX\n\nIf the integrity of the values are very important you could calculate a checksum \"CRC\" to send along the message so the receiver can check for errors.","Q_Score":1,"Tags":"python,arduino","A_Id":59809228,"CreationDate":"2020-01-17T20:33:00.000","Title":"If I want to send data to arduino via serial, should I send a long string at once, or send each variable separately?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to create a tool with Python and the Twitter API to be able to create lists of tweets that match certain criteria like \"contains the word Python\" or \"has at least 2 likes\". Or simple stats like top posters, most liked, etc.\nAll of my search pointed me to the Tweepy project. But for that I need 0Auth tokens. So I applied for a developer account and was denied with the comment \"we are unable to serve your use case\".\nDo I have any alternatives?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":158,"Q_Id":59811949,"Users Score":0,"Answer":"Well, as a general answer for these situations, you can always use a web-based automation tool, which is basically a library that interacts with the remote feature of the browsers and replicates what would be you \"opening the website, logging in, etc\" and can subsequently parse all data from the rendered elements.\nTry looking at selenium, i've used that library in the past to raw scrap facebook and it worked flawless.\nEdit: Note that this isn't a twitter specific library, you will have to find the html tags in the login website and use them to log in, same for parsing data, etc.","Q_Score":3,"Tags":"python,twitter","A_Id":70450120,"CreationDate":"2020-01-19T16:16:00.000","Title":"using Python and the Twitter API without authentication tokens","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am doing a project where I need to send device parameters to the server. I will be using Rasberry Pi for that and flask framework. \n1. I want to know is there any limitation of HTTPS POST requests per second. Also, I will be using PythonAnywhere for server-side and their SQL database. \nInitially, my objective was to send data over the HTTPS channel when the device is in sleep mode. But when the device (ex: car) wakes up I wanted to upgrade the HTTPS to WebSocket and transmit data in realtime. Later came to know PythonAnywhere doesn't support WebSocket.\nApart from answering the first question, can anyone put some light on the second part? I can just increase the number of HTTPS requests when the device is awake (ex: 1 per 60 min in sleep mode and 6 per 60sec when awake), but it will be unnecessary data consumption over the wake period for transmission of the overhead. It will be a consistent channel during the wake period.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":569,"Q_Id":59822489,"Users Score":2,"Answer":"PythonAnywhere developer here: from the server side, if you're running on our platform, there's no hard limit on the number of requests you can handle beyond the amount of time your Flask server takes to process each request. In a free account you would have one worker process handling all of the requests, each one in turn, so if it takes (say) 0.2 seconds to handle a request, your theoretical maximum throughput would be five requests a second. A paid \"Hacker\" plan would have two worker processes, and they would both be handling requests, to that would get you up to ten a second. And you could customize a paid plan and get more worker processes to increase that.\nI don't know whether there would be any limits on the RPi side; perhaps someone else will be able to help with that.","Q_Score":1,"Tags":"python-3.x,http,flask,websocket,pythonanywhere","A_Id":59829441,"CreationDate":"2020-01-20T11:38:00.000","Title":"Limit of HTTPS request per seconds","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was 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. \nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":583,"Q_Id":59825266,"Users Score":0,"Answer":"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.","Q_Score":0,"Tags":"ocr,tesseract,python-tesseract","A_Id":59855444,"CreationDate":"2020-01-20T14:24:00.000","Title":"Does anyone know how Tesseract - OCR postprocessing \/ spellchecking works?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am looking for a solution to find the percentage area covered by a polygon inside another polygon, from geo coordinates using python. \nThe polygon can be either fully reside inside the other one or a portion of the second polygon.\nIs there a solution to this. \nPlease advice.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":232,"Q_Id":59827622,"Users Score":0,"Answer":"Percentage is just area of intersection over area of the (other) polygon:\narea(intersection)\/area(polygon2).\nBasically any of geometry packages should be able to compute this, as they all support area and intersection functions: I think Geopandas, SymPy, Shapely (and others I missed) should be able to do this. There might be differences in supported formats. \nYou did not specify what Geo coordinates you use though. I think Geopandas and SymPy support only 2D maps (flat map) - meaning you need to use appropriate projection to get exact result, and Shapely works with spherical Earth model.","Q_Score":0,"Tags":"python,geospatial","A_Id":59835207,"CreationDate":"2020-01-20T16:42:00.000","Title":"Python package\/function to get percentage area covered by one polygon in another polygon using geo coordinates","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Robot Framework. I came across a scenario where i just want to create Employee details and not assert, is there a way in Robot framework where i can run a file which has KeyWords section and not TestCases and still execute the operation?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":152,"Q_Id":59841252,"Users Score":0,"Answer":"No, you can\u2019t execute keyword without testcase.","Q_Score":2,"Tags":"python,robotframework","A_Id":59841374,"CreationDate":"2020-01-21T12:32:00.000","Title":"How to run Keywords directly instead of TestCases In robot Framework","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to develop a system for trace and debugging an external device via COM port.\nMain service will be developed using python to receive, analyse & store logs data. \nWe decided to stream log data to web browser with gRPC protocol and draw live charts.\nHighest rate if data is 50K of signals per second and maximum size of every signal is just 10 bytes.\nSystem will be used in local network or same PC so we do not have bandwidth limits.\nWe want to make sure the web-grpc platform can cover this rate per second.\nThanks for your recommendations.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":93,"Q_Id":59849029,"Users Score":1,"Answer":"The throughput limit is mostly decided by the browser and the protobuf overhead. Since the latter is application specific, you should do a benchmark with real data on your preferred browsers.","Q_Score":0,"Tags":"benchmarking,grpc,rate,grpc-python","A_Id":59872414,"CreationDate":"2020-01-21T20:50:00.000","Title":"web-gRPC Performance Rate per second","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"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 !","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":604,"Q_Id":59850250,"Users Score":1,"Answer":"Here is a start:\nimport win32com.client\nERwin = win32com.client.Dispatch(\"erwin9.SCAPI\")\nI 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.","Q_Score":0,"Tags":"python,api,erwin","A_Id":60781882,"CreationDate":"2020-01-21T22:38:00.000","Title":"Erwin API with Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Let's say I've several devices each having a temperature. All messages related to device temperature are published on topics device\/1\/temerature, device\/2\/temperature, etc. . I handle all messages published on this topic with Python paho-mqtt with a callback function which uses a wildcard expression client.message_on_callback_add(\"device\/+\/temperature\", ...). Is there a way to get the value of the wildcard expression, here + directly (w.o. need for parsing of msg.topic)?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2027,"Q_Id":59882816,"Users Score":2,"Answer":"No, the callback includes the topic the message was published to.\nIt is up to you to extract what ever information you need from the topic.","Q_Score":1,"Tags":"python,python-3.x,mqtt,paho","A_Id":59884314,"CreationDate":"2020-01-23T16:12:00.000","Title":"How to get wildcard value from mqtt topic?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using GNU Radio's logging functionality in some custom python blocks I've built for a flowgraph. Among other things, the logging methods are useful for recording the (rough) start time of the flowgraph to a log file. I would also like to record the end time of the flowgraph (i.e., the rough time I kill the flowgraph in companion) in a log message written to the log file. To be clear, I'm looking for a solution that will work when I run the flowgraph from GNU Radio Companion. Is there an easy way to do this?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":212,"Q_Id":59901161,"Users Score":1,"Answer":"In GNU Radio blocks, you can overload the stop method to do exactly that, execute code at flow graph stop time.\nGenerally, the \"stop\" button in GRC is a rather hardcore thing; if you instead have a finishing condition in your flowgraph itself (e.g. closing of the window if you're using Qt GUI, or finishing of any block), this could be approached from that logical \"I should be done\" point of view, rather than \"someone else tries to kill me\".","Q_Score":1,"Tags":"python,logging,gnuradio,gnuradio-companion","A_Id":59919568,"CreationDate":"2020-01-24T17:29:00.000","Title":"GNU Radio Companion -- logging a message just prior to flowgraph shutdown","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I need to make a python script that gathers large amounts of information about vcenters. I basically call every single diagnostic possible, one after the other, gathering this info into a database daily for machine learning. This logs into the vcenter via python's pyvmomi and then calls for information about all resource centers, calls for information about all clusters, calls for the hosts on each cluster and information about them, and calls for information about every vm on every host. Where can I see the strain on vcenter? Where is it hosted? I guess the issue is I've been assigned a task, and I can gather documentation and get it done, but I dont want to cause strain on very important tools for our business. How can I be sure this does not cause issues with bandwidth or slow important processes like CPU sharing, memory allocation, and host switching.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":124,"Q_Id":59903835,"Users Score":0,"Answer":"You can see the overall stats of the vCenter in the VAMI (vCenter Appliance Management Interface), where you can monitor the CPU and RAM utilization. If you want deeper, more precise, info, it would require logging into the vCenter locally, which is generally not recommended. \nvCenter will, in general, handle your queries sequentially. They will queue up if the vCenter can't handle them immediately. The issue is that it will also queue up the other tasks being processed and there's no real way to give tasks a priority. \nIf you have vROps running in your environment, that might be a better place to pull all of those metrics... assuming they're available there.","Q_Score":0,"Tags":"python,vmware,stress-testing,vsphere,pyvmomi","A_Id":60078159,"CreationDate":"2020-01-24T21:21:00.000","Title":"How can I tell what strain is caused by pyvmomi on vmware?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"All the FreeSwitch documentations are given assuming you have installed Debian. So for CentOs or any RHEL distribution users are having a problem.\nWhen I tried to follow the mod_python documentation given by FreeSwitch, I am getting errors.\nNow, How can I install mod_python or any other modules?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":361,"Q_Id":59928304,"Users Score":0,"Answer":"In CentOs for installing any software, search the yum repo.\nLike here,\nI ran\nyum search freeswitch\nI got all the FreeSwitch modules. Now find your required modules and install.\nLike here for mod_python module, I typed\nyum install freeswitch-python.x86_64\n\nNow, type cd \/etc\/freeswitch\/autoload_configs\/ and edit modules.conf.xml\nAdd and save the file and exit.\nNow, use fs_cli command and type reloadxml.\nAfter this restart your linux system and again type fs_cli and type module_exists mod_python.\nThis should show true. If so, that means mod_python installation is successful.","Q_Score":0,"Tags":"centos7,python-module,freeswitch","A_Id":59928305,"CreationDate":"2020-01-27T09:33:00.000","Title":"FreeSwitch mod_python(or any other modules) installation on CentOs 7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have two same python file in different location and these scripts will be invoked and executed in random time. If one script is executing, I want other script to wait until that job is finished. How can I get it done?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":148,"Q_Id":59958145,"Users Score":0,"Answer":"you can have a global Flag in somewhere like DB and change your code in a way that script1 only runs when flag is True and script2 only runs when flag is set to false. you should change the value of flag in both scripts.\nOr you can use Trigger. Trigger script2 from script1 after his work is finished.","Q_Score":0,"Tags":"python-3.x,parallel-processing,singleton,semaphore","A_Id":59963099,"CreationDate":"2020-01-28T22:37:00.000","Title":"Avoid duplicate execution of same python script in different location when invoked by cron","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have found that there are a lot of similarities between both modules in the area of creating temp files using io.BytesIO() or io.StringIo() and tempfile.TemporaryFile()\nWhat is the purpose of each one ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1099,"Q_Id":59967774,"Users Score":4,"Answer":"io.BytesIO() create a file-like object linked to a memory area, and should be used to store binary data (like data used to represent an image, a music, a MS Word document, etc.).\nio.StringIO() create a file-like object linked to a memory area, and should be used to store text data (like a html page, a php script, etc).\ntempfile.TemporaryFile() create a temp file on the disk (not in memory). Use first argument mode to specify or not the b flag to determine if the file should store binary data or only text.","Q_Score":3,"Tags":"python-3.x,temporary-files,stringio,bytesio","A_Id":59967841,"CreationDate":"2020-01-29T13:05:00.000","Title":"What are the differences between tempfile module and IO file-like objects","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I 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.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":196,"Q_Id":59994662,"Users Score":2,"Answer":"Can you please post your script?\nIf you are just starting the program without a shebang it probably should not run and probably throw an ImportError\nTry adding a shebang (#!) at the first line of you script.\nA shebang is used in unix to select the interpreter you want to run your script.\nWrite this in the first line: #!\/usr\/bin\/env python3\nIf this doesn't help try running it from the terminal using a precending dot like this:\npython3 .\/{file's_name}.py","Q_Score":0,"Tags":"python,module,root","A_Id":59994858,"CreationDate":"2020-01-30T21:18:00.000","Title":"Cannot import module from linux-ubuntu terminal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I run the whole think on a RP4 so i wont have matlab installed on it. Its more likely that the Simulink model will be complied to C or C++.","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":127,"Q_Id":60045354,"Users Score":-1,"Answer":"I am looking for Simulink soultions only. Running Simulink or the engine is not an option for me on RP4, as i mentioned.","Q_Score":2,"Tags":"python,matlab,simulink","A_Id":60080758,"CreationDate":"2020-02-03T18:48:00.000","Title":"Is there a way to use a Python script output as Simulink model input?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I 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.\nBoth python and sublime are installed on E:\\\nWhen opening cmd prompt I can change dir and am able to run py from there without an issue.\nI'm assuming that my sublime is not pointing to the correct dir but don't know how to resolve this issue.","AnswerCount":2,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":5706,"Q_Id":60066455,"Users Score":-2,"Answer":"i had the same problem, so i went to the microsoft store (windos 10) and simply installed \"python 3.9\" and problem was gone!\nsorry for bad english btw","Q_Score":0,"Tags":"python-3.x,sublimetext","A_Id":65723885,"CreationDate":"2020-02-04T22:26:00.000","Title":"Python was not found but can be installed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"My python project is organised as one big file right now. The code is organised with def functions and I have a good overview. I like that because it enables me to work in one file only and i can look for code snippets that i have already done easily via the search function. \nHowever, I keep reading and people keep telling me that an organisation of python code in modules and importing them is best practice. \nCan you please point out why organising python code in modules is better than having one large script.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":95,"Q_Id":60073849,"Users Score":0,"Answer":"It's mainly a matter of preference while planning maintainability. Some people can manage 10 thousand lines of codes in a single file without even flinching. However, when you are putting so much in a single file, problems like separating namespaces, naming variables, functions and even classes start to occur. \nIntroducing Module-level separation is a good practice when your application\/library starts to get bigger. But when even module-level separation is not enough, you know it's time to create packages.","Q_Score":0,"Tags":"python","A_Id":60074041,"CreationDate":"2020-02-05T10:33:00.000","Title":"Organisation of Python code. One big file versus multiple modules, packages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a project to display sensor data on Python GUI. Sensor data is coming at a rate of 2kHz on serial port using Arduino. I was using pyserial (using readline()) to read the sensor data on my laptop. After hours of debugging I found that python was able to read around 400 samples\/sec i.e. reading frequency is around 400Hz. \nIs there any way to read the serial data at higher rate with the help of python?\nThanks in Advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":473,"Q_Id":60077770,"Users Score":0,"Answer":"Assuming the sensor is designed to transmit 2kHz data and is doing so properly, my guess is that the time your Python code is taking to read a data sample, process the data, update a plot, etc is the limiting factor. Are you reading and processing samples one at a time? Is there a smart way to read all of the available in a big chunk reducing the number of individual read\/process steps?\nAre you plotting the data in \"real time\"? If so, plot updates are slow.","Q_Score":0,"Tags":"python,arduino,pyserial","A_Id":60291573,"CreationDate":"2020-02-05T14:15:00.000","Title":"How to read highspeed Serial-data using Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm writing server using python and ZMQ. REQ-REP pattern. Sometimes, if the server crashes or restarts, then it stops seeing any messages sent to it at all. What could be the problem?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":68,"Q_Id":60078021,"Users Score":1,"Answer":"Q : What could be the problem?\n\nThe nature of a principally unsafe, mutual-deadlock prone distributed-Finite-State-Automaton is.\nGiven the REP dies during the REQ waiting for a response, deadlock\nGiven the REQ dies during the REP waiting for a request, chances are to restore REQ\/REP quickstep\nGiven the REQ dies before the REP sends the response, deadlock\nGiven the REQ dies during the REP sending the response, deadlock\nGiven the REP dies before the REQ sending a request, chances are to restore REQ\/REP quickstep","Q_Score":0,"Tags":"python,zeromq,pyzmq","A_Id":60081226,"CreationDate":"2020-02-05T14:29:00.000","Title":"ZMQ server doesn't see any messages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a coverage report that may be lying or distorted. It says that I have coverage for a line in my Django model code. I can't see where that line is being exercised. I can see that the module is imported, that the class is imported, but not that it's being invoked\/instantiated.\nThus, coverage report says I have Line A covered. Presumably that means Line B, somewhere, is exercising it. I'd like to know where Line B is. Is there a way to find the set of Line-B's (one or more) that are calling Line A, in my tests? \nIt seems this could be an annotation in the coverage report somehow\/somewhere. It's definitely knowable, since coverage has to keep track of a thing being used. \nI'm not seeing it.\nIf this isn't implemented, I'd like to suggest it. I know, it may be too complex as a full stack trace for each line of execution. But, maybe just the inspect of the immediate calling frame would be a good start, and helpful.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":387,"Q_Id":60100319,"Users Score":1,"Answer":"Here's a fun way to discover what covers that line:\nInsert a bug in the line.\nIf you then run the tests, the ones truly covering the line will fail. The stacktraces should include Line B.","Q_Score":2,"Tags":"python,unit-testing,pytest,code-coverage,agile","A_Id":66437126,"CreationDate":"2020-02-06T17:15:00.000","Title":"Python Coverage Says Line A is Covered, Need to Know From Where","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"For ray remote jobs, I can see stderr gets printed to the driver session.\nHowever, is there a way to get the stdout for remote jobs? Checking individual job logs can be very useful for debugging.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":560,"Q_Id":60118071,"Users Score":3,"Answer":"If you are using Mac, try checking the path\n\/tmp\/ray\/session_latest\/logs\/*.\nThis should contain stdout and stderr of the Ray cluster. \nNote that the ray directory is probably removed if your cluster is shut down.","Q_Score":2,"Tags":"python-3.x,ray","A_Id":60130355,"CreationDate":"2020-02-07T17:09:00.000","Title":"Where does ray stdout go?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working with responder the python web framework and trying to get remote_addr.\nI looked req.header but there's no data. No client or remote_addr field in req.\nAnd I googled for a while but I didn't get any information.\nHow can I solve this problem?\nThank you.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":52,"Q_Id":60148527,"Users Score":0,"Answer":"First argument of the handler (declare it req commonly) stores starlette.requests.Request in req._starlette.\nSo we can get remote_addr by looking at req._starlette.client.host.\nAdditionally, we can get remote_addr from WebSocket object by ws.scope[\"client\"][0] (index 1 is the port).","Q_Score":0,"Tags":"python,web,server,frameworks,web-frameworks","A_Id":60149603,"CreationDate":"2020-02-10T10:34:00.000","Title":"How to get remote_addr with responder?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to add someone to a specific server and then DM said person with just the discord ID.\nThe 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! \nHas anyone an idea how to do that?\nThanks for any help","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":91,"Q_Id":60149133,"Users Score":0,"Answer":"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.","Q_Score":1,"Tags":"python,oauth-2.0,discord,discord.py","A_Id":60342379,"CreationDate":"2020-02-10T11:09:00.000","Title":"Discord.py: Adding someone to a discord server with just the discord ID","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I type in which python I get: \/home\/USER\/anaconda3\/bin\/python\nIf 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\nShould that not be the same? And is it not better to set it: usr\/lib\/python\/\nHow would I do that? Add it to the PYTHONPATH or set the PYTHONPATH to that? But how to set which python?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1577,"Q_Id":60164658,"Users Score":4,"Answer":"You're mixing 2 environment variables:\n\nPATH 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\nPYTHONPATH 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.","Q_Score":6,"Tags":"python,linux,python-requests,environment,pythonpath","A_Id":60165035,"CreationDate":"2020-02-11T08:29:00.000","Title":"which python vs PYTHONPATH","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a binary file encrypted via Vigenere cipher. I need to carry out a known plaintext attack. I know that the encrypted plaintext starts with phrase Attack at Dawn. \nHow exactly would I go about doing it. \nDo I keep the encrypted data in binary or do I somehow convert it to string?\nAlso, my idea is to brute force all possible keywords up to length 14(len(Attack at Dawn)) but that seems like it might take a while. Is there a more optimal solution?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":426,"Q_Id":60217192,"Users Score":1,"Answer":"You want to build a plain text attack to get the key. The first letter of the key can be found by the amount of shifting between the initial A of Attack and the first letter of the encrypted text. Then you will get the second letter of the key from the shift amount of the second letter of the message.\nYou can then iterate on all the letters of the initial part that you know.\nBut without more info I cannot say whether upper and lower case letters matter, not if the spaces are encrypted or left apart...","Q_Score":0,"Tags":"python,encryption,vigenere","A_Id":60217777,"CreationDate":"2020-02-13T22:06:00.000","Title":"Vigenere decryption of binary file without knowing the key in Python3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've a conceptual doubt, I don't know if it's even possible.\nAssume 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.\nCan I send a mail from User A using the account of User X via Python? If so, how shall I do the log in?\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":539,"Q_Id":60223039,"Users Score":1,"Answer":"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.\nIt 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.\n\nIf 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).","Q_Score":0,"Tags":"python,email,outlook,windows-authentication","A_Id":60223473,"CreationDate":"2020-02-14T09:01:00.000","Title":"Send mail via Python logging in with Windows Authentication","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using python to extract Arabic tweets from twitter and save it as a CSV file, but when I open the saved file in excel the Arabic language displays as symbols. However, inside python and notepad or word, it looks good. May I know where is the problem?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":38869,"Q_Id":60239099,"Users Score":0,"Answer":"Excel is known to have an awful csv import sytem. Long story short if on same system you import a csv file that you have just exported, it will work smoothly. Else, the csv file is expected to use the Windows system encoding and delimiter.\nA rather awkward but robust system is to use LibreOffice or Oracle OpenOffice. Both are far beyond Excel on any feature but the csv module: they will allow you to specify the delimiters and optional quoting characters along with the encoding of the csv file and you will be able to save the resulting file in xslx.","Q_Score":13,"Tags":"python,excel,csv,arabic,arabic-support","A_Id":60239351,"CreationDate":"2020-02-15T13:13:00.000","Title":"CSV file with Arabic characters is displayed as symbols in Excel","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using python to extract Arabic tweets from twitter and save it as a CSV file, but when I open the saved file in excel the Arabic language displays as symbols. However, inside python and notepad or word, it looks good. May I know where is the problem?","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":38869,"Q_Id":60239099,"Users Score":33,"Answer":"This is a problem I face frequently with Microsoft Excel when opening CSV files that contain Arabic characters. Try the following workaround that I tested on latest versions of Microsoft Excel on both Windows and MacOS:\n\nOpen Excel on a blank workbook\nWithin the Data tab, click on From Text button (if not\n activated, make sure an empty cell is selected)\nBrowse and select the CSV file\nIn the Text Import Wizard, change the File_origin to \"Unicode (UTF-8)\"\nGo next and from the Delimiters, select the delimiter used in your file e.g. comma\nFinish and select where to import the data\n\nThe Arabic characters should show correctly.","Q_Score":13,"Tags":"python,excel,csv,arabic,arabic-support","A_Id":60243234,"CreationDate":"2020-02-15T13:13:00.000","Title":"CSV file with Arabic characters is displayed as symbols in Excel","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"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.\nMy question is how can I add python to my vitis platform?\nThank you","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":440,"Q_Id":60245542,"Users Score":0,"Answer":"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.","Q_Score":3,"Tags":"python,fpga,xilinx","A_Id":60378725,"CreationDate":"2020-02-16T04:54:00.000","Title":"how to add python in xilinx vitis","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have used VegaLite.jl to plot a choropleth map in Julia. And Geopandas to plot the same in Python.\nAs I want to make a benchmark between both I would like to know if Geopandas has been fully written in Python or if it is just a wrapper?\nThank you","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":51,"Q_Id":60271109,"Users Score":2,"Answer":"GeoPandas itself is written in pure python, but it depends on fiona, rtree, pyproj and shapely. All of them are using C libraries to do the work. Fiona GDAL, rtree libspatialindex, pyproj PROJ6 and shapely GEOS.\nRegarding plotting, GeoPandas uses matplotlib. I see that matplotlib has some C code, but not sure if it is used in this case.","Q_Score":1,"Tags":"python-3.x,visualization,geopandas","A_Id":60278880,"CreationDate":"2020-02-17T22:12:00.000","Title":"Is Geopandas fully written in python language?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to run my Python code within ATOM in Win10\nI have installed all packeges like: atom-python-run, script but anyway the program is not runnig.\nIn official page written to press F5 ,F6 to run script but doing that tries to compile the script with the gpp package (which I had installed before) as if it were C\/C++ code.\nIs it possible to change button for running a python script?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1763,"Q_Id":60290921,"Users Score":0,"Answer":"You just need to press additional fn key along with f5 or f6.","Q_Score":0,"Tags":"python,windows-runtime,atom-editor","A_Id":68616582,"CreationDate":"2020-02-18T23:30:00.000","Title":"How to run python scripts in Atom if F5 is not working?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":".doc files, .pdf files, and some image formats all contain metadata about the file, such as the author.\nIs 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?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":277,"Q_Id":60290971,"Users Score":2,"Answer":"On Linux and most Unixes, .py's are just text (sometimes unicode text).\nOn Windows and Mac, there are cubbyholes where you can stash data, but I doubt Python uses them.\n.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.","Q_Score":0,"Tags":"python,metadata","A_Id":60291005,"CreationDate":"2020-02-18T23:36:00.000","Title":"Do .py Python files contain metadata?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"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?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":21439,"Q_Id":60300787,"Users Score":18,"Answer":"So, I solved the issue by running the command:\nconda config --set channel_priority false. \nAnd then proceeded with the unittest download with the command run:\nconda install -c spyder-ide spyder-unittest. \nThe first command run conda config --set channel_priority false may solve other issues such as:\nSolving environment: failed with initial frozen solve. Retrying with flexible solve","Q_Score":5,"Tags":"tabs,spyder,python-unittest","A_Id":60338462,"CreationDate":"2020-02-19T12:51:00.000","Title":"Errors such as: 'Solving environment: failed with initial frozen solve. Retrying with flexible solve' & 'unittest' tab","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a REST API service that I want to call on at scheduled times. Currently, I call the API using a basic cronjob on a server every day at 8:00am.\nI want to scale up and allow my users to schedule a time they would like to receive the notification from my API call. How could I go about doing this? I know I would need to keep a database of user requests and their associated times, however I am not sure if continuing to use cron is the best way about this... (I would prefer not to use third party services in order to keep costs down)\nI am having trouble wrapping my head this, if anybody has any advice that would be much appreciated!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":42,"Q_Id":60309869,"Users Score":1,"Answer":"If the time frame is going to be something simple, like one-per-day, once-per-week, etc., using the cron.d folder is a fairly trivial and in my opinion appropriate solution. \nThe simplest way would be each user having their own file with a simple one-line cron statement that reflects their selected time. When the user selects their time, part of your service creates the correct file for that user. You can go on from there. \nWhether or not you put them in a database is really a question of your own system design; given a proper file naming scheme, you could feasibly do this without having to keep that requested time in persistent storage.","Q_Score":0,"Tags":"python,rest,api,automation,cron","A_Id":60329310,"CreationDate":"2020-02-19T21:55:00.000","Title":"How could I schedule an API call that users sign up for?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am given X RabbitMQ queues. Some of the queues contain duplicate messages (message is stored in queue A as well as in queue B for example).\nI am trying to achiveve one thing: process all the messages from \"input\" queues (I made a consumer that connects to these queues), remove duplicate messages on the go and send the result data to one output queue.\nWhat would be the fastest and most efficient way to do this? \nAs far as I know AMQP message_id property is optional, so I have to implement some kind of comparing \"seen\" messages to the newly arrived ones to achieve my goal.\nHashing message bodies came to my mind, but as I am relatively new to algorithms I am not sure which function to use and what to focus on.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":160,"Q_Id":60363070,"Users Score":1,"Answer":"I ended up hashing the message body using SHA1 and storing hash of seen messages.\nMessages that have not been seen are forwarded to result queue, already seen are discarded.","Q_Score":0,"Tags":"python,rabbitmq,amqp,pika","A_Id":60410605,"CreationDate":"2020-02-23T14:14:00.000","Title":"What is the best way to merge RabbitMQ queues using Python pika library?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Which script is executed if a directory is passed as argument to python (e.g. if python is called in this way: $ python3 Domoticz-Google-Assistant\/)?\nBest regards,\nwewa","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":30,"Q_Id":60363746,"Users Score":1,"Answer":"If you execute a directory as an argument to python, the file named __main__.py will be executed.","Q_Score":1,"Tags":"python,command-line,debian,command-line-arguments","A_Id":60363890,"CreationDate":"2020-02-23T15:25:00.000","Title":"Which python script is executed if directory path is passed as command line argument to python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am looking for a way to boot an unattended diagnostic on HPE Proliant G10 units and to execute a specified test within embedded diagnostics (in this case extensive system test).\nSo far i understand you can boot directly to embedded diagnostics through redfish however i can't find a way to attach more instructions to the boot command in order to when booted into embedded diagnostics, continue and execute extensive system test.\nDoes anyone know of any possible workaround to achieve this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":52,"Q_Id":60372592,"Users Score":0,"Answer":"After i have been in contact with HPE regarding this issue and after they have checked internally it turns out that there really is not a built in way to do this. Once the embedded diagnostics is booted it no longer have any active connection to the iLO itself and can't take commands such as what to do once booted.\nIf anyone would find some innovative solution to this, please contact me :)!\nBest regards,\nNuzvee","Q_Score":0,"Tags":"python,python-3.x,rest,boot,diagnostics","A_Id":60505084,"CreationDate":"2020-02-24T09:10:00.000","Title":"HPE redfish - boot unattended embedded diagnostics","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a docker image that consists of a python script, which takes some arbitrary source code and eval()'s it\nLet's say the code was rm -rf. Would this delete anything on the host's file system? \nI think the answer is \"no\", but I just want to confirm before trying it out.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":841,"Q_Id":60403970,"Users Score":1,"Answer":"So on the one hand, yes, Docker's filesystem isolation means that commands like rm -rf by default can't do more than corrupt the container's filesystem.\nThere's a fairly wide variety of things people do routinely that weaken this. Do you bind-mount your host's source code into the container to simplify development? Malicious code could corrupt your development tree, or surreptitiously slip commits into your .git directory. Bind-mount the Docker socket into the container so you can launch other containers? It's trivial to take advantage of that to root the whole host.\nThis is also just a narrow slice of what's possible with eval(). Linux kernel exploits happen fairly regularly, and since Docker containers share the host kernel, eval()ed code could take advantage of this. There are also things like cryptocurrency miners that aren't dangerous per se but you still don't want to be running them for other people.\nAs far as your narrow question goes, yes, Docker gives you protection from malicious code corrupting the host filesystem, but there are still a lot of other things malicious code could do and I would not try to use a Docker container as a sandbox for truly untrusted code.","Q_Score":0,"Tags":"python,docker,file","A_Id":60405371,"CreationDate":"2020-02-25T22:14:00.000","Title":"Can \"rm -rf\" on a docker container delete files on the host?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am unable to find the pylogit package in python, when I run this \"import pylogit as pl\", I get back the error saying no module called pylogit. can you please advise.","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":118,"Q_Id":60404205,"Users Score":3,"Answer":"pylogit is not a standard Python module. It is not installed by default. You need to install the library on your machine with a package manager like pip or conda.","Q_Score":0,"Tags":"python,installation,package,python-import","A_Id":60404234,"CreationDate":"2020-02-25T22:38:00.000","Title":"No module called pylogit","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to Python unit testing and I am not sure how i can create a unit test of this function that returns a connection make sure that it always returns something?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":275,"Q_Id":60415665,"Users Score":0,"Answer":"For unit testing any SQL connection, you can use the command SELECT 1 which will always return 1 if the command executed successfully. You can specify more columns, column names, and types by just specifying the values in the query.\nExample: SELECT 1 as NUMBER, 'hello world' as TEXT","Q_Score":0,"Tags":"python,python-3.x,python-2.7,unit-testing,amazon-redshift","A_Id":60443580,"CreationDate":"2020-02-26T14:03:00.000","Title":"Redshift connection unit testing in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have more than 2000 unittests\/pytests in my project. Many of them ask API, but API can be lagged. Is there a way to expect APILagError in every single test and throw SKIP\/XFAIL for any test if this error occurs?\nCurrent:\n\ntest_1: ok\ntest_2: fail\ntest_3: ok\n\nresult: 1 fail, 2 ok => tests failed\nWanted:\n\ntest_1: ok\ntest_2: skip\/xfail\ntest_3: ok\n\nresult: 2 ok, 1 skipped\/xfailed => tests passed","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":158,"Q_Id":60421489,"Users Score":3,"Answer":"I feel your pain. I'm going to do that annoying SO thing where I don't actually answer your question as you posed it, but suggest you change directions. You should choose one of:\n\nmock that API so it doesn't time out any more and your tests aren't flakey\ntreat your API lag as normal behavior and increase the allowed duration of API calls so typical lag time doesn't result in a failed test\ntreat your API lag as a bug and go fix it so your tests pass \n\nWhy are flakey tests bad?\nFlakey tests mean you can't tell the difference between broken code and a slow API call. So your tests aren't helping you catch bugs. So what's the point?\nWhy would I ever mock the API? It's not \"real\"!\nYou'd do this if you want to test anything outside of the API. Decouple your logic from the API's behavior to eliminate flakiness and make your code more maintainable.\nYou might also be able to get a similarly-behaved but much faster API to test against as your mock. Like check out the API's code locally and populate it with a small set of data. Hit that in your tests instead of the production API. That would let you check its logic separate from its lagginess.","Q_Score":0,"Tags":"python,pytest,python-unittest","A_Id":60422050,"CreationDate":"2020-02-26T19:48:00.000","Title":"Allow failure for all tests if specific Error is thrown","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to unit testing and wanted to perform some tests on the below listed functions. Thanks for the help.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1034,"Q_Id":60436442,"Users Score":0,"Answer":"Indent the class body.\nYou need to mark your tests as tests. If you are using unittest, your class should subclass unittest.TestCase\nIt's not officially a unit test if you access databases, but in practice it is fine.\nThe test doesn't test much. It just inserts objects. That actually has value, but it would be better if you tested a meaningful sequence of behavior. Maybe retrieve the objects and compare input to output.\nYou call to_db twice. Are you sure the first param ( batch ) as passed into_dynamo_db_in_batchesis really aboto` object?","Q_Score":0,"Tags":"python,python-3.x,unit-testing,mocking,amazon-dynamodb","A_Id":60436904,"CreationDate":"2020-02-27T15:18:00.000","Title":"Performing unit test for dynamo db functions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a flask based app, when I run coverage on the pytests in windows using python 3.8 it runs very slowly. It performs much better in python 3.7. The following are the test completion times using a the same laptop, the Ubuntu times are the same machine running as a VM.\n\npython 3.8.2 - Windows 10 - coverage - **199** seconds\npython 3.8.2 - Windows 10 - pytest - 15 seconds\npython 3.8.2 - Ubuntu - coverage - 26 seconds\npython 3.8.2 - Ubuntu - pytest - 15 seconds\npython 3.7.5 - Windows 10 - coverage - **30** seconds\npython 3.7.5 - Windows 10 - pytest - 15 seconds\npython 3.7.5 - Ubuntu - coverage - 26 seconds\npython 3.7.5 - Ubuntu - pytest - 15 seconds\n\nDoes anyone have any idea why 3.8 on windows running coverage is so slow?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":308,"Q_Id":60437839,"Users Score":3,"Answer":"The cause is that with python 3.8 coverage is installing without C extensions, but with 3.7 it is installing with c extensions. \nNow I need to find out why this is the case.","Q_Score":2,"Tags":"python,windows,ubuntu","A_Id":60451563,"CreationDate":"2020-02-27T16:35:00.000","Title":"coverage runs very slowly on windows with python 3.8, but not 3.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I need to integrate pivotal tracker manually because I want some extra options, but I'm getting a \"failed to open TCP connection\" error.\nI'm working from localhost and gitlab is in an intranet. I've tried both the example in ruby in the docs and a similar script in python, but both give me the same error.\nWould appreciate any help to resolve it. Thanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1199,"Q_Id":60441326,"Users Score":0,"Answer":"add the IP address to the HOSTS file.","Q_Score":0,"Tags":"gitlab,webhooks,gitlab-api,git-webhooks,python-gitlab","A_Id":67804914,"CreationDate":"2020-02-27T20:32:00.000","Title":"Hook execution failed: Failed to open TCP connection to ::1:8000 (Connection refused - connect(2) for \"::1\" port 8000)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"In order to ease adoption of the CDK toolkit in my company's cloud department, I'd like to write some diagnostics tools to test the architecture described in a CDK app before deploying it. Specifically whether the Security Group rules and IAM policies allow for communication between instances on the correct ports. \nHowever I can't seem to access security group rules created between instances in the stack. Is there any way to do so that doesn't involve wrapping the SecurityGroup construct or Connections class to store all rules as you add them(because that means no backwards compatibility among other concerns)? Thanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":131,"Q_Id":60454196,"Users Score":0,"Answer":"CDK just does not seem to expose very many attributes. I can't piece together the topology in any practical way for now.","Q_Score":0,"Tags":"python,aws-cdk,infrastructure-as-code","A_Id":60486009,"CreationDate":"2020-02-28T14:56:00.000","Title":"Retrieving attributes from a CDK stack or app construct tree for offline tests","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am having 3 test classes in a single file.\nEach Class has its own setup and teardown methods. I want to make config in pytest where I can parallelize the run of 3 test classes in separately in 3 threads. How do I achieve this?\nPlease help.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":259,"Q_Id":60483136,"Users Score":1,"Answer":"Install xdist plugin and use -n=count_of_threads. If the tests have to be run in parallel then we can use --dist=loadscope to group all the tests in the same test class.\n--dist=loadscope: tests will be grouped by the module for test functions and by class for test methods, then each group will be sent to an available worker.\n\npytest filename -n=thread_count --dist=loadscope","Q_Score":1,"Tags":"python,testing,automation,automated-tests,pytest","A_Id":60520291,"CreationDate":"2020-03-02T05:44:00.000","Title":"Running Parallel tests Class wise in pytest","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I used cmake to build my project. I tried sudo apt-get install libboost-all-dev, but it didn't solve my issue. Is there a way to solve this problem? Thanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1081,"Q_Id":60485840,"Users Score":0,"Answer":"I had a similar problem, and found that the needed library was installed under the name \/usr\/lib\/\/libboost_python38.so (for x86_64 in my case that's \/usr\/lib\/x86_64-linux-gnu\/libboost_python38.so).\nSo I ran sudo ln -s \/usr\/lib\/x86_64-linux-gnu\/libboost_python38.so \/usr\/lib\/x86_64-linux-gnu\/libboost_python-py38.so and was able to link OK.\nI ran into this specifically when trying to install pygattlib under python 3.8.","Q_Score":1,"Tags":"boost-python","A_Id":68330070,"CreationDate":"2020-03-02T09:26:00.000","Title":"how to install boost_python-py38 on ubuntu system","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Nipyapi version: latest version\nNiFi version: 1.9\nNiFi-Registry version: None\nPython version: 2.7\nOperating System: ubuntu\n\nDescription\nI want to get all process group but just from the root canvas, when I call canvas.list_all_process_group(pg_id) I got all pg from all nifi. I am asking if there is any solution to get just from root canvas.\nWhat I Did\nplayground_pg=canvas.list_all_process_groups(pg_id=root_pg.id)","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":297,"Q_Id":60492557,"Users Score":0,"Answer":"You want nipyapi.nifi.ProcessGroupsApi().get_process_groups(pg_id), which only returns the Process Groups from the target, and not from all descendants.\nThe canvas.list_all_process_group(pg_id) is designed to get everything everywhere quickly.","Q_Score":0,"Tags":"python,apache-nifi,nipyapi","A_Id":60580633,"CreationDate":"2020-03-02T16:01:00.000","Title":"List all process group from root canvas","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Nipyapi version: latest version\nNiFi version: 1.9\nNiFi-Registry version: None\nPython version: 2.7\nOperating System: ubuntu\n\nDescription\nI want to get all process group but just from the root canvas, when I call canvas.list_all_process_group(pg_id) I got all pg from all nifi. I am asking if there is any solution to get just from root canvas.\nWhat I Did\nplayground_pg=canvas.list_all_process_groups(pg_id=root_pg.id)","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":297,"Q_Id":60492557,"Users Score":0,"Answer":"There are canvas.get_process_group and canvas.get_process_group_status function, do either of those return what you're looking for?","Q_Score":0,"Tags":"python,apache-nifi,nipyapi","A_Id":60532742,"CreationDate":"2020-03-02T16:01:00.000","Title":"List all process group from root canvas","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Building a shared (.so) library with nvcc for a small C++ project. When I load this library in python with ctypes.CDLL(), the operation seems to succeed. But when I look at the resulting object with dir(libc), all I see are built-in methods, not any of my C++ functions from the library. \nWhat am I doing wrong?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":37,"Q_Id":60512631,"Users Score":0,"Answer":"Ok... I needed to have extern \"C\" preceeding the function declarations in my .h file.","Q_Score":0,"Tags":"python,c++,dll,ctypes,nvcc","A_Id":60513191,"CreationDate":"2020-03-03T17:29:00.000","Title":"Python ctypes.CDLL loads my shared library successfully, but I can't see any of my C++ functions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I 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. \nAny help appreciated","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":4046,"Q_Id":60513592,"Users Score":1,"Answer":"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.","Q_Score":2,"Tags":"python-3.x,tensorflow2.0,huggingface-transformers","A_Id":60905909,"CreationDate":"2020-03-03T18:37:00.000","Title":"How to use huggingface T5 model to test translation task?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to implement a backend server that can read (to perform some action) users gmail every time a new mail is received. I am able to figure out that using gmail API users.watch, my server can be notified every time a new email is received. Now, for fetching new mails from gmail my server needs User credentials (Auth token) that are provided by the user at the time of opting in to be watched. Is there anyway these credentials can be sent to my server along with the push notification (maybe using users.watch API). \nOne method I came across to achieve the same is to store auth and refresh token in a DB, that will be accessible only by my server. But it will be better if the purpose can be achieved without storing credentials in the DB.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":137,"Q_Id":60525479,"Users Score":2,"Answer":"When the user authenticates your application you are given a refresh token assuming that you requested offline access. You should store this in a secure place associated with the user on your server.\nWhen you get a push notification you should then retrieve the refresh token that you have stored on your server and use that to request a new access token that you can use to access the users data.\nThe push notification system has no way of sending you the authorization nor would it be a very wise idea if it was storing your authorization.","Q_Score":2,"Tags":"gmail-api,google-cloud-pubsub,google-api-python-client,google-cloud-python","A_Id":60528026,"CreationDate":"2020-03-04T11:55:00.000","Title":"How to read users gmail after receiving push notification from gmail users.watch API?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm pretty new to python and would like to have autocompletion using vs code inside my project.\nFor external modules it works fine but I dont get autocompletion for my own files\/modules.\nFor example, I have a main.py file inside my src folder and a roboter.py next to it.\nI import a Roboter class via from roboter import Roboter and it runs fine but I dont get any autocompletion on it.\nAlso, I'm using no virtual env but have all other packages global on which I do get autocompletion.\nWhat am I missing here?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":429,"Q_Id":60577660,"Users Score":0,"Answer":"Okay, installing a 64 bit version of python instead of a 32 bit version did the job.","Q_Score":0,"Tags":"python,visual-studio-code,autocomplete","A_Id":60577812,"CreationDate":"2020-03-07T12:45:00.000","Title":"VS Code Autocomplete python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I don't know much about that topic so I'm asking for your understanding...\nThis is not question about Bluetooth connection!\nI have WIRELESS headphones and I want to detect the connection between the 2.4GHz receiver and the headphones (Steelseries Arctis 7, if that helps). The receiver is connected via USB to the PC. \nHow do I do it in Python? I tried trackerjacker module but it's on linux only and I'm on Windows 10.\nAlso, gamesense module is not for this stuff I guess so I'm really clueless if it's even possible to this...","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":78,"Q_Id":60580667,"Users Score":0,"Answer":"You can try \"winwifi\" package of python for windows env.","Q_Score":0,"Tags":"python,python-3.x,detection,wireless,headphones","A_Id":60580735,"CreationDate":"2020-03-07T18:04:00.000","Title":"How to detect a WIRELESS (not Bluetooth) connection?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm 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?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":65,"Q_Id":60590628,"Users Score":1,"Answer":"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.","Q_Score":0,"Tags":"python,api,twitter,twitter-oauth","A_Id":60590725,"CreationDate":"2020-03-08T18:20:00.000","Title":"How can I use the Twitter API to look up accounts from email addresses?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm 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?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":65,"Q_Id":60590628,"Users Score":0,"Answer":"There is no way to do a lookup based on email address in the Twitter API.","Q_Score":0,"Tags":"python,api,twitter,twitter-oauth","A_Id":60601136,"CreationDate":"2020-03-08T18:20:00.000","Title":"How can I use the Twitter API to look up accounts from email addresses?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to run an idle file in python 3.8.2... An error keeps popping up and says \"No module named 'discord'\". I'm trying to make a discord bot, but IDLE can't seem to find a module called discord. It keeps highlighting the import discord statement on line 1.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":635,"Q_Id":60590764,"Users Score":1,"Answer":"I guess you didn't installed discord module. Please install it using \"pip install discord\"","Q_Score":0,"Tags":"python","A_Id":60590934,"CreationDate":"2020-03-08T18:33:00.000","Title":"Error message in IDLE 3.8.2: No module named 'discord'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've got a content creation tool, updating files in perforce. \nThese files have been inconsistently created as binary or text.\nI would like to get the file type of an existing depot file so when the user saves a new revision, it will export the correct type from the tool.\nIt seems too hacky to just always export as text to avoid file corruption of those p4 type files. Aside from larger file sizes, are there other issues with checking in a text file as Binary in perforce?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":638,"Q_Id":60606894,"Users Score":0,"Answer":"I would like to get the file type of an existing depot file \n\nMost Perforce commands that report on files will include the filetype as part of the output. The simplest one is p4 files; if you run p4 files FILENAME there will be a filetype like (text) at the end of the output.\n\nso when the user saves a new revision, it will export the correct type from the tool.\n\nBe aware that Perforce's filetype is not the same as your tool's concept of filetype! To Perforce, .PNG and .PDF are both just binary.\n\nAside from larger file sizes, are there other issues with checking in a text file as Binary in perforce?\n\nA binary file is essentially \"not text\" and will disable all of the Perforce features that depend on the concept of line breaks and textual characters -- RCS delta storage is one, but you also won't get line ending format conversion, diff\/merge, p4 annotate, p4 grep, et cetera.\nIf the text files generated by this tool aren't diffable or human-readable, and if they aren't expected to obey native line ending conventions (or if they aren't portable across platforms in the first place), then binary sounds like the right choice across the board.","Q_Score":1,"Tags":"python,perforce","A_Id":60608298,"CreationDate":"2020-03-09T19:09:00.000","Title":"How do I get the Perforce file type, of a given depot path, through python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I 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>","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":650,"Q_Id":60613155,"Users Score":1,"Answer":"Use pytest-sugar\npip install pytest-sugar\nRun your tests after it,\nYou could something like Results (10.00s) after finishing the tests","Q_Score":3,"Tags":"python,pytest","A_Id":60613797,"CreationDate":"2020-03-10T07:31:00.000","Title":"How to find time take by whole test suite to complete in Pytest","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using VScode with python code and I have a folder with sub-directories (2-levels deep) containing python tests. \nWhen 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. \nI tried to type the directory path but it does not accept it. \nCan someone please help on how to achieve this?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2111,"Q_Id":60665350,"Users Score":0,"Answer":"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).\nAlso, make sure to keep __init__.py file in your \"tests\" folder.\nI am keeping the pytest \"tests\" folder within a subdirectory, and there are no issues with VS Code discovering the tests.","Q_Score":11,"Tags":"python,visual-studio-code","A_Id":68447227,"CreationDate":"2020-03-13T05:38:00.000","Title":"How do I select a sub-folder as a directory containing tests in Python extension for Visual studio code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using VScode with python code and I have a folder with sub-directories (2-levels deep) containing python tests. \nWhen 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. \nI tried to type the directory path but it does not accept it. \nCan someone please help on how to achieve this?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2111,"Q_Id":60665350,"Users Score":0,"Answer":"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.","Q_Score":11,"Tags":"python,visual-studio-code","A_Id":60713976,"CreationDate":"2020-03-13T05:38:00.000","Title":"How do I select a sub-folder as a directory containing tests in Python extension for Visual studio code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to write my first Python code in Lambda function that will check whether i'm able to SSH (port 22) in to an EC2 instance.\nI have created an EC2 instance with Security Group 22 CidrIP my public IP\n then, created a Lambda function with python 3.8 as runtime in the same account\nNow, through code i,m trying to SSH into EC2 by passing EC2 Public IP, Username, Key pair\nand execute one command, example: sudo su\nQuestion:\n\nWhere should i place my keypair?\nWhat is the code to SSH in to EC2 from lambda funtion?","AnswerCount":1,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":4179,"Q_Id":60686223,"Users Score":6,"Answer":"The first thing I would say is that you should almost never SSH from Lambda into EC2. There are much better ways to remotely run scripts on EC2, including:\n\nSSM Run Manager\nExpose an API on the EC2 instance and call that API\n\nIf you really want to do this, perhaps for some academic reason, then:\n\nstore the keypair in Secrets Manager and give the Lambda permission to read it\nuse a Python package such as Fabric or Paramiko\n\n[Update: it seems that you're trying to validate that SSH access is blocked]\nThe best way to validate security groups is to use the EC2 API, describe the instance(s), enumerate the security groups and their inbound rules. If you don't trust that approach then you could try to SSH to the instance using the method I proposed above (though you only need to try to connect for the test to be useful, presumably).\nThe problem you're going to have is that the security groups could potentially have been set up to block all SSH access (which is the default, by the way) with the exception of a single 'attacker' IP address which is allowed. Your Lambda SSH connection attempt will fail, because it's not coming from that one 'attacker' IP, yet your Lambda test will report \"I cannot access the web server over SSH, test is successful\". That's an invalid test.","Q_Score":1,"Tags":"python,amazon-web-services,amazon-ec2,ssh,aws-lambda","A_Id":60686978,"CreationDate":"2020-03-14T18:50:00.000","Title":"How to ssh into EC2 instance from lambda function","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing a program which I will send to someone as a single .py file. \nI want to be able to include sound in this program which the person can hear without requiring extra wav\/mp3 files as well. Is this possible? I'm open to using external modules, etc, just as long as it can all be included in one file when I send it.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":889,"Q_Id":60693983,"Users Score":0,"Answer":"You could use the library winsound to include your audio as a string of bytes in your .py file.","Q_Score":1,"Tags":"python,python-3.x,audio","A_Id":60694104,"CreationDate":"2020-03-15T14:33:00.000","Title":"How to play any kind of sound in python without using file or directory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have prepared a draft email in Gmail that I need to send to several people but Gmail does not allow me to. The draft email has text, an image in it, and formatting.\nI'd ideally want to send the draft to my list of contacts one by one just changing who it's addressed to. I can put the list of contacts in one column of excel and the name in another. \nI could also just make the draft start with \"Dear sir\/madam\" and send the same draft to my contacts without any modification.\nIf the body of my email was just text I guess I'd just use SMTP, but with all the formatting, and image in it I don't know what to do.\nWhat is the easiest way to do this? Would using Selenium make sense? Anything else that's better?\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":79,"Q_Id":60716815,"Users Score":0,"Answer":"You could use a JavaMail API to send email. \nFor formatting you can use the html formatting inside your code, which serves like your draft. \nRead the contacts from a file and replace the variable in \"Dear\" $varName. \nAnd to trigger it multiple times you could use java.util.Timer class. \n\nHope it helps.","Q_Score":0,"Tags":"python,selenium,automation,smtp,gmail","A_Id":60717386,"CreationDate":"2020-03-17T05:44:00.000","Title":"How to send a draft email that I've prepared in several to several contacts in gmail one by one?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been trying to install sent2vec on Amazon EC2. However, I think there's something wrong in what I am doing.\nCould you please give me some guidance.\nThanks","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1033,"Q_Id":60718059,"Users Score":1,"Answer":"I found it out myself.\nDownload the zipped version from github.\n\nwget https:\/\/github.com\/epfml\/sent2vec\/archive\/master.zip\n\nunzip master.zip\n\nmake\n\nsudo python3.7 -m pip install . ( I am using python3.7, hence mentioned. you can try sudo pip install . also. )\n\n\n(if you fail at step 4, try this as well sudo apt-get install python3.7-dev)\nThat's it!","Q_Score":1,"Tags":"python-3.x","A_Id":60718117,"CreationDate":"2020-03-17T07:36:00.000","Title":"How to install sent2vec module?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to connect to RDS with python with IAM Database Authentication.\nI can find how to connect to RDS with IAM SSL certification or how to connect to RDS with psycopg2.\nBut I cannot find how to connect to RDS with python with IAM Database Authentication.\nIs there any way to do that?\nthanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":41,"Q_Id":60735695,"Users Score":0,"Answer":"I can do that just only to use psycopg2 with sslrootsert.\nThanks!","Q_Score":0,"Tags":"python,amazon-iam,rds","A_Id":60749502,"CreationDate":"2020-03-18T08:16:00.000","Title":"Connect to AWS RDS with python with IAM Database Authentication","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am 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.\nSo I just wanted to ask if anyone could describe the process of doing so (or if its even possible at all).","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":27,"Q_Id":60741595,"Users Score":0,"Answer":"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 \n1\/ 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)\nand\n2\/ a modern web framework (flask comes to mind) - much cleaner, but possibly a bit overkill for one simple script.\nIn both cases you'll have to learn about the HTTP protocol.","Q_Score":0,"Tags":"python,html","A_Id":60742166,"CreationDate":"2020-03-18T14:26:00.000","Title":"Is there any way that I can insert a python file into a html page?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Im new at this discord.py thing. I've just done a discord.py bot, it works ok, but sometimes the bot repeats constantly the command messages.\nI googled this problem and found out that maybe is for running the script over and over again (like when you save and run after edited or added functions).\nSo I want to stop running the process, just like when I restart windows, the bot is offline (if I run the script after restarting windows, the bot acts normaly).\nPls help\nIf someone needs the code, I can paste it here then.\nPD: I made the bot exact as a tutorial...","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":21516,"Q_Id":60750793,"Users Score":0,"Answer":"just type exit in visual studio code output terminal and your bot will be disconnected. Enjoy the day","Q_Score":3,"Tags":"python,sublimetext3,discord.py","A_Id":70487529,"CreationDate":"2020-03-19T04:08:00.000","Title":"How to stop running discord bot process (python)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Im new at this discord.py thing. I've just done a discord.py bot, it works ok, but sometimes the bot repeats constantly the command messages.\nI googled this problem and found out that maybe is for running the script over and over again (like when you save and run after edited or added functions).\nSo I want to stop running the process, just like when I restart windows, the bot is offline (if I run the script after restarting windows, the bot acts normaly).\nPls help\nIf someone needs the code, I can paste it here then.\nPD: I made the bot exact as a tutorial...","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":21516,"Q_Id":60750793,"Users Score":0,"Answer":"Easy way to solve this is by regenerating your bot token. Doing so will shutdown all active scripts. For anyone new to the Discord API, if you ever get an error that says something on the lines of 'Access Denied,' this solution should also help you.","Q_Score":3,"Tags":"python,sublimetext3,discord.py","A_Id":66404102,"CreationDate":"2020-03-19T04:08:00.000","Title":"How to stop running discord bot process (python)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Im new at this discord.py thing. I've just done a discord.py bot, it works ok, but sometimes the bot repeats constantly the command messages.\nI googled this problem and found out that maybe is for running the script over and over again (like when you save and run after edited or added functions).\nSo I want to stop running the process, just like when I restart windows, the bot is offline (if I run the script after restarting windows, the bot acts normaly).\nPls help\nIf someone needs the code, I can paste it here then.\nPD: I made the bot exact as a tutorial...","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":21516,"Q_Id":60750793,"Users Score":1,"Answer":"This message really is not discord.py specific and applies to every script which runs indefinetely.\nYou are running multiple instances of your bot. If you run it in an IDE envoirment, then there should be a stop button somewhere. If you are running it in console, closing the console window will close the bot.\nEdit: If you are running it in sublime3 like your tags suggest, every time you want to close your bot, go to \"Tools\" and then \"Cancel Build\" (hotkey: CTRL + Break). As soon as you run another instance of your bot, sublime \"decouples\" the current script in favour of the new one and this method does not work anymore. Then you have to manually go through your running processes (command line or Task Manager) and search for any \"Python\" processes.\nIn general I reccomend running the script in the commandline instead as you have more control over it.","Q_Score":3,"Tags":"python,sublimetext3,discord.py","A_Id":60756179,"CreationDate":"2020-03-19T04:08:00.000","Title":"How to stop running discord bot process (python)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am installing kaldi in ubuntu 18.04. python2.7 is one of the dependencies to install kaldi. I have installed python2.7 by sudo apt-get install pytho2.7. Then to check the prerequisites run\nextras\/check_dependencies.sh. The result showing - \"python2.7 is installed, but the python2 binary does not exit. Creating a symlink and adding this to tools\/env.sh\"\nWhat is the next step to do?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":787,"Q_Id":60769739,"Users Score":0,"Answer":"i just input 'ln -fs \/usr\/bin\/python2.7'","Q_Score":2,"Tags":"python-2.7,binary,symlink,kaldi","A_Id":69186659,"CreationDate":"2020-03-20T06:52:00.000","Title":"kaldi python2 binary issue","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Our codebase is checking high cyclomatic complexity using Radon. I have a function which is triggering this linter error, but I would like for it to pass the linter, similar to something like a pylint disable. Is there a way to do that with radon?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":527,"Q_Id":60779674,"Users Score":3,"Answer":"If you are using Radon as a flake8 plugin, you can append # noqa R701 to the line with the function definition.\nIf you are using Radon standalone, there is no mechanism to skip a function or code block based on comments or any other markup - so, it is not possible.","Q_Score":1,"Tags":"python,static-analysis,cyclomatic-complexity","A_Id":60780794,"CreationDate":"2020-03-20T18:23:00.000","Title":"How to disable radon high cyclomatic complexity check?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"trying to open a .csv file within my script, have the .csv file UTF-8 and yet I can't work out where to save it in order to be able to open it within python, I keep getting FileNotFoundError: [Errno 2] No such file or directory: 'billing_profile_test.csv'\nAny help would be greatly appreciated, thank you!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":12,"Q_Id":60782925,"Users Score":0,"Answer":"Hello are you working with Idle? If so you should be able to save as (ctrl + shift + s) to prompt a save menu to pop up. From there you will know the working directory where you should put your file, other than that a good place to look is \nC:\\Users\\{Your User}\\AppData\\Local\\Programs\\Python\\Python37-32","Q_Score":0,"Tags":"python-3.x,csv,import,path","A_Id":60784266,"CreationDate":"2020-03-20T23:31:00.000","Title":"Python PATH unable to be located","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I solved an MIP problem, with making the solving process sleep for 1 second every branch using BranchCallback (single thread). I noticed from the log that the system time measured in seconds changed every run, while the deterministic time measured in ticks didn't. However, the problem was that the latter didn't even change whether the 1-second sleep was applied or not. On the contrary, The system time did record the sleep time.\nI also tried to get the deterministic time using the callback api, but it only counted 0.0 ticks for the 1-second sleep. It's not a problem about the sleep mode, because a simple piece of code counting for a large number also showed 0.0 ticks. I thought it might not record the code running time.\nWhat exactly does the determministic time measure in CPLEX? Is there any method to measure the real running time (especially the real callback running time) as the system time did, but in a deterministic way?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":151,"Q_Id":60785497,"Users Score":2,"Answer":"The deterministic time is an approximation for the work that CPLEX does (you can think of it as number of instructions executed inside CPLEX). Doing nothing does not execute any instructions so does not count towards deterministic time.\nMoreover, deterministic time is only measured inside CPLEX. It does not account for time spent in user code like callbacks.\nIf you want to measure the time spent in your callback then you have to do that yourself (there is no point for CPLEX to track this): just take a time stamp at the beginning of your callback, one at the end of your callback and then compute the difference. The CPLEX callbacks have functions to take time stamps, see the reference documentation.\nIn case you want to have a determinstic time for code you wrote then you have to roll your own and first of all define what deterministic time means for your code.","Q_Score":0,"Tags":"python,cplex,deterministic","A_Id":60809454,"CreationDate":"2020-03-21T07:36:00.000","Title":"CPLEX: How to get the real running time in a deterministic way? (Python)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a script running on my raspberry, these script is started from a command from an php page. I\u2019ve multiple if stetements, now I would like to pass new arguments to the script whithout stopping it. I found lots of information by passing arguments to the python script, but not if its possible while the svpcript is already running to pass new arguments. Thanks in advance!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":42,"Q_Id":60788782,"Users Score":1,"Answer":"The best option for me is to use a configuration file input for your script.\nSome simple yaml will do. Then in a separate thread you must observe the hash of the file, if it gets changed that \nmeans somebody has updated your file and you must re\/adjust your inputs.\nBasically you have that constant observer running all the time.","Q_Score":1,"Tags":"python,raspberry-pi3","A_Id":60788836,"CreationDate":"2020-03-21T14:09:00.000","Title":"Passing arguments to a running python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"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. \nI'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. \nWhat'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.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":113,"Q_Id":60790792,"Users Score":0,"Answer":"If I have understood the question correctly, roughly what you are asking is how to find the best source to understand a module. \nIf you are using an inbuilt python module, the best source is the python documentation.\nScapy 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).\nFor 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.","Q_Score":0,"Tags":"python,function,module,documentation,scapy","A_Id":60791154,"CreationDate":"2020-03-21T17:11:00.000","Title":"How to read the documentation of a certain module?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Discord bot I use on a server with friends.\nThe 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.\nI 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\"\nAny help would be appreciated!","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":4363,"Q_Id":60790811,"Users Score":-1,"Answer":"async function myFunction () {}\nthis should fix your problem\nhaving multiple instances could be possible with threads,\nbut this is just a much more easy way","Q_Score":2,"Tags":"python,bots,discord","A_Id":67353378,"CreationDate":"2020-03-21T17:12:00.000","Title":"Efficient Way to Run Multiple Instances of the Same Discord Bot (Discord)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I\u2019m interested in and researching how to build an indeed bot that applies to applications for me as well as all the other application job sites. so I can work a lot smarter and have more leads and clients coming in.\nI want to automate this process as it takes personal time to apply to each application. and I want to create a bot that goes to all the job sites for me and apply for me.\nsuch as:\nIndeed\nGlassdoor\nMonster\nLinkedin\netc\u2026\nI see there is a lot of great web developers and coders in this forum. and I know you guys have the skills and knowledge to give amazing information on this subject!\nHow should I go about doing this?\nHow do I get started on this project?\nWhat are the steps I need to make to make this happen?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":212,"Q_Id":60801161,"Users Score":0,"Answer":"The only other recommendation I can make would be to pick a tool set (e.g., a programming language, database, operating system) and ask specific questions about those around a bit more detail about how you would do things. Otherwise, good work.","Q_Score":0,"Tags":"python,automation,project,build-automation","A_Id":60804048,"CreationDate":"2020-03-22T15:24:00.000","Title":"How to Build | Code an Indeed Bot to Automate Applying to Applications?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"what does ahead of any installs of python or git mean? does it mean something like making a copy of the git files to a new folder at the end of \"C:\\src\\depot_tools\\\"?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":180,"Q_Id":60813273,"Users Score":0,"Answer":"PATH is the environment variable consisting of directories searched for program names. \u201cAhead of\u201d usually means before; i.e., the directory where depot_tools is should be earlier on PATH (more to the left) than any python or git. (Why? I have no idea... I\u2019m not familiar with the tool.)","Q_Score":0,"Tags":"python,git,visual-studio,environment-variables,chromium","A_Id":60813633,"CreationDate":"2020-03-23T12:07:00.000","Title":"Add depot_tools to the start of your PATH (must be ahead of any installs of Python and or git)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"There is a Twitter user who posts valuable stuff and I want to save his tweets not as text but as images (screenshots) just as you see it on your phone or computer.\nI installed python-twitter and tweepy but I didn't find a solution in the docs and neither in communities so far. \nAlternatively: Is there another way to save tweets in a kind of pretty, visually appealing way? \nThank you in advance.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":622,"Q_Id":60844601,"Users Score":1,"Answer":"I usually use this site called tweetcyborg.com It converts any tweet into an image.","Q_Score":0,"Tags":"twitter,tweepy,python-twitter","A_Id":60850782,"CreationDate":"2020-03-25T07:39:00.000","Title":"How can I save tweets of a user as images?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"There is a Twitter user who posts valuable stuff and I want to save his tweets not as text but as images (screenshots) just as you see it on your phone or computer.\nI installed python-twitter and tweepy but I didn't find a solution in the docs and neither in communities so far. \nAlternatively: Is there another way to save tweets in a kind of pretty, visually appealing way? \nThank you in advance.","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":622,"Q_Id":60844601,"Users Score":0,"Answer":"I figured it out. Using Selenium Webdriver to open the Twitter account page in the browser, then scrape the tweets and use a screenshot tool to make an image. This looping through all tweets.","Q_Score":0,"Tags":"twitter,tweepy,python-twitter","A_Id":65981671,"CreationDate":"2020-03-25T07:39:00.000","Title":"How can I save tweets of a user as images?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am learning python3 by using cs1robots library.\nSo I typed \"from cs1robots import*\"\nThis code works at python IDLE but not works at Pycharm saying \"No module named 'PIL' \"\nI hope to find answer for it!","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":114,"Q_Id":60851676,"Users Score":1,"Answer":"You have to install PIL in Pycharm separately. You can do the following\n1) Write your code in Pycharm\n2) File > Setting > \"Your Opened Project\" > Click on the add sign (+)\n3) Then search for the relevant package in the search bar","Q_Score":0,"Tags":"python-3.x","A_Id":60852329,"CreationDate":"2020-03-25T15:11:00.000","Title":"No module named 'PIL' only in pycharm (works well at IDLE)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am learning python3 by using cs1robots library.\nSo I typed \"from cs1robots import*\"\nThis code works at python IDLE but not works at Pycharm saying \"No module named 'PIL' \"\nI hope to find answer for it!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":114,"Q_Id":60851676,"Users Score":0,"Answer":"I solved this by changing new environment to existing environment in Pycharm setting.","Q_Score":0,"Tags":"python-3.x","A_Id":60861025,"CreationDate":"2020-03-25T15:11:00.000","Title":"No module named 'PIL' only in pycharm (works well at IDLE)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"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.\nConsider 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.\nWhat would be the best way of module A to output its progress? I guess it's a design decision.\n\nWould 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?\nWould 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.\nIs there maybe any other approach to this that could be used?\n\nPointing me towards already existing solutions would be very helpful!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":43,"Q_Id":60900639,"Users Score":0,"Answer":"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.","Q_Score":0,"Tags":"python,python-3.x,design-patterns,progress","A_Id":60915414,"CreationDate":"2020-03-28T11:38:00.000","Title":"How to populate module internal progress status to another module?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to ask about deploying a bot in 2 different servers. Is there any way to differentiate the two bot instances? For example, I would like to run a bot for serverA and another instance of the same bot in serverB (testing server). I would like to have it so that the bot would respond to a command like \"!ping\" only once in serverB when testing even if serverA and serverB both have running instances of my bot (meaning there are 2 different running scripts of the same code). My dilemma is that if I have two of the same code running in 2 different terminals, when I try to call for !ping command in serverB, it performs the action twice since there are 2 instances.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":226,"Q_Id":60921774,"Users Score":0,"Answer":"Running a bot in 2 terminals is not the same as having your bot join 2 servers. You'll only have 1 instance of the bot running but it's basically listening to both servers.\nDifferentiating between different servers is generally not needed because the bot will be responding in the context of the server it got a command from. However, if you want to keep track of certain data with files you can do so by including the server name in the file name. This way you can store data for each server separately.","Q_Score":1,"Tags":"python-3.x,client,discord.py","A_Id":60932793,"CreationDate":"2020-03-29T22:54:00.000","Title":"Discord.py differentiating between two different servers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to submit a job to EMR cluster via Livy. My Python script (to submit job) requires importing a few packages. I have installed all those packages on the master node of EMR. The main script resides on S3 which is being called by the script to submit job to Livy from EC2. Everytime I try to run the job on a remote machine (EC2), it dies stating Import Errors(no module named [mod name] )\nI have been stuck on it for more than a week and unable to find a possible solution. Any help would be highly appreciated.\nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1096,"Q_Id":60931595,"Users Score":1,"Answer":"These packages that you are trying to import. Are they custom packages ? if so how did you package them. Did you create a wheel file or zip file and specify them as --py-files in your spark submit via livy ?\nPossible problem.\nYou installed the packages only on the master node. You will need to log into your worker nodes and install the packages there too. Else when u provision the emr , install the packages using bootstrap actions\nYou should be able to add libraries via \u2014py-files option, but it\u2019s safer to just download the wheel files and use them rather than zipping anything yourself.","Q_Score":1,"Tags":"python,python-3.x,amazon-emr,livy","A_Id":60941345,"CreationDate":"2020-03-30T13:26:00.000","Title":"Python packages not importing in AWS EMR","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm building a django webapp where i need to stream some stock market trades on a webpage in real time. In order to do that, i'm searching for various approaches, and i found about Pusher and RabbitMQ.\nWith RabbitMQ i would just send the message to RMQ and consume them from Django, in order to get them on the web page. While looking for other solutions, i've also found about Pusher. What it's not clear, to me, is the difference between the two, technically. I don't understand where would i use Rabbit and where would i use Pusher, can someone explain to me how are they different? Thanks in advance!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":741,"Q_Id":60935742,"Users Score":4,"Answer":"You may be thinking of data delivery, non-blocking operations or push\nnotifications. Or you want to use publish \/ subscribe, asynchronous\nprocessing, or work queues. All these are patterns, and they form\npart of messaging.\nRabbitMQ is a messaging broker - an intermediary for messaging. It\ngives your applications a common platform to send and receive\nmessages, and your messages a safe place to live until received.\nPusher is a hosted service that makes it super-easy to add real-time data and functionality to web and mobile applications.\nPusher sits as a real-time layer between your servers and your\nclients. Pusher maintains persistent connections to the clients -\nover WebSocket if possible and falling back to HTTP-based\nconnectivity - so that as soon as your servers have new data that\nthey want to push to the clients they can do, instantly via Pusher.\nPusher offers libraries to integrate into all the main runtimes and\nframeworks. PHP, Ruby, Python, Java, .NET, Go and Node on the server\nand JavaScript, Objective-C (iOS) and Java (Android) on the client.","Q_Score":0,"Tags":"python,django,rabbitmq,pusher","A_Id":60935979,"CreationDate":"2020-03-30T17:08:00.000","Title":"What's the difference between RabbitMQ and Pusher?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am pretty new to Pyvmomi and vsphere automation.\nI have been trying to automate the user and group creation in vsphere but could not locate the method in Pyvmomi which could help me automate the process of user creation.\nI already have a user created in vcenter (abc@xyz.local)\nThis user has administrative privileges\nNow, I want to create a session with user abc@xyz.local and add new users in Vcenter 'users and groups'. Once the new users are created, I have to add these users to different groups.\nAll these has to be done via automation using python.\nIs there a way to automate this?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":750,"Q_Id":60980474,"Users Score":0,"Answer":"Unfortunately, the SSO API is all private and unavailable through pyvmomi and the rest of the SDKs.","Q_Score":0,"Tags":"python,automation,vsphere,vcenter,pyvmomi","A_Id":60981943,"CreationDate":"2020-04-01T21:16:00.000","Title":"How to automate the user creation in vcenter using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am evaluating python memory profiling. I would like to automate memory leak profiling with Jenkins and publish the report to Sonarqube. The current memory tool I am using is memory_profiler. Does Jenkins & Sonarqube support this integration? Or are there any python memory tools which I should consider which can integrate well into Jenkins & Sonarqube? Thanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":159,"Q_Id":60983567,"Users Score":0,"Answer":"Well, I don't think Sonarqube supports that. \nThe only thing that I see you could do, is to run the memory profiler as you are doing, but instead of uploading to sonarqube as per your approach, you could create a html report from the memory profiler results and attach it to your Jenkins build.","Q_Score":3,"Tags":"python,jenkins,testing,memory,sonarqube","A_Id":61457197,"CreationDate":"2020-04-02T02:56:00.000","Title":"Python memory profiler with Sonarqube & Jenkins","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I wrote a python script that accesses system features which require root privileges. \nThis \"master\" script is configured by running another Python script file, \"config.py\", using exec, that the user of my script would write and which configures some state variables in my script.\nThe master script file is root-owned while the config file is user owned (since my script users would want to modify this file).\nObviously this is not ideal, since the users of my script could run root-level commands in the config script. Is there a way to run the config file in user-level even if the master file was run in root?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":133,"Q_Id":60993916,"Users Score":0,"Answer":"Since it\u2019s a config file, you might be better off making it something non-executable like a plain ini \/ yaml etc. I\u2019m assuming you want to include it to access some constants. Sometimes it requires a little more work to set up, but ultimately, if the only code that runs is yours, you can be safe(er).","Q_Score":0,"Tags":"python,linux,scripting,sudo","A_Id":61003260,"CreationDate":"2020-04-02T14:26:00.000","Title":"Run python file in sudo but config file in user space","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Jenkins setup is on Ubuntu.\nLocal: Created a virtual environment using python 3.6, running tests through command line using pythom -m pytest - .\/{test.py} which is successful\nJenkins job:\nIn the Build > Shell script, creating a virtual environment the same way done locally and running the commands.\npython3.6 -m venv jenkins-venv\nsource ${WORKSPACE}\/jenkins-venv\/bin\/activate \npip install --no-cache-dir -r ${WORKSPACE}\/project\/requirements.txt\npython -m pytest -v ${WORKSPACE}\/project\/test_day1.py \nError:\n ERROR collecting scripts\/\nImportError while importing test module '\/var\/lib\/jenkins\/workspace\/job_name\/project\/test_Login.py'.\nHint: make sure your test modules\/packages have valid Python names.\nModuleNotFoundError: No module named","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":619,"Q_Id":60994459,"Users Score":0,"Answer":"This happens if your PATH variable includes that module's directory on your machine but not on Jenkins.","Q_Score":0,"Tags":"python,jenkins","A_Id":60994553,"CreationDate":"2020-04-02T14:52:00.000","Title":"Python tests run locally on ubuntu but fails when run through Jenkins with error \"ImportError while importing test module '\/var\/lib\/jenkins\/workspace\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Very New to this but I would essentially like to read my counter value from my CLICK PLC into my python.\nMy Click Series PLC only has a RS232 Port with Modbus protocal . Can I use pymodbus for this?\nIs there another way to do this?\nAny help would be greatly appreciated","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":295,"Q_Id":61001472,"Users Score":0,"Answer":"After more research. yes it is possible to use pymodbus.\nRS 232 is an older serial communication protocol that can use Modbus ASCII and Modbus RTU software protocols(Binary).\npymodbus supports both these .\nYou just need to direct pymodbus to the com port your \"Slave devices\" are connected \/ daisy-chained to.\nremember there can only be one master to 247 nodes.","Q_Score":0,"Tags":"python,serial-port,modbus,plc,pymodbus","A_Id":61019632,"CreationDate":"2020-04-02T21:30:00.000","Title":"Read Counter value From CLICK PLC to python using pymodbus with RS232 port","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I wrote a simple Python program 'guessing_game.py'. When I try to run this code in the command prompt using python -m guessing_game.py, the program runs fine, but in the end, it says:\n\nError while finding module specification for 'guessing_game.py'\n(ModuleNotFoundError: path attribute not found on 'guessing_game'\nwhile trying to find 'guessing_game.py').\n\nWhen I run the same program using python -guessing_game.py, it runs fine, and it doesn't show that message as well.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1791,"Q_Id":61013491,"Users Score":1,"Answer":"Because you're trying to run it as a module?\n\n-m Search sys.path for the named module and execute its contents as the main module.\nSince the argument is a module name, you must not give a file\n extension (.py). The module-name should be a valid Python module name,\n but the implementation may not always enforce this (e.g. it may allow\n you to use a name that includes a hyphen).","Q_Score":0,"Tags":"python,modulenotfounderror","A_Id":61013537,"CreationDate":"2020-04-03T13:55:00.000","Title":"ModuleNotFoundError: __path__ attribute not found on 'guessing_game' while trying to find 'guessing_game.py'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing an ReactionRoles-Discord-Bot in Python (discord.py).\nThis Bot saves the ReactionRoles-Smileys as UFT8-Encoded. \nThe type of the encoded is bytes but it's converted to str to save it.\nThe string looks something like \"b'\\\\xf0\\\\x9f\\\\x98\\\\x82'\".\nI am using EMOJI_ENCODED = str(EMOJI.encode('utf8')) to encode it, but bytes(EMOJI_ENCODED).decode('utf8') isn't working.\nDo you know how to decode it or how to save it in a better way?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":387,"Q_Id":61015025,"Users Score":0,"Answer":"The output of str() is a Unicode string. EMOJI is a Unicode string. str(EMOJI.encode('utf8')) just makes a mangled Unicode string.\nThe 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.","Q_Score":0,"Tags":"utf-8,python-3.7,discord.py,decoding","A_Id":61015149,"CreationDate":"2020-04-03T15:17:00.000","Title":"Print an UTF8-encoded smiley","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How to auto-run python script made by me when the system is booted on jetson nano?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4006,"Q_Id":61031032,"Users Score":0,"Answer":"Step 1: Create a shell file.\nsudo nano \/usr\/local\/bin\/startup.sh: Type this on the terminal. A new sh file is created. This file consists of the python file that is to be executed. I gave the name startup.sh. It can be any name XYZ.sh\n#! \/bin\/sh: This is called the shebang. This would execute our script using a Bourne shell. This tells the system that the commands in this file should be fed to the interpreter.\nsleep 10: This pauses a script for a certain amount of time. He re we pause it for 10 seconds.\nIn the next line, we insert the code that we use to run the program on the terminal.\nOPENBLAS_CORETYPE=ARMV8 \/usr\/bin\/python3 path\/of\/the\/python\/code.py\nIt looks like this:\n#! \/bin\/sh\nsleep 10\nOPENBLAS_CORETYPE=ARMV8 \/usr\/bin\/python3 \/home\/sooraj\/Downloads\/incabin-monitoring-system-main\/netstreamfeb17.py\nNow we close the file using Ctrl+X. and save it.\nStep 2: Create a service file\nsudo nano \/etc\/systemd\/system\/startup.service\nThings to write inside it.\n[Unit]\nDescription = INTU_IPC start-uo specific script\n[Service]\nType= idle\nExecStartPre = \/bin\/sleep 10\nExecStart = \/usr\/local\/bin\/startup.sh\nUser=sooraj# write your user name here\n[Install]\nWantedBy = multi-user.target\nNow we close the file using Ctrl+X. and save it.\nstep 3: Give permission.\nsudo chmod +x \/usr\/local\/bin\/startup.sh\nstep 4: enable, start and stop\nsudo systemctl enable startup.service\nsudo systemctl start startup.service\nsudo systemctl stop.service\nAfter starting, to view if it works, we can observe it in the terminal by\njournalctl -u startup.service -f\nIf we edit the service file for the next time, we need to reload it before enabling and starting.\nsudo systemctl daemon-reload\nsudo systemctl enable startup.service\nsudo systemctl start startup.service\nAdditional information.\nsystemctl is-enabled startup.service #checks if the service file is enabled.\nsystemctl is-failed startup.service #checks if the service file failed to start.\nsystemctl is-active startup.service #checks if the service file is active.\nsudo systemctl list-unit-files \u2014 type=service #display the list of service files.","Q_Score":0,"Tags":"python-3.x,nvidia-jetson,startupscript,nvidia-jetson-nano","A_Id":72109493,"CreationDate":"2020-04-04T16:17:00.000","Title":"Auto-run python script when system is booted on jetson nano","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I've seen a lot of other questions here about this topic however none have helped. I am coding on Jupyter Notebook using Python 3, to organize my code I am trying to use 2 different modules for my program. Thus I have 1 module called let's for simplicity call it abc.ipynb and now created a different module called for simplicity edf.ipynb (Both on Jupyter Notebook) \nAt first i wasn't able to import abc to edf but after importing the import_ipynb package and fixing the PYTHONPATH it worked. \nHowever, now I just want to import variables from abc to edf, I am trying:\n\nfrom abc import x\nimport abc print(abc.x)\nI even tried calling a function\n\nAll give 1 of below errors:\n\ncannot import name 'x' from 'abc'\nmodule 'abc' has no attribute 'function'\n\nAny advice? I already created an init.py in my folder however I think it is of no use since I am working with .ipynb","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":870,"Q_Id":61032792,"Users Score":2,"Answer":"Try changing the name of the file other than \"abc\". Python already has a module called abc","Q_Score":2,"Tags":"python,jupyter-notebook","A_Id":61035073,"CreationDate":"2020-04-04T18:23:00.000","Title":"How to import variables from other .ipynb on Jupyter Notebook?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to set up a Windows 64-bit PC Virtual Environment with Python 2.7 to run a script that I didn't write, \nand I'm not entirely sure the usage it has, but it imports pythoncom (a .NET communication module as far as I could understand). \nIt seems that the module exists in pywin32 and pypiwin32 (installed both),\nI can see the module is installed in the environment when typing \"pydoc modules\" and \"pydoc pythoncom\", but it still fails to import the module when running the script.\nI can only use pywin32-244,\nit has a .dll named pythoncom27.dll inside its wheel file,\nI can't seem to find a workaround, \nanyone knows why it might happen?\n(all of the versions I gave are not optional (for python, the package) - I cannot change them they has to remain the same)\nFurthermore - In newer versions of python3.x it's running fine. \nfrom the python CommandLine I can actually import it! \nany reason for me to be able to import it and see it in all of the mentioned ways and still not to be able to import it via a script? maybe something wrong with the script or the way im running it?\nAlso might be important - the script that gives the error is just imported through another script,\nso I'm actually running T1.py which then imports T2.py which gives the error when trying to import pythoncom...\nThanks in Advance!\nOren","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":180,"Q_Id":61043139,"Users Score":0,"Answer":"The problem was that I wasn't using the virtualenv to run the script,\nafter activating the virtualenv, typing in the cli \"script.py\"\nwill execture the script from the system's default python env, even though it says (Venv) in the cli,\nTo run it in the Venv's python environment you need to type in 'python script.py'\nOren","Q_Score":0,"Tags":"python,import,module,pythoncom","A_Id":61058034,"CreationDate":"2020-04-05T13:11:00.000","Title":"pythoncom module not found (pywin32 is installed) - with a Python2.7 virtual environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My device send to serial port every 5 seconds. So, I have two situations for using.\nThe first one, port is open-close every 5 secs, after send data.\nAnd open once time, and use it persistence (Try to check port is opened before using).\nWhich use-case is better?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":54,"Q_Id":61055120,"Users Score":1,"Answer":"You should not open \/ close your serial device every n seconds, because time drifting might make you loose data written to your serial port.\nIn order to keep your program running smootly, why don't you create a new thread which opens the serial port and keeps reading in a while loop ?","Q_Score":0,"Tags":"python,python-3.x,pyserial","A_Id":61055977,"CreationDate":"2020-04-06T07:45:00.000","Title":"Open device with pyserial","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"My OS is Linux Mint 19. I have several versions of Python 3.6, 3.7. My Pillow version is 5.1. I am trying to do from PIL import _imaging but I am getting a problem at 3.7 showing that I can not import it. As follow:\nImportError: cannot import name '_imaging' from 'PIL' (\/usr\/lib\/python3\/dist-packages\/PIL\/__init__.py)\nIf I run from the terminal with Python 3.6 I am not getting this kind of problem.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":96,"Q_Id":61058725,"Users Score":1,"Answer":"Did you install Pillow for the newer Python version?\npython3.7 -m pip install Pillow","Q_Score":0,"Tags":"python-3.6,python-3.7","A_Id":61058822,"CreationDate":"2020-04-06T11:27:00.000","Title":"from PIL import _imaging problem, 3.6 running well and 3.7 not running","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I making a application, in this application you can watch movies and songs. \nFor this i'm using angular for frontend and python\/flask for backend.\nEventually this application will run on a raspberry pi 4, to store the mp4 and mp3 files i'm using a simple usb flash drive. For now i just want it to work on my laptop. So the program needs to know where to get the files from and render them in de html.\nWhat is the best approach to load in the mp3 and mp4 files from that usb to display them in the application?\nOn first hand I just thought to give the path where the usb drive is located and then put that in de audio or video tag. Bu i'm not sure this is the right way.\nDoes anyone know what would be the best approach to do this?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":122,"Q_Id":61060180,"Users Score":0,"Answer":"Hi Ronny here is a simple way to get the path and play using it:\n{{{ import easygui, vlc\nmedia = easygui.fileopenbox(title=\"Choose media to open\") \nplayer = vlc.MediaPlayer(media)\nplayer.play() }}} \nthis program will ask the path of the folder to you and play the file to you in vlc media player.","Q_Score":0,"Tags":"python,html,angular,typescript,flask","A_Id":61060318,"CreationDate":"2020-04-06T12:45:00.000","Title":"Taking content (mp4 and mp3) from usb drive and use it in a application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I making a application, in this application you can watch movies and songs. \nFor this i'm using angular for frontend and python\/flask for backend.\nEventually this application will run on a raspberry pi 4, to store the mp4 and mp3 files i'm using a simple usb flash drive. For now i just want it to work on my laptop. So the program needs to know where to get the files from and render them in de html.\nWhat is the best approach to load in the mp3 and mp4 files from that usb to display them in the application?\nOn first hand I just thought to give the path where the usb drive is located and then put that in de audio or video tag. Bu i'm not sure this is the right way.\nDoes anyone know what would be the best approach to do this?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":122,"Q_Id":61060180,"Users Score":0,"Answer":"Various methods and it depends on how you want it done. You can: \n\nRun a CLI command finding .mp3 files through regex. E.g. find \/media | grep *\\.mp3:\nThis will automatically find all .mp3 files in the folder and subfolders.\nYou can run a CLI command inside your Python script e.g. with the subprocess module. Save all the available paths to a mp3 file in an array and process them further from here.\nYou can code a relative path in your program and mount your USB into your working directory's subfolder audio. mount -o remount,ro \/dev\/sda1 ~\/path\/to\/your\/project\/audio:\nAll the audio files are then located in your audio folder which is part of your project. You can have dummy files in there and when you mount your USB into that folder the USB mp3 files are shown.\nThis approach requires you to manually mount before executing your Python program. It is also in my opinion the cleanest approach.\n\nThe manual mounting on the second approach might become a concern for you but for this there are also solution out there where you can define automatic mount points. However these aren't solved in Python.","Q_Score":0,"Tags":"python,html,angular,typescript,flask","A_Id":61060545,"CreationDate":"2020-04-06T12:45:00.000","Title":"Taking content (mp4 and mp3) from usb drive and use it in a application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm writing a discord bot for educational purposes and out of boredom. In many tutorials command functionality is realized through on_message() but I found some that use @bot.command too. I don't have enough experience to tell which will be better in the long run and I didn't find any such information in discord.py docs. Which one should I use and why?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":69,"Q_Id":61096498,"Users Score":2,"Answer":"Which one should I use and why?\n\nI would depend what you want to do specifically. on_message is completely open-ended, so if you need to process arbitrary messages and have your bot react then that's the one to use e.g. maybe you want to reply to people using words of more than 4 syllables and tell them their long words hurt or something.\nCommands are much more structured and used for explicitly interacting with bots.\nSo by default you'd use commands, and if your use case doesn't fit commands, then you'd use the more freeform on_message.","Q_Score":0,"Tags":"python,discord.py","A_Id":61096913,"CreationDate":"2020-04-08T08:32:00.000","Title":"Should I use on_message() or @bot.command?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I can use \ncc = message.CC to display the list of Carbon copy names for a mail item. However they are just names. How can I display full mailadress for cc list?\nfor sender mail address\uff0cI can use message.sender.GetExchangeUser().PrimarySmtpAddress to get. but message.CC cannot use this because the output data type is \u201cstr\u201d. message.sender output data type is win32com.client.CDispatch.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":272,"Q_Id":61101159,"Users Score":0,"Answer":"Loop through the MailItem.Recipients collection, check for the items with Recipient.Type == olCC. use Recipeint.AddressEntry property to retrieve the corresponding AddressEntry object. Check if AddressEntry.Type == \"EX\". If yes, use AddressEntry.GetExchangeUser().PrimarySmtpAddress, otherwise use AddressEntry.Address.","Q_Score":0,"Tags":"python-3.x,outlook","A_Id":61148410,"CreationDate":"2020-04-08T12:53:00.000","Title":"Extract CC list full mail address from outlook mail","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The goal is to compare the power of Python metaclasses with metaprogramming systems of other languages such as Groovy, Xtend, Nemerle, CLOS, OpenJava, BSJ (BackStage Java), Iguana\/J, compiler plugins for Scala, Cyan, etc.\nAssume class MyMeta is the metaclass of class MyClass. \nCan MyMeta generate code in MyClass that intercepts get and set of MyClass instance attributes?\nCan a method of MyMeta be called when MyClass is inherited, even if the subclass metaclass is not MyMeta?\nCan a method of MyMeta be called when a MyClass method is overridden in a subclass, even if the subclass metaclass is not MyMeta?\nCan a method of MyMeta be called when a method of MyClass uses an attribute that has not been declared?\nCan MyMeta handle the AST of MyClass or another equivalent representation?\nFor example, can MyMeta check if each class method has at most 20 statements? Or add a statement after the second method statement? Or rename a method?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":30,"Q_Id":61103185,"Users Score":0,"Answer":"Can MyMeta generate code in MyClass that intercepts get and set of\n MyClass instance attributes?\n\nYes. That can be done by injecting a __getattribute__ and a __setattr__ methods in the class. But if the attributes are declared in some other form (like, with annotations), it can also create descriptors for each attribute to handle only changes to those attributes. However, it can't trivially guess what are individual \"instance attributes\" if those are just defined in the classic way, of being set in code, inside the class' __init__ (but the first approach covers all attributes anyway); \n\nCan a method of MyMeta be called when MyClass is inherited, even if\n the subclass metaclass is not MyMeta?\n\nA subclass will automatically inherit the MyMeta as their metaclasses. If there is a conflict due to other bases, when using multiple inheritance, having other metaclasses, the subclass can't be created at all. (Unless one creates a suitable metaclass that inherits from both metaclasses, that is). _TL;DR: yes. and no,there is no subclass with a different metaclass than its parents'.\n\nCan a method of MyMeta be called when a MyClass method is overridden\n in a subclass, even if the subclass metaclass is not MyMeta?\n\nThere is no such a thing as \"subclass's metaclass not being MyMeta\". And then, \nthe metaclass acts on the subclass creation and can detect method overrides. And, it can even be made to detect method overrides by monkey-patching after the class is created (by having the metaclass implement __setattr__)\n\nCan a method of MyMeta be called when a method of MyClass uses an\n attribute that has not been declared?\n\nYes, by setting suitable __getattribute__ and __setattr__ methods as given earlier. There is no ready-made functionality for this (and no need for a metaclass as well, just a mixin implementing both methods would work)\n\nCan MyMeta handle the AST of MyClass or another equivalent\n representation? For example, can MyMeta check if each class method has\n at most 20 statements? Or add a statement after the second method\n statement? Or rename a method?\n\nThe metaclass is called way after the AST has been created and baked into bytecode. But it can introspect into the methods bytecode to check anything it wants, and it can fetch their source code (if available), and re-generate the AST, and it can recreate other methods to replace the original ones - the substitutes having all-new bytecode. \nThat kind of thing, however is rarely, if ever used and sounds like overkill.\nA more pythonic approach would be to use decorators, and use the metaclass to auto-apply decorators on methods. These decorators can provide wrapper functions to run preamble and post-call code for each of the methods if needed.","Q_Score":1,"Tags":"python,reflection,metaprogramming,metaclass","A_Id":61110449,"CreationDate":"2020-04-08T14:30:00.000","Title":"If MyMeta is the MyClass metaclass in Python 3.x, what types of manipulation can MyMeta do with MyClass?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Python algorithm that can be parallelized fairly easily.\nI don't have the resources locally to run the whole thing in an acceptable time frame.\nFor each work unit, I would like to be able to:\n\nLaunch an AWS instance (EC2?)\nSend input data to the instance\nRun the Python code with the data as input\nReturn the result and aggregate it when all instances are done\n\nWhat is the best way to do this?\nIs AWS Lambda used for this purpose? Can this be done only with Boto3?\nI am completely lost here.\nThank you","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":729,"Q_Id":61126183,"Users Score":0,"Answer":"A common architecture for running tasks in parallel is:\n\nPut inputs into an Amazon SQS queue\nRun workers on multiple Amazon EC2 instances that:\n\n\nRetrieve a message from the SQS queue\nProcess the data\nWrite results to Amazon S3\nDelete the message from the SQS queue (to signify that the job is complete)\n\n\nYou can then retrieve all the results from Amazon S3. Depending on their format, you could even use Amazon Athena to run SQL queries against all the output files simultaneously.\nYou could even run multiple workers on the same instance if each worker is single-threaded and there is spare CPU available.","Q_Score":1,"Tags":"python,multithreading,amazon-web-services,parallel-processing,cloud","A_Id":61132717,"CreationDate":"2020-04-09T16:49:00.000","Title":"Run parallel Python code on multiple AWS instances","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"This executable generation is on raspbian linux, on my raspberry-pi:\nInstall pyinstaller: (I had to try this several times, as I got the error \"http.client.RemoteDisconnected: Remote end closed connection without response\" but it suddenly worked):\n$ pip3 install pyinstaller \nIn directory with my tiny_test.py file:\n$ pyinstaller -F tiny_test.py\nThen, in the created dist folder, I tried to run the compiled executable:\n$ tiny_test\nThis gave the error:\n\"tiny_test: tiny_test: cannot execute binary file\"","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":673,"Q_Id":61131998,"Users Score":0,"Answer":"short answer:\n$ .\/tiny_test\nlong anser:\nCheck the executable file properties:\n$ file tiny_test\n\"tiny_test: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter \/lib\/ld-linux-armhf.so.3, for GNU\/Linux 3.2.0, BuildID[sha1]=ad32521ad141d04ca4fc066798301621367c7964, stripped\"\nLSB executable files need to be run like this:\n$ .\/tiny_test\nThis worked for me!","Q_Score":0,"Tags":"python,raspberry-pi,pyinstaller,executable","A_Id":61131999,"CreationDate":"2020-04-09T23:47:00.000","Title":"pyinstaller raspberry pi compiling, how to execute program from command line","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"What is actually the difference between using unit tests and normal tests? \nBy normal tests I mean, using the if statement for example to determine if the calculation is equal to the desired answer if it returns false, we can raise AssertionError","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1683,"Q_Id":61183855,"Users Score":0,"Answer":"For quality control. If you are coding an app called \"app1\" with a function f1 and an other function f2 (f2 is using f1) inside you own library\nWithout unit test:\nYou can make a change in function f1 test it, it will work in f2 but you will not notice that in you program \"app0\" you wrote 2 weeks ago it will make you app crash because in your old app \"app0\" you have a function f3 and f3 is also using f1....\nWith unit test:\nYou can catch that type of nasty bug because the test for the function f3 will not pass anymore and you IDE will tell you that when you change the function f1 in \"app1\"\nI hope it make sense (english is not my native language)","Q_Score":0,"Tags":"python,python-3.x,unit-testing,python-unittest","A_Id":61185695,"CreationDate":"2020-04-13T08:12:00.000","Title":"Difference between using unit test and doing tests normally in Python3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to get input from the user and send this input to all bot subscribers.\nso 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 \nthanks :]","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":289,"Q_Id":61185980,"Users Score":0,"Answer":"If you want to get an user input, the logic is a bit different. I suppose you are using longpolling.\nWhen 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:\nYou receive the update, and ask the user for input, then you set user_input[user's id]['input'] = true\nThen when you receive another update you just check that variable with an if (if user_input[userid]['input']: # do something).\n\nIf your problem is 403 Forbidden for \"user has blocked the bot\", you can't do anything about it.","Q_Score":1,"Tags":"python,input,telegram,chatbot,telegram-bot","A_Id":61230604,"CreationDate":"2020-04-13T10:32:00.000","Title":"how i ask for input in my telegram chat bot python telebot","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"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?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":39,"Q_Id":61186084,"Users Score":0,"Answer":"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.\n\nWhen 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.","Q_Score":0,"Tags":"macos,python-3.7,keypress,python-idle,getch","A_Id":61891827,"CreationDate":"2020-04-13T10:39:00.000","Title":"How to monitor key presses in Python 3.7 using IDLE on Mac OSX","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Suppose we're writing a CPython extension module in C.\nWhen defining an extension, we are required to supply a PyMODINIT_FUNC PyInit_(void). Nowhere in this declaration is a native calling convention specified.\nWhether on Linux or on Windows, how can the extension developer ensure that the PyInit_ function is compiled using the correct calling convention, so that the interpreter calls it successfuly during runtime? Is there some magic in the Python headers that takes care of this for us? Or something else?\nThe same question applies to native functions contained in the extension module, and exposed to Python wrapped as function objects. How do we ensure that these are compiled in a manner compatible with the Python interpreter calling convention?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":219,"Q_Id":61213535,"Users Score":2,"Answer":"The default calling convention is automatically made by the compiler. PyMODINIT_FUNC is either void (in Python 2) or PyObject * (in Python 3), nothing more.\nThe Python dynamic module loader uses the default convention of the platform (not that it has any jurisdiction over that; it's to the platform).","Q_Score":1,"Tags":"c,cpython,calling-convention","A_Id":61213901,"CreationDate":"2020-04-14T17:19:00.000","Title":"How is a C extension compiled with the correct native calling convention?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm programming a Telegram bot. I want to search for a specific message in a telegram channel and get its message id. Is it possible? Thx in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1011,"Q_Id":61228148,"Users Score":3,"Answer":"As far as I know, you aren't able to search though messages (in a specific chat) by just using Telegram's bot API. You need an MTProto client to do that. You can use pyrogram or telethon to interface with MTProto then use messages.search.\nBut, there is a catch. If the message you're searching is in a channel, you can webscrape https:\/\/t.me\/s\/CHANNELUSERNAME with a library like BeautifulSoup.","Q_Score":1,"Tags":"python,api,bots,telegram,py-telegram-bot-api","A_Id":61230228,"CreationDate":"2020-04-15T11:58:00.000","Title":"How can i search for a specific message in a chat in python? (pyTelegramBotAPI)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python module which is really big (more than 1 Gigabyte) and I'm importing a class from this module in another python script with the command from module import class. The thing is, when I firt launch my python script, the memory consumption is really high and the script takes a very long time to execute (few minutes!). When launching it after that, it takes significantly less time (a few seconds) and uses less memory but still a lot for me.\nWhat I think my script does is that it loads all the data from the module when I first launch it into memory which is why it takes so much time and memory. \nIs there a way to change that and not have my script import the whole module but only specific parts which I would like ?\nThanks for taking the time to answer :)","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":1385,"Q_Id":61230840,"Users Score":3,"Answer":"Short answer: no, there's no way to avoid this. The first time a module is imported in a gien process, all it's top-level statements (imports, def, class, and of course assignment) are executed to build the runtime module object. That's how Python work, and there are very valid reasons for it to work that way.\nNow the solution here is quite simple: 1\/ split your gigantic module into proper (high cohesion \/ low coupling) modules and only import the parts you need, and 2\/ instead of defining gigabytes of data at the top-level, encapsulate this part in functions with some caching system to avoid useless re-computations.","Q_Score":4,"Tags":"python,performance,memory-management","A_Id":61231439,"CreationDate":"2020-04-15T14:08:00.000","Title":"How to import a class from a module without importing the whole module","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've built the image successfully, but when I run docker run it returns nothing.\nI also have a bash script that contains AWS crendential (because a Python script within the container requires credential to log into AWS to perform something), when I tried to run that script it also returns nothing, has anyone encountered this issue? Many thanks.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1379,"Q_Id":61233802,"Users Score":1,"Answer":"Did you do: docker run -it xxxx?\n-i flag, connects your terminal to STDIN\n-t flag, provides a better visualization of what you see on the screen\n-it is a syntactic coating for -i -t flags used separately\nAlso, what does it show on doing docker ps --all? Does it show that the container is running?","Q_Score":1,"Tags":"python,bash,amazon-web-services,docker,containers","A_Id":61238369,"CreationDate":"2020-04-15T16:29:00.000","Title":"docker run command returns nothing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am using DBT (data build tool) as an ETL tool for data analytics . \nThe command \ndbt test\nResuts in the test cases being pass\/fail on the output terminal but need to export this result into JSON\/HTML\/XML format for reporting.\nAny help in this regard ?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2389,"Q_Id":61238395,"Users Score":2,"Answer":"If you are executing this on an UNIX shell like Mac or Linux, you can try with tee like this.\ndbt run | tee -a your_log_file.txt\nThis will create and append there on the a log file of your choosing for whatever results of the dbt run command.","Q_Score":1,"Tags":"python,json,reporting,dbt","A_Id":61239586,"CreationDate":"2020-04-15T20:51:00.000","Title":"Can the results of dbt test be converted to report","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a 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. \nNow i wanted to ask if this is somehow possible to make and in which programming Languages is it makeable?\nEDIT: Solved the Problem with pypresence","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1942,"Q_Id":61250120,"Users Score":0,"Answer":"In your startup, where DiscordSocketClient is available, you can use SetGameAsync(). This is for C# using Discord.NET.\nTo answer your question, I think any wrapper for Discord's API allows you to set the current playing game.","Q_Score":1,"Tags":"python,c#,file,discord,status","A_Id":61250409,"CreationDate":"2020-04-16T12:20:00.000","Title":"Set Custom Discord Status when running\/starting a Program","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I use python boto3\nwhen I upload file to s3,aws lambda will move the file to other bucket,I can get object url by lambda event,like\nhttps:\/\/xxx.s3.amazonaws.com\/xxx\/xxx\/xxxx\/xxxx\/diamond+white.side.jpg\nThe object key is xxx\/xxx\/xxxx\/xxxx\/diamond+white.side.jpg \nThis 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?\nthanks!!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":984,"Q_Id":61265226,"Users Score":1,"Answer":"You should use urllib.parse.unquote and then replace + with space.\nFrom my knowledge, + is the only exception from URL parsing, so you should be safe if you do that by hand.","Q_Score":0,"Tags":"python,amazon-web-services,amazon-s3,aws-lambda,boto3","A_Id":61267789,"CreationDate":"2020-04-17T06:16:00.000","Title":"how to get s3 object key by object url when I use aws lambda python?or How to get object by url?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to install OpenCV on Raspbian Buster. I've followed a guide but when I try to import cv2 in Python 3.8.0 it says No module named 'cv2'. Python 3.8.0 is set to my default Python installation, but when I navigate to \/usr\/local\/lib\/python2.7\/dist-packages, that's where I see the cv2 module. It is also installed under python3.7, but not under 3.8. Is there a way I can use it with Python 3.8? \nEDIT: I seem to have fixed it by creating a symbolic link between the Python3.8 and 3.7 site-packages folder.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":415,"Q_Id":61271567,"Users Score":0,"Answer":"You can install current opencv for python3 with sudo pip3 install opencv-python. Note the use of pip3 to install for python3.","Q_Score":0,"Tags":"python,python-3.x,python-2.7,opencv","A_Id":61271698,"CreationDate":"2020-04-17T12:22:00.000","Title":"Installing OpenCV on Raspbian Buster","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I 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. \nWhich 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?\nHowever if it is right and has no correlation with the issue, then what is the problem?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":6390,"Q_Id":61277217,"Users Score":1,"Answer":"You have to change directory to sherlock twice. (it works for me)","Q_Score":1,"Tags":"python,linux,path,pip,errno","A_Id":61730646,"CreationDate":"2020-04-17T17:23:00.000","Title":"Python3: can't open file 'sherlock.py' [Errno 2] No such file or directory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently running jupyter notebooks on a Raspberry Pi Zero W. I was trying to download textblob through terminal. The \"pip install -U textblob\" downloaded. However, I received the following:\n\"WARNING: The script tqdm is installed in '\/home\/pi\/.local\/bin' which is not on PATH...\" for each script.\nWhen I went to execute the second line \"python -m textblob.download_corpora\" - I just get \"No module named textblob\"\nAs you can probably guess, I'm quite new to all of this and trying to learn as I go. Please help! :)\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":276,"Q_Id":61296438,"Users Score":0,"Answer":"just put python3 -m textblob.download_corpora in terminal\nWorks for me.","Q_Score":0,"Tags":"python","A_Id":70622138,"CreationDate":"2020-04-18T21:24:00.000","Title":"python -m textblob.download_corpora => No module named textblob","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing a test using Stateful Testing feature of hypothesis.\nI am finding out that after a certain number of state changes, the testing restarts from the beginning.\nHow can I make it continue along existing path?\nI have set max_examples=1 and stateful_step_count=999999 but that does not seem to help.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":33,"Q_Id":61324716,"Users Score":0,"Answer":"Occasional restarts are an intentional feature of stateful tests, and must be possible for us to present a minimal (fewest steps) counterexample if your test fails.\nIn your specific case, I suspect that the statemachine is 'getting stuck' and having to retry some steps. Because it could not complete max_step steps, it may not count as an example for max_examples!\nFor more detailed comments, I'd have to see your actual code and an example output :-)","Q_Score":0,"Tags":"python,python-hypothesis","A_Id":61377574,"CreationDate":"2020-04-20T14:18:00.000","Title":"Stateful Testing gives up halfway and restarts from the beginning","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I run an app and from the app it directs me to chrome for login. After which I give my email and password and then after successful login I get redirected to app. Now the question is in case I need to run it again I need to manually clear the cache and free up space every time login happens and this does not allow me to run all codes in one stretch. Can you please let me know is there a way to automate clearing cache and free up space using python and appium.I run my code on ubuntu os platform.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":208,"Q_Id":61337086,"Users Score":0,"Answer":"Add adb shell pm clear packageName to your test file wherever you need and try","Q_Score":0,"Tags":"browser-cache,appium-android,python-appium,appium-desktop,android-chrome","A_Id":61352803,"CreationDate":"2020-04-21T06:17:00.000","Title":"Is there any way of clearing cache and free up space from android using appium python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I was wondering if there is any function\/tool in Python which allows me to get the absolute path of a file directly from the computer, instead of having to manually search for the absolute path of the particular file, or having to shift the file to the same folder as the script. I am trying to access a .csv file stored in another folder different from my python script.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":25,"Q_Id":61337235,"Users Score":0,"Answer":"You can use the os.path module. See the join method which will accept relative path fragments and the abspath method which will give you the absolute path.","Q_Score":0,"Tags":"python,file,directory,path,absolute","A_Id":61337473,"CreationDate":"2020-04-21T06:27:00.000","Title":"Is there a way to get an absolute path of a file which is not in the current working directory (in Python)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need my discord bot to send a message whenever a specific youtube channel uploads a video. How would I do this in python? I just want examples of the different ways it can be done.","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":1093,"Q_Id":61375754,"Users Score":-1,"Answer":"For this you need to use the Google data api, aka the youtube api, and combine it with the discord api. the discord api is pretty easy to understand, but the youtube one is pretty hard. so i sugesst you dig deep in how apis work and how the youtube data api functions","Q_Score":1,"Tags":"python,discord,discord.py","A_Id":62121296,"CreationDate":"2020-04-22T21:55:00.000","Title":"How to make a discord bot send a message in a channel when a video is uploaded by a specific youtuber","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am a student and I am learning to create a Twitter bot using PyCharm. When I used the command: pip install tweepy\nthe terminal displays this statement (after some other lines) :\nInstalling collected packages: idna, urllib3, chardet, certifi, requests, six, PySocks, oauthlib, requests-oauthlib, tweepy\nfollowed by this error:\nERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'c:\\\\users\\\\name\\\\desktop\\\n\\folder1\\\\folder2\\\\folder3\\\\folder4\\\\our first twitter bot\\\\venv\\\\L\nib\\\\site-packages\\\\oauthlib\\\\oauth2\\\\rfc6749\\\\grant_types\\\\__pycache__\\\\resource_owner_password_credentials.cpython-37.pyc'\nI cannot import tweepy in my program now. Please help me solve this problem. Thank you.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":63,"Q_Id":61400938,"Users Score":0,"Answer":"You have to enable long file names in windows.\nOpen Regedit and change HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\FileSystem\\LongPathsEnabled to 1. Restart or sign out to apply for new settings.","Q_Score":1,"Tags":"python-3.x,pycharm,tweepy","A_Id":65447755,"CreationDate":"2020-04-24T04:03:00.000","Title":"How to fix Environment Error while installing tweepy in PyCharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I tried to run the telegram API through my Jupyter Notebook but while importing it showed the following error\nfrom telethon import TelegramClient\n----> 2 from telethon.errors.rpc_errors_401 import SessionPasswordNeededError\n 3 \n 4 # (1) Use your own values here\n 5 api_id = 11111\nModuleNotFoundError: No module named 'telethon.errors.rpc_errors_401'","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":922,"Q_Id":61403979,"Users Score":0,"Answer":"The module to be used for SessionPasswordNeededError is telethon.errors.rpcerrorlist. Try using from telethon.errors.rpcerrorlist import SessionPasswordNeededError","Q_Score":0,"Tags":"python,api,jupyter-notebook,telegram,telethon","A_Id":66260235,"CreationDate":"2020-04-24T08:14:00.000","Title":"Telegram API (ModuleNotFoundError: No module named 'telethon.errors.rpc_errors_401')","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to find a way to edit and run a sequence of python scripts in a less manual way.\nFor context, I am running a series of simulations, which consist in running three codes in order 10 times, making minor changes to each code every time. The problem I am encountering is that this process leads to easy mistakes and chaotic work.\nThese are the type of edits I have to make to each code.\n- Modify input\/output file name\n- Change value of a parameter\nWhat is the best practice to deal with this? I imagine that the best idea would be to write another python script that does all this. Is there a way to edit other python codes, from within a code, and run them?\nI don't intend or want anyone to write a code for me. I just need to be pointed in a general direction. I have searched for ways to 'automatize' codes, but haven't yet been successful in finding a solution to my query (mainly the editing part).\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":27,"Q_Id":61415027,"Users Score":1,"Answer":"The thing that can change (files or parameter values) should be able to be either passed in or injected. Could be from a command line parameter, configuration file, or method argument. This is the \"general direction\" I offer.","Q_Score":1,"Tags":"python,python-3.x,ubuntu,automation,automated-tests","A_Id":61415081,"CreationDate":"2020-04-24T18:23:00.000","Title":"Edit and run a sequence of scripts in a less-manual way [Python]","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have noticed that yum install python3 or apt-get install python3 python 3.6 but I am unable to understand why it installs this specific version; 3.8 is the latest version of python. Why does it pick 3.6 in specific ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2469,"Q_Id":61474288,"Users Score":1,"Answer":"This just depends on the OS you are using. Each OS packages a certain version of python and sticks with it. For example:\n\nCentOS 7: python 3.6\nCentOS 8: python 3.6\nUbuntu 16.04: python 3.5\nUbuntu 18.04: python 3.6\nUbuntu 20.04: python 3.8\n\nNOTE: There are some OS that use rolling releases and that thus will update their default python version, but that is more rare.","Q_Score":1,"Tags":"python,linux,yum","A_Id":61475027,"CreationDate":"2020-04-28T06:50:00.000","Title":"Why does yum install python3 install python3.6","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently trying to host my first discord bot on heroku. In order to get the bot up and running I have to pass several tokens for discord authentication such as authentication for some APIs I'm using. \nDuring development I was using a config.json file which contains all the information I need for the bot to work. This works fine when hosted on my local machine, however I'm not sure if I should upload a file which contains passwords to a remote server like Heroku. \nWhat would be a proper and secure way for me to pass my API credentials to Heroku?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":88,"Q_Id":61480468,"Users Score":0,"Answer":"the way to provide credentials\/tokens\/pwd is to use Config Vars.\nOnly the application admin has access to this info (in the Heroku Dashboard).\nIt is acceptable to trust the hosting infrastructure with this data as your applications are running on it and require it. For top security applications you would probably use a different hosting solution (private cloud) or run your own server.","Q_Score":1,"Tags":"python-3.x,heroku,discord","A_Id":61481664,"CreationDate":"2020-04-28T12:43:00.000","Title":"How do I securely pass API credentials to a remote Heroku server that my python script is hosted on?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Where are the standard python modules located? I'm talking about the random, turtle, etc. modules.","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":84,"Q_Id":61483964,"Users Score":0,"Answer":"These are located under the Lib sub directory in Main Python installation directory.\nfor example: if you have installed Python in C:\\Program Files\\Python37.\nThe standard packages will be in C:\\Program Files\\Python37\\Lib.","Q_Score":1,"Tags":"python,module","A_Id":61484097,"CreationDate":"2020-04-28T15:28:00.000","Title":"Where are the standard python modules located?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was thinking in how to include some metadata in my script files in a way that other scripts could process this information without interfering in its .\/ execution.\nYAML Front Matter came to my mind, but obviously its --- syntax produce error either in #!\/bin\/bash as in #!\/usr\/bin\/python3, for example.\n\nIs there some simple way to allow a non-comment block (as Front Metter's one) to be ignored by script .\/ execution?\nOr any other known way to make a file carry some metadatas possible to be accessed anyway without interfer in its generic execution?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":61,"Q_Id":61494337,"Users Score":1,"Answer":"If you can't use a comment, you could use a Python object of some kind.\nThis is a bit like the way doctstrings work in Python: The string is an expression but it's evaluation doesn't have side effects and Python uses it as metadata.\nHowever if you need a shebang (#!...) that does have to come first. Your metadata processor will have to skip that line.","Q_Score":0,"Tags":"python-3.x,file,scripting,metadata,yaml-front-matter","A_Id":61494413,"CreationDate":"2020-04-29T04:38:00.000","Title":"Is possible to have a Front Matter header in a script?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am having issues installing Anaconda on my Raspberry Pi.\nWhen I attempt to install Anaconda I get this message:\nAnaconda3-20.02-Linux-x86_64.sh: line 404:\/home\/ubuntu\/anaconda3\/conda.exe: cannot execute binary file: Exec format error\nWhen I try installing installing mini conda i get this:\nERROR:\ncannot execute native linux-armv7l binary, output from 'unman -a' is:\nLinux user 5.4.0-1008-raspi #8-Ubuntu SMP Wed Apr 8 11:13:06 UTC 2020 aarch64 aarch64 aaarch64 GNU\/Linux","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":23567,"Q_Id":61508312,"Users Score":3,"Answer":"The problem is it looks like you're using the wrong shell script to install:\nAnaconda3-20.02-Linux-x86_64.sh\nThe Raspberry PI 4 has ARM architecture and is capable of running ARM-64 instructions if you have the 64-bit version of Ubuntu installed. You can check with uname -a and if you see aarch64 you can run the 64-bit instruction set.\nIt looks like your distribution is for 32-bit ARM, due to the armv7l output from uname so you would want to look for packages with the armv7l suffix.\nThere is not very good ARM support right now with a lot of software but hopefully that will change now that Apple is moving to ARM-64.\nIf Anaconda offers a shell script it should look like this:\nFor 32-bit ARM:\n\nAnaconda3-20.02-Linux-armv7l.sh\nAnaconda3-20.02-Linux-aarch32.sh\n\nFor 64-bit ARM:\n\nAnaconda3-20.02-Linux-arm64.sh\nAnaconda3-20.02-Linux-aarch64.sh","Q_Score":5,"Tags":"python-3.x,ubuntu,anaconda,raspberry-pi4","A_Id":63864100,"CreationDate":"2020-04-29T17:49:00.000","Title":"Installing Anaconda on Raspberry Pi 4 with Ubuntu 20.04","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a few python projects, that I am the only one working on. The environment is setup via venv. However, I cannot use the remote Python venv environment locally. I am newer to python. Locally, I am mounting the remote directory via ExpanDrive, connecting via SFTP on my mac.\nReason for this setup is some scripts are running via CRON periodically and, centralization. Appreciate any suggestions!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":47,"Q_Id":61508766,"Users Score":0,"Answer":"Figured it out.\nInstalled remote-ssh in vscode and that solved the problem.","Q_Score":0,"Tags":"python-3.x,remote-server","A_Id":61512602,"CreationDate":"2020-04-29T18:12:00.000","Title":"How to work on a Python project, on a remote linux server, locally on a macbook?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am trying to create a textfsm template with the Netmiko library. While it works for most of the commands, it does not work when I try performing \"inc\" operation in the network device. The textfsm index file seems like it is not recognizing the same command for 2 different templates; for instance:\n\nIf I am giving the command - show running | inc syscontact\nAnd give another command - show running | inc syslocation\n\nin textfsm index; the textfsm template seems like it is recognizing only the first command; and not the second command.\nI understand that I can get the necessary data by the regex expression for syscontact and syslocation for the commands( via the template ), however I want to achieve this by the \"inc\" command from the device itself. Is there a way this can be done?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":144,"Q_Id":61515453,"Users Score":0,"Answer":"you need to escape the pipe in the index file. e.g. sh[[ow]] ru[[nning]] \\| inc syslocation","Q_Score":0,"Tags":"netmiko,python-textfsm","A_Id":62872404,"CreationDate":"2020-04-30T03:30:00.000","Title":"TextFSM Template for Netmiko for \"inc\" phrase","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to build a simple kivy app for mobiles \/ desktops which uses Twitter to authenticate users at the login screen. I am using Tweepy with Python to authenticate the users.\nThe authentication process works fine when I run the code from command line. It generates a redirect url which I open in a browser to authenticate the user and then it generates a pin. The pin is copied and entered into the command line interface of the parent Python program as an input and the authentication process completes successfully.\nIs there a way to copy the generated pin from the browser's html content and directly use it as an input in the program without any human intervention? This would enhance the user experience and people would not get confused as to what to do with the PIN. I was playing around with the weburl, urllib and htmlparser libraries in Python and was wondering if there any way to achieve this behaviour?\nPlease help.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":43,"Q_Id":61538233,"Users Score":2,"Answer":"You need to create an intermediate web app which runs on a server with a static ip address. The authentication code \/ PIN should be returned by Twitter to this intermediate app, which in turn can exchange it with your mobile\/desktop app.","Q_Score":0,"Tags":"python-3.x,kivy,tweepy,kivy-language","A_Id":62116704,"CreationDate":"2020-05-01T07:05:00.000","Title":"How to achieve authentication with Twitter in Kivy App without manual intervention","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am a single developer that creates python programs to automate my work. I often update the code as work duties change or I find improvements. I want to have a cloud-based version control like Github but I don't want all of the other capabilities that the tutorials seem to push me through. I want to write code on my computer, save a copy to github, update code on computer, update the copy on Github, etc. I don't need to clone, fork, pull, work in teams, develop on multiple computers, etc. Is there a simple way to push changes directly to a Github repository without Git?\nI am using PyCharm Community Edition with Python 3.7 Windows 10","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1211,"Q_Id":61552001,"Users Score":1,"Answer":"Just because you want simplicity, install GitHub desktop.\n1) Create a repository in GitHub.\n2) Enter the repo link in GitHub desktop and press the clone button to download it.\n3) Write your code\n4) To upload, just click commit and push button\nNothing else that you need to know and worry about","Q_Score":0,"Tags":"python,github,save","A_Id":61552116,"CreationDate":"2020-05-01T22:49:00.000","Title":"How can I only use Github to save versions of my code as I continuously develop?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any way we can find what kind of encoding is used in bytes string with codecs in python. There is a method in chardet chardet.detect(string)['encoding'] Is there any method similar to this in codecs python","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":122,"Q_Id":61556170,"Users Score":0,"Answer":"There isn't a built-in method, because it wouldn't be possible to reliably determine this for arbitrary values and arbitrary encodings. (For example, any text containing only ASCII characters is valid in most other encodings.)\nThe best you could do is a series of try-catch blocks where you guess a series of encodings (eg UTF8, UTF16) and go to the next if there is an invalid character.","Q_Score":0,"Tags":"python,codec","A_Id":61556375,"CreationDate":"2020-05-02T08:00:00.000","Title":"Codec find bytes string encoding","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hi everyone i want to create a new telegram bot similar to @usinifobot.\nthis is how it works:\nyou just send someone username to this bot and it will give you back his\/her chat id.\ni want to do same thing but i dont khow how to do it with python-telegram-bot.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":943,"Q_Id":61562744,"Users Score":0,"Answer":"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\nyou need telegram client api for this and to hold a real account (not a bot) online to make checks by another library\nand 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\nI created similar bot @username_to_id_bot for getting ids of any entity and faced all these moments","Q_Score":0,"Tags":"python,bots,telegram,telegram-bot","A_Id":61562993,"CreationDate":"2020-05-02T16:30:00.000","Title":"How can i get someone telegram chat id with python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"On my Pi (with the lite text only Linux on it) a Python-Program is started through rc.local! When I log in the (headless) Pi then I do not see the output of the program (simple print-commands). I can see that Python3 is running when I use \"pa -S\" and \"top\", but I cannot switch to the output from the program.\nHow can I make the output visible in the terminal-window like it is when I start the program straight from the command line? \nThanks and cheers, \nUlrich","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":59,"Q_Id":61566441,"Users Score":0,"Answer":"You can not do that, you must write the output into a file with redirection.\nIn the rc.local, you can write: your_program >> logfile_name 2>&1\nBut the logfile must be sometimes deleted.\nSearch for [linux] redirection!","Q_Score":0,"Tags":"python,terminal,process,visible","A_Id":61566935,"CreationDate":"2020-05-02T21:19:00.000","Title":"How to watch an automatically startet python script on raspberry \/ raspian?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"pi@Clone:~$ lsb_release -a\nNo LSB modules are available.\nDistributor ID: Raspbian\nDescription: Raspbian GNU\/Linux 9.4 (stretch)\nRelease: 9.4\nCodename: stretch\nI had Python 2.7.13 and was trying this bit of code. Then after much searching there were some discussions about this version of Python, and those pre 3.5, did not support f functions so I upgraded and am now using Python3.7. Rather than getting the f something error, now it says \nModuleNotFoundError: No module named 'netmiko'\nI even tried this from the >>> prompt: typing import netmiko, but get the same annoying ModuleNotFound error.\n'''\npi@Clone:~$ python3.7\nPython 3.7.4 (default, May 2 2020, 09:56:22) \n[GCC 6.3.0 20170516] on linux\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n\n\n\nimport netmiko\n Traceback (most recent call last):\n File \"\", line 1, in \n ModuleNotFoundError: No module named 'netmiko'\n\n\n\nTried the below from the cli prompt using python3.7 finename.py\nBut it never got past the fist command: from netmiko import ConnectHandler. I get the same old error:\nModuleNotFoundError: No module named 'netmiko'","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":281,"Q_Id":61568915,"Users Score":0,"Answer":"i'm not an expert in python, i've faced the same issue doing my network automation stuff \nand i solved concluding that every instance of python3.x needs its own modules so you need to reinstall netmiko for the new python3.x you got there !!\nand you may need to install setuptools and ez_install for pip and python before installing netmiko.\nI hope some expert see this and try to explain in more details for you.","Q_Score":0,"Tags":"python","A_Id":61850117,"CreationDate":"2020-05-03T02:30:00.000","Title":"I'm not able to launch use paramiko or netmiko in my Debian Pi machine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to develop a IoT application using Python that runs on ships and sends data occasionally when a network connection is available. This is the case in about 10% of the time.\nIs there any pattern \/ implementation available who handles exactly this use case? I already read about MQTT and RabbitMQ\/AMQP but the implementations expect that the client reaches the broker at the time of sending the message. What I need is some type of local persistance that builds up a local queue and sends the messages when a connection is detected. \nI know that I could handle that for myself and us a SQLite DB but I think that this is no rare use case so I am sure there must be a solution for this and I just used the wrong search terms.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":46,"Q_Id":61576742,"Users Score":0,"Answer":"The pattern you're looking for is already implemented in the standard PAHO MQTT Client, as part of the Quality Of Service (QOS) flow.\nAll you need to do, is to call the method 'publish' with the parameter 'qos' being equal to 2. The framework will take care of everything else for you, and automatically buffer the messages till a connection is available.\nThere are 2 points to notice however:\n- the buffer is an in-memory buffer, that is in a case of a power outage, all messages will be lost. If the messages cannot be lost in such a scenario, you have to implement persistent storage of messages into a local file \/ database.\n\nAs an in-memory buffer it is limited by the total available memory for your python code. So for very large number of messages or message size, possibly exceeding available memory, you would also have to implement persistent local storage.","Q_Score":0,"Tags":"python,rabbitmq,mqtt,iot","A_Id":61641332,"CreationDate":"2020-05-03T15:09:00.000","Title":"Pattern for handling message delivery in IoT applications when not online 24\/7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Basically, I recently started Python. I'm working on a project where I need audio to play. I searched up some libraries that can play audio and tried simpleaudio. I'm using Windows and sucessfull installed simpleaudio using: pip3 install simpleaudio.\nHowever, when I tried to use simpleaudio in my project with import simpleaudio as sa, it gives me this error: \nTraceback (most recent call last):\n File \"d:\\coding\\python\\python projects\\random tests\\soundtest.py\", line 1, in \n import simpleaudio as sa\nModuleNotFoundError: No module named 'simpleaudio'\nAny idea what is wrong?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2216,"Q_Id":61583989,"Users Score":0,"Answer":"It's possible you installed the library for python2 instead of python3. In ubuntu pip is python2 and pip3 is python3- I'm not sure if that's the case on windows or not.","Q_Score":1,"Tags":"python,simpleaudioengine","A_Id":61584322,"CreationDate":"2020-05-04T01:49:00.000","Title":"ModuleNotFoundError: No module named 'simpleaudio'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Basically, I recently started Python. I'm working on a project where I need audio to play. I searched up some libraries that can play audio and tried simpleaudio. I'm using Windows and sucessfull installed simpleaudio using: pip3 install simpleaudio.\nHowever, when I tried to use simpleaudio in my project with import simpleaudio as sa, it gives me this error: \nTraceback (most recent call last):\n File \"d:\\coding\\python\\python projects\\random tests\\soundtest.py\", line 1, in \n import simpleaudio as sa\nModuleNotFoundError: No module named 'simpleaudio'\nAny idea what is wrong?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2216,"Q_Id":61583989,"Users Score":0,"Answer":"After I installed simpleaudio, import simpleaudio as sa worked with no errors. I've run into similar errors before, and it was always because the version of pip I was using and the Python interpreter I was using didn't match. You probably need to either switch to using the same interpreter as pip3 or install the package for whatever interpreter you're using","Q_Score":1,"Tags":"python,simpleaudioengine","A_Id":61584048,"CreationDate":"2020-05-04T01:49:00.000","Title":"ModuleNotFoundError: No module named 'simpleaudio'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was creating a program to encrypt every file in a directory, and it worked, but I encrypted my working directory. I lost all my programs and the key itself. I used cryptography.fernet. Is there any way to get my files back?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":421,"Q_Id":61585325,"Users Score":2,"Answer":"No, it's not. Fernet (like any good encryption algorithm) is designed so there's no way to decrypt the data without the key.\nYour only hope (such as it is) would be that you'd generated the key poorly (e.g. not using Fernet.generate_key()).","Q_Score":1,"Tags":"python,encryption,cryptography,key","A_Id":61599671,"CreationDate":"2020-05-04T04:43:00.000","Title":"Can I decrypt the files that I made using cryptography.fernet without my key?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to get response from sending request to the AWS. I have the secretkey\/AccessKey of AWS.\nWhat is the method\/syntax to access the aws APi, for example GetCredentialReport is an API of AWS, How to access this api?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":969,"Q_Id":61586015,"Users Score":1,"Answer":"You can use get_credential_report() API in boto3 for credential repot\nget_credential_report()\nRetrieves a credential report for the AWS account. For more information about the credential report, see Getting Credential Reports in the IAM User Guide .\nSee also: AWS API Documentation\nRequest Syntax\nresponse = client.get_credential_report()\nResponse Structure\n(dict) --\nContains the response to a successful GetCredentialReport request.\nContent (bytes) --\nContains the credential report. The report is Base64-encoded.\nReportFormat (string) --\nThe format (MIME type) of the credential report.\nGeneratedTime (datetime) --\nThe date and time when the credential report was created, in ISO 8601 date-time format.\nTry this code\nimport os\nimport boto3\nfrom dotenv import load_dotenv\nload_dotenv()\nAWS_ACCESS_KEY_ID = os.getenv('AWS_ACCESS_KEY_ID')\nAWS_SECRET_ACCESS_KEY = os.getenv('AWS_SECRET_ACCESS_KEY')\nclient = boto3.client(\n 'iam',\n aws_access_key_id=AWS_ACCESS_KEY_ID,\n aws_secret_access_key=AWS_SECRET_ACCESS_KEY\n)\nresponse = client.generate_credential_report()","Q_Score":1,"Tags":"python,amazon-web-services,amazon-iam,rest","A_Id":61586228,"CreationDate":"2020-05-04T06:00:00.000","Title":"How to get response and access the AWS Api with python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to this, so apologize if the step is easy.\nI have a Device which I am programming, which uses a raspberry pi (Debian). I have connected via SSH using PuTTY.\nI 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.\nHowever, here is the problem:\nThe 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.\nWhen I run sudo apt-get install python3-venv, I can see in the prompt that it automatically starts installing packages for python3.4. \nDoes anyone know how I can specify that I wish to install python 3.5 or 3.7?\nAny help would be greatly appreciated.\nRegards\nScott","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":218,"Q_Id":61587277,"Users Score":0,"Answer":"Does it not have the python3.7 command?\nI just checked a venv I have running on a 3b+ and it seems to have it.","Q_Score":0,"Tags":"python,python-3.x,raspberry-pi,debian,wpa-supplicant","A_Id":61587349,"CreationDate":"2020-05-04T07:38:00.000","Title":"Installing python 3.5 or higher in a virtual environment on a raspberry pi","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created some code for sending alerts, for now only by emails. I was wondering if there is an easy way to send push notifications to iOS and Android mobiles using Python. Thanks a lot.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5163,"Q_Id":61587817,"Users Score":0,"Answer":"Without getting device tokens from the devices (iOS \/ Android), and without a valid APNS certificate for the iOS app, there is no way to send push notification to any app.\nFor iOS, device token and certificate is must.\nFor Android, a Firebase project has to be setup, and the device token has to be fetched from the app.\nIf you are the owner of the backend that the mobile apps are using, it is easy to send device tokens from the apps provided you have access to the Firebase project (for Android) and the certificate used (for iOS).","Q_Score":3,"Tags":"python-3.x,push-notification","A_Id":61588623,"CreationDate":"2020-05-04T08:14:00.000","Title":"How to send notifications to iOS and Android using Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"we have some COBOL Caller Handlers which are executed\/called by external applications built in VB\/Java. what we are looking is instead of going through other applications, is there way to call those caller handlers directly from Python so we can test them directly from Python automation framework","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":469,"Q_Id":61594290,"Users Score":1,"Answer":"I have a CICS program\/transaction bound to a web interface in CICS, so that i can drive my transaction via http post\/put\/get, maybe you are looking for a tighter bind though?","Q_Score":0,"Tags":"python,cobol,cics","A_Id":61598057,"CreationDate":"2020-05-04T14:13:00.000","Title":"what are my chances to call CICS Transactions or COBOL programs from Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"we have some COBOL Caller Handlers which are executed\/called by external applications built in VB\/Java. what we are looking is instead of going through other applications, is there way to call those caller handlers directly from Python so we can test them directly from Python automation framework","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":469,"Q_Id":61594290,"Users Score":0,"Answer":"For the Java APIs I would recommend, ditching python and wrting the tests in Groovy.\nThis is a scripting language that runs on a JVM, which means it can call all java APIs natively.\nAs well as support the normal builtin scripting stuff like dictionarys, currying functions, regex support -- all valid java code is also valid Groovy code. So you can cut and paste your java API calls into your testing scripts.","Q_Score":0,"Tags":"python,cobol,cics","A_Id":61608297,"CreationDate":"2020-05-04T14:13:00.000","Title":"what are my chances to call CICS Transactions or COBOL programs from Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have the following:\n1. AWS (lambda) layer of runtime python 3.6.\n2. A lambda function of runtime python 3.7 that uses the above layer.\nThe layer packages it's modules in a zip with the required hierarhcy of \"python\/lib\/python3.6\/site-packages\".\nThe problem is that the lambda function does not find (i.e. fails to import) the layer modules, unless I explicitly do something like: sys.path.append('\/opt\/python\/lib\/python3.6\/site-packages'), which I feel is a workaround.\n\nI would expect aws lambda framework to smoothly allow a 3.7 runtime to import modules from a layer with version < 3.7. (by adding the matching python path or by some other way).\nIs there such a way that I missed?\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":420,"Q_Id":61616494,"Users Score":0,"Answer":"This layer hierarchy python\/lib\/python3.6\/site-packages is not needed. You could just do pip install xxx -t folder, zip it, upload it, and set an PYTHONPATH=\/opt environment variable.","Q_Score":0,"Tags":"python,aws-lambda,aws-lambda-layers","A_Id":61616808,"CreationDate":"2020-05-05T15:13:00.000","Title":"AWS lambda of python runtime 3.7 using layer of runtime 3.6","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How useful would it be running code from the ide Visual studio code 24\/7 on a Raspberry pi? I'm trying to have this project send texts at certain times a day and running it on my computer all day seems like a bad idea I've read. So how plausible would it be to get a raspberry pi and run this code on it all day?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":130,"Q_Id":61616842,"Users Score":0,"Answer":"Well, the 24\/7 isn't a problem. The nice thing about Rasberry PI they all run under 10 watts. The problem will be running Visual Studio. I don't think you can bring VStudio up on a RPI; it is way too big. Running the application itself, shouldn't be an issue though, depending on size and complexity of course. Create and debug the application someplace else, then running the python on RPI should not be an issue.","Q_Score":0,"Tags":"python,windows,raspberry-pi","A_Id":61617009,"CreationDate":"2020-05-05T15:29:00.000","Title":"How plausible is it running code on a Raspberry Pi 24\/7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"For a project at school I need to run a python file using powershell. I tried installing the interpreter and using the command python pythonTest.py but nothing happened.\nDo i need to import something in powershell?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":66,"Q_Id":61636522,"Users Score":0,"Answer":"You have to check the box add python to path when you install python. So first uninstall then reinstall making sure you ticked the checkbox and proceed then you can run python files in powershell.","Q_Score":0,"Tags":"python,powershell","A_Id":61636582,"CreationDate":"2020-05-06T13:32:00.000","Title":"running python files in powershell","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"For a project at school I need to run a python file using powershell. I tried installing the interpreter and using the command python pythonTest.py but nothing happened.\nDo i need to import something in powershell?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":66,"Q_Id":61636522,"Users Score":0,"Answer":"FIXED\nI was running it in admin mode and apparently it doesn't work when you're in adminmode","Q_Score":0,"Tags":"python,powershell","A_Id":61659815,"CreationDate":"2020-05-06T13:32:00.000","Title":"running python files in powershell","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have created a few test classes using \"unittest\" package to my Python app.\nIn this app, there is a step that the user inserts a path to excel file (from the GUI) and I want to test some cases about this input file. \nIn my test class, I want to kill the program if the user inserts the wrong input (and verifies that exception was thrown).\nThe problem begins because:\nThe behavior of the program is to open a pop-up window (represents the error) and return to the main menu.\nSo, what is the way to stop my program (from test class) after the pop-up window was opened?\nI'm thinking to use tearDown, but I need some advice to kill the program and not continue to the main menu.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":36,"Q_Id":61664939,"Users Score":0,"Answer":"Correct me if i'm wrong, I dont know much about this, but I believe exit() will work if you put it within the exception condition. Hope I was able to help!","Q_Score":0,"Tags":"python,unit-testing,testing,mocking,automated-tests","A_Id":61665450,"CreationDate":"2020-05-07T18:18:00.000","Title":"How to kill Python program from Test class using 'unittest'?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I\u2019ve looked through this forum and couldn\u2019t find a clear answer to helping my situation. \nTo explain: I\u2019m currently trying to develop an IOT device that mainly consists of a raspberry pi 3. As it\u2019s for a start up business idea I want to reduce costs and not have a server on the cloud. \nI thought it would be a good idea to have flask run with gunicorn on the pi and this would be accessed by a desktop app or mobile app that would know the IP address of the pi as well as it\u2019s flask endpoints. \nI wanted the pi to be accessible from any other network (not just its local one). I have host on \u201c0.0.0.0\u201d and port 5000 for development but can\u2019t access it through my mobile network. \nI have seen similar posts mentioning ngrok (which might make data less secure?). I\u2019ve seen that I might have to forward the port of the pi to the router. But I think this might involve accessing the router set up. And I don\u2019t want to have to do this for every new client. \nI have checked other posts on the forum but can\u2019t seem to find what I\u2019m looking for. \nCan I ask this forum if my understanding is correct? Can anyone help me out? \nAny advice would be greatly appreciated!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":595,"Q_Id":61675492,"Users Score":0,"Answer":"If I understood the problem correctly,\nIf you want to connect to your raspberry pi remotely you should know the IP address of your raspberry pi and need port forwarding. After that, you can connect to your raspberry pi with a public ip address. For example publicraspberrypiaddress:5555 (which port are you using)\nNgrok gives a random subdomain for connection so I don't know how you recognize the ngrok url when device is not near of you.\nAlternatively, you can use cotunnel. It gives static url and the device appears on the cotunnel dashboard so you can manage your raspberry pi remotely with ssh terminal too. \nOr you should develop your own tunnel-like service, or change your project structure. I don't know another way.","Q_Score":0,"Tags":"python,flask,raspberry-pi3,ip-address","A_Id":61699730,"CreationDate":"2020-05-08T08:54:00.000","Title":"Accessing IOT raspberry pi outside of network using flask with Gunicorn","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"So, I have a project tested using pytest and using the pytest-cov module to report coverage.\nSome of the code involves bootstrapping and configuration and the canonical way of running this is starting via a shell script. The current unit tests use the subprocess module to test running this shell script on mocked data. I would like the code report against the coverage and I am trying specifically to avoid\n1) Heavily modifying the wrapper to support the test scenario. Also, this runs the risk of doing 2).\n2) Running the boostrap code outside the wrapper (e.g. by forking the process and running the code directly), since I want these tests to be as realistic as possible.\nIs there any (canoical, Pythonic) way of propagating the coverage collection to all subproceses, even when launched using subprocess.Popen? I can easily solve the problem using a hack, so this is not something I am looking for.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":339,"Q_Id":61678372,"Users Score":0,"Answer":"This actually works out of the box. The reason for me thinking this did not work was that the path mappings w.r.t. the Docker volumes were incorrect, as the modules loaded by the subprocess were bind mounted in the container. Coverage is only reported when the paths match up exactly.","Q_Score":0,"Tags":"python,pytest,coverage.py","A_Id":62195477,"CreationDate":"2020-05-08T11:42:00.000","Title":"Measure coverage across subprocesses","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"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","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":280,"Q_Id":61683552,"Users Score":0,"Answer":"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.","Q_Score":0,"Tags":"python,discord.py","A_Id":61711270,"CreationDate":"2020-05-08T16:25:00.000","Title":"Why is my python discord bot suddenly duplicating responses to commands","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a quite complex software system which was developed in ruby and has been now all \"translated\" and transported into python. The last thing which is left is a series of *.txt.erb templates. I would like to leave them as they are but have a python library which does what the old ruby routine was doing, that is creating a series of *.txt files which follow the *.erb templates structure. I have looked a lot around but I cannot find an answer. \nProbably for a more expert python programmer this might be a simple question.\nThanks a lot for your help!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":118,"Q_Id":61683706,"Users Score":0,"Answer":"I've solved the problem changing the *txt.erb templates into *.txt files and I've coded a python script which reads the file and substitute the general variable into the specific variable I want to, for both file content and file name.\nThank you for the help!","Q_Score":0,"Tags":"python,ruby,erb,templating","A_Id":61770422,"CreationDate":"2020-05-08T16:33:00.000","Title":"How to read\/translate *txt.erb template (ruby) with python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"Every time i try to upload a code or erase flash it gets me \"A fatal error occurred: Timed out waiting for packet content\"\nC:\\esptool>python esptool.py --port com4 erase_flash\nesptool.py v3.0-dev\nSerial port com4\nConnecting........_\nDetecting chip type... ESP32\nChip is ESP32D0WDQ6 (revision 1)\nFeatures: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None\nCrystal is 40MHz\nMAC: 24:6f:28:a2:5a:7c\nUploading stub...\nRunning stub...\nStub running...\nErasing flash (this may take a while)...\nA fatal error occurred: Timed out waiting for packet content","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1328,"Q_Id":61691037,"Users Score":0,"Answer":"is your USB cable a charger cable only? This happens a lot. Charger cables look almost the same as charge\/data cables. Though the heads look the same, sometimes a charger cable is slightly thinner b\/c it only has two conductors in the jacket. Charger\/Data cables however have at least 4 wires, Data +, Data -, Power and Ground. Test your cable with another data device, or try a slightly thicker cable.","Q_Score":0,"Tags":"python,arduino,esp8266,esp32,esptool","A_Id":61754602,"CreationDate":"2020-05-09T02:29:00.000","Title":"Can't upload my code to esp32 and not able able to erase flash","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to load a CUDA library compiled from source into a Python program. On my Windows machine, it successfully loads the code. However, on my university's Unix computer cluster, it fails with the error:\n\nImportError: dynamic module does not define module export function\n (PyInit_deform_conv_cuda)\n\nI have located the actual *.so file that was produced by the compilation process and discovered that grep finds an instance of 'PyInit_deform_conv_cuda' in it.\nThat makes me think that maybe the loader is loading the wrong file or something. I was hoping to debug the loader, but my trace statements never execute.\nI am running Python 3.7 on both machines.\nCan anybody tell what might be going wrong? Either with the loading of the module or with my debugging efforts?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":63,"Q_Id":61691643,"Users Score":0,"Answer":"I would never have guessed this and I feel kind of stupid. \nThe problem was that I installed the library into one Python environment and tried to run it from another. \nI'm posting this in case someone else makes this mistake. The error message wasn't at all helpful int this case.","Q_Score":0,"Tags":"python,c++","A_Id":61749295,"CreationDate":"2020-05-09T04:03:00.000","Title":"Python fails to load C++ library even though PyInit_ entry exists","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So, I want to be able to write Python code in my Visual Studio Code on my Windows PC. On my network is a raspberry pi 4, which I would like to execute said code on and receive any errors or output from. \nIs it possible for me to write some python code on my Windows PC, \"run\" it on the Raspberry pi, and receive any outputs of the program on my Windows PC? \nThe reason I wish to do this is that Visual Studio Code generally helps me write any code, and it is more time consuming for me to use other IDE's, and my code uses PyBluez, something I can't just test on my Windows PC (which has no Bluetooth module)\nI hope my question is in the right format and such! This is my first time posting! Any comments appreciated!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":218,"Q_Id":61717230,"Users Score":1,"Answer":"It seems that my answer was to use the Remote Development pack on Visual Studio Code (it's an extension) to ssh into my raspberry pi. It's worked well for me for the past few days, and I highly recommend it. It allowed me to access the entire sd card and access any files I need to, while also giving me an SSH terminal and run the program ON the other machine.\nFor anyone who does this; set up the whole ssh key thing, to stop having to give the password to the pi so often. \nThe scp command would also work, I think, but is more complex than what I want to do.\nThank you so much for the answer, JL Peyret!","Q_Score":2,"Tags":"python,bluetooth,raspberry-pi,ide","A_Id":61798111,"CreationDate":"2020-05-10T18:57:00.000","Title":"Can I run and develop a python program from another computer?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I try to run my discord python bot:\nqbasty@cody-discord-bot:~\/matrixcraft-cody$ pm2 start Cody.py --interpreter=python\n[PM2][ERROR] Interpreter python is NOT AVAILABLE in PATH. (type 'which python' to double check.)\nI get that error.\nUbuntu 20 on DigitalOcean.","AnswerCount":1,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":3701,"Q_Id":61728462,"Users Score":10,"Answer":"Here is what worked for me :\npm2 start bot.py --name bot --interpreter python3","Q_Score":4,"Tags":"python,discord","A_Id":64982779,"CreationDate":"2020-05-11T11:19:00.000","Title":"[PM2][ERROR] Interpreter python is NOT AVAILABLE in PATH. (type 'which python' to double check.)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Im trying to figure out how ansible executes the commands on the remote host, I get that it uses ssh\/winrm to connect to the remote host but from there it would have to assume the remote host has python\/powershell (depends on the os) and all the libraries their code need to run.\nso basically what im asking is :\n\ndoes ansible require the remote host to have python in the right version on it.\ndoes it require the remote host to have the libraries their code uses.\nif not does it transfer the modules when it connects and removes them afterwards.\nelse it may \"compile\" the modules and transfer them","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":38,"Q_Id":61731191,"Users Score":0,"Answer":"Ansible works by connecting to your nodes and pushing out small programs, called \"Ansible modules\" to them. These programs are written to be resource models of the desired state of the system. Ansible then executes these modules (over SSH by default), and removes them when finished.","Q_Score":0,"Tags":"python,ansible,infrastructure","A_Id":61731574,"CreationDate":"2020-05-11T13:43:00.000","Title":"how does ansible executes on a remote host?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have downloaded odoo9 source code from https:\/\/www.github.com\/odoo\/odoo --depth 1 --branch 9.0 --single-branch .\n and started the odoo server but i see \"ImportError: No module named werkzeug.utils\" error.\nI tried installing with \nsudo apt-get install -y python3-werkzeug and could see it is installed successfully.\nAgain when I run the server I still see the same import issue.\nhow could I fix this import errors when I already installed them.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2913,"Q_Id":61745614,"Users Score":0,"Answer":"Odoo 9.0 is no longer supported since long ago, and it only works with Python 2, so you'd have to install python2-werkzeug instead (if available).\nOnly Odoo 11.0 and newer run under Python 3.","Q_Score":1,"Tags":"python,odoo","A_Id":61748697,"CreationDate":"2020-05-12T06:56:00.000","Title":"ImportError: No module named werkzeug.utils","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've created a Python simple server.py and client.py chat.\nI was wondering if it is possible to deploy server.py on heroku so that it's always running and I can access the server from any client.py at any time.\nI've tried deploying the simple server.py to heroku but it doesn't print anything in the logs section and it seems like it didn't even start the code as it should print \"server on\" but it doesn't.\nI think that I'm missing something in the Procfile or in the requirements.txt file.\nIs there another way to do this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":64,"Q_Id":61762007,"Users Score":0,"Answer":"Try heroku ps:scale web=1 so your dyno can work","Q_Score":0,"Tags":"python,sockets,heroku,server","A_Id":61807922,"CreationDate":"2020-05-12T21:11:00.000","Title":"python heroku socket server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm using sublime text 3 and I want to run ipynb files. I have installed helium. In the document, it says to execute a block I should execute Helium: Execute Block in the command palette. But can't seem to find that command.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":798,"Q_Id":61766361,"Users Score":1,"Answer":"Step 1.) run %connect_info in a localhosted jupyter notebook and copy the json output\nStep 2.) In sublime text editor, press \"Ctrl+shift+P\" and type hermes: start kernel and copy paste this json you copied from step 1.\nYou should see a blank page popout.\nStep 3.) Open your py file you want to execute, and select the lines you want to execute using mouse and again press \"Ctrl+shift+P\" and type hermes: execute cell (you will see an option now), click on that and your output should run on the black page which popped out in step 2.\nNote : If your localhost jupyter notebook is running in a specific folder, make sure that the py file you want to run using helium\/hermes is under that jupyter notebook access, basically the py file has to be under the same folder you ran jupyter from.","Q_Score":1,"Tags":"ipython,sublimetext3,helium","A_Id":63818323,"CreationDate":"2020-05-13T04:18:00.000","Title":"Unable to run helium with sublime text","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I tried crontab -e.\n@reboot python3 \/home\/hyebin\/project\/tensorrt_demos\/trt_ssd.py --model ssd_mobilenet_v2_face --usb --vid 1 --width 1280 --height 780\n1.Do I just have to add it to the bottom line of the crontab -e?\n2. Is it okay to have additions, such as '--model'?\n3. What should I do if we have such additions?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":169,"Q_Id":61774546,"Users Score":1,"Answer":"it's better to use absolute paths in crontab rather that just python3.\nexample:\n@reboot \/path\/to\/command arg1 arg2\nit should work fine with arguments such as --model\nto find your absolute path to python3 you can run which python3 and use that","Q_Score":0,"Tags":"python,nvidia-jetson","A_Id":61774949,"CreationDate":"2020-05-13T12:22:00.000","Title":"How do I run Python scripts automatically on Jetson TX2?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"There is a bit of Matlab code id like to automate with an existing Python Project (through their supplied API which only runs on python v3.4 for my particular Matlab version). The Project im trying to build it into uses python 3.6.\nIs there a way in which a Python 3.6 process can call a Python 3.4 process and intercommunicate with it in a relatively non hacky way?","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":46,"Q_Id":61779481,"Users Score":-1,"Answer":"If you don't need Python 3.6, you can just downgrade your version to match the 3.4 needed by Matlab. Other parts of the Python project might be affected though too, but this depends on how big the existing project is and what it's doing.","Q_Score":0,"Tags":"python,matlab-engine","A_Id":68492750,"CreationDate":"2020-05-13T16:08:00.000","Title":"Python 3.6 <-> Python 3.4 intercommunication","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Mid-last year bitbucket released support for automated aws lambda deployments. However, it seems that it only works for the most rudimentary of use cases.\nMy use case:\n1) My lambda functions are too big to update the lambda function directly with a zip, I need to upload that zip to an s3 bucket first and then update the lambda function\n2) I require quite a few python dependencies (numpy pandas etc) that need to be compiled on an awslinux docker image for them to work on lambda.\nHow are others managing automated deployment from bitbucket to aws lambda with a similar use case?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":113,"Q_Id":61782640,"Users Score":0,"Answer":"I would suggest taking a look at the Serverless Framework. It has a CLI tool that allows you to compose an entire Serverless service by configuring various managed services and Lambda together and then easily deploy with a single command: serverless deploy. This can then be used in something BitBucket Pipelines to automate deployment when changes to configuration have been made. \nAlternatively, I know the Serverless Framework has a CI\/CD feature built into their Serverless Framework Pro dashboard that supports GitHub and will soon support BitBucket as well. \nIf you need some help getting started they have a tone of learning materials and documentation at serverless.com","Q_Score":0,"Tags":"python,deployment,aws-lambda,bitbucket-pipelines,docker-image","A_Id":61790744,"CreationDate":"2020-05-13T18:54:00.000","Title":"Bitbucket deployments no support for s3-based lambda functions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python bot which I'm hosting on digital ocean. \nRight now to run it persistently I'm using virtual terminal screen and I see that this way is far from stable. \nHow I can schedule my bot script to run forever and being re-run if it crashes ? \nAnd also how I can schedule some other python scripts to run once in an hour ?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1287,"Q_Id":61792661,"Users Score":1,"Answer":"You can use crontab to schedule process.\nTo run hourly, you can use like this\n\n0 * * * * \/my\/program\/path\n\n(minute, hour, day of month, month, day of week)","Q_Score":1,"Tags":"python,ubuntu,telegram-bot","A_Id":61793989,"CreationDate":"2020-05-14T08:26:00.000","Title":"Run Python script persistently on server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"A lot of the languages I know of (like C++, C, Rust, etc.) print multiple error messages at a time. Then why does python print only one error message?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":324,"Q_Id":61808721,"Users Score":0,"Answer":"Difficult to answer the exact why. I cannot look into the head of the developers of the C-python, jython, pypy or others.\nMany errors will only be seen at run time as python is an interpreted language without strict typing.\nHowever each file is compiled to byte code if there is no syntax error. \nSo for syntax errors I cannot give you the reason, as it should have been technically possible. However I never had issues with this as I use tools like pylint or flake8 to check the code for me.\nThese tools can detect multiple errors and give a lot of warnings about coding style as well.\nSo I cannot tell you the why, but only what to do to get multiple errors in one go.\nThese tools can be configured to just display certain kinds of errors.\nto install one or the other tool, just type:\npip install flake8 or pip install pylint\nThen type just flake8 or pylint in the directory where all your code is located\nor type flake8 or pylint to check just one file.\nPlease note, that many IDEs like for example Microsoft Visual Studio Code, Pycharm, and others can be configured to run these tools automatically for you and signal any issues even before you execute your code.","Q_Score":1,"Tags":"python,error-messaging","A_Id":61809008,"CreationDate":"2020-05-14T22:49:00.000","Title":"Why does python print only one error message?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I 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","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":85,"Q_Id":61842467,"Users Score":0,"Answer":"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.","Q_Score":1,"Tags":"python","A_Id":61842486,"CreationDate":"2020-05-16T19:30:00.000","Title":"How do i run a python project nonstop ( even when i close the computer )","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to programming and learned a little bit of Python in the previous two weeks and wrote an automation script that scrapes Categories and articles in each category from a website. Now I want to test that script on my WordPress blog and post articles in their respective categories in the WordPress blog. Can someone direct me to any thorough guide to executing this process? I have done some research on this but there is very little information available on the internet.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":55,"Q_Id":61846902,"Users Score":1,"Answer":"The best way is to write a php code (in your site) where you will upload the json file. the script will then save data to your database .Modify the python script to save the scraped data in json(many languages easily support it + has more usage and is faster) then upload it to the php file.From database you can display your data","Q_Score":0,"Tags":"python,php,wordpress,web-scraping","A_Id":61847623,"CreationDate":"2020-05-17T04:14:00.000","Title":"Can I post Python scraped articles to my wordpress site using XML-RPC?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've made some changes directly on the code located in the PythonAnywhere files. In this way, some of them are a little bit different from the reppository GitHub files. \nAssuming the PyhonAnywhere files are correct, what is the best way to 'copy' them and move to the GitHub?\nThank you!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":118,"Q_Id":61847295,"Users Score":2,"Answer":"If your PythonAnywhere project already connected to GitHub:\n\nRun Bash console on PythonAnywhere\nMove to directory with your repository\nMake git push","Q_Score":1,"Tags":"python,django,pythonanywhere","A_Id":61848084,"CreationDate":"2020-05-17T05:13:00.000","Title":"Modifications PythonAnywhere -> GitHub","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a maven project that has its source file in JAVA. I had to add some functionality in the project through some already written code. But these new files were written in PYTHON. Hence I decided to make a shell script that can run both the java and python files with desired args. But since my java source files are in the maven project, I am not able to write a shell script without exploiting the structure of the maven project.\nSo, how can I run the above files without ruining the structure of my maven project?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":155,"Q_Id":61873458,"Users Score":0,"Answer":"As Andersen mentioned that Maven can compile and execute .java files, it means it is only specific to java. For python files, you need setup.py to build python based project. You can not directly call a function written in Python from Java class. Now coming back to your requirements, I can think that you have to build separately java project using Maven with the command mvn clean install and you have to run setup.py if available in python project. Since you cannot call a python function from java class, you have to create an exe file in python using pyinstaller or using py2exe and you invoke the exe file from java. The above I mentioned in one of the approaches. Another approach is to rewrite the python code in java and build using maven. This will be the good approach based upon the requirement. Besides, if you are interested to build java project using Maven and you want to build python project, you can write a .bat file.","Q_Score":0,"Tags":"java,python,shell,maven","A_Id":61873953,"CreationDate":"2020-05-18T15:41:00.000","Title":"Running a maven project and a python file through shell script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am trying to deploy a simple user bot on Google App Engine Flexible Environment running python3.7, but I get the following error. Can anyone help me with suggestions of solving this?\n\"File \"\/env\/lib\/python3.7\/site-packages\/telethon\/client\/auth.py\", line 20, in phone: typing.Callable[[], str] = lambda: input('Please enter your phone (or bot token): '), EOFError: EOF when reading a line\"\nThank you for your time","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":780,"Q_Id":61884537,"Users Score":0,"Answer":"Telethon (obviously) requires you to login and make a normal user session on your account, which natively requires you to input your number when asked and enter the code received but since Google App engine doesn't allow input as @Sashidhar mentioned, depending on your userbot implementation, you can try using the userbot.session method for authentication, it can be generated locally and placed in the Google App Engine.","Q_Score":0,"Tags":"google-app-engine-python,telethon","A_Id":62506639,"CreationDate":"2020-05-19T06:25:00.000","Title":"Hosting a Telethon User BOT on google-app-engine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am looking for an entrypoint in DeepSecurity 12 to launch malware scan \"On Demand\".\nI only found a way to do it by creating a schedule task, but it is not conveniant for my needs.\nThanks a lot in advance guys,\nCheers !","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":68,"Q_Id":61910052,"Users Score":0,"Answer":"To the best of my knowledge, you do need to use the Scheduled Task API to launch a malware scan on demand. But do note that you can set the \"run now\" field of a scheduled task (new or existing) to \"true\" to trigger an immediate scan, which makes it more convenient.\nCheers,\nMorgan\nP.S. I work in R&D for Trend Micro.","Q_Score":0,"Tags":"python,api,deepsecurity","A_Id":61917501,"CreationDate":"2020-05-20T09:50:00.000","Title":"Is there an API entrypoint to launch malware scan immediately without scheduling it (On Demand) in DeepSecurity 12?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have to set up a ssh connection using python. I am using the pexpect module to which I need to pass user credentials.\nI keep my code in a Git repo. How can I handle the password?\nShould I - \n\nEncode it with baseurl64 or\nKeep it in the Jenkins password manager?\n\nWhat are the best standards you follow?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":70,"Q_Id":61944947,"Users Score":3,"Answer":"You should not store secrets unencrypted in a Git repository. Anyone who obtains a copy of that repository can get access to those secrets. Even if the repository is private, sometimes unauthorized users get access to repositories, and you definitely want to limit the possible damage.\nBase64-encoding secrets does not hide them, so you should not use that option. The best way to set up an SSH connection would be to generate a key without a passphrase and store it in your CI secret store, and then in your CI job saving it to a temporary file and using it with ssh -i.\nIf that's not possible, you can use a password with your pyexpect option and store that in your CI secret store.","Q_Score":1,"Tags":"python,python-3.x,git,python-2.7,github","A_Id":61945057,"CreationDate":"2020-05-21T22:38:00.000","Title":"How to handle application password in Git repo","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I would like to measure the coverage of my Python code which gets executed in the production system.\nI want an answer to this question:\n\nWhich lines get executed often (hot spots) and which lines are never used (dead code)?\n\nOf course this must not slow down my production site.\nI am not talking about measuring the coverage of tests.","AnswerCount":3,"Available Count":1,"Score":-0.1325487884,"is_accepted":false,"ViewCount":365,"Q_Id":61951275,"Users Score":-2,"Answer":"Maybe make a text file and through your every program method just append some text referenced to it like \"Method one executed\". Run the web application like 10 times thoroughly as a viewer would and after this make a python program that reads the file and counts a specific parts of it or maybe even a pattern and adds it to a variable and outputs the variables.","Q_Score":5,"Tags":"python,code-coverage,performance-testing","A_Id":61951412,"CreationDate":"2020-05-22T08:56:00.000","Title":"How can I measure the coverage (in production system)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Im creating a email system and discovered that I need to turn on access from less secure apps.\nIve heard that this can be dangerous to turn on and was wondering if there was a way to connect without turning it on?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":114,"Q_Id":61953926,"Users Score":0,"Answer":"Nope, no way to use smtp without enabling less secure apps. Gmail sends you an alert every time there is a new login, including on less secure apps, so as long as you monitor that there's really no need to worry.","Q_Score":0,"Tags":"python,python-3.x,email,smtp,smtplib","A_Id":62186583,"CreationDate":"2020-05-22T11:25:00.000","Title":"Workaround for \"access from less secure apps\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running some simulations in Python on my laptop, for my master degree project, and recently discovered that my desktop computer has almost the same performance of my laptop, when performing the same exact code. The problem is that my laptop has an i7 processor, while the desktop computer an i3. More specifically:\nLaptop: i7-5500U @2.40 GHz (64bit, dual core)\nDesktop: i3-4150 @3.50 GHz (32bit, one core)\nI am not an expert on computer science, neither I study it, and this is quite surprising to me. I know that the number of cores should not affect the performance, since python only uses one, but does it really all rely on clock frequency? And if yes, what are the advantages of having an i7 with such clock frequency? Is there some other data I am missing? What data one has to take under consideration to forecast computer's performance?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":175,"Q_Id":61969577,"Users Score":0,"Answer":"There are really too many factors in determining why your performance is like that. Consider:\n\nIs your program memory-bound or calculation-bound?\nDoes your code really use multiple cores?\nIs your program slowed down by disk access?\nAre you using different language versions or performance settings?\n\nThere are really many factors like these; some of them are difficult to answer and impossible to guess.\nYou could try profiling this if important enough.","Q_Score":0,"Tags":"python,performance,processor","A_Id":61970421,"CreationDate":"2020-05-23T08:51:00.000","Title":"Comparing python performance from hardware specifics","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I apologize if this is a naive question as I'm a learning developer. I'm trying to come up a project to work on in the summer to build my portfolio as a Python developer and as of right now I'm in the planning stages and just want to know if I'm on the right track.\nBut without going into the specifics, I essentially want to get the meta data from one YouTube video every hour from the time it was uploaded and the current time and make a time vs views\/hour plot using the YouTube API and display it on a website\nI've looked into webscrapers, but from my understanding, those scripts can only take one instance at a time.\nWould I need to learn PHP as well in order to store the data from each instance the API is called? Or is there a way to do what I'm thinking of natively in Python?\nIf so would I need to know it extensively?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":126,"Q_Id":61973637,"Users Score":0,"Answer":"Part 1 - YouTube API only returns a total viewCount. You won't be able to ask for a video's viewCount from 6 hours ago, for example. However, you can call the API every hour for the video viewCount and store the numbers yourself going forward.\nPart 2 - PHP vs Python doesn't matter. You can store data with either code.","Q_Score":0,"Tags":"python,php,youtube,youtube-api,youtube-data-api","A_Id":61988971,"CreationDate":"2020-05-23T14:35:00.000","Title":"Trying to use YouTube API to check views of a video every hour. Can Python be used to store the data or is PHP needed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working with the librosa library, and\nI would like to know what information is returned by the librosa.load function when I read a audio (.wav) file.\nIs it the instantaneous sound pressure in pa, or the just the instantaneous amplitude of the sound signal with no units?","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":9943,"Q_Id":61986490,"Users Score":3,"Answer":"To add to the above answer, you may also use librosa function\nlibrosa.get_duration(y,sr) to get the duration of the audio file in seconds.\nOr you may use len(y)\/sr to get the audio file duration in seconds","Q_Score":5,"Tags":"python,signal-processing,librosa,audio-analysis","A_Id":63709994,"CreationDate":"2020-05-24T13:12:00.000","Title":"What does librosa.load return?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"The question says it all. If I have a cronjob that runs a python script, what will the value of __name__ be?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":60,"Q_Id":61989210,"Users Score":2,"Answer":"The same as if you run it directly from your shell. There is no difference between running it from your shell or from the crontab.","Q_Score":0,"Tags":"python,cron,cron-task","A_Id":61989247,"CreationDate":"2020-05-24T16:48:00.000","Title":"What will __name__ be when python script run from crontab?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I need to develope a python cgi script for a server run on Windows+IIS. The cgi script is run from a web page with Windows authentification. It means the script is run under different users from Windows active directory. \nI need to use login\/passwords in the script and see no idea how to store the passwords securely, because keyring stores data for a certain user only. Is there a way how to access password data from keyring for all active OS users?\nI also tried to use os.environ variables, but they are stored for one web session only.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":138,"Q_Id":62005012,"Users Score":1,"Answer":"The only thing I can think of here is to run your script as a service account (generic AD account that is used just for this service) instead of using windows authentication. Then you can log into the server as that service account and setup the Microsoft Credential Manager credentials that way.","Q_Score":0,"Tags":"python,environment-variables,python-keyring","A_Id":63603194,"CreationDate":"2020-05-25T14:54:00.000","Title":"Secure password store for Python CGI (Windows+IIS+Windows authentification)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm having trouble getting the VS Code PyTest code runner to work the way I'd like. It seems pytest options may be an all-or-nothing situation.\nIs there any way to run different sets of PyTest options easily in the VS Code interface?\nFor example:\n\nBy default, run all tests not marked with @pytest.mark.slow.\n\nThis can be done with the argument -m \"not slow\"\nBut, if I put that in a pytest.ini file, then it will never run any tests marked slow, even if I pick that particular test in the interface and try to run it. The resulting output is collected 1 item... 1 item deselected.\n\nRun sometimes with coverage enabled, and sometimes without.\n\nThe only way I can see to do this is to run PyTest from the command line, which then loses the benefit of auto-discovery, running\/debugging individual tests from the in-line interface, etc.\nWhat am I missing?\nNote: Currently using VS Code 1.45.1, Python 3.7.6, and PyTest 5.3.5","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":838,"Q_Id":62012775,"Users Score":3,"Answer":"You're not missing anything. There currently isn't a way to provide per-execution arguments to get the integration you want with the Test Explorer.","Q_Score":1,"Tags":"python,visual-studio-code,pytest","A_Id":62053867,"CreationDate":"2020-05-26T00:24:00.000","Title":"How to run different Pytest arguments or marks from VS Code test runner interface?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to be able to run a python script like a keyboard macro, just by pressing a certain combination of buttons. Is it possible, if yes, how?","AnswerCount":4,"Available Count":3,"Score":-0.0996679946,"is_accepted":false,"ViewCount":7326,"Q_Id":62014315,"Users Score":-2,"Answer":"you click f5 if you have windows","Q_Score":5,"Tags":"python,autohotkey","A_Id":62014390,"CreationDate":"2020-05-26T03:44:00.000","Title":"Can I run a python script from a keyboard shortcut?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to be able to run a python script like a keyboard macro, just by pressing a certain combination of buttons. Is it possible, if yes, how?","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":7326,"Q_Id":62014315,"Users Score":0,"Answer":"Yes, if you're on a Mac, you can create a 'quick action' in Automate using an apple script to tell Terminal to do something like 'tell application \"Terminal\" to do script \"python myscript.py\"'. Then, you can go into your keyboard shortcut preferences and add a hotkey to the action.","Q_Score":5,"Tags":"python,autohotkey","A_Id":69284433,"CreationDate":"2020-05-26T03:44:00.000","Title":"Can I run a python script from a keyboard shortcut?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to be able to run a python script like a keyboard macro, just by pressing a certain combination of buttons. Is it possible, if yes, how?","AnswerCount":4,"Available Count":3,"Score":-0.049958375,"is_accepted":false,"ViewCount":7326,"Q_Id":62014315,"Users Score":-1,"Answer":"Try Ctrl + F5. It worked for me.","Q_Score":5,"Tags":"python,autohotkey","A_Id":66092644,"CreationDate":"2020-05-26T03:44:00.000","Title":"Can I run a python script from a keyboard shortcut?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have the following setup:\n\nWindows 10\npython installed via Anaconda\nVirtual environment setup via Anaconda for running and testing my project with pytest\ngit version control via MINGW \n\nNow I'd like to set a githook that runs all my tests before I push. I have the following problem: I can't activate my virtual environment within the githook.\nI tried to activate my anaconda env in the githook script but I can't get it to work. activate as command is not available and calling the whole path ..\/Anaconda3\/Scripts\/activate.bat does nothing.\nI also tried to use python-githooks to configure the hook for me, but this doesn't seem to work in Windows (it can't read PWD from the environment...)\nI'm gratefull for any suggestions.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":149,"Q_Id":62016261,"Users Score":0,"Answer":"The solution was to create a .bat-File at the root of the git repository, with:\ncall C:\\...\\Anaconda3\\Scripts\\activate.bat\ncall activate fs_env\npytest\nand to call this file within the pre-push file in .git\/hooks with:\n.\/runtests.bat","Q_Score":3,"Tags":"python,windows,git,githooks,anaconda3","A_Id":62023870,"CreationDate":"2020-05-26T06:54:00.000","Title":"pytest githook on Windows with Anaconda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been learning HTML and CSS for about a year, I\u2019m a massive noob at Python and I would like someone to clear some things up for me if possible.\nI'm wanting to use a browser extension to automate some work tasks, there's a few good ones that work with JS but I'd like to focus on Python.\nI understand that python would require a interpreter to work, I've ran some basic scripts on my PC but I don't understand how you'd execute scrips externally on the web.\nDo web browsers have a built in interpreter?\nAre there such extensions that exist?\nAnd if so do they have interpreters built in?\nPython is a brand new concept to me and I apologise if this is a stupid question. I aim to get the basics down first and then pick up a Raspberry Pi for some project work.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":43,"Q_Id":62023510,"Users Score":1,"Answer":"Do web browsers have a built in interpreter?\n\nThey have a JavaScript console in dev tools instead of python","Q_Score":0,"Tags":"python,web,browser,automation,scripting","A_Id":68939635,"CreationDate":"2020-05-26T13:42:00.000","Title":"Noob Question About Python Web Automation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am running an ongoing command on a Windows Anaconda Powershell terminal to scrape Twitter data. I would like to be able to receive a notification if the code drops, preferably either email or SMS message. I've been able to find some packages that do this in OS but not Windows. Any ideas on how this could be set up?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":40,"Q_Id":62026273,"Users Score":0,"Answer":"you can create a python script which call your code inside it and get notified using knockknock.","Q_Score":0,"Tags":"python,windows,terminal,conda","A_Id":62057477,"CreationDate":"2020-05-26T15:54:00.000","Title":"Terminal command to notify if code has stopped running","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new to this, so I apologize if my question is uneducated:\nI have a USB device for which I know the ProductID and VendorID. From what I understand, it should be a HID device which sends a serial stream to my computer. I was to write a script in python in order to read that serial stream, but I am getting nowhere. Is there a way for Python's serial library to find a device from a PID and VID?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":11297,"Q_Id":62031686,"Users Score":0,"Answer":"You can also just do an 'ls \/dev\/tty*.*' and find the USB device rather than go through to voluminous amount of garbage dumped by 'ioreg'.","Q_Score":1,"Tags":"python,pyserial,libusb,usbserial","A_Id":72361824,"CreationDate":"2020-05-26T21:25:00.000","Title":"Reading a serial signal from a USB port with Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have started to learn text mining and natural language processing using R and Python. Recently, I was trying to perform some basics tasks such as: (1) the most frequent terms used within a set of documents (email documents) and (2) clustering. The \"problem\" comes with some repetitive paragraphs, such as disclaimers, signatures on emails, etc; because they are adding some noise to my results.... Is there a way to identify boilerplate or repetitive paragraphs within the set of documents? In order to remove them during the preprocessing tasks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":100,"Q_Id":62033609,"Users Score":1,"Answer":"Measuring the similarity of documents is a huge topic, and an active area of research. There are many ways of identifying boilerplate, none of them perfect. \nBut check out the wydyr package functions. Break documents into paragraph-size sections (or smaller.) Use pairwise_count and pairwise_cor to get similarity measures between, e.g. the opening and closing sections of documents.\nAlso, get a copy of Text Mining with R by Silge and Robinson; pay attention to Chapter 4.","Q_Score":0,"Tags":"python,r,nlp,boilerplate","A_Id":62034429,"CreationDate":"2020-05-27T00:33:00.000","Title":"Identify duplicated paragraphs (boilerplate) within several email documents","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I started a script that sends me an email if a specific condition occours and its running from vps, but since I've not yet received any emails, I'm wondering if the script is still running. I also forgot the name of the \"xxxxxx.py\" file thats running. \nWhat can I do??","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":343,"Q_Id":62070280,"Users Score":0,"Answer":"If your VPS is linux-based with a ssh server listening, you should be able to connect to it, opening a terminal. After that You can try using the ps ax or top or htop command to display all processes running.\nYou can then use a pipe to filter out the word \"py\" :\nps ax | grep \"py\"","Q_Score":1,"Tags":"python,pandas,server,putty,vps","A_Id":62070408,"CreationDate":"2020-05-28T16:54:00.000","Title":"How to check if a script is still running in my server?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python script set to go off every minute in my crontab file:\n*\/1 * * * * ~\/ticker.py\nI've set permissions of ticker.py with chmod +x ticker.py to make the file executable.\nI am still getting \/bin\/sh: \/home\/ec2-user\/ticker.py: Permission denied in my \/var\/spool\/mail\/ec2-user mail file.\nI'm using an Amazon Linux EC2 instance. I appreciate any help with this. Thank you","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":424,"Q_Id":62071214,"Users Score":0,"Answer":"Found out the fix. Super simple but unsure why the #!\/usr\/bin\/env shebang didn't fix it in the first place.\nI replaced *\/1 * * * * ~\/ticker.py with *\/1 * * * * python ~\/ticker.py.\nThanks for the input.","Q_Score":0,"Tags":"python,unix,cron","A_Id":62075429,"CreationDate":"2020-05-28T17:47:00.000","Title":"Getting crontab \"permission denied\" on Python script even though it has executable permissions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am working on a web app in which some content is generated in the form of text (and will soon include images as well). I want to add a share button which will allow the user to add this content to their Instagram story. \nSo the flow of this is going to be:\n\n\nUser does something on the website\nThe website generates some content based on user input\nUser clicks on \"Share on Instagram\" and posts it on his\/her story \n\n\nIs there a way to do this using Javascript or an API call like the Twitter share option directly from the HTML ?\nI am using Python on the backend (Flask) and JS on the frontend","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":7688,"Q_Id":62071327,"Users Score":10,"Answer":"OK, lets make this simple.\nThe direct answer as found on the official Facebook developers page is no. You can't trigger an API to create an instagram story, as for now only the \"read-mode\" is supported through API.\nBut as most things in life you can hack your way arround. Let's then copy a funcional method.\nYou create a button that says, \"share on your instagram stories\" and here's what it is gonna do:\n\nTrigger a function on the back-end that creates a screenshot\/image or a video of the content you want to share\nSend that content to the user so it's the last content they have in the gallery\nTrigger the open story camera in Instagram app with this link: instagram:\/\/story-camera. (the last content they have will be the content u sent and will be the first thing they see for posting a story)\n\nIt goes without saying that this will work when the website is opened in a phone and not in a desktop browser as in desktop you can't post stories.\nPS: I'm sure there is a way to send that content directly to the editing in the stories, so you don't have to select the image you sent to the client, but I didn't figure that out yet. Hope this works for you, cheers.","Q_Score":8,"Tags":"javascript,python,html,api,instagram","A_Id":65893635,"CreationDate":"2020-05-28T17:53:00.000","Title":"Share content of a webpage to Instagram story","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I need to visualize XGBoost's effects and I want to extract a single tree from it that has the highest accuracy on the test set. Is is built in in any way, or do I have to test by hand all of the trees? I'm using the Python version.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":63,"Q_Id":62071417,"Users Score":0,"Answer":"If you'd like to inspect individual trees in a tree ensemble model, then you should consider switching from a boosting-type algorithm (eg. XGBoost, LightGBM, GBM) to a bagging-type algorithm (eg. Random Forest).\nBy definition, the bagging algorithm grows trees in decreasing \"smartness\" order. In this case, the highest accuracy tree model is probably the first one in the XGBoost tree ensemble.","Q_Score":0,"Tags":"python,decision-tree,xgboost","A_Id":62078974,"CreationDate":"2020-05-28T17:58:00.000","Title":"XGBoost - select tree with the highest accuracy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have had scores of servers running a Python script via Apache and mod_wsgi for years now. I recently am building on RHEL7 and have run into an issue where my Python script calling R procedures are bombing out only via Apache stating it cannot find my pip installed Python modules in my Apache log.\nimport pandas as pd\nModuleNotFoundError: No module named 'pandas'\nThis seems to only affect modules getting installed in \/usr\/local\/lib64\/python3.6\/site-packages which is where my custom modules are being installed with pip.\nEven if I append it, it ignores it.\nsys.path.append(r'\/usr\/local\/lib64\/python3.6\/site-packages')\nI manually built mod_wsgi from source.\nI'm ready to abandon mod_wsgi because I have to get my application deployed for my users.\nAny help is greatly appreciated.\nThanks,\nLou","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":169,"Q_Id":62078449,"Users Score":0,"Answer":"It was a file priv issue with \/usr\/lib64\/python3.6 and \/usr\/lib\/python3.6 directories and their child directories. Root ran fine, but running as Apache had no access. You had to chmod-R 755 on both directory trees. Worked fine with Apache after that. Sometimes it\u2019s the simple things we forget to check first.","Q_Score":0,"Tags":"python,python-3.x,apache,mod-wsgi","A_Id":62274064,"CreationDate":"2020-05-29T03:56:00.000","Title":"Running Python in mod_wsgi in Apache Cannot See Python Modules in \/usr\/local\/lib64\/python3.6\/site-packages","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to get the list of telegram groups(name) which I am a part of. Like a text file or something else. How can I do that?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":8289,"Q_Id":62098696,"Users Score":1,"Answer":"Another way - use web-version of the telegram and parse HTML. Here are steps:\n\ncreate folder with only groups;\ngo to web-version, open this folder;\nrun code copy($$(\".dialog-title .peer-title\").map(function(e){return e.textContent})) in console, it will copy title of groups on screen into clipboard;\nif you have a lot groups on several screens, list groups below and make previous step again;\njoin all the groups into one big list;\nprofit!","Q_Score":3,"Tags":"telegram,python-telegram-bot","A_Id":69032852,"CreationDate":"2020-05-30T06:29:00.000","Title":"How to get a list of all the telegram groups I have joined?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am creating a script that uses \n\npython 3.7.3 \npyserial 3.4 \npytest 5.4.2\n\nThe scripts run on a windows 10 machines that communicates with another device. On some occasions I see that the string I pass into serial module write method is either transmitted with a character missing or on rare occasions with one of the characters substituted. I have checked the baud rate to make sure the windows machine and the device are using the same baud rate, and have found the baud rates and all other serial port settings to be the same.\nI have drilled into the pyserial module into the file serialwin32.py in the write method. I can see that the string I pass in definitely is passed into this function.\nWhen I use Teraterm on the windows machine I do not incur this problem.\nAlso when I run the same python scripts on an ubuntu machine the problem does not occur.\nAny help on where the issue may be will be appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":92,"Q_Id":62126792,"Users Score":0,"Answer":"What baud rate are you using? Can it be increased? If not and it works on TeraTerm but not in Python, as you noted, it could be a flow control issue that is resolved by having your code mirror the flow control used in TeraTerm. If none of that pans out, could you describe in more detail the test you are doing in TeraTerm? When using TeraTerm, are you typing in the data or pasting it? Make sure to try pasting data (or maybe create a TeraTerm macro) that really hammers data through the interface so that you can be sure that TeraTerm really is working and not masking the same issue as the script.","Q_Score":0,"Tags":"python,windows,pyserial","A_Id":69170806,"CreationDate":"2020-06-01T06:27:00.000","Title":"Python Serial Port omitting characters in transmission","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I ran the revert command to undo my previous commit but then realized I had made a mistake. \nHow can I undo my revert action and restore to my previously committed state?\nExample: \n(1) In my project, I have two files A and B and then I committed the changes and push the changes to GitHub.\n(2) I added file C and committed changes but didn't push the changes to Github.\n(3) I ran the Revert which removed the file C from my project but it was a mistake.\nHow can I undo my last action of Revert to bring back the file C, which was committed and then reverted on my local repo but never pushed to Github?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":226,"Q_Id":62129574,"Users Score":0,"Answer":"'git reflog' to list last few HEADS.\nChoose commit id of the change you wanted.\ngit reset to that commit id.","Q_Score":0,"Tags":"python,git,github","A_Id":62129632,"CreationDate":"2020-06-01T09:49:00.000","Title":"How to undo a revert action to move back to my previous commit in git","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed pywikibot and set up the config as described in the instructions. However when I put \"importpywikibot\" at the top of my script it says \"No module named pywikibot\". Do I have to install pywikibot somewhere special?\nThanks.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":158,"Q_Id":62152681,"Users Score":0,"Answer":"First change \"importpywikibot\" to \"import pywikibot\"\nYou need to create your python file in the \"core\" directory otherwise it will say \"no module named pywikibot\".\nAfter installing pywikibot, you'll find core directory in C=> users=> your username => core\nAnd do it from your cmd prompt. It showed error when I used vs code but worked fine when I run the program in the cmd.","Q_Score":0,"Tags":"python,pywikibot","A_Id":63213503,"CreationDate":"2020-06-02T13:04:00.000","Title":"How to import pywikibot?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How do I enable method autocompletion for discord.py in PyCharm? Until now I've been doing it the hard way by looking at the documentation and I didn't even know that autocomplete for a library existed. So how do I enable it?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1231,"Q_Id":62159638,"Users Score":1,"Answer":"The answer in my case was to first create a new interpreter as a new virtual environment, copy over all of the libraries I needed (there is an option to inherit all of the libraries from the previous interpreter while setting up the new one) and then follow method 3 from above. I hope this helps anyone in the future!","Q_Score":1,"Tags":"python,python-3.x,pycharm,discord,discord.py","A_Id":62162550,"CreationDate":"2020-06-02T19:12:00.000","Title":"How to enable PyCharm autocompletion for imported library (Discord.py)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently making a small hobby project where I use a Raspberry Pi Zero to control a set of RGB LED's.\nI've got a basic python app so far that is built on Flask that allows me to set up a web server so that the LED colours can be set remotely.\nMy main concern is that I'm self-taught as far as programming goes and I don't know squat about security.\nThe plan is essentially to be sending any port 80 traffic to the raspberry pi on my home network and give friends my IP. I may eventually get a domain name to simplify things.\nShould I have any security concerns when I set this up live full-time? I don't know if it's possible to access my private network via the raspberry pi or if I'm just being paranoid.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":199,"Q_Id":62162817,"Users Score":1,"Answer":"You can try putting your Raspberry PI on separate vlan and put your home devices on another vlan. Please note you need a router which supports vlan and configure it in a way that the both vlans cant talk to each other \nAlso, try using HTTPS for your webserver and don't run the webserver process as root user. If you want to go more crazy you can put a firewall.\nThese are generic suggestions for hardening the security for any web app.","Q_Score":1,"Tags":"python,security,flask,raspberry-pi","A_Id":62162893,"CreationDate":"2020-06-02T23:12:00.000","Title":"Raspberry Pi as a web server security","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I know there is a lot of debate within this topic.\nI made some research, I looked into some of the questions here, but none was exactly it.\nI'm developing my app in Django, using Python 3.7 and I'm not looking to convert my app into a single .exe file, actually it wouldn't be reasonable to do so, if even possible.\nHowever, I have seen some apps developed in javascript that use bytenode to compile code to .jsc\nIs there such a thing for python? I know there is .pyc, but for all I know those are just runtime compiled files, not actually a bytecode precompiled script.\nI wanted to protect the source code on some files that can compromise the security of the app. After all, deploying my app means deploying a fully fledged python installation with a web port open and an app that works on it.\nWhat do you think, is there a way to do it, does it even make sense to you?\nThank you","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":83,"Q_Id":62169485,"Users Score":0,"Answer":"The precompiled (.pyc) files are what you are looking for. They contain pre-optimized bytecode that can be run by the interpreter even when the original .py file is absent. \nYou can build the .pyc files directly using python -m py_compile . There is also a more optimized .pyo format that further reduces the file size by removing identifier names and docstrings. You can turn it on by using -OO.\nNote that it might still be possible to decompile the generated bytecode with enough effort, so don't use it as a security measure.","Q_Score":1,"Tags":"python,django","A_Id":62170274,"CreationDate":"2020-06-03T09:30:00.000","Title":"How to compile single python scripts (not to exe)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to retrieve versions of all packages from specific index. I'm trying to sending GET request with \/user\/index\/+api suffix but it not responding nothing intresting. I can't find docs about devpi rest api :( \nHas anyone idea how could I do this?\nBest regards, Matt.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":218,"Q_Id":62194793,"Users Score":2,"Answer":"Simply add header Accept: application\/json - it's working!","Q_Score":2,"Tags":"python,python-3.x,devpi","A_Id":62222635,"CreationDate":"2020-06-04T12:37:00.000","Title":"Devpi REST API - How to retrieve versions of packages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to find out what the best tool is for my project.\nI have a lighttpd server running on a raspberry pi (RPi) and a Python3 module which controls the camera. I need a lot of custom control of the camera, and I need to be able to change modes on the fly. \nI would like to have a python script continuously running which waits for commands from the lighttpd server which will ultimately come from a user interacting with an HTML based webpage through an intranet (no outside connections). \nI have used Flask in the past to control a running script, and I have used FastCGI to execute scripts. I would like to continue using the lighttpd server over rather than switching entirely over to Flask, but I don't know how to interact with the script once it is actually running to execute individual functions. I can't separate them into multiple functions because only one script can control the camera at a time. \nIs the right solution to set up a Flask app and have the lighttpd send requests there, or is there a better tool for this?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":105,"Q_Id":62195974,"Users Score":0,"Answer":"You have several questions merged into one, and some of them are opion based questions as such I am going to avoid answering those. These are the opinion based questions.\n\nI am trying to find out what the best tool is for my project.\nIs the right solution to set up a Flask app and have the lighttpd send requests there\nIs there a better tool for this?\n\nThe reason I point this out is not because your question isnn't valid but because often times questions like these will get flagged and\/or closed. Take a look at this for future referece.\nNow to answer this question: \n\" I don't know how to interact with the script once it is actually running to execute individual functions\"\nTry doing it this way:\n\nModify your script to use threads and\/or processes.\nYou will have for example a continously running thread which would be the camera.\nYou would have another non blocking thread listening to IO commands.\nYour IO commands would be comming through command line arguments.\nYour IO thread upon recieving an IO command would redirect your running camera thread to a specific function as needed.\n\nHope that helps and good luck!!","Q_Score":0,"Tags":"python,flask,lighttpd,pi,picamera","A_Id":62197672,"CreationDate":"2020-06-04T13:32:00.000","Title":"Use HTML interface to control a running python script on a lighttpd server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am trying to find out what the best tool is for my project.\nI have a lighttpd server running on a raspberry pi (RPi) and a Python3 module which controls the camera. I need a lot of custom control of the camera, and I need to be able to change modes on the fly. \nI would like to have a python script continuously running which waits for commands from the lighttpd server which will ultimately come from a user interacting with an HTML based webpage through an intranet (no outside connections). \nI have used Flask in the past to control a running script, and I have used FastCGI to execute scripts. I would like to continue using the lighttpd server over rather than switching entirely over to Flask, but I don't know how to interact with the script once it is actually running to execute individual functions. I can't separate them into multiple functions because only one script can control the camera at a time. \nIs the right solution to set up a Flask app and have the lighttpd send requests there, or is there a better tool for this?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":105,"Q_Id":62195974,"Users Score":1,"Answer":"I have used Flask in the past to control a running script, and I have used FastCGI to execute scripts.\n\nGiven your experience, one solution is to do what you know. lighttpd can execute your script via FastCGI. Python3 supports FastCGI with Flask (or other frameworks). A python3 app which serially processes requests will have one process issuing commands to the camera.\n\nI would like to continue using the lighttpd server over rather than switching entirely over to Flask, but I don't know how to interact with the script once it is actually running to execute individual functions.\n\nConfigure your Flask app to run as a FastCGI app instead of as a standalone webserver.","Q_Score":0,"Tags":"python,flask,lighttpd,pi,picamera","A_Id":62200945,"CreationDate":"2020-06-04T13:32:00.000","Title":"Use HTML interface to control a running python script on a lighttpd server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using the pho MQTT client library successfully to connect to AWS. After the mqtt client is created, providing the necessary keys and certificates is done with a call to client.tls_set() This method requires file paths to root certificate, own certificate and private key file.\nAll is well and life is good except that I now need to provide this code to external contractors whom should not have direct access to these cert and key files. The contractors have a mix of PC and macOS systems. On macOS we have keychain I am familiar with but do not know how to approach this with python - examples\/library references would be great. On the PC I have no idea which is the prevalent mechanism to solve this.\nTo add to this, I have no control over the contractor PCs\/Macs - i.e., I have no ability to revoke an item in their keychain. How do I solve this?\nSorry for being such a noob in security aspects. No need to provide complete examples, just references to articles to read, courses to follow and keywords to search would be great - though code examples will be happily accepted also of course.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":22,"Q_Id":62201091,"Users Score":1,"Answer":"Short answer: you don't.\nLonger answer:\nIf you want them to be able connect then you have no choice but to give them the cert\/private key that identifies that device\/user.\nThe control you have is issue each contractor with their own unique key\/cert and if you believe key\/cert has been miss used, revoke the cert at the CA and have the broker check the revocation list.\nYou can protect the private key with a password, but again you have to either include this in the code or give it to the contractor.\nEven if the contractors were using a device with a hardware keystore (secure element) that you could securely store the private key in, all that would do is stop the user from extracting the key and moving it to a different machine, they would still be able to make use of the private key for what ever they want on that machine.\nThe best mitigation is to make sure the certificate has a short life and control renewing the certificate, this means if a certificate is leaked then it will stop working quickly even if you don't notice and explicitly revoke it.","Q_Score":0,"Tags":"python,security,mqtt,tls1.2","A_Id":62203164,"CreationDate":"2020-06-04T17:52:00.000","Title":"How to prevent direct access to cert files when connecting MQTT client with Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How do you decide on denoting a member function in C++ and\/or python\nas static?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":51,"Q_Id":62203286,"Users Score":0,"Answer":"When your member function doesn't use any of the member variables, and doesn't call any other nonstatic member functions (of the same class), it can be static itself.","Q_Score":0,"Tags":"python,c++","A_Id":62203381,"CreationDate":"2020-06-04T20:08:00.000","Title":"How do you decide on denoting a member function in C++ and\/or python as static?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to string together lambda functions. The first lambda function is on a 30 minute timer to scrape and put the data in a S3 bucket, the next lambda function retrieves and parses that data and puts it in a seperate S3 bucket, and the last function performs analysis on that data and sends the user (in this case myself) an email of the results via pythons smtplib module.\nInstead of having the last two lambda functions running on timers, I want the second function to be triggered when the first function is done, and the last function to be triggered when the second function is done. As well as, deleting the two folders in the first S3 bucket and the contents in the second S3 bucket to save on memory and processing time.\nIs there a way to do this totally in the AWS web interface rather than rewrite the python code I already have?","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":732,"Q_Id":62220738,"Users Score":0,"Answer":"All the answers here work. To summarize, you could:\n\nTrigger the lambdas when a file arrives in an S3 bucket\nUse Step Functions co-ordinate the 3 lambda functions, one after another\nUse Lambda destinations (on success) to orchestrate the workflow\n\nAll of these accomplish what you wish for, and here's some extra info.\n\nFor the S3 option you can specify which events trigger the lambda (e.g. PutObject), and even the prefix and suffix of the file(s).\nFor Step functions, this is my favorite options. It's an expensive option (typically 5-10x more than lambda) but, it actually orchestrate everything, and the view you get from the console is amazing. It's very easy to triage issues if they occur.\nFor Lambda destinations, you can also set a onFailure mode, so that the you can get alerted if the function fails. onSuccess will of course lead to the next function in question.\n\nHope that helps.","Q_Score":2,"Tags":"python,amazon-web-services,amazon-s3,aws-lambda","A_Id":62231258,"CreationDate":"2020-06-05T17:11:00.000","Title":"AWS Lambda function completion triggers another lambda function","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have this weird bug of No module named 'timeout_decorator' when trying to import timeout_decorator. I have timeout-decorator==0.4.1 installed in my virtual environment and I am able to import timeout_decorator in python interpreter. But when I ran pytest test.py, it threw this error. I have pytest version 5.4.2. Anyone has any ideas ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1203,"Q_Id":62226414,"Users Score":0,"Answer":"I think I have some problems with my virtual environment and the module probably did not point to the right system path. It works when the python packages are in the system path.","Q_Score":0,"Tags":"python,timeout,pytest","A_Id":62249288,"CreationDate":"2020-06-06T01:52:00.000","Title":"No module named 'timeout_decorator'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a file structure that looks something like this:\nMaster:\n\nFirst\n\n\ntrain.py\nother1.py\n\nSecond\n\n\ntrain.py\nother2.py\n\nThird\n\n\ntrain.py\nother3.py\n\n\nI want to be able to have one Python script that lives in the Master directory that will do the following when executed:\n\nLoop through all the subdirectories (and their subdirectories if they exist)\nRun every Python script named train.py in each of them, in whatever order necessary\n\nI know how to execute a given python script from another file (given its name), but I want to create a script that will execute whatever train.py scripts it encounters. Because the train.py scripts are subject to being moved around and being duplicated\/deleted, I want to create an adaptable script that will run all those that it finds.\nHow can I do this?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":142,"Q_Id":62239031,"Users Score":1,"Answer":"If you are using Windows you could try running them from a PowerShell script. You can run two python scripts at once with just this:\npython Test1.py\npython Folder\/Test1.py\nAnd then add a loop and or a function that goes searching for the files. Because it's Windows Powershell, you have a lot of power when it comes to the filesystem and controlling Windows in general.","Q_Score":0,"Tags":"python,tensorflow,directory,subdirectory","A_Id":62239246,"CreationDate":"2020-06-06T23:06:00.000","Title":"Running all Python scripts with the same name across many directories","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a file structure that looks something like this:\nMaster:\n\nFirst\n\n\ntrain.py\nother1.py\n\nSecond\n\n\ntrain.py\nother2.py\n\nThird\n\n\ntrain.py\nother3.py\n\n\nI want to be able to have one Python script that lives in the Master directory that will do the following when executed:\n\nLoop through all the subdirectories (and their subdirectories if they exist)\nRun every Python script named train.py in each of them, in whatever order necessary\n\nI know how to execute a given python script from another file (given its name), but I want to create a script that will execute whatever train.py scripts it encounters. Because the train.py scripts are subject to being moved around and being duplicated\/deleted, I want to create an adaptable script that will run all those that it finds.\nHow can I do this?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":142,"Q_Id":62239031,"Users Score":1,"Answer":"Which OS are you using ?\nIf Ubuntu\/CentOS try this combination:\nimport os\n\/\/put this in master and this lists every file in master + subdirectories and then after the pipe greps train.py \ntrain_scripts = os.system(\"find . -type d | grep train.py \") \n\/\/next execute them\npython train_scripts","Q_Score":0,"Tags":"python,tensorflow,directory,subdirectory","A_Id":62239087,"CreationDate":"2020-06-06T23:06:00.000","Title":"Running all Python scripts with the same name across many directories","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have been trying to develop web pages locally (in Windows 10) and running in my local browser (chrome, vivaldi). Right now I have 3 different ways to run simple servers locally: php's built in server, python's http.server module, and vscode's LiveServer. When I run the php server, I can execute php code properly, as one would expect. But calling php urls using the other two, I get a \"Save File\" dialog! Where is that coming from? Instead of a simple \"not found\" I get the dialog. So I have two questions: (1) Why am I getting the save file dialog? (2) Is it possible to process php files using LiveServer or python's http.server module (which I don't expect can ever support php)","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":107,"Q_Id":62240144,"Users Score":1,"Answer":"if the save dialog is being shown it's cause the server can't interpret php code. You have to check these servers configs to check their integration with PHP (if they they can do that).","Q_Score":0,"Tags":"php,visual-studio-code,server,python-server-pages","A_Id":62240208,"CreationDate":"2020-06-07T02:20:00.000","Title":"Why do local test servers open a \"save file\" dialog?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a probably very special question, but I would still be very happy about your help. First things first, I have basic Python and Dart\/Flutter skills. For days I have been trying in vain for a solution to connect a Raspbarry Pi (Python) and a smartphone (Flutter). I want to be able to control an LED using a flutter app, so I have to control the GPIO Pins via a Flutter application. I totally don't care whether the connection is established via Bluetooth or the Internet. I can't find any instructions or a tutorial on the internet, so my question is whether you might have found a good video or blog entry on this topic. I would be very happy if you could write me a link to a good explanation in the answer box. It would be even better if someone of you knows how to connect an Rpi and a smartphone and that person could explain it to me. Many many thanks in advance and greetings","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":422,"Q_Id":62246164,"Users Score":1,"Answer":"Why you don't create a Websocket\/Http_Server in Rpi Python that interacts with the GPIO and in other side create another Websocket\/Http_Client for your flutter mobile app and exchange data between them.","Q_Score":1,"Tags":"python,flutter,dart,bluetooth,raspberry-pi","A_Id":62246296,"CreationDate":"2020-06-07T13:37:00.000","Title":"How can you control the GPIO pins of an Rpi via flutter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any way to see whether a message forwarded to the telegram channel from another channel has been edited (and at what time)? \nVia API or some other tools.\nWebsite version of telegram at web.telegram.org shows what time the forwarded message has been originally posted, but it doesn't display whether that message has been edited afterwards.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1110,"Q_Id":62285883,"Users Score":0,"Answer":"No, that's not possible. When you forward a channel post to any sort of chat on Telegram, the label \"edited\" will be removed.","Q_Score":1,"Tags":"telegram,telegram-bot,python-telegram-bot,telegraf,node-telegram-bot-api","A_Id":64194389,"CreationDate":"2020-06-09T15:15:00.000","Title":"Can I see whether message forwarded to the group has been edited and at what time?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I don't know how it happened, but my sys.path now apparently contains the path to my local Python project directory, let's call that \/home\/me\/my_project. (Ubuntu).\necho $PATH does not contain that path and echo $PYTHONPATH is empty.\nI am currently preparing distribution of the package and playing with setup.py, trying to always work in an virtualenv. Perhaps I messed something up while not having a virtualenv active. Though I trying to re-install using python3 setup.py --record (in case I did an accidental install) fails with insufficient privileges - so I probably didn't accidentally install it into the system python.\nDoes anyone have an idea how to track down how my module path got to the sys.path and how to remove that?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":53,"Q_Id":62292976,"Users Score":0,"Answer":"I had the same problem. I don't have the full understanding of my solution, but here it is nonetheless.\nMy solution\nRemove my package from site-packages\/easy-install.pth\n(An attempt at) explanation\nThe first hurdle is to understand that PYTHONPATH only gets added to sys.path, but is not necessarily equal to it. We are thus after what adds the package into sys.path.\nThe variable sys.path is defined by site.py.\nOne of the things site.py does is automatically add packages from site-packages into sys.path.\nIn my case, I incorrectly installed my package as a site-package, causing it to get added to easy-install.pth in site-packages and thus its path into sys.path.","Q_Score":0,"Tags":"python-3.x,setuptools","A_Id":64670582,"CreationDate":"2020-06-09T22:36:00.000","Title":"Project directory accidentally in sys.path - how to remove it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am supposed to run following command for an assignment to analyze the functions in rsa.py\npython -m cProfile -s time rsa.py < tests\/1verdict32.in\nI am assuming this file uses tests\/1verdict32.in as in the input file to rsa.py.\nbut I am not familiar with how cProfile works with a file as an input\ncan someone explain to me how this is supposed to work? especially what is the relevance of \"<\" character in the above line?\nps: the directory structure is\nWD\/\n -rsa.py\n -hello.py\n -tests\/\n -1verdict_32.in\nalso when I run above command, it gives \"system cannot find the file specified\" error\nbut the profiler works when I use it on file hello.py\ni.e. for the command: python -m cProfile -s time hello.py","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":76,"Q_Id":62306414,"Users Score":1,"Answer":"You have a typo.\nYour file is 1verdict_32.in, and you're attempting to pass in 1verdict32.in, without the underscore. That's why your shell complains.\nBeyond that, < ... is a simple shell redirection operator; it means that the shell (bash, zsh, fish, cmd, ...) opens the file ... and writes it into the process's standard input (in Python, that's sys.stdin).","Q_Score":0,"Tags":"python,input,cmd,cprofile","A_Id":62306636,"CreationDate":"2020-06-10T14:44:00.000","Title":"using cprofile with input files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am making a CRM web application. I am planning to do its backend in python(because I only know that language better) and I have a friend who uses flutter for frontend. Is it possible to link these two things(flutter and python backend)? If yes how can it be done...and if no what are the alternatives I have?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1054,"Q_Id":62306900,"Users Score":0,"Answer":"I used $.ajax() method in HTML pages and then used request.POST['variable_name_used_in_ajax()'] in the views.py","Q_Score":0,"Tags":"python,flutter,flutter-web","A_Id":63479644,"CreationDate":"2020-06-10T15:08:00.000","Title":"linking web application's backend in python and frontend in flutter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am making a CRM web application. I am planning to do its backend in python(because I only know that language better) and I have a friend who uses flutter for frontend. Is it possible to link these two things(flutter and python backend)? If yes how can it be done...and if no what are the alternatives I have?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1054,"Q_Id":62306900,"Users Score":0,"Answer":"Yes you both can access same Django rest framework Backend. Try searching for rest API using Django rest framework and you are good to go.\nOther alternatives are Firebase or creating rest API with PHP.\nYou would need to define API endpoints for different functions of your app like login,register etc.\nDjango rest framework works well with Flutter. I have tried it. You could also host it in Heroku\nUse http package in flutter to communicate with the Django server.","Q_Score":0,"Tags":"python,flutter,flutter-web","A_Id":62307029,"CreationDate":"2020-06-10T15:08:00.000","Title":"linking web application's backend in python and frontend in flutter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a script that is throwing a CERTIFICATE_VERIFY_FAILED on one of the PCs available to me, but not the other. The certificate was updated last week. How do I check if there is a cached version of the certificate somewhere, and get it refreshed? \nI tried manually updating the .pem file in the lib\/site-packages\/certifi folder but that doesn't seem to make a difference.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":53,"Q_Id":62313105,"Users Score":0,"Answer":"Try running command pip install certifi","Q_Score":0,"Tags":"python,certificate,urllib2","A_Id":62316490,"CreationDate":"2020-06-10T21:03:00.000","Title":"Python: CERTIFICATE_VERIFY_FAILED, Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We have a big C# application, would like to include an application written in python and cython inside the C#\nOperating system: Win 10\nPython: 2.7\n.NET: 4.5+\nI am looking at various options for implementation here.\n(1) pythonnet - embed the python inside the C# application, if I have abc.py and inside the C#, while the abc.py has a line of \"import numpy\", does it know how to include all python's dependencies inside C#?\n(2) Convert the python into .dll - Correct me if i am wrong, this seems to be an headache to include all python files and libraries inside clr.CompileModules. Is there any automatically solution? (and clr seems to be the only solution i have found so far for building dll from python.\n(3) Convert .exe to .dll for C# - I do not know if i can do that, all i have is the abc.exe constructed by pyinstaller\n(4) shared memory seems to be another option, but the setup will be more complicated and more unstable? (because one more component needs to be taken care of?)\n(5) Messaging - zeromq may be a candidate for that. \nRequirements:\nBoth C# and python have a lot of classes and objects and they need to be persistent\nC# application need to interact with Python Application\nThey run in real-time, so performance for communication does matter, in milliseconds space.\nI believe someone should have been through a similar situation and I am looking for advice to find the best suitable solution, as well as pros and cons for above solution.\nStability comes first, then the less complex solution the better it is.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":499,"Q_Id":62318896,"Users Score":0,"Answer":"For variant 1: in my TensorFlow binding I simply add the content of a conda environment to a NuGet package. Then you just have to point Python.NET to use that environment instead of the system Python installation.","Q_Score":1,"Tags":"c#,python-2.7,zeromq,shared-memory,python.net","A_Id":62543620,"CreationDate":"2020-06-11T07:07:00.000","Title":"Alternatives for interaction between C# and Python application -- Pythonnet vs DLL vs shared memory vs messaging","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have aws lambda running python 3 service.\nI am measuring my service duration(simple time -time) from the start of the lambda invocation(first invocation line) till the end(last invocation line).\nIm getting results that are pretty dramatically different than aws reported duration and billed duration.\nMost of the time my measures indicates on average of 730.9 ms\nAnd aws reported duration and billed duration reports on Duration: 1058.36 ms Billed Duration: 1100 ms.\nWhere the difference can come from?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":483,"Q_Id":62320107,"Users Score":1,"Answer":"Prior to function invocation, the instance must be spun up. I believe AWS Lambda charges for the setup time of the function as part of the execution time.\nAny imports or other assets that must be loaded before your function is invoked count against the total execution time, and your timer doesn't start until after that inital loading time.","Q_Score":0,"Tags":"python,python-3.x,aws-lambda,duration","A_Id":62320296,"CreationDate":"2020-06-11T08:24:00.000","Title":"Difference between aws lambda duration and my measures duration","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a flask app that is intended to be hosted on multiple host. That is, the same app is running on different hosts. Each host can then send a request to the others host to take some action on the it's respective system. \nFor example, assume that there is systems A and B both running this flask app. A knows the IP address of B and the port number that the app is hosted on B. A gets a request via a POST intended for B. A then needs to forward this request to B. \nI have the forwarding being done in a route that simply checks the JSON attached to the POST to see if it is the intended host. If not is uses python's requests library to make a POST request to the other host. \nMy issue is how do I simulate this environment (two different instance of the same app with different ports) in a python unittest so I can confirm that the forwarding is done correctly?\nRight now I am using the app.test_client() to test most of the routes but as far as I can tell the app.test_client() does not contain a port number or IP address associated with it. So having the app POST to another app.test_client() seems unlikely. \nI tried hosting the apps in different threads but there does not seem to be a clean and easy way to kill the thread once app.run() starts, can't join as app.run() never exits. In addition, the internal state of the app (app.config) would be hidden. This makes verifying that A does not do the request and B does hard. \nIs there any way to run two flask app simultaneously on different port numbers and still get access to both app's app.config? Or am I stuck using the threads and finding some other way to make sure A does not execute the request and B does? \nNote: these app do not have any forums so there is no CSRF.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":95,"Q_Id":62328279,"Users Score":0,"Answer":"I ended up doing two things. One, I started using patch decorator from the mock library to fake the response form systems B. More specifically I use the @patch('requests.post') then in my code I set the return value to \"< Response [200]>\". However this only makes sure that requests.post is called, not that the second system processed it correctly. The second thing I did was write a separate test that makes the request that should have been sent by A and sends it to the system to check if it processes it correctly. In this manner systems A and B are never running at the same time. Instead the tests just fake there responses\/requests. \nIn summery, I needed to use @patch('requests.post') to fake the reply from B saying it got the request. Then, in a different test, I set up B and made a request to it.","Q_Score":0,"Tags":"python,flask,python-requests,python-unittest","A_Id":62338499,"CreationDate":"2020-06-11T15:48:00.000","Title":"Test interaction between flask apps","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I just have finished the project with Python. I need to add requirements.txt. Is there a way in a command line to list all the dependencies I have been using along with their versions? \nI have researched but it looks like I need to go manually through every single one of them, I was wondering if there is a better way to accomplish this?\nThank you.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":31,"Q_Id":62329755,"Users Score":0,"Answer":"to do that you need to type the following command pip\/pip3 freeze\nafter that you can copy the dependencies into the requirements.txt file","Q_Score":1,"Tags":"python,import,dependencies,requirements","A_Id":62330296,"CreationDate":"2020-06-11T17:07:00.000","Title":"is there a way to list all dependancies that being used for the specific project in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Wanting to expand my horizons I decided to pick up programming and I've read that python is very beginner-friendly, knowing this I downloaded the program in addition to the PyCharm text editor and started to write some small stuff like print commands and the like. However, I wanted to start doing more and embarked on a mission to replicate a game off the internet, more specifically snake just to see how it all functions together in a cohesive manner. Every tutorial begins with \"import\" commands in addition to something like \"math\" and \"random\" directly after, turning red every single time. But for me, it just turns grey with the original orange \"import\" text also turning grey with a help icon saying to optimize my imports but just deleting my text altogether when I click it. I can find anything on the web to help me with what I'm dealing with leading me to believe that its probably an easy fix that I, for whatever reason can't seem to find. I really don't have a clue as to what to do and im increasingly becoming more and more frustrated.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":50,"Q_Id":62355522,"Users Score":2,"Answer":"That is okay, PyCharm is only signaling you that you haven't used that module yet. This can help Developers in large programs to save code and memory. Don't worry about it just ignore it and continue.","Q_Score":1,"Tags":"python","A_Id":62356636,"CreationDate":"2020-06-13T04:27:00.000","Title":"How do I optimize imports in Python using PyCharm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What I want to do is mimic an operating system without reinventing the wheel. When my Pi boots up I want it to have a custom bootup so it goes straight into my program.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":34,"Q_Id":62367259,"Users Score":1,"Answer":"What SO it have? Raspian? LibreElec? another one?\nIf you are on raspian you can edit \/etc\/rc.local and put over there the commands to start the programs","Q_Score":0,"Tags":"java,python,raspberry-pi","A_Id":62367377,"CreationDate":"2020-06-14T00:58:00.000","Title":"How to boot to program on Raspberry Pi?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I use Heroku to host my discord.py bot, and since I've started using sublime merge to push to GitHub (I use Heroku GitHub for it), Heroku hasn't been running the latest file. The newest release is on GitHub, but Heroku runs an older version. I don't think it's anything to do with sublime merge, but it might be. I've already tried making a new application, but same problem. Anyone know how to fix this?\nEdit: I also tried running Heroku bash and running the python file again","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":43,"Q_Id":62368748,"Users Score":1,"Answer":"1) Try to deploy branch (maybe another branch)\n2) Enable automatic deploy","Q_Score":1,"Tags":"python,heroku","A_Id":62368911,"CreationDate":"2020-06-14T05:35:00.000","Title":"Heroku won't run latest python file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I know there are several ways to kill a process if I know the process id.\nBut similar to ctrl+C in keyboard interrupt, looking for such interrupt using a command.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":76,"Q_Id":62373356,"Users Score":0,"Answer":"use this Command to kill the process(\nkillall -s 9 [process name] )","Q_Score":0,"Tags":"python,linux,process,kill","A_Id":62373407,"CreationDate":"2020-06-14T13:44:00.000","Title":"How can I stop the running command in linux without knowing the pid?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to figure out the position of the moon given an observer in a lunar orbit. I have searched the internet already, but cannot find if PyEphem has this capability. Any suggestions?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":26,"Q_Id":62379196,"Users Score":1,"Answer":"PyEphem does not, alas, have that capability.","Q_Score":0,"Tags":"python,astronomy,pyephem","A_Id":62387529,"CreationDate":"2020-06-14T23:05:00.000","Title":"PyEphem -- satellites with a lunar orbit?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am running a python script on Heroku which runs every 10 minutes using the Heroku-Scheduler add-on. The script needs to be able to access the last time it was run. On my local machine I simply used a .txt file which I had update whenever the program was run with the \"last run time\". The issue is that Heroku doesn't save any file changes when a program is run so the file doesn't update on Heroku. I have looked into alternatives like Amazon S3 and Postgresql, but these seem like major overkill for storing one line of text. Are there any simpler alternatives out there?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":48,"Q_Id":62394659,"Users Score":0,"Answer":"If anyone has a similar problem, I ended up finding out about Heroku-redis which allows you to make key-value pairs and then access them. (Like a Cloud Based Python Dictionary)","Q_Score":0,"Tags":"python,heroku,amazon-s3,heroku-postgres","A_Id":62411106,"CreationDate":"2020-06-15T18:28:00.000","Title":"Way to store a single line of changing text on Heroku","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"We have an android application, We need to schedule the below tasks on weekly once.\n\nHave to automatically log out from our application.\nThen have to log in automatically.\n\nI google it and found Automation Testing Framework - Android UI Automation Using Python Wrapper but I wish to run the above task by scheduling.\nI am not an Android developer, Kindly assist me to accomplish this task.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":38,"Q_Id":62426581,"Users Score":0,"Answer":"In case of logout user after a perticular time, then you need to create a middle layer(like intercepter) while calling api through retrofit in mobile end.\nA logic follow in middle layer and your backend:\nyou need to send specific error code your from backend after a perticular time.\nAt mobile end we check that code in middle layer if error code is match then call logout user api and at same time call login api.\nIf you want only logout and not want to login again then send another error code for that.","Q_Score":0,"Tags":"android,python-3.x,scheduled-tasks","A_Id":62428198,"CreationDate":"2020-06-17T10:13:00.000","Title":"have to schedule UI task in Android: have to automatically log out from our application and login automatically","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an IPad that loads every email from my inbox immediately. Because of some spam in my mails I want to install an email cleaner\/filter. I already tried spamassassin and some other self written python code on my raspi that find and deletes all spam mails each second from the server. The problem is that the emails altough they are deleted from the server my IPad still gets most of them.\nMy question is if there's a easy solution to avoid my IPad loading some of the spam before my program deletes it. That means that my IPad wouldn't even see the mails because they're filtered by any device in the network.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":37,"Q_Id":62431375,"Users Score":0,"Answer":"If anyone has the same problem...\nThis solution worked for me. I added a new email account to the mail server. On my IPad I use the IMAP server (for receiving) from the new account while the SMTP server (for sending) is the same as before. That means sending mails hasn't changed. I wrote a little python script that sends every non spam mail to the new account. It's running 24\/7 on my raspi. That means that I now only see the mails I want to see while I can send mails like I'm used to it.\nIf you also want to write a program like this you should start looking up how to receive and send emails in your favorite language. \nOf course this works for every email client.","Q_Score":0,"Tags":"python,email,networking","A_Id":62447395,"CreationDate":"2020-06-17T14:27:00.000","Title":"Deleting spam mails from inbox before mail client loads them","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm having trouble doing this and can't find a good way to select them all. I need to get the live updates as well as the normal headlines. Basically every bolded headline on the site. Also, I need to get the embedded link that activates when these are clicked. I have some basic knowledge of HTML and have webscraped a few things before, but am struggling with this for some reason. Can someone walk me through it?\nUpon further inspection, it seems I might want to find the children of all article classes?","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":59,"Q_Id":62438887,"Users Score":-1,"Answer":"You could use the requests module to download the page's HTML code, then parse it by h3 tags, which I've noticed are used for headlines.\nYou can then use the .find(string) method to find such HTML tag, and when you do, find the next instance of <\/h3> from that index of the HTML code onward.\nI couldn't understand which and how many headlines you want to parse, but you can use a while loop to keep parsing for every h3 tag on the page, until you can't find a new one (the .find() method should return -1 if it doesn't locate the string).","Q_Score":1,"Tags":"python,web-scraping,beautifulsoup","A_Id":62439089,"CreationDate":"2020-06-17T21:46:00.000","Title":"Getting the headlines and headline links from NPR.org with Beautiful Soup","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I now have an HTML file and I want to send it as a table, not an attachment by using outlook. The code that I found online only sends the file as an attachment. Can anyone give me ideas on how to do it properly?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":33,"Q_Id":62442067,"Users Score":0,"Answer":"You can use the HTMLBody property of the MailItem class to set up the message body.","Q_Score":0,"Tags":"python,html,email,outlook","A_Id":62479266,"CreationDate":"2020-06-18T03:50:00.000","Title":"How to send a HTML file as a table through outlook?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'll keep it short.\nUsing ZMQ to communicate between Python(server) and C ( client ). ( made a game ) \nThe goal is to get the server side running only when the client connects.\nIs there a way to detect something in ZeroMQ to start the program?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":49,"Q_Id":62452921,"Users Score":0,"Answer":"Q : \"Is there a way to detect something in ZeroMQ to start the program?\"\n\nI'll keep it short.\nYes, there is.\n\n read all details in the published API about using the socket_monitor() for handling this and similar events. Definitely doable & easy to integrateYou will soon fall in love with the ZeroMQ's smart tools & the designed-in art of the Zen of ZeroDefinitely a good pick :o)","Q_Score":1,"Tags":"python,c,zeromq","A_Id":62455495,"CreationDate":"2020-06-18T14:56:00.000","Title":"Detecting a \"join\" ZMQ","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a question regarding setting up different Python interpreters on sublime text when using SFTP on the remote server and the local one.\nThe thing is, I would like to use anaconda's autocomplete function in both local and remote environments, but these two environments have different settings. The local one is Python 3.6 whereas the remote one is Python3.7 with totally different packages. How should I set up the anaconda on Sublime Text to make it work? For example, when it's not on SFTP, use the local virtual environment, but when it comes to the remote server, use the remote virtual environment accordingly.\nAny suggestions are appreciated!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":97,"Q_Id":62453166,"Users Score":1,"Answer":"Anaconda doesn't work that way. It needs to actually run the Python executable locally. Even over an SSH connection, the local instance of the plugin can't talk to the remote Python. The only way you could do this is if you install Sublime on the remote server and connect from your local computer using a terminal server or remote XWindows session.","Q_Score":0,"Tags":"python,sublimetext3,sublime-anaconda","A_Id":62457581,"CreationDate":"2020-06-18T15:07:00.000","Title":"How to setup different Python interpreters on Sublime Text with SFTP and local?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In my project, Automation anywhere setup is already in use.\nHence is there any way by which i can push and pull credentials using a Python script From 'AA'.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":66,"Q_Id":62474198,"Users Score":0,"Answer":"You can use oauthlib by installing it 'pip install oauthlib'\nYou can use it to store credential in local file system and even refresh credential and validate it.","Q_Score":0,"Tags":"python,automationanywhere","A_Id":62474291,"CreationDate":"2020-06-19T16:02:00.000","Title":"Is there any way where Automation anywhere can be used as a credentials vault to store and fetch credentials using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"i am trying to develop a web application using HTML, PHP, and java script and i will include the Traveling salesman problem. should i use python for implementation or stick to java script? and what is the difference between them? which one is less complicated?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":450,"Q_Id":62476487,"Users Score":0,"Answer":"Adding additional languages to your application adds more complexity to your project. You already have two programming languages and a markup language in your project. Use javascript if you want to solve the problem on the client, or use php if you want to solve the problem on the server. If python is your language of choice, you can serve webpages from a python framework like flask instead of apache\/php.","Q_Score":0,"Tags":"javascript,python,html,algorithm,traveling-salesman","A_Id":62476679,"CreationDate":"2020-06-19T18:30:00.000","Title":"Traveling Salesman Problem implementation language","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Description:\n\nUsing the menu Script Library > iCloud in Pythonista 3 on iPad shows .py files created in Pythonista, but not files created in another IDE and saved to that iCloud folder\n\nSteps to reproduce:\n\ncreate .py file in an IDE on MacBook Pro\nsave the file on MacBook Pro in iCloud > Pythonista 3 > \nin Pythonista 3 on iPad, open the main menu (hamburger menu) and select `Script Library > iCloud > \n\nExpected:\n\nPythonista file navigator shows all files in the folder\n\nActual:\n\nPythonista file navigator shows only the files created in Pythonista\n\nQuestions:\n\nIs Pythonista caching an index of its iCloud folder separately? If so, is there a way to get Pythonista to reindex the folder?\nHow to see all the files in the Pythonista iCloud folder, and thus use that folder for syncing files between iPad and MacBook Pro?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1199,"Q_Id":62490043,"Users Score":0,"Answer":"Problem:\n\nPythonista does seem to be either a) relying on an outdated index of the iCloud > Pythonista folder itself, or b) not downloading the files from iCloud automatically. We need to force Pythonista to fetch the file details directly and\/or download the files.\n\nSolution:\n\nUnder the main menu (hamburger menu), click the +, then Import..., and select Files from the contextual menu. This will access the iCloud drive.\nSelect the Pythonista folder from iCloud.\n\nThis should trigger Pythonista to download the current files from iCloud. You won\u2019t need to actually complete the import procedure - it\u2019s enough to access the iCloud drive through the import menu.","Q_Score":1,"Tags":"python,icloud,pythonista","A_Id":62490044,"CreationDate":"2020-06-20T18:29:00.000","Title":"Pythonista 3 doesn\u2019t show iCloud files created on MacBook Pro","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Description:\n\nUsing the menu Script Library > iCloud in Pythonista 3 on iPad shows .py files created in Pythonista, but not files created in another IDE and saved to that iCloud folder\n\nSteps to reproduce:\n\ncreate .py file in an IDE on MacBook Pro\nsave the file on MacBook Pro in iCloud > Pythonista 3 > \nin Pythonista 3 on iPad, open the main menu (hamburger menu) and select `Script Library > iCloud > \n\nExpected:\n\nPythonista file navigator shows all files in the folder\n\nActual:\n\nPythonista file navigator shows only the files created in Pythonista\n\nQuestions:\n\nIs Pythonista caching an index of its iCloud folder separately? If so, is there a way to get Pythonista to reindex the folder?\nHow to see all the files in the Pythonista iCloud folder, and thus use that folder for syncing files between iPad and MacBook Pro?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1199,"Q_Id":62490043,"Users Score":1,"Answer":"You can also open the files in Pythonista using the \"Files\" app from Apple on the same device. Once you opened them this way, they usually show up in Pythonista\u00b4s file browser\/open file menu just fine. That way you don't have to go through the hassle of doing this on another iOS device and the sharing... .","Q_Score":1,"Tags":"python,icloud,pythonista","A_Id":71858046,"CreationDate":"2020-06-20T18:29:00.000","Title":"Pythonista 3 doesn\u2019t show iCloud files created on MacBook Pro","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to know how to perform the below mentioned task\nI want to upload a CSV file to a python script 1, then send file's path to another python script in file same folder which will perform the task and send the results to python script 1.\nA working code will be very helpful or any suggestion is also helpful.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":62,"Q_Id":62499885,"Users Score":0,"Answer":"You can import the script editing the CSV to the python file and then do some sort of loop that edits the CSV file with your script 1 then does whatever else you want to do with script 2.\nThis is an advantage of OOP, makes these sorts of tasks very easy as you have functions set in a module python file and can create a main python file and run a bunch of functions editing CSV files this way.","Q_Score":0,"Tags":"python-3.x","A_Id":62500465,"CreationDate":"2020-06-21T14:24:00.000","Title":"Sending Information from one Python file to another","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to integrate allure report with python, so i have a single python class(Unit test)\nwhich contains three methods setup, test, tearDown\nIn test method i read a excel file[loop through it] and verify some content\nbut in allure report only 1 test is displayed, Is there any way to mark this looping method as a individual test case, so that in allure reported multiple test cases should be displayed.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":206,"Q_Id":62509767,"Users Score":0,"Answer":"A testcase is a function.\nSo you could turn to pytest.mark.parametrize.","Q_Score":2,"Tags":"python,python-3.x,allure","A_Id":68568522,"CreationDate":"2020-06-22T07:52:00.000","Title":"How to create multiple test case in Allure report python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a locustfile, which is for generating load for a certain target website.\nIn my case i need to crate 1800 rps. but i am not able to generate that much in the single locustfile.\nSo i have created 4 locust file and generate 450 rps for each. but the rps not give as my expectation. It was dropped and became as very low.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":195,"Q_Id":62527624,"Users Score":0,"Answer":"You can run the same locustfile as master\/worker setup where you start a worker for each core you have on your machine.","Q_Score":0,"Tags":"python,load-testing,locust","A_Id":62528576,"CreationDate":"2020-06-23T04:59:00.000","Title":"How do i generate 1800 rps in locust, from one locustfile?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am looking for the best solution for Python to autopost to instagram from a database of images. I have already made a script using instabot that does this but cant figure out how to post a carousel of images, instead of just one.\nI am wondering what the current best solution for Python Instagram coding is as there is quite a lot of outdated information floating around the web...","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":307,"Q_Id":62529675,"Users Score":1,"Answer":"You Can Use A Combination Of Selenium and PyAutoGUI And It Will Be Really Easy! :D\nHope It Helps,\nYash","Q_Score":1,"Tags":"python,instagram","A_Id":62529791,"CreationDate":"2020-06-23T07:39:00.000","Title":"Automatic Instagram Posting in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to find out there is a p4 command that can find cl submitted in a depot branch from a cl submitted in another depot branch.\nlike -\nif CL 123 was submitted to branch \/\/code\/v1.0\/files\/...\nand same code changes were also submitted to another branch \/\/code\/v5.0\/files\/...\ncan i find out cl in 2nd branch from cl 123?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":745,"Q_Id":62540591,"Users Score":2,"Answer":"There are a few different methods; which one is easiest will depend on the exact context\/requirements of what you're doing.\nIf you're interested in the specific lines of code rather than the metadata, p4 annotate is the best way. Use p4 describe 123 to see the lines of code changed in 123, and then p4 annotate -c v5.0\/(file) to locate the same lines of code in v5.0 and see which changelist(s) introduced them into that branch. This method will work even if the changes were copied over manually instead of using Perforce's merge commands.\nIf you want to track the integration history (i.e. the metadata) rather than the exact lines of code (which may have been edited in the course of being merged between codelines, making the annotate method not work), the easiest method is to use the Revision Graph tool in P4V, which lets you visually inspect a file's branching history; you can select the revision from change 123 and use the \"highlight ancestors and descendants\" tool to see which revisions\/changelists it is connected to in other codelines. This makes it easy to see the context of how many integration steps were involved, who did them, when they happened, whether there were edits in between, etc.\nIf you want to use the metadata but you're trying for a more automated solution, changes -i is a good tool. This will show you which changelists are included in another changelist via integration, so you can do p4 changes -i @123,123 to see the list of all the changes that contributed to change 123. On the other side (finding changelists in v5.0 that 123 contributed to), you could do this iteratively; run p4 changes -i @N,N for each changelist N in the v5.0 codeline, and see which of them include 123 in the output (it may be more than one).","Q_Score":0,"Tags":"python-3.x,perforce,changelist,p4python,perforce-integrate","A_Id":62540734,"CreationDate":"2020-06-23T17:34:00.000","Title":"In P4, how do i check if a change submitted to one branch is also submitted to another branch using command","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Pytest, and having the following structure of tests :\nClassA.py\n\n\n---------------test_a\n---------------test_b\n---------------test_c\nAnd Also\nClassB.py\n\n\n---------------test_d\n---------------test_e\n---------------test_f\nI'm running my tests via terminal command\n(i.e.: pytest -v -s ClassA.py)\nMy question:\nIs there a way to run ClassA & ClassB in parallel (2 instances you might say),\nwhile maintaining order on each class - separately?\nMeaning I want all tests from ClassA will run on 1st browser instance, and all tests from ClassB will run on a different instance.\nI'm also familiar with parallel test execution using the 'pytest-xdist' plug-in.\nBut once using it the test cases that are in ClassA and ClassB are executed in the mixed order, so that is not good for me.\nEDITED:\nMy main purpose is to avoid from test_a running on a separate browser instance of test_b.\nI would like the tests on each class to run on the same browser instance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":179,"Q_Id":62551432,"Users Score":0,"Answer":"Yes, it is possible. Mark the test with order using pytest-order plugin and use pytest n 2 --dist loadfile. It will run Class A test in one browser and then initiate ClassB test in 2nd browser. Make sure you are passing the driver instance from conftest with the scope set to class","Q_Score":1,"Tags":"python,pytest,xdist,pytest-xdist","A_Id":68718438,"CreationDate":"2020-06-24T09:04:00.000","Title":"Using Pytest, I can't find a way to run 2 test classes at once in parallel, while each class has several tests?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I used auto-py-to-exe to convert a Python script into an executable file and it converts it to an executable without any problems, but when I launch the executable the following error happens:\nModuleNotFoundError: No module named 'pandas'\n[11084] Failed to execute script test1\nAny ideas on how to fix this? I've tried many libraries to convert the Python file to and Executable and all give me the same error. I've tried with cx_Freeze, PyInstaller, py2exe, and auto-py-to-exe. All give me a ModuleNotFoundError, but when I run the script on the IDE it runs perfectly.","AnswerCount":3,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":1862,"Q_Id":62561716,"Users Score":2,"Answer":"Are you trying pip install pandas?","Q_Score":0,"Tags":"python,exe,pyinstaller,py2exe,cx-freeze","A_Id":62561762,"CreationDate":"2020-06-24T18:24:00.000","Title":"ModuleNotFoundError: No module named 'pandas' when converting Python file to Executable using auto-py-to-exe","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I used auto-py-to-exe to convert a Python script into an executable file and it converts it to an executable without any problems, but when I launch the executable the following error happens:\nModuleNotFoundError: No module named 'pandas'\n[11084] Failed to execute script test1\nAny ideas on how to fix this? I've tried many libraries to convert the Python file to and Executable and all give me the same error. I've tried with cx_Freeze, PyInstaller, py2exe, and auto-py-to-exe. All give me a ModuleNotFoundError, but when I run the script on the IDE it runs perfectly.","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":1862,"Q_Id":62561716,"Users Score":2,"Answer":"A script that runs in your IDE but not outside may mean you are actually working in a virtual environment. Pandas probably is not installed globally in your system. Try remembering if you had created a virtual environment and then installed pandas inside this virtual environment.\nHope it helped,\nVijay.","Q_Score":0,"Tags":"python,exe,pyinstaller,py2exe,cx-freeze","A_Id":62561815,"CreationDate":"2020-06-24T18:24:00.000","Title":"ModuleNotFoundError: No module named 'pandas' when converting Python file to Executable using auto-py-to-exe","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I used auto-py-to-exe to convert a Python script into an executable file and it converts it to an executable without any problems, but when I launch the executable the following error happens:\nModuleNotFoundError: No module named 'pandas'\n[11084] Failed to execute script test1\nAny ideas on how to fix this? I've tried many libraries to convert the Python file to and Executable and all give me the same error. I've tried with cx_Freeze, PyInstaller, py2exe, and auto-py-to-exe. All give me a ModuleNotFoundError, but when I run the script on the IDE it runs perfectly.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":1862,"Q_Id":62561716,"Users Score":1,"Answer":"For cx_freeze, inlcude pandas explicitly in the packages. Like in the example below -\nbuild_exe_options = {'packages': ['os', 'tkinter', 'pandas']}\nThis should include the pandas module in you build.","Q_Score":0,"Tags":"python,exe,pyinstaller,py2exe,cx-freeze","A_Id":62567997,"CreationDate":"2020-06-24T18:24:00.000","Title":"ModuleNotFoundError: No module named 'pandas' when converting Python file to Executable using auto-py-to-exe","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've included this library as a layer to my lambda function but when I go to test it I get the error: cannot import name 'etree' from 'lxml'\nThere are multiple posts about people having this issue and some say to that I need to build it to compile some c libraries. Most posts say to look for another file or folder name 'lxml' which I've verified is not the issue.\nI'm able to run the same code I've deployed to my layer on my local linux workstation and it runs without an issue.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":146,"Q_Id":62564463,"Users Score":2,"Answer":"Turns out my lambda was running python version 3.8 and that version is not compatible with the version of lxml I am using 4.5.1. Changing the run time to 3.7 fixed the issue. Hope this helps someone.","Q_Score":0,"Tags":"python-3.x,aws-lambda,lxml","A_Id":62564464,"CreationDate":"2020-06-24T21:37:00.000","Title":"lxml library in AWS Lambda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a few things that are calling the same lambda function and when called I need to know which group they are in. How can I obtain which IoT thing group they are in via a python lambda function? I've tried checking if there is anything I can work with in the client and context objects, but can't find anything.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":237,"Q_Id":62571223,"Users Score":1,"Answer":"There are provisions for creating a rule that can call a Lambda function and pass in data from the MQTT message that triggered the rule. In a typical architecture, the Lambda functions are invoked via a Rule and not directly by IoT client. The AWS IoT Rules Engine ( based on SQL-based language) enable to select data from message payloads and send the data to other services, such as AWS Lambda or S3 etc.\nThe Rule processes a JSON based message from the topic on which it is listening and by default passes the result to the Lambda function as event parameter of your handler without adding or removing any data. Accordingly, if the message has no data of interest , then that data might be unavailable for Lambda function.\nOne option can be embedding the Things group name inside message from the Thing. This data can be parsed at Lambda. The event parameters can be helpful at Lambda function for fetching the Thing related information provided the Thing information is conveyed inside the MQTT message or added by Rule's SQL to the result passed to the Lambda function.","Q_Score":1,"Tags":"python,amazon-web-services,aws-lambda,aws-iot","A_Id":62605704,"CreationDate":"2020-06-25T08:38:00.000","Title":"How to obtain thing group name from AWS lambda function","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm an experienced developer, but not very familiar with Python and Pyramid.\nI'm trying to follow some (a bit old and unclear) instructions on deploying a Pyramid web application. My OS is Ubuntu 16.04.\nThe instructions say to install virtualenv and Pyramid - I do so with apt install virtualenv and apt install python-pyramid. Then they say I should run the app in a virtual environment, so I build that with virtualenv . -ppython3, and activate it with source bin\/activate. I install the application from a ready-to-run buildout from GitHub. The buildout includes a \"production.ini\" file with parameters to pserve.\nBut Pyramid is not included in the virtual environment built with virtualenv. (There is no \"pserve\" in the bin directory, e.g.) So I can't run the applications with bin\/pserve etc\/production.ini, as the instructions say. And if I try with only \"pserve\", I get errors when trying to access files like \"var\/waitress-%(process_num)s.sock\". Files that the app excepts to find in the virtual environment.\nI've looked for flags to tell virtualenv to include Pyramid, but couldn't find any. Am I overlooking something? I'd be most grateful for some help! :-)\n\/Anders from Sweden","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":146,"Q_Id":62578228,"Users Score":0,"Answer":"You mentioned it's using buildout - I assume this is zc.buildout. buildout usually manages its own virtualenv and handles installing all of the necessary dependencies. It really depends on how that buildout is configured as there's no standard there for what to do or how to run your app. I would normally expect pserve to be exposed in the bin folder, but maybe another app-specific script is exposed instead.","Q_Score":0,"Tags":"python,virtualenv,pyramid","A_Id":62607113,"CreationDate":"2020-06-25T14:53:00.000","Title":"Pyramid not included in Python virtualenv","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm asking this question because I've noticed that a lot of (if not all) discord bots go offline every few hours, then come back 2 seconds later. After making my own bot, it does the exact same thing (and it's only in 4 servers). Every few hours, it goes offline for 2 seconds then comes back. Does anyone have an explanation as to why this happens?\nDebugging\nWhen the problem occurs, it also triggers on_ready(), which seems to me to mean that it isn't discord, but the client.\nOther Information\n\nI am using discord.py-rewrite library, but I've seen this happen with the discord.js library as well\nThis happens in active servers\nUnless most bot developers make the same mistake, this is not a problem with my code.\nThis is not a pressing issue for me. I am just mostly curious why and am not necessarily looking for a solution, though I would appreciate it if you had one.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":327,"Q_Id":62595104,"Users Score":1,"Answer":"It could be possible that the Raspberry Pi loses connection to the discord client if it's connected wirelessly to the internet. Mine does the same for other servers unless it's connected through ethernet.","Q_Score":0,"Tags":"python,python-3.x,discord.py,discord.py-rewrite","A_Id":62688949,"CreationDate":"2020-06-26T12:49:00.000","Title":"Discord.py bot goes offline repeatedly","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"tl;dr: If you manage hundreds of terraform files, is it worth writing a high level engine in a fully fledged programming language to manages those files ?\nI spend a lot of time, editing, copying, and changing terraform files for infrastructure changes. Although the cicd used to make changes to the infrastructure, deploying a new release, uses cp, and seds to change terraform files and create new ones.\nI find that a bit complicated to introduce changes to our cicd pipelines.\nI thought of having a set of template that I could manage using a python engine, to create files, plan and apply, ...\nIs it a good idea ? Do you have experience, or have you tried that too ?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":108,"Q_Id":62595446,"Users Score":2,"Answer":"Generic templating of Terraform HCL modules (.tf files) seems like an almost insurmountable goal and you would lose a lot of smart editor and IDE support in the process.\nYou would be better off moving the changing values into .tfvars or terragrunt.hcl files and sticking to you sed script or subscribing to Gruntwork and using their terraform-update-variable script which has a lot of testing and functionality that might prove useful.","Q_Score":0,"Tags":"python,automation,terraform,continuous-deployment,continuous-delivery","A_Id":62597927,"CreationDate":"2020-06-26T13:09:00.000","Title":"Is templating Terraform files a good idea?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Scenario\nHi, I have a collection of APIs that I run on Postman using POST requests. The flask and redis servers are set up using docker.\nWhat I'm trying to do\nI need to profile my setup\/APIs in a high traffic environment. So,\n\nI need to create concurrent requests calling these APIs\n\nThe profiling aims to get the system conditions with respect to memory (total memory consumed by the application), time (total execution time taken to create and execute the requests) and CPU-time (or the percentage of CPU consumption)\n\n\nWhat I have tried\nI am familiar with some memory profilers like mprof and time profiler like line_profiler. But I could not get a profiler for the CPU consumption. I have run the above two profilers (mprof and line_profiler) on a single execution to get the line-by-line profiling results for my code. But this focuses on the function wise results.I have also created parallel requests earlier using asyncio,etc but that was for some simple API-like programs without POSTMAN. My current APIs work with a lot of data in the body section of POSTMAN\nWhere did I get stuck\nWith docker, this problem gets trickier for me.\n\nFirstly, I am unable to get concurrent requests\n\nI do not know how to profile my APIs when using POSTMAN (perhaps there is an option to do it without POSTMAN) with respect to the three parameters: time, memory and CPU consumption.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":247,"Q_Id":62597631,"Users Score":0,"Answer":"I suppose that you've been using the embbed flask server(dev server) that is NOT production ready and,by default, it supports only on request per time. For concurrent requests should be looking to use gunicorn or some other wsgi server like uWsgi.\nPostman is only a client of your API, i don't see it's importance here. If you want to do a stress test or somethin like that, you can write your own script or use known tools, like jmetter.\nHope it helps!","Q_Score":0,"Tags":"python,python-3.x,docker,postman,profiler","A_Id":62598094,"CreationDate":"2020-06-26T15:06:00.000","Title":"How to profile my APIs for concurrent requests?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"The key strike work. Menu drops down. Shows nothing. Maybe files. This continue in all projects.\nIt also high-lights imports as if it\u2019s not there. But the project operates just the same.\nI don\u2019t know is this is a root\/path issue.\nShowed others and asked around and No One has any ideas. This has been hurting my productivity and learning. Tried uninstalling and reinstalling through Brew. Problem persists.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":39,"Q_Id":62609872,"Users Score":1,"Answer":"Uh, have you tried Ctrl+Shift+P ?","Q_Score":0,"Tags":"python,django,macos,visual-studio-code,macos-catalina","A_Id":62609947,"CreationDate":"2020-06-27T12:12:00.000","Title":"Why does the Vscode command pallet does not work","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Traceback (most recent call last): File \"\/usr\/lib\/python3.6\/site-packages\/pgadmin4-web\/setup.py\", line 17, in import builtins ImportError: No module named builtins","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":817,"Q_Id":62622492,"Users Score":1,"Answer":"Execute it with python3. IE:\npython3 \/usr\/lib\/python3.6\/site-packages\/pgadmin4-web\/setup.py","Q_Score":0,"Tags":"python,centos7","A_Id":62642940,"CreationDate":"2020-06-28T12:22:00.000","Title":"Facing import builtins ImportError during installation of pgadmin4 in centos7?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm wondering how would I run my 2 discord bots at once from main, app.py, file.\nAnd after I kill that process (main file process), they both would stop.\nTried os.system, didn't work. Tried multiple subprocess.Popen, didn't work.\nAm I doing something wrong?\nHow would I do that?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2390,"Q_Id":62627581,"Users Score":0,"Answer":"I think the good design is to have one bot per .py file. If they both need code that is in app.py then they should 'import' the common code. Doing that you can just run both bot1.py and bot2.py.","Q_Score":1,"Tags":"python,discord.py","A_Id":62627674,"CreationDate":"2020-06-28T19:56:00.000","Title":"How to start multiple py files (2 discord bots) from one file at once","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to upload a python lambda function via a zip file. I copied all of my python files into a directory called \"lambda\", installed all of the libraries directly into that directory, did chmod -R 755 . to make sure all of those files are executable, and then zipped the directory with zip -r ..\/analysis.zip .\nThe file that holds my lambda function is called \"main.py\" and the lambda function is called \"handler\", so by AWS Lambda convention, I set the file it should be looking for to main.handler in the AWS Lambda page. I check my cloudwatch logs for this lambda function and still get an error saying aws cannot find the main module and also cannot find some regex._regex module as well.\nThis is the official error:\n[ERROR] Runtime.ImportModuleError: Unable to import module 'main': No module named 'regex._regex'\nDoes anyone know what can be the problem? I have deployed aws lambda functions before using the same process and this is the first time I am getting this issue.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":612,"Q_Id":62630980,"Users Score":0,"Answer":"Lambda operates on a Python function\/method not at the file. So the function handler must point to a actual function\/method not a file.\nSo within your main.py file, there must be a function e.g. test_function, and your handler has to be main.test_function. The name of the function in AWS is irrelevant to the function.\nHope that helps.","Q_Score":0,"Tags":"python,amazon-web-services,aws-lambda","A_Id":62635247,"CreationDate":"2020-06-29T03:56:00.000","Title":"Why does AWS Lambda not able to find my main.py?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to upload a python lambda function via a zip file. I copied all of my python files into a directory called \"lambda\", installed all of the libraries directly into that directory, did chmod -R 755 . to make sure all of those files are executable, and then zipped the directory with zip -r ..\/analysis.zip .\nThe file that holds my lambda function is called \"main.py\" and the lambda function is called \"handler\", so by AWS Lambda convention, I set the file it should be looking for to main.handler in the AWS Lambda page. I check my cloudwatch logs for this lambda function and still get an error saying aws cannot find the main module and also cannot find some regex._regex module as well.\nThis is the official error:\n[ERROR] Runtime.ImportModuleError: Unable to import module 'main': No module named 'regex._regex'\nDoes anyone know what can be the problem? I have deployed aws lambda functions before using the same process and this is the first time I am getting this issue.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":612,"Q_Id":62630980,"Users Score":0,"Answer":"By the description and error message your naming convention seems right.\nThe error message indicates that you're missing the regex module. However, from your description you seem to have packaged the dependancies correctly.\nUsually, it would then be a case of a runtime miss match. However, I have had struggles with regex and lambda when runtimes do match. By default now, I don't go above python 3.6 at the moment. I have struggled with other dependancies on lambda, such as pickle, on higher versions recently. Whilst everything seems to operate fine on 3.6.\nI got rid of the regex error on lambda with python 3.6 by downloading the taar.gz file from pypi and running setup.py... rather than pip3 install. It's a bit of pain, but it worked.","Q_Score":0,"Tags":"python,amazon-web-services,aws-lambda","A_Id":62635592,"CreationDate":"2020-06-29T03:56:00.000","Title":"Why does AWS Lambda not able to find my main.py?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to implement a way to know when a specific device has stopped publishing messages to an mqtt broker and in that case send an email to myself. I want to do this to be able to know if there is a problem with the device that is publishing the messages so I can check it and turn it back on. To try to accomplish this I created a mqtt client that subscribes to the topic that the device publishes e.g. test\/device_1 and then set as last will and testament for that device status\/device_1 where I put as payload=\"Offline\". Ideally, I want to be able to do this for more than 1 device, but let's assume I just want it for the simple case of one device.\nI created another script that implements another client that is subscribed to the topic status\/device_1 and then on the on_message function it checks if it gets the payload=\"Offline\" and if it does get it then I send an email to myself.\nThis approach however doesn't work as when I turn off my device, the mqtt client that is subscribed to the topic test\/device_1 keeps listening but gets no messages. In other words, it doesn't send its last will even when the topic is empty. However, it seems to work when I stop the script that is subscribed to the topic test\/device_1.\nAm I missing something or is it not possible to accomplish what I am trying to do? Any advice is appreciated!","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1204,"Q_Id":62660177,"Users Score":2,"Answer":"First LWT messages are only published by the broker if the client goes offline unexpectedly, which means if it shuts down cleanly then it will not get published, you have to manually publish a message as part of shut down process.\nYou can set the retained flag on the LWT so that any client that subscribes after the device has gone offline it will still see the state message.\nYou should also clear that message on when the device starts up, either by publishing something like Online or a null payload to clear the retained message.","Q_Score":2,"Tags":"python,mqtt,mosquitto,paho","A_Id":62663512,"CreationDate":"2020-06-30T14:48:00.000","Title":"Mqtt check if subscribed topic has stopped publishing messages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"When running some tests as part of building an application using pybuilder (pyb) getting this exception:\nBUILD FAILED - TypeError: () takes 0 positional arguments but 1 was given (pybuilder\/plugins\/python\/unittest_plugin.py:177)\nWhat could be possibly wrong ? I checked all the class functions, they have \"self\" as parameters in them. There are no lambda expressions.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":40,"Q_Id":62668762,"Users Score":0,"Answer":"The problem was resolved by patching\nsite-packages\/pybuilder\/plugins\/python\/unittest_plugin.py.\nThe \"return runner_generator(stream=output_log_file)\" statement was replaced by\n\"return runner_generator()\" in \"_create_runner\" function.","Q_Score":0,"Tags":"python,pybuilder","A_Id":62958669,"CreationDate":"2020-07-01T02:31:00.000","Title":"Python TypeError when executing unit tests","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was using the ConversationID of the mails in the Inbox and the mails in the Sent Items, assuming that the IDs will be same for the mails that we replied to, and it is same but the problem begins with Email Chains (or the Re: mails aka Conversations).\nSince the ID remains the same, and people keep replying even after days, performing a simple\ndatetime - datetime (with same ConversationIDs) results in outputs such as -1Day 20:05:01, -9Days etc.\nI just want to find the Response time of first reply to any mail, that enters the inbox.\n(Sorry, cannot share Code).","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":270,"Q_Id":62672490,"Users Score":0,"Answer":"To get the Response Time from a Chain of Mails which all have exactly the same ConversationID (generated automatically by Outlook), I did the following:\nI already had two Pandas DFs (let's say 'A' and 'B'), having the two columns each, namely:\nConversationID and Time (for received and sent mails).\nNow,\n\nCreated a Pandas DataFrame 'C' with an inner join of 'A' and 'B' on `ConversationID'.\n(This gave me all the mails that I had replied to).\n\nSort the both the Time columns as \"Ascending\".\n(This brings the First Mail received and the First Mail replied to the top).\n\nNow filter the new DataFrame 'C' on both Time columns with the condition,\nReplied Mail Time > Received Mail Time\n(Removes the -1 day outputs I was getting)\n\nGroupby on Received Mail Time and use .first()\n(Finally giving a genuine response time, after calculating Replied Mail Time - Received Mail Time)","Q_Score":0,"Tags":"python,outlook","A_Id":62834467,"CreationDate":"2020-07-01T08:14:00.000","Title":"Python Outlook (MAPI) Get Response Time of Mails Replied","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently doing Selenium testing with Pytest. There will be around 10 tests, however, a user may only have 70-80% of the data available to test (which is fine).\nIs there a way to then say, if 7\/10 tests have passed, pass the overall pytest, but still show the failing tests\nThis will interact with a CI\/CD pipeline, and it seems that if even 1 tests fails, that the Jenkins just sees red.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":73,"Q_Id":62677374,"Users Score":0,"Answer":"As suggested, if there isn't enough data for tests. Then don't run them.\nI was able to find a database table which only contains the users with the relevant data. Now all tests are passing 100%.\nThanks everyone for the help.","Q_Score":0,"Tags":"python,selenium,jenkins,testing,pytest","A_Id":62699363,"CreationDate":"2020-07-01T12:56:00.000","Title":"Pytest pass overall if >50% of Selenium tests pass","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've scheduled a Cron job like below but it is not executing. Do I need to put command before or is it ok to write only path.\n\nWith Command in the cronjob: 0 4 * * 1 python \/app\/www\/html\/RegionSubregion\/ceeinca.py\nWithout command in the cronjob: 0 4 * * 1 \/app\/www\/html\/RegionSubregion\/ceeinca.py\n\nWhich one is correct here?\nI need to run this particular python script on 1st day (Monday) of everyweek at 4AM. Please guide. Thank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":79,"Q_Id":62677624,"Users Score":0,"Answer":"Option 1 works if you give execute permission to the file.\nExecute Permission: chmod +x \/app\/www\/html\/RegionSubregion\/ceeinca.py","Q_Score":0,"Tags":"python,linux,cron","A_Id":62709173,"CreationDate":"2020-07-01T13:10:00.000","Title":"How to schedule Cron Job in Linux","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have an python daemon init script that has to get messages from other init script when they are starting.Since it is the initial boot stage of my raspberry Pi board\ni don't want to use any IPC for message passing.Is there any simple way that i can pass message from my other init scripts to python daemon.Thanks in advance for any great suggestions for this issue.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":173,"Q_Id":62681949,"Users Score":0,"Answer":"You can use named pipe. First you instantiate named pipe using mkfifo, which creates file representing the pipe. Then you open this file in both scripts - in one for writing and in another one for reading. After that you can just write some data to the opened file in one script and read it back in another.\nNote that pipes are unidirectional, which means that if you need to communicate in both directions, then you need to create two pipes.","Q_Score":1,"Tags":"linux-kernel,raspberry-pi,daemon,python-daemon","A_Id":62710334,"CreationDate":"2020-07-01T17:06:00.000","Title":"Send message to a Python daemon script from another init script without using IPC","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I uploaded my project folder to GitHub so I can work on it from both my desktop and my laptop.\nI did some work on the project on my laptop and pushed the latest commit to GitHub and hopped on my desktop to see if it worked.\nI accidentally cloned the repository to the wrong location, but when I went to delete it to clone it to the right folder, I got a pop-up saying that I \"need permission to perform this action. [I] require permission from to make changes to this folder\".\nI'm kind of stumped.\nI tried taking control of the folder through Properties, but that hasn't seemed to change anything.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2247,"Q_Id":62688781,"Users Score":0,"Answer":"It depends on your OS, but:\n\na repository cloned into a wrong folder can simply be moved to the right folder (no need to re-clone)\nif that is not possible (no move or deletion), you can as a workaround leave it there, and re-clone it to the right directory\n\n\nI was able to delete the folder by deleting the files inside and working my way up\n\nIt is possible another process kept an handle on the folder itself, which would prevent its deletion.","Q_Score":1,"Tags":"python,git,permissions,administrator","A_Id":62688827,"CreationDate":"2020-07-02T04:00:00.000","Title":"Can't delete cloned git repo on my computer?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I uploaded my project folder to GitHub so I can work on it from both my desktop and my laptop.\nI did some work on the project on my laptop and pushed the latest commit to GitHub and hopped on my desktop to see if it worked.\nI accidentally cloned the repository to the wrong location, but when I went to delete it to clone it to the right folder, I got a pop-up saying that I \"need permission to perform this action. [I] require permission from to make changes to this folder\".\nI'm kind of stumped.\nI tried taking control of the folder through Properties, but that hasn't seemed to change anything.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2247,"Q_Id":62688781,"Users Score":0,"Answer":"If you cloned it in the wrong directory, try moving it to the right directory.\nIf you finished working with it and wish to delete it, then:\nGoto properties>security>edit permissions and give full control to your user account and then try deleting it, if that doesn't work, check if that directory is open in any other program(my directory was open in vscode), then try deleting it should work.","Q_Score":1,"Tags":"python,git,permissions,administrator","A_Id":63426381,"CreationDate":"2020-07-02T04:00:00.000","Title":"Can't delete cloned git repo on my computer?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have been working with ML Studio (classic) and facing a problem with \"Execute Python\" scripts. I have noticed that it takes additional time to perform some internal tasks after which it starts executing the actual Python code in ML Studio. This delay has caused an increased time of 40-60 seconds per module which is aggregating and causing a delay of 400-500 seconds per execution when consumed through Batch Execution System or on running the experiments manually. (I've multiple Modules of \"Execute Python\" scripts)\nFor instance - If I run a code in my local system, suppose it takes 2-3 seconds. The same would consume 50-60 seconds in Azure ML Studio.\nCan you please help understand the reason behind this or any optimization that can be done?\nRegards,\nAnant","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":153,"Q_Id":62696966,"Users Score":2,"Answer":"The known limitations of Machine Learning Studio (classic) are:\nThe Python runtime is sandboxed and does not allow access to the network or to the local file system in a persistent manner.\nAll files saved locally are isolated and deleted once the module finishes. The Python code cannot access most directories on the machine it runs on, the exception being the current directory and its subdirectories.\nWhen you provide a zipped file as a resource, the files are copied from your workspace to the experiment execution space, unpacked, and then used. Copying and unpacking resources can consume memory.\nThe module can output a single data frame. It's not possible to return arbitrary Python objects such as trained models directly back to the Studio (classic) runtime. However, you can write objects to storage or to the workspace. Another option is to use pickle to serialize multiple objects into a byte array and then return the array inside a data frame.\nHope this helps!","Q_Score":2,"Tags":"python-3.x,azure,azure-machine-learning-studio,azure-machine-learning-service","A_Id":62697100,"CreationDate":"2020-07-02T13:00:00.000","Title":"Why does Azure ML Studio (classic) take additional time to execute Python Scripts?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"First, sorry if my question is not clear or is too simple, but I'm getting confuse about it. I have an EC2 instance where I want to run some python code previously developed in my computer. I want to automatically install all the packages that the python script use instead of doing pip in my EC2 instance for every package. I don't know if I need to use Docker, create a repository in GitHub and then clone it from my EC2 instance, or there is another alternative.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":417,"Q_Id":62700635,"Users Score":2,"Answer":"You have a few options to go about it.\n\nSetup bootstrap to install your packages when you stand up a new EC2 instance.\ncreate EC2 instance from image, using docker or with aws AMI.\n\nThis will setup an EC2 instance with all the dependency packages ready.","Q_Score":0,"Tags":"python,amazon-web-services,github,amazon-ec2","A_Id":62700715,"CreationDate":"2020-07-02T16:07:00.000","Title":"Automatically install python modules in EC2","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I know it's possible to disable InsecureRequestWarning but I need the opposite, I want to either catch it or make the request abort and throw an exception if this warning is present.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":139,"Q_Id":62710891,"Users Score":1,"Answer":"I've solved it with warnings.filterwarnings(\"error\"), which turns warnings into errors so they can be caught with try catch.","Q_Score":0,"Tags":"python,python-3.x,python-requests","A_Id":62712580,"CreationDate":"2020-07-03T07:52:00.000","Title":"Is there a way to catch InsecureRequestWarning from python request","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to store a non-rectangular array in Python. The array has millions of elements and I will be applying a function to each element in the array, so I am concerned about performance. What data structure should I use? Should I use a Python list or a numpy array of type object? Is there another data structure that would work even better?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":364,"Q_Id":62744462,"Users Score":2,"Answer":"You can use the dictionary data structure to store everything. If you have ample memory, dictionaries is a good option. The hashing process makes them faster.","Q_Score":0,"Tags":"python,multidimensional-array,data-structures","A_Id":62744575,"CreationDate":"2020-07-05T18:02:00.000","Title":"What is the best way to store a non-rectangular array?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to zip just a file in Python which present in a folder. I am finding hard to create zip file with the below code snippet. It does create zip file, but it has complete folder structure inside.\nimport zipfile as zip\nroot=r\"C:\\XXXX\\YYYYYY\\ZZZZ\\\"\nfile=\"abc.txt\"\nzipper=zip.ZipFile(file=os.path.join(root,file.replace(\"txt\",\"zip\")),mode=\"w\",compression=zip.ZIP_DEFLATED)\nzipper.write(os.path.join(root,file))\nzipper.close()\nActual output:\n#################\nabc.zip\n|\nXXXX - Folder\n|\nYYYYYY - Folder\n|\nZZZZ - Folder\n|\nabc.txt\nExpected output\n###############\nabc.zip\n|\nabc.txt","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":29,"Q_Id":62764961,"Users Score":0,"Answer":"One way I learnt and working is :\nos.chdir(root)\nTo set the working directory to the folder where the files are present. Then, pass just the filename instead of complete path to create zip.\nNot sure, if it is the correct and best way.","Q_Score":0,"Tags":"python-3.x,zip","A_Id":62765101,"CreationDate":"2020-07-06T21:41:00.000","Title":"zipfile : zip only the files present in a directory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I made a new file and I wanted to push it to my remote repo. But I accidentally force push the new file and overwrite it. So, I missed my previous files in my remote repo and now only the new added file is available in my remote repo. Is there any way to recover my missed files?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":294,"Q_Id":62766619,"Users Score":1,"Answer":"git has a big undo stack : git reflog\nYou can probably find the sha1 of the commit you \"overwrote\" in one of the following two places :\n\ngit reflog : the history of all commits that once have been the active commit you were working on\ngit reflog origin\/master (or git reflog origin\/anybranch) : the history of all the places you have seen for origin\/master, updated each time you ran git fetch or git pull\n\nOnce you have this sha1, you can :\n\nrebase on top of it : git rebase sha1\nget the previous content of the file and do something with it : git checkout sha1 -- the\/file\n...","Q_Score":0,"Tags":"python,git,github,gitlab,repository","A_Id":62774095,"CreationDate":"2020-07-07T01:03:00.000","Title":"Lost files after git force push","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running a Python gdb script on a program that runs with a Pintool. Specifically, I used the -appdebug_enable switch and created a semantic breakpoint in the Pintool that automatically triggers the breakpoint and runs the Python script that I sourced. The script basically inspects local and global variables and scans the memory that was dynamically allocated by the program. I notice that the gdb script runs orders of magnitude slower than if I run the program and gdb without the Pintool. I also tried with a dummy Pintool to see if my Pintool implementation caused the slowdown but it did not seem to be the case.\nMy conclusion is that Pin slows down my gdb script, but can anyone explain how and why? Is there any tool I can use to profile the performance slowdown from Pin?\n(I understand that gdb performance is not something people usually care too much about, but I am curious about the source of the slowdown.)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":207,"Q_Id":62767550,"Users Score":0,"Answer":"In your case PIN is used as a JIT (just in time) compiler. So it is effectively stopping your program whenever instruction sequence change, and recompile (main reason for delay) and also add some instructions of its own (additional delays). PIN takes your program executable as argument. From first instruction to next branch instruction (call,jmp,ret) it regenerate sequence of instruction with its additional set of instructions that will transfer control back to PIN framework after executing the generated instruction sequence. While regenerating code PIN allows a user using instrumentation code to inject additional analysis code.","Q_Score":0,"Tags":"gdb,intel-pin,gdb-python","A_Id":63295872,"CreationDate":"2020-07-07T03:08:00.000","Title":"Intel Pin GDB Runtime Overhead","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"what can I do if I want to collectstatic again in pythonanywhere? I did it because I remove oneline in my remote repository and when I collectstatic it didn't work (new styles don't apply) so what can I do?\nI'm not an speaker of English.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":30,"Q_Id":62768194,"Users Score":1,"Answer":"You should check whitenoise. It helps in maintaining static files in deployment in django.","Q_Score":0,"Tags":"javascript,python,html,css,django","A_Id":62789163,"CreationDate":"2020-07-07T04:33:00.000","Title":"About Django and static files in deployment from pythonanywhere","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I was wonder what if i had 1 million users, how much time will take it to loop every account to check for the username and email if the registration page to check if they are already used or not, or check if the username and password and correct in the log in page, won't it take ages if i do it in a traditional for loop?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":50,"Q_Id":62775839,"Users Score":1,"Answer":"Rather than give a detailed technical answer, I will try to give a theoretical illustration of how to address your concerns. What you seem to be saying is this:\n\nLinear search might be too slow when logging users in.\n\nI imagine what you have in mind is this: a user types in a username and password, clicks a button, and then you loop through a list of username\/password combinations and see if there is a matching combination. This takes time that is linear in terms of the number of users in the system; if you have a million users in the system, the loop will take about a thousand times as long as when you just had a thousand users... and if you get a billion users, it will take a thousand times longer over again.\nWhether this is a performance problem in practice can only be determined through testing and requirements analysis. However, if it is determined to be a problem, then there is a place for theory to come to the rescue.\nImagine one small improvement to our original scheme: rather than storing the username\/password combinations in arbitrary order and looking through the whole list each time, imagine storing these combinations in alphabetic order by username. This enables us to use binary search, rather than linear search, to determine whether there exists a matching username:\n\ncheck the middle element in the list\nif the target element is equal to the middle element, you found a match\notherwise, if the target element comes before the middle element, repeat binary search on the left half of the list\notherwise, if the target element comes after the middle element, repeat binary search on the right half of the list\nif you run out of list without finding the target, it's not in the list\n\nThe time complexity of this is logarithmic in terms of the number of users in the system: if you go from a thousand users to a million users, the time taken goes up by a factor of roughly ten, rather than one thousand as was the case for linear search. This is already a vast improvement over linear search and for any realistic number of users is probably going to be efficient enough. However, if additional performance testing and requirements analysis determine that it's still too slow, there are other possibilities.\nImagine now creating a large array of username\/password pairs and whenever a pair is added to the collection, a function is used to transform the username into a numeric index. The pair is then inserted at that index in the array. Later, when you want to find whether that entry exists, you use the same function to calculate the index, and then check just that index to see if your element is there. If the function that maps the username to indices (called a hash function; the index is called a hash) is perfect - different strings don't map to the same index - then this unambiguously tells you whether your element exists. Notably, under somewhat reasonable assumptions, the time to make this determination is mostly independent from the number of users currently in the system: you can get (amortized) constant time behavior from this scheme, or something reasonably close to it. That means the performance hit from going from a thousand to a million users might be negligible.\nThis answer does not delve into the ugly real-world minutia of implementing these ideas in a production system. However, real world systems to implement these ideas (and many more) for precisely the kind of situation presented.\nEDIT: comments asked for some pointers on actually implementing a hash table in Python. Here are some thoughts on that.\nSo there is a built-in hash() function that can be made to work if you disable the security feature that causes it to produce different hashes for different executions of the program. Otherwise, you can import hashlib and use some hash function there and convert the output to an integer using e.g. int.from_bytes. Once you get your number, you can take the modulus (or remainder after division, using the % operator) w.r.t. the capacity of your hash table. This gives you the index in the hash table where the item gets put. If you find there's already an item there - i.e. the assumption we made in theory that the hash function is perfect turns out to be incorrect - then you need a strategy. Two strategies for handling collisions like this are:\n\nInstead of putting items at each index in the table, put a linked list of items. Add items to the linked list at the index computed by the hash function, and look for them there when doing the search.\n\nModify the index using some deterministic method (e.g., squaring and taking the modulus) up to some fixed number of times, to see if a backup spot can easily be found. Then, when searching, if you do not find the value you expected at the index computed by the hash method, check the next backup, and so on. Ultimately, you must fall back to something like method 1 in the worst case, though, since this process could fail indefinitely.\n\n\nAs for how large to make the capacity of the table: I'd recommend studying recommendations but intuitively it seems like creating it larger than necessary by some constant multiplicative factor is the best bet generally speaking. Once the hash table begins to fill up, this can be detected and the capacity expanded (all hashes will have to be recomputed and items re-inserted at their new positions - a costly operation, but if you increase capacity in a multiplicative fashion then I imagine this will not be too frequent an issue).","Q_Score":2,"Tags":"python,algorithm,sorting,web,data-structures","A_Id":62777412,"CreationDate":"2020-07-07T12:57:00.000","Title":"what the fastest method to loop through a very large number of account in a log in page","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"We handle 10-20 payments daily using Paypals IPN system.\nThe past hour or so Paypal has been sending the IPNs in the wrong order.\nOur payments are subscriptions.\nSo generally they send.\nSubscr_signup\n& shortly after that\nsusbcr_payment.\nBut today they've been sending the subscr_payment before the subscr_signup every time. Which messed up our flow since the payment tries to link itself with a subscriber which it can't so it throws an error. This has forced us to manually add all the information which is a headache.\nAny ideas on how I should solve this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":34,"Q_Id":62780899,"Users Score":0,"Answer":"IPN is an asynchronous, best-effort delivery service. The \"Instant\" in its name, can be misleading, since that service was created a long time ago, and it was instant relative to, say, waiting for an email and processing things manually.\nSince payments and subscription profile creations are separate events in separate systems, you may receive notifications of each event in any order.\nYou should be able to create new\/temporary\/placeholder subscriber objects with the first subscr_payment event alone -- and if necessary fill in any missing information (or activate the placeholder) when you do receive a subscr_signup even.","Q_Score":0,"Tags":"python,django,paypal","A_Id":62781905,"CreationDate":"2020-07-07T17:36:00.000","Title":"Paypal IPN sent in the wrong order","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been trying to install discord on my raspberry pi, but its saying error code 1 and I need a more updated version of python (3.4.5). However, Thonny Python says it's version is 3.7.3.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3322,"Q_Id":62798274,"Users Score":0,"Answer":"Python on raspberry pi comes preinstalled with version 2 and version 3 of python\nTry using pip3 install discord and see if that fixes it","Q_Score":0,"Tags":"python,discord","A_Id":62805382,"CreationDate":"2020-07-08T15:26:00.000","Title":"Install discord on raspberry pi","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Currently, I'm working on docplex on python.\nI just found out that result from IBM cplex Ilog and docplex is way different.\nEven though their constraints, objective function, everything are identical, their solution is very different.\nIn some cases, docplex says infeasible even though it is feasible in Ilog.\nI tried to limit integrality and minimum gap in docplex tolerances but the same problem happens.\nIs there anyone have idea why this happens? and how to solve this??","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":339,"Q_Id":62821830,"Users Score":0,"Answer":"Something must be different between the two versions. You can use refine_conflict to know the source of infeasibility","Q_Score":0,"Tags":"python-3.x,cplex,docplex","A_Id":62825481,"CreationDate":"2020-07-09T18:56:00.000","Title":"IBM cplex ilog VS docplex in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Currently, I'm working on docplex on python.\nI just found out that result from IBM cplex Ilog and docplex is way different.\nEven though their constraints, objective function, everything are identical, their solution is very different.\nIn some cases, docplex says infeasible even though it is feasible in Ilog.\nI tried to limit integrality and minimum gap in docplex tolerances but the same problem happens.\nIs there anyone have idea why this happens? and how to solve this??","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":339,"Q_Id":62821830,"Users Score":1,"Answer":"To complement Alex's answer: in Docplex, Model.export_as_lp(path'c:\/temp\/mymodel.lp') is the way to generate a LP file from you Docplex model.\nIn Cplex's Python API, you have a Cplex instance, use cpx.write('c:\/temp\/mymodel_cplex.lp') to generate the LP files.\nIf your models are identical, then both LP files should also be identical (except maybe some differences in variable ordering, e.g. x2+x1 instead of x1+x2).\nIf you need to work the same model both APIs, then you must first reach this equality before going further.\nDOcplex has tools to investigate infeasible models, but there is no point until you ensure both models are identical.","Q_Score":0,"Tags":"python-3.x,cplex,docplex","A_Id":62829763,"CreationDate":"2020-07-09T18:56:00.000","Title":"IBM cplex ilog VS docplex in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a file with a list of UUIDs for Assets (9000+) in my company. Now the basic task is importing that file into a list of UUID so that my program can loop and check if a number of other UUIDS match.\nNow the question is, would using a bloom filter for the initial list allow me to do a quick search with the second list. would a bloom filter introduce any use in this case?\na) Learning bloom filters is something I want to do\nb) would 9000+ Items in an array (list, dict) which I would need to loop through be efficient?\nMany Thanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":338,"Q_Id":62827441,"Users Score":0,"Answer":"A bloom filter would help you eliminate UUIDs that are not present in your list before searching. This can be useful if your lookup is otherwise very expensive. However a dictionary lookup is very fast due to hashing and using a bloom filter in this case likely won't net you much of an improvement.","Q_Score":0,"Tags":"python,arrays,list,bloom-filter,bloom","A_Id":62827477,"CreationDate":"2020-07-10T04:39:00.000","Title":"Will using a bloom filter be faster than searching a dictionary or list in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing a python script that generates a list of integers and is supposed to send this list to a concurrently running C++ program that is constantly awaiting input. What is a quick and painless way to design the link between these two languages?\nI have considered possibilities such as:\n\nwriting the python result to a file, while listening for file updates in C++ and loading it as soon as new data is available.\nusing python pexpect package and including a command line interface in the C++ program, so that it receives the data through cin.\n\nBoth above possibilities seem a bit too hacky to me. Are there better options, which would not require to become an expert in C++ library coding for python?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":38,"Q_Id":62855721,"Users Score":1,"Answer":"You could set up a Socket and an OutputStream in the python app to send the data, and another Socket and an InputStream in the C++ program to receive the data.","Q_Score":1,"Tags":"python,c++,data-transfer","A_Id":62855860,"CreationDate":"2020-07-11T23:45:00.000","Title":"How to send python list to C++ application awaiting input?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"why we should openfaas instead of lambda functions in AWS or other serverless functions by cloud service providers?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":76,"Q_Id":62866325,"Users Score":1,"Answer":"The idea is to avoid lock-in to a specific vendor. With Open Faas you can run wherever you want while AWS Lambda is tied to AWS.","Q_Score":0,"Tags":"python,amazon-web-services,azure,google-cloud-functions,openfaas","A_Id":62866524,"CreationDate":"2020-07-12T20:50:00.000","Title":"OpenFaas vs serverless functions provided by cloud service providers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm working on a pre-existing python code-by-zapier zap. The trigger is \"Code By Zapier; Run Python\". I've made some changes to the contained python script, and now when I go to test that step I run into the following error message:\n\nWe couldn\u2019t find a run python\nCreate a new run python in your Code by Zapier account and test your trigger again.\n\nIs there any way of figuring out what went wrong?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":104,"Q_Id":62867738,"Users Score":0,"Answer":"I'm guessing a little bit, but I think this issue stems from repeatedly testing an existing trigger without returning a new ID.\nWhen you run a test (or click the \"load more\" button), then Zapier runs the trigger and looks through the array for any new items it hasn't seen before. It bases \"newness\" on whether it recognizes the id field in each returned object.\nSo if you're testing code that changed, but is returning objects with previously seen ids, then the editor will error saying that it can't find any new objects (the can't find new run pythons is a quirk of the way that text is generated; think of it as \"can't find objects that we haven't seen before).\nThe best way to fix this depends on if you're returning an id and if you need it for something.\n\nYour code can return a random id. This means every returned item will trigger a Zap every time, which may or may not be intended behavior.\nYou can probably copy your code, change the trigger app (to basically anything else), run a successful test (which will overwrite your old test data), and then change it back to Code by Zapier and paste your code. Then you should get a \"fresh\" test. Due to changes in the way sample data is stored, I'm not positive this works now\nDuplicate the zap from the \"My Zaps\" page. The new one won't have any existing sample data, so you should be able to test normally.","Q_Score":0,"Tags":"python-3.x,zapier","A_Id":62905665,"CreationDate":"2020-07-13T00:23:00.000","Title":"How to troubleshoot \"We couldn\u2019t find a run python\"?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a config file in an S3 bucket that needs to be modified by adding the response from ec2.describe_subnets and sent to an api endpoint. Is there a way to automate this process using Lambda to get the file from S3 without having to save it to a temp directory?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":230,"Q_Id":62883144,"Users Score":0,"Answer":"Is there a way to automate this process using Lambda to get the file from S3 without having to save it to a temp directory?\n\nIf you're asking about modifying the contents of the S3 Object, then the answer is no, it's not possible because S3 doesn't support that kind of operation. The only thing you can do is overwrite the entire object (ie, not just parts of it).\nIf you're asking about overwriting the S3 Object with new contents, then yes, it is possible to do it \"without having to save it to a temp directory\" if you do it in memory, for example.\nDownload the object from S3 without writing it to storage, make the changes in memory, and re-upload it to S3. If the file size is too big to fully store in memory, you can do it in a streaming fashion, too (i.e., initiate the download, for each chunk you download you make the necessary changes, and upload the modified chunk with a multipart upload, clear up the memory, repeat, etc).\nAs a final note, do keep in mind that S3 supports only eventual consistency for updates. This means that after you update the object, subsequent reads may still download the previous version. If whatever is consuming the file cannot properly deal with that, you'll probably need a different approach (i.e., don't overwrite, but write a new object with a new key, and send that new key to the consumer; or just use storage system that does support strong consistency, such as DynamoDB).","Q_Score":0,"Tags":"python-3.x,amazon-web-services,amazon-s3,aws-lambda","A_Id":62884456,"CreationDate":"2020-07-13T19:44:00.000","Title":"How can I edit an xml file that is stored in S3 without using a temp directory?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using monkeyrunner for my test. but the problem is that it is using python 2 instead of version 3. I've installed python3 only on my system. I do not know where is the python 2! is it on the test phone?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":52,"Q_Id":62889386,"Users Score":0,"Answer":"Monkey runner is using the embedded python 2.x implementation and there is no way to change it unless its developers update it.\nI had to use txt file instead of JSON to port my code to python 2.x .","Q_Score":0,"Tags":"python,android,testing,monkeyrunner","A_Id":63558911,"CreationDate":"2020-07-14T06:38:00.000","Title":"Monkeyrunner is using python 2.x instead of 3.x","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm creating a chatbot with Amazon Lex and the idea is that a user can drop an Excel file into a Slack channel and the bot sends the file to the appropriate Lambda function. What is the best way to achieve this goal?\nIt would also be acceptable if the Lex bot uploads the file somewhere else accessible (s3, EC2, Github, etc.) and then sends the address to the Lambda functions.\nI do not see any SlotTypes that support this type of input.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":482,"Q_Id":62896237,"Users Score":1,"Answer":"Lex PostText or PostContent method doesn't support the upload load files.\n\nwhere as in slack you will get the file url in payload when user uploads a file.\nCreate slot type Eg.- File. keep the enumeration value as uploaded.\nWhen slotToElicit is File check whether url is exists or not in the payload. if exists send the URL to lex using the session attributes and fill the slot value as Uploaded(Default value). If user doesn't upload a file fill the slot value with some random text to elicit the slot again.\nWith the help of Session attributes you can have access to file and upload it to S3.","Q_Score":0,"Tags":"python,amazon-web-services,slack,aws-lex","A_Id":64303167,"CreationDate":"2020-07-14T13:22:00.000","Title":"Uploading a file to Amazon Lex","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have business objects, that I would like to (de)serialize from and into a .yaml file.\nBecause I want the .yaml to be human readable, I need a certain degree of control over the serialize and deserialize methods.\nWhere should the serialization logic go?\nA) If I teach every object, how to de\/serialize itself, but that probably violates the single-responsibility-principle.\nB) If I put it inside a common serialization module, that might violate the open-closed-principle, since more business objects will be added in the future. Also, changes to objects need now be performed in two places.\nWhat is the SOLID approach to solve this conundrum for tiny-scale applications?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":113,"Q_Id":62897076,"Users Score":0,"Answer":"Usually in this kind of situation, you'll want the business objects to handle their own serialization. This doesn't necessarily violate the single responsibility principle, which asserts that each object should have one job and one boss. It just means that the one job includes serializability. The user owns the business object, and wants to be able to serialize it, so the requirement for serializability comes from the same place as those other requirements -- the user.\nThere are a couple danger areas, though. Firstly, do you really need to insist that the business object is serializable, or can you leave it up to the user to decide whether they are serializable or not? If you are imposing a serializability requirement, then there's a good chance that your are violating the SRP that way, because as you evolve the serialization system, you will be imposing your own requirements on the objects.\nSecond, you probably want to think long and hard about the interface the these objects use to serialize themselves. Does it have to be yaml? Why? Does it have to be to a file? Try not to impose requirements that are subject to change, because they depend on particular implementation decisions that you're making in the rest of the system. That ends up being a violation of SRP as well, because they those objects have to evolve according to requirements from 2 different sources. It's better if the objects themselves initiate their own serialization, and can choose the implementation to the greatest extent possible.","Q_Score":1,"Tags":"python-3.x,serialization,design-patterns,solid-principles","A_Id":62946560,"CreationDate":"2020-07-14T14:07:00.000","Title":"Where to put *serialization* in SOLID programming","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"About the data :\nwe have 2 video files which are same and audio of these files is also same but they differ in quality.\nthat is one is in 128kbps and 320kbps respectively.\nwe have used ffmpeg to extract the audio from video, and generated the hash values for both the audio file using the code : ffmpeg -loglevel error -i 320kbps.wav -map 0 -f hash -\nthe output was : SHA256=4c77a4a73f9fa99ee219f0019e99a367c4ab72242623f10d1dc35d12f3be726c\nsimilarly we did it for another audio file to which we have to compare ,\nC:\\FFMPEG>ffmpeg -loglevel error -i 128kbps.wav -map 0 -f hash -\nSHA256=f8ca7622da40473d375765e1d4337bdf035441bbd01187b69e4d059514b2d69a\nNow we know that these audio files and hash values are different but we want to know how much different\/similar they are actually , for eg: like some distance in a-b is say 3\ncan someone help with this?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":807,"Q_Id":62953484,"Users Score":1,"Answer":"You cannot use a SHA256 hash for this. This is intentional. It would weaken the security of the hash if you could. what you suggest is akin to differential cryptoanalysis. SHA256 is a modern cryptographic hash, and designed to be safe against such attacks.","Q_Score":3,"Tags":"python,audio,ffmpeg,computer-vision,similarity","A_Id":62953553,"CreationDate":"2020-07-17T11:57:00.000","Title":"how do we check similarity between hash values of two audio files in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm working on an application that runs on different platforms like Windows, Ubuntu and Raspberry Pi. Think of it as a webapp served by a Python Flask server. So far I have been running the app on Ubuntu. I want to port the code and make the app run on Windows and Raspberry Pi as well.\nThis is what's common among all platforms - the core part of the app, the flask server remains unchanged along with the UI code\nThis is what's different - the data and the functionalities. If Ubuntu and Windows version of the app has a dozen features, the one for Raspberry Pi will have only half of those. The data that is needed for the functionalities also changes accordingly. Another notable change is utility functions. For ex: I will have to use different Text-to-Speech programs on each of these platforms.\nIt works if I create separate repos for each. I want to know what the development and code management process for such a scenario will be like. Below are the thoughts I have on mind which I feel I could try out:\n\nSeparate repos for supporting each platform\nSingle repo with different folders for each\nSingle repo with common code separated out(I'm not sure if this is doable)\nDifferent branches for each platform support\n\nWould love to know what the standard procedure is for such a development activity and how usual each of the above 4 approaches are(especially 4). Thanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":23,"Q_Id":62958785,"Users Score":0,"Answer":"Usually what one does is either some sort of feature checking or abstraction, or both. For example, you can write an interface for text to speech and then provide an implementation for each platform. Similarly, you can do a feature check for feature foo and then define it as absent or present on each platform.\nThis is the approach most codebases use, and it maintains better compatibility across versions than separate repos. Using separate branches means you'll likely end up with a lot of conflicts merging features into various branches.\nIt may be that some platform-specific or feature-specific code will live in separate files or folders, and that's necessary and okay. It may be desirable to isolate that code so it doesn't load dependencies that don't exist, for example. But you will want to share most of the code as much as possible with uniform interfaces.\nBy making it feature based, you focus on the features available, so if the Raspberry Pi becomes more capable, then you just turn on the feature. Similarly, if you decide you want to support macOS, you can just find out what features that OS can support and turn those on. Similarly, you can add an abstraction for the native text-to-speech layer on macOS, and then flip that feature as well.","Q_Score":0,"Tags":"python,version-control,raspberry-pi,repository,cross-platform","A_Id":62986689,"CreationDate":"2020-07-17T17:12:00.000","Title":"Maintain source code of app that runs on different platforms","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I successfully configured gurobi on centos 7 and it works if I try gurobi_cl on a test.lp file where the test.lp file contains just one line:\nMinimize\nNow i try to import gurobi from a script that is launched from httpd an I get this error:\nFrom gurobi import *\nFile\"\/usr\/lib\/python2.7\/site-packages\/gurobipy\/init.py\" line 1 in \nFrom .gurobi import *\nImportError: libgurobi90.so: cannot open shared object file:\nNo such file or directory\nI am using gurobi9.0.1 and python 3.7 and I don't know why gurobi is calling python 2.7 in the log below.\nCould you please help me?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":45,"Q_Id":62959519,"Users Score":0,"Answer":"Solved the problem. I had to add gurobi_pi.conf under old.so.conf containing the path to my gurobi folder\n\nldconfig","Q_Score":0,"Tags":"python-3.x,httpd.conf,gurobi","A_Id":62959715,"CreationDate":"2020-07-17T18:04:00.000","Title":"Problem when importing gurobi through httpd","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Is there any way to use python libraries like pandas etc to Sikuli script? Or can I run Sikuli .py file through any python interpreter?\nI have written a script that runs through SikuliX UI using run button as well as through the command line eg C:\\Users\\*****\\Desktop\\Sikuli2\\sikulixide-2.0.4.jar -r C:\\Users\\*****\\Desktop\\Sikuli2\\Calculator.sikuli.\nI also tried from sikuli import * and from sikuli.Sikuli import * but I'm not able to run the script into any python interpreter say Jupyter.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":103,"Q_Id":62982020,"Users Score":0,"Answer":"You cant use sikuli in python (for now)\nYou can use some python libraries - just try them to see if the work with jython","Q_Score":0,"Tags":"python,sikuli-x","A_Id":66341453,"CreationDate":"2020-07-19T15:08:00.000","Title":"Is there any way to use python libraries like pandas etc to Sikuli script? Or can I run Sikuli .py file through any python interpreter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python script that runs a discord bot. The bot only works when the script is running, which means that in order to use it I must constantly be running a python script which is something I don't want to do. I've looked into cloud services to deploy it on and I keep getting talk about event loops and other mumbo jumbo. Is there a safe and easy way to deploy a python script over a cloud of some sort.\nAny help is very welcome.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":167,"Q_Id":62989198,"Users Score":1,"Answer":"I personally suggest Heroku, I'm using it for running multiple scripts for free. You can use scheduler addon for scheduling scripts to run at particular time as well. Please refer to heroku documentation & get started!","Q_Score":2,"Tags":"python,python-3.x,cloud,discord.py","A_Id":62989248,"CreationDate":"2020-07-20T05:34:00.000","Title":"Can I deploy python scripts over a cloud instead of running them on my own computer?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can you send an email from a Databricks platform?\nI would like to send an email from a notebook in Databricks with Python. I'm wondering if there's already an SMTP client already configured that I can use. I tried to do it, but didn't succeed.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":59,"Q_Id":62992249,"Users Score":1,"Answer":"The answer is \"no\". There's no smtp client included in Databricks.\nBut you can define yours outside and use it through the Databricks platform.","Q_Score":1,"Tags":"python,smtp,databricks","A_Id":66561871,"CreationDate":"2020-07-20T09:16:00.000","Title":"Is there a smtp client included in Databricks platform to be able to send emails?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to get notify whenever the new files added to a directory in FTP server. Is there any method to tell me that new files are added?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":826,"Q_Id":63011667,"Users Score":0,"Answer":"FTP does not support this natively. Hence you do one of the following:\n\nwrite a short script to watch the directory and send an email\/notification (just a few lines Python)\nuse an existing module, aka pywatch\nuse an orchestration operator such as Airflow sensor, if your files are part of a larger process and you want to trigger jobs when the files arrive","Q_Score":0,"Tags":"python,python-3.x,python-2.7,ftp","A_Id":63011904,"CreationDate":"2020-07-21T09:41:00.000","Title":"How to get notify whenever a new files is added to directory in FTP server?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm having an issue using Python in my Mac Terminal Shell.\nI used Python through Mac Terminal yesterday, but after I worked in Pycharm this morning, there seems to be an issue with my terminal.\nNow when I simply write 'python', I receive this message:\n\nzsh: no such file or directory: \/usr\/local\/bin\/python3.7\n\nAny help, getting me back to using Python in my terminal would be appreciated!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1118,"Q_Id":63015974,"Users Score":1,"Answer":"Apparently the PATH of your S.O. It can't find the file to launch Python in your terminal so you could:\n\nreinstall Python from the command line (zsh) and validate the \"python\" command again from the terminal\n\nfind the file associated with Python with commands like \"find\" and then modify the path of the PATH to the path where the Python launcher is","Q_Score":0,"Tags":"python,macos,shell,terminal,command","A_Id":63016373,"CreationDate":"2020-07-21T13:48:00.000","Title":"zsh can't find python home directory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I used import twitter and then tried authenticating using the following command - Twitter(auth=OAuth(access_token, access_token_secret, consumer_key, secret_key))\nOn running the program I get the error: name Twitter not defined. When I use from twitter import *, it works. Why is it so?\nI am asking this because if i use tweepy instead, a simple import tweepyworks. Also, doesn't import twitter work the same as from twitter import *?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":29,"Q_Id":63019030,"Users Score":2,"Answer":"Try twitter.Twitter (auth=OAuth(access_token, access_token_secret, consumer_key, secret_key))","Q_Score":0,"Tags":"python,twitter","A_Id":63019081,"CreationDate":"2020-07-21T16:36:00.000","Title":"error: name Twitter not defined on using import twitter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I\u2019m making a robot car using a Raspberry Pi. I\u2019ve attached a raspberry pi camera on top of the car; the images are clear when the car isn\u2019t moving but when it is moving the images are blurry. Is anyone aware of any solutions (either hardware or software) to stop the blurry images when driving?\nThank you","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":39,"Q_Id":63022756,"Users Score":0,"Answer":"I believe that your issue is that as the car is moving, the camera is vibrating. You need to stabilise the camera or make your car move slower.","Q_Score":1,"Tags":"python,raspberry-pi,picamera","A_Id":63022850,"CreationDate":"2020-07-21T20:38:00.000","Title":"How to stop blurry images on Raspberry Pi Robot car?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I use python to develop code on my work laptop and then deploy to our server for automation purposes.\nI just recently started using git and github through PyCharm in hopes of making the deployment process smoother.\nMy issue is that I have a config file (YAML) that uses different parameters respective to my build environment (laptop) and production (server). For example, the file path changes.\nIs there a git practice that I could implement that when either pushing from my laptop or pulling from the server it will excluded changes to specific parts of a file?\nI use .gitignore for files such as pyvenv.cfg but is there a way to do this within a file?\nAnother approach I thought of would be to utilize different branches for local and remote specific parameters...\nFor Example:\nLocal branch would contain local parameters and production branch would contain production parameters. In this case I would push 1st from my local to the local branch. Next I would make the necessary changes to the parameters for production, in my situation it is much easier to work on my laptop than through the server, then push to the production branch. However, I have a feeling this is against good practice or simply changes the use of branches.\nThank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":273,"Q_Id":63022930,"Users Score":1,"Answer":"Config files are also a common place to store credentials (eg : a login\/pwd for the database, an API key for a web service ...) and it is generally a good idea to not store those in the repository.\nA common practice is to store template files in the repo (eg : config.yml.sample), to not store the actual config file along with the code (even add it in .gitignore, if it is in a versioned directory), and add steps at deployment time to either set up the initial config file or update the existing one - those steps can be manual, or scripted. You can backup and version the config separately, if needed.\nAnother possibility is to take the elements that should be adapted from somewhere else (the environment for instance), and have some user: $APP_DB_USER entries in your config file. You should provision these entries on both your servers - eg : have an env.txt file on your local machine and a different one on your prod server.","Q_Score":0,"Tags":"python,git,github,version-control,pycharm","A_Id":63024055,"CreationDate":"2020-07-21T20:53:00.000","Title":"What is the best way to manage client\/server specific files with git?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"tl;dr: Does Ansible have a variable containing the current Python interpreter?\nAs part of my playbook, I am creating a Python script on the controller (to be run by another command), and I want that script to be run by the Python interpreter being used by Ansible. To do this I am trying to set the interpreter in the shebang of the script.\nIf I were to set the interpreter manually, I could use the ansible_python_interpreter variable (and I have had it working that way). If I don't set the interpreter manually, then Ansible will auto-discover an interpreter, but I can no longer use the ansible_python_interpreter variable because it is not set.\nFrom looking through the documentation I have been unable to find any way to see which interpreter Ansible has auto-detected. Is there something I've missed?\n(Ansible version 2.9.10, Python 3.6)\n\nThe complete situation:\nI am running Ansible on AWX (open-source Ansible Tower), using a custom virtual environment as the runner. I use Hashicorp Vault as a secret management system, rather than keeping secrets in AWX. For access to Vault I use short-lived access tokens, which doesn't work well with AWX's built-in support for pulling secrets from Vault, so instead I do it manually (so that I can supply a Vault token at job launch time). That works well for me, generally.\nIn this particular case, I am running ansible-vault (yes, there are too many things called 'vault') on the controller to decrypt a secret. I am using the --vault-password-file argument to supply the decryption password via a script. Since the virtual env that I am using already has the hvac package installed, I wish to just use a brief Python script to pull the password from Hashicorp Vault. All works fine, except that I can't figure out how to set the shebang on this script to point at the virtual environment that Ansible is using.\nIf I can't get a useable answer to this, I suppose I can change to instead pull the password directly into Ansible and then use the --ask-vault-pass flag to pass the password that way. It just seems to me that the interpreter should really be exposed somewhere by Ansible, so I'm trying that first.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":462,"Q_Id":63023699,"Users Score":0,"Answer":"With gather_facts: yes you should be able to get the active python using the ansible_facts.python variable.","Q_Score":5,"Tags":"python,ansible","A_Id":63025081,"CreationDate":"2020-07-21T21:57:00.000","Title":"Does Ansible expose its auto-discovered Python interpreter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm using an API in python and when I make a request to this API, the server must send a audio mensage in a channel.\nIn a text channel I use a webhook, that gives me the context of the channel. I need something like that to be abble to play the audio.\nThere is any way to do this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":940,"Q_Id":63044586,"Users Score":0,"Answer":"You can not play the audio file after sending it through bot.\nWhat you can do is download the audio file and play it using FFMPEG","Q_Score":0,"Tags":"python,api,discord,discord.py,discord.py-rewrite","A_Id":63314438,"CreationDate":"2020-07-22T23:27:00.000","Title":"How use a API call with discord.py?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm reviewing the concepts of OOP, reading .\nHere the book defines interface as\n\nThe set of all signatures defined by an object\u2019s operations is called the interface to the object. (p.39)\n\nAnd the abstract class as\n\nAn abstract class is one whose main purpose is to define a common interface for its subclasses. An abstract class will defer some or all of its implementation to operations defined in subclasses; hence an abstract class cannot be instantiated. The operations that an abstract class declares but doesn\u2019t implement are called abstract operations. Classes that aren\u2019t abstract are called concrete classes. (p.43)\n\nAnd I wonder, if I define an abstract class without any internal data (variables) and concrete operations, just some abstract operations, isn't it effectively just a set of signatures? Isn't it then just an interface?\nSo this is my first question:\n\nCan I say an abstract class with only abstract functions is \"effectively (or theoretically)\" an interface?\n\nThen I thought, the book also says something about types and classes.\n\nAn object\u2019s class defines how the object is implemented. The class defines the object\u2019s internal state and the implementation of its operations. In contrast, an object\u2019s type only refers to its interface\u2014the set of requests to which it can respond. An object can have many types, and objects of different classes can have the same type. (p.44)\n\nThen I remembered that some languages, like Java, does not allow multiple inheritance while it allows multiple implementation. So I guess for some languages (like Java), abstract class with only abstract operations != interfaces.\nSo this is my second question:\n\nCan I say an abstract class with only abstract functions is \"generally equivalent to\" an interface in languages that support multiple inheritance?\n\nMy first question was like checking definitions, and the second one is about how other languages work. I mainly use Java and Kotlin so I'm not so sure about other languages that support multiple inheritance. I do not expect a general, comprehensive review on current OOP languages, but just a little hint on single language (maybe python?) will be very helpful.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":390,"Q_Id":63050082,"Users Score":2,"Answer":"No.\n\nIn Java, every class is a subclass of Object, so you can't make an abstract class with only abstract methods. It will always have the method implementations inherited from Object: hashCode(), equals(), toString(), etc.\n\nYes, pretty much.\n\nIn C++, for example, there is no specific interface keyword, and an interface is just a class with no implementations. There is no universal base class in C++, so you can really make a class with no implementations.\nMultiple inheritance is not really the deciding feature. Java has multiple inheritance of a sort, with special classes called \"interfaces\" that can even have default methods.\nIt's really the universal base class Object that makes the difference. interface is the way you make a class that doesn't inherit from Object.","Q_Score":2,"Tags":"java,python,oop,inheritance,design-patterns","A_Id":63054571,"CreationDate":"2020-07-23T08:31:00.000","Title":"Is an abstract class without any implementation and variables effectively interface?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I try to copy the files in virtual environment I get the above error.The command is cp -r AmritaAura_local\/amrita_aura\/aura AmritaAura_local\/local_setup\/venv\/lib\/python2.7\/site-packages.\nWhere am I going wrong ? What does the error indicate in python?What does cannot stat means ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":140,"Q_Id":63054547,"Users Score":0,"Answer":"Proper path name should be given in destination directory and also the location of source directory should be opened in terminal.Then cp -r src_directory(only the relative path) destination_directory(full path) should be given.","Q_Score":0,"Tags":"python,file,virtualenv,cp,stat","A_Id":63063812,"CreationDate":"2020-07-23T12:41:00.000","Title":"cp: cannot stat 'AmritaAura_local\/amrita_aura\/aura': No such file or directory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"im trying to read the information from a TM1650 (is working with a 7 segment and 3 digits display) to a raspberry.\nFirstable i was working with an arduino but after too many tryings y found that y cannot read diferents address value there at the same time(i need to read the adress value of 52,53 and 54 possition).\nI have also an raspberry pi 4 and i wanted to know if there ir an code than can helpme to read the display data.\npd: the display is in to another board, that i have no program, thats what i wanna get the data.\nSorry for my bad english","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":57,"Q_Id":63092204,"Users Score":0,"Answer":"if someone needs help with that in the future, the solution is to use threads, i used the library protothreads. Just remind not to use \"delay\" , try to use \"millis\". (Arduino)","Q_Score":0,"Tags":"python,raspberry-pi,display,i2c","A_Id":63458424,"CreationDate":"2020-07-25T18:45:00.000","Title":"Trying to read multiples address in i2c with raspberry","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to set a prefix for each cog?\nFor example the Cog with admin commands has the prefix pa! and the cog for some fun commands pf!.\nWithout using on_message.\nEdit:\nI guess I have to go more in detail:\n\nMy cog for serverstats has a command called 'stats', this command should get\ntriggered when I'm using pa!\nMy cog for fun has a 'stats' command too. This should be triggered when I'm\nusing pf!\n\nMy only thought up to now was to set the default prefix to p! and then call the command astats. But I want to have a better way.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":681,"Q_Id":63105582,"Users Score":0,"Answer":"If all of your commands are in the on_message event, you can split the message content with spaces (\" \") and check the first element of the splitted list for the prefix and put the avaibale commands under an if statement. This could work, but will be slighly resource heavy depending on the amount of the commands","Q_Score":3,"Tags":"python,discord.py","A_Id":70622633,"CreationDate":"2020-07-26T20:53:00.000","Title":"Different prefix for each Cog?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible to set a prefix for each cog?\nFor example the Cog with admin commands has the prefix pa! and the cog for some fun commands pf!.\nWithout using on_message.\nEdit:\nI guess I have to go more in detail:\n\nMy cog for serverstats has a command called 'stats', this command should get\ntriggered when I'm using pa!\nMy cog for fun has a 'stats' command too. This should be triggered when I'm\nusing pf!\n\nMy only thought up to now was to set the default prefix to p! and then call the command astats. But I want to have a better way.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":681,"Q_Id":63105582,"Users Score":0,"Answer":"I think this is an interesting question as I have had the same one for some time. I had an idea for implementing this myself although it does use the on_message function but not just that.\nBasically my thought was to override the cog class and add a way for it to denote what prefix it should have. I thought use a custom argument in @commands.command to signify what prefix to use but this was for commands themselves.\nThen in the on_message function you will need to determine there what command to call. Possibly the use of a global dict that correlates what prefix to what command.\nThis was just my own personal brainstorming and you will need to keep in mind if you allow each server to set their own prefixes and how to go about allowing that plus allowing them to set custom prefixes for each command. Good luck I hope this helps","Q_Score":3,"Tags":"python,discord.py","A_Id":63105679,"CreationDate":"2020-07-26T20:53:00.000","Title":"Different prefix for each Cog?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I built a python script (bot) for a game and I do plan on building a GUI for it to make it more user friendly. However I wanted to add some sort of security along with it, something that would only give access to whoever I want, so maybe adding some kind of encryption key to it, I was thinking something along the lines of an encrypted key to unlock the files and with limited use(a few days for example). I am new when it comes to this specific 'security' topic, so I need help better understanding what my options are and what I can do or search for. Thank you for reading.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":63,"Q_Id":63126414,"Users Score":0,"Answer":"after days of searching and trying I figured the easiest way was to use a web API to check requests, you can use for example cryptolens web api or any other api and your encrypted file will work just fine.","Q_Score":0,"Tags":"python,encryption","A_Id":63198843,"CreationDate":"2020-07-28T03:01:00.000","Title":"Safety\/Encryption for python script (bot)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a discord bot written in python. It doesn't do much, however if you spam commands while it is in the middle to replying to another command, it freaks out. is there a way to make it refuse other commands until it has finished with the current process?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":47,"Q_Id":63127434,"Users Score":1,"Answer":"Maybe some global variable \"ready\" and just allow to run commands if ready is true?\nAt start of command set ready to false and at the end to true.","Q_Score":1,"Tags":"python,discord,bots","A_Id":63129807,"CreationDate":"2020-07-28T05:13:00.000","Title":"(discord.py) How can I make it so my bot that doesn't reply to other commands until the current command is finished","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I built a python weather using tweepy and it works fine but it needs me to run the script with my computer.\nHow can I deploy my python script on a 'server' or something so I don't need to run the script 24\/7 on my laptop ?\nThanks for help !","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":70,"Q_Id":63134050,"Users Score":1,"Answer":"If your internet connection is stable and you don't mind initial cost: Raspberry Pi.\nIf you are a student you can get $50 store credit at Digital Ocean through the GitHub Education Pack.\nIf you have a credit card and don't mind verifying (doesn't cost and has no subscription costs) you can use the free tier in Google's cloud. With a verified CC you can host on Heroku 24\/7 for the entire month. Without a verified CC you can host it 24\/7 for ~2-3 weeks every month. AWS also offers some free tier solution.\nYou can also just outright pay for a VPS every month. I currently use Vultr and pay $2.5 per month.","Q_Score":1,"Tags":"python,hosting,tweepy","A_Id":63134282,"CreationDate":"2020-07-28T12:22:00.000","Title":"Python twtter-bot hosting?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I built a python weather using tweepy and it works fine but it needs me to run the script with my computer.\nHow can I deploy my python script on a 'server' or something so I don't need to run the script 24\/7 on my laptop ?\nThanks for help !","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":70,"Q_Id":63134050,"Users Score":2,"Answer":"You could buy a raspberry pi.\nI use it only for such things.\nelectricity: ~2-4W\nIt isn't that expensive and you can host many projects for a low price.","Q_Score":1,"Tags":"python,hosting,tweepy","A_Id":63134151,"CreationDate":"2020-07-28T12:22:00.000","Title":"Python twtter-bot hosting?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm making a discord bot that kicks bots that are invited to the server who were not invited by users with specific roles. I am struggling to find out who invited a bot to the server. I ran a few tests and came to the conclusion that an invite code\/link is not created when someone invites a bot. I know I can see who invited a bot in the AuditLogs but I want to kick a bot automatically if it is invited by an admin who should not be able to invite them.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":97,"Q_Id":63163142,"Users Score":0,"Answer":"One way to solve this issue is to just not allow people other than admins to invite people to the server. However, if you want people to be ale to invite others, just not bots, here is what you can do: When a bot joins the server, you can use your bot to check iterate over the audit logs and check if the action is an invite and the target is the bot they you can check who invited the bot. From there on just check if who invited the bot is an admin, if not, kick the bot.","Q_Score":0,"Tags":"python,discord.py","A_Id":63207891,"CreationDate":"2020-07-29T22:06:00.000","Title":"Discord.py I want to have something in my code that gives me the person who invited a bot","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Background :\nIn our project we are doing bulk deployment in that we are having around 10 AWS Lambda functions, Few Scala applications and few configuration files. Currently we are deploying 10 lambdas if there is no change as well.\nProblem :\nLets say we have changed code in Scala class, committed to GIT and from there using Jenkins we are deploying the changes. As we have no differentiation between Lambda and Scala changes we are deploying all the Lambdas, Scala classes and Configuration files as well.\nQuestion :\nMy question here is if we implement SAM on top of our Lambdas and then will separate it out deploying all the lambdas at a time as a separate Jenkins pipeline. If there is a change for 1 Python code in Lambda functions will it allow to deploy only delta Lambdas.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":212,"Q_Id":63173449,"Users Score":0,"Answer":"sam deploy will only deploy resources if they have changed. Otherwise it noops (no operation).","Q_Score":0,"Tags":"python,scala,amazon-web-services,jenkins,aws-sam","A_Id":63185227,"CreationDate":"2020-07-30T12:44:00.000","Title":"Deploying AWS Lambda using AWS SAM in Jenkins","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"Background :\nIn our project we are doing bulk deployment in that we are having around 10 AWS Lambda functions, Few Scala applications and few configuration files. Currently we are deploying 10 lambdas if there is no change as well.\nProblem :\nLets say we have changed code in Scala class, committed to GIT and from there using Jenkins we are deploying the changes. As we have no differentiation between Lambda and Scala changes we are deploying all the Lambdas, Scala classes and Configuration files as well.\nQuestion :\nMy question here is if we implement SAM on top of our Lambdas and then will separate it out deploying all the lambdas at a time as a separate Jenkins pipeline. If there is a change for 1 Python code in Lambda functions will it allow to deploy only delta Lambdas.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":212,"Q_Id":63173449,"Users Score":0,"Answer":"You always have to deploy the entire stack using sam deploy. If some of your lambdas don't have changes, then --no-fail-on-empty-changeset will be your new friend.","Q_Score":0,"Tags":"python,scala,amazon-web-services,jenkins,aws-sam","A_Id":65644545,"CreationDate":"2020-07-30T12:44:00.000","Title":"Deploying AWS Lambda using AWS SAM in Jenkins","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I'd like to create a git pre-commit hook for my project that runs autopep8 on files modified by the potential commit. I only want to run it on Python files, not the other C++ files, text files, etc. How can I programmatically detect whether a file is a Python file? Not all of the Python files in the repository have the .py extension, so I cannot rely upon that.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":157,"Q_Id":63182584,"Users Score":1,"Answer":"You can't.\nAt least not in such general case and with perfect accuracy. Your best bet is to make sure all your python files in the repo do have .py extension or are disntinguished from other files in some simple, finite amount ways.\nYour next best bet is file command.","Q_Score":7,"Tags":"python","A_Id":63184501,"CreationDate":"2020-07-30T23:02:00.000","Title":"How to Programmatically detect whether a file is a Python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0}]