Today's Question:  What does your personal desk look like?        GIVE A SHOUT

 PYTHON


  Where Have You Installed Your Python Packages?

PrefaceI am writing this article because I recently noticed in the Python community that there are several frequently asked questions:Why does running the command after installing pip result in a "executable not found" error?Why does importing a module result in a "ModuleNotFound" error?Why can I run my code in PyCharm, but it doesn't work in the command prompt?Rather than just providing solutions, it is better to teach people how to fish. To address these types of issues, you need to understand how Python locates packages. I hope that after reading this article, you will find it helpful.How P...

9,643 1       PYTHON PATH PATH_PREFIX PACKAGE LOCATION


  Problem and Solution for Installing wxPython on Ubuntu 20.04

When we try to install wxPython lib on Ubuntu system to do software GUI development,most of time we may meet some installation and lib dependency problems. For the latest Ubuntu version, the problems still happen. Below are some common problems which happened frequently and their solution:---------------------------------------------------------------------------------------------------------------Problem [1]: Install wxPython on Ubuntu 20.04 fail because of dependency package Gtk is not installed.Error Message:No package 'gtk+-3.0' found Package gthread-2.0 was not found in the pkg-config sea...

22,956 7       UBUNTU 20.04 WXPYTHON PYTHON


  Mutli-inheritance bug between python 2.7 and 3.7

When we have run a py3.7 code under py2.x or a py2.x code under 3.x ,if a class do mutli-inheritance from 2 parent and the 2 parents also got inheritance from same parent, the different way to handle inheritance chain between python 2 and 3 will cause some running time bug:Assume we got this sample program inheritTest.py :# Purpose: Test mutli-inheritance different between python2 and 3# Author: Yuancheng Liu# Created: 2019/05/16class A: def getVal(self): print("call A's getVal()") def setVal(self): print("call A's setVal()")class B(A): def getVal(self): ...

2,599 1       INHERITANCE PYTHON 3 PYTHON


  Bug caused by using changeable value as the default in "python method overload"​

In python we can set the passed in parameter's default value to make the function has the same running feature as the method overload in Java.Define a function like this:def testFunction(self, param1, param2=None, param3=None):Normally we use "None" as the parameter's default value. We can also use str/bool as the default value, but is it OK we use empty list [] as its default value?This is our test program:""" A test program using empty list as the passed-in parameter's default value."""class TestFunc(object): def __init__(self, id, parm = []): self.ObjId = id self.parm = ...

2,820 0       PYTHON


  Is Python all set to triumph over Java?

Python is one of the top programming languages of the present time. A variety of companies with different backgrounds and offerings have embraced the capabilities of Python to make wonderful tech products. As, Java is also known to be one of the most recognized languages, therefore, there is a constant battle that takes place between the two languages. Python wants to dethrone Java as the number one, whenever it is and vice versa. It is like the tussle between Android and iOS which is never ending. Both of the languages were introduced to the world in the 90’s.Shortly after the emergence...

1,746 0       DEVELOPMENT JAVA PYTHON DJANGO


  Python Disrupts the Programming Language World- Gets Hot and Popular

Python is one of the fastest growing languages currently. It is undeniable that more and more programmers use Python and deploy it to the best of their use. Everyone, from the freelancer and startups to giant corporations and even governments, is using Python. Let us have a look at the reasons that make it so popular. Training:According to research, 8 out of 10 tech schools in the US teach Python over JAVA. Even the three major MOOC platforms, edX, Coursera, and Udacity have a similar approach and have introductory programmes before anything else and promote it on a massive level. &n...

9,305 1       DEVELOPMENT PYTHON TEAM


  Use pdb to help understand python program

 As I have mentioned in Why do I need a debugger?:(3) Debugger is a good tool to help you understand code.So when I come across difficulty to understand vfscount.py code in bcc project, I know it is time to resort to pdb, python's debugger, to help me.The thing which confuses me is here:counts = b.get_table("counts")for k, v in sorted(counts.items(), key=lambda counts: counts[1].value): print("%-16x %-26s %8d" % (k.ip, b.ksym(k.ip), v.value))From previous code:BPF_HASH(counts, struct key_t, u64, 256);It seems the v's type is u64, a...

1,247 0   


  Learning Python as your first programming language

Python is a widely used general-purpose, high-level programming language Its design philosophy emphasizes code readability, and its syntax allows programmers to express concepts in fewer lines of code than would be possible in languages such as C. Python now becomes more and more popular and is now being used the first teaching language in some universities. Why would you like to learn Python as your first programming language? Below are the reasons.Python is a high-level language with dynamic typing. It means it won't bother you with things like pointers and memory management, and provides yo...

12,260 0       ADVANTAGE PYTHON