r00t.gr

Programming and more

Entries for the ‘Python’ Category

Create a tuple that has only one item, Python

Tuples are lists that are immutable (cannot be changed). To create a tuple with one item you have to use a comma: single = (2,)single = (2,) If you just type single = (2)single = (2) This will give you a variable containing 2

How to get the size of a List in Python

Ok trivial question, maybe not good for a post, but remember this blog replaced my personal notes, and I am just learning python 🙂 The right way to get the size of a list (In Python reffered as length) is this:   psychedelics= [] psychedelics.append("lsd") psychedelics.append("dmt") psychedelics.append("thc")   len(psychedelics)psychedelics= [] psychedelics.append("lsd") psychedelics.append("dmt") psychedelics.append("thc") len(psychedelics) In […]

How to read a Url in Python

I started learning Python today. I have several java programs that collect/copy content from many webpages in the internet, they work great, but they use a lot of memory, and I need that memory. Also it’s always fun to learn something new and I always hear the best things about Python, which is easy and […]