Python Tutorial

How To Connect MongoDB And Create Database Collection In Python Source Code

Pymongo is a popular mongo database python driver library. We can use it to manage the mongo database. In this article, I will show you how to install pymongo library and how to use pymongo to connect to the mongo database. It also tells you how to create a mongo database and collection in python […]

How To Connect MongoDB And Create Database Collection In Python Source Code Read More »

How To Change Python Interpreter In Eclipse Pydev Project To Use Different Python Virtual Environment Library

When I develop a python program in the eclipse Pydev project, I need to import a package pymongo into this python program like the below source code. import pymongo if __name__ == ‘__main__’: pass But it shows an error message Unresolved import: pymongo in the source code, you can see this error message when you move

How To Change Python Interpreter In Eclipse Pydev Project To Use Different Python Virtual Environment Library Read More »

How To Fix Failed To Unlink Socket File Error When Start Mongo DB On MacOS

When i start mongo db on macOS console by run command mongod, i got below error message. {“t”:{“$date”:”2020-09-09T10:45:30.049+08:00″},”s”:”E”,  “c”:”NETWORK”,  “id”:23024,   “ctx”:”initandlisten”,”msg”:”Failed to unlink socket file”,”attr”:{“path”:”/tmp/mongodb-27017.sock”,”error”:”Permission denied”}}

How To Fix Failed To Unlink Socket File Error When Start Mongo DB On MacOS Read More »

How To Print Text From Standard Output (Stdout) To File In Python

When you run print(‘ hello python ‘) in python code, it always print the text on screen, this is because python standard output is screen console. But we always want to print the text to a file instead of screen console, especially print exception error messages when exception occurred in python source code.

How To Print Text From Standard Output (Stdout) To File In Python Read More »

How To Debug Python Code In Ipython And Jupyter Notebook

When you run a python script file in the iPython command console or jupyter notebook web page, if your source code has an exception, it will throw out the exception and stop at the line where the exception occurred. In this situation, you can set breakpoints and run into iPython debug mode, then you can

How To Debug Python Code In Ipython And Jupyter Notebook Read More »

How To Introspect ( Look Inside ) Python Objects In IPython

IPython provide some magic command ( ?, ??, %pdef, %pdoc, %psource, %pfile ) for you to look inside python objects(  variable, function, class. module, object etc ). In this article i will tell you how to use them to introspect python objects in IPython. Below example need an ipython environment, if you do not install

How To Introspect ( Look Inside ) Python Objects In IPython Read More »