An anti-pattern is a common response to a recurring problem that is usually ineffective and risks being highly counterproductive.
We should always strive against creating antipatterns in our code.
Do not use global foobar
in Python. Instead use the Global Object Pattern.
- The Global Object Pattern
- How do I share global variables across modules?
- How to avoid using global variables?
Here is an example where the extension and filename misleads the reader to assume the file contents follow a packet capture format, however, the contents are instead an ASCII dump and the file is not readable by Wireshark.
wlanpi@wlanpi:/tmp $ file lldpneightcpdump.cap
lldpneightcpdump.cap: ASCII text
What's wrong with this? The file extension is misleading.
The better file extension in this example would be .txt
or similar rather than .cap
. It better represents the contents.
A file with extension .cap
should have contents similar to this:
wlanpi@wlanpi:~ $ file test.cap
test.cap: pcap capture file, microsecond ts (little-endian) - version 2.4 (Ethernet, capture length 262144)