I had a look at the python 2D plotting library matplotlib. For more information about this library, you might want to have a look at the corresponding Wikipedia article. I’m looking for a way to make simple plots from x,y value pairs and it […]
Tag: python
JSON in Python and Common Lisp
Both, Python and Common Lisp have libraries for writing and reading JSON format. JSON can be used as an alternative to XML, when not only machines will read the data. XML can be hard to read when you have more tags than data. JSON […]
Regular Expressions: Groups
In Python, you can write the following, to capture groups of characters with regular expressions. >>> import re >>> print(“Match is ‘” … + re.search(‘\\s([a-z]+)\\s’, … ‘My text string.’).group(1) + “‘”) Match is ‘text’ >>> This is quite straightforward. In C#, you can write […]
Package basics
Packages form the basic building blocks of software components in many programming languages. For example, in Java you use the package statement to define the package for a class as follows. package a.b; public class C { public static void main(String[] args) […]
Some notes on lists in Java and Python
Java and Python both have collection types (or compound data types). For a general introduction into collection types, you might want to have a look at Wikipedia. One of the most basic collection types is a list. In Java, you use the interface java.util.List […]
About coding conventions
Coding conventions are an important part of software development. Contrary to popular belief, it is not only the functionality of the code that matters, what the code does, but also the readability, what the code looks like. That is because code is read much […]
Writing shell scripts in Python
After browsing the web for some time, your download folder might be filled with a lot of files of different type. PDF files, image files and more. Or maybe you collected a lot of files in a temp folder and now you want to […]
How do I write and read plain text files in Python?
Writing and reading plain text files is easy in Python. Look at the following functions. def write_file(txt, filename): with open(filename, ‘w’) as f: f.write(txt) def read_file(filename): with open(filename, ‘r’) as f: return […]