Control flow in Python

This week I have started learning python just for the sake of picking up another programing language other than javaScript that I have been working with for years. I do very much still like javaScript a lot, and thing that it is a great starting language for people who have zero experience programing, I just think that it is time to finally start trying out something else.

Anyway one big part of learning a new language is to learn what there is to work with when it comes to control flow. That is how to go about writing basic elements of code such as if statements, while loops, and other elements of a language that control the flow of a program. In python there are a number of features that are not all that different from what I am all ready familiar with in javaScript, there are of course if statements, while loops, and functions. So in this post I will be taking a look at these various control flow options.

This post on control flow in python will be fairly basic as control flow is a basic aspect of learning a language. However it is still never the less something that I need to learn all over again even though I have years of programing experience with control flow in javaScript. Also in order to really understand how to work with control flow statements in python I am also going to need to at least learn a little when it comes to other related topics like boolean values, and expressions.

Read More

Built in Python functions

I have started to learn python, and one of the first things that I have become aware of when doing so is like many other programing environments there are a number of built in functions. It is always a good idea to take a moment to look over what there is to work with when it comes to built in functions before getting into user space modules, and python is no exception to this. If I need a function that does something the first collection of functions that I should look at are these built in functions, then what there is to work with when it comes to standard libraries, then user space libraries, and then if all else fails look into what I need to do in order to come up with my own solution.

This post will then be a general overview of all of the built in functions to work with in python. I might not get to covering all of them, but I will at least mention the ones that strike me as the most important thus far when it comes to getting started with python at least.

Read More

Getting started with Python

I like javaScript a lot, but I think that I am long overdue for learning at least one or two additional languages beyond just that of javaScript. I have started a collection of posts on bash scripts which I think can be thought of as another kind of language, although bash is only good for a very specific style of programing that has to do with automating work in a POSIX system such as Linux. Speaking of Linux I also wrote a post on gcc, and in that post I put together a few simple C language examples as I think that doing so is called for if I am going to write a post on gcc.

However I think that when it comes to starting another serious collection of content on another language, maybe it would be best to start with learning the very basics at least of python. I have took the time to start another personal collection of source code examples on python, and now I think that I should start writing some content on the subject.

So far there is a great deal that I like about python compared to a javaScript environment. I do like node still very much, but I can all ready see why a lot of people might prefer python when it comes to writing some kind of desktop application, of back end system. When it comes to built in modules there is just so much more to work with compared to node.

I am still pretty new to python, but I have to say that the process of learning it is going fast. Of course I do have a lot of experience with programing, so much of what is going on is just learning how to do things I all ready know how to do just with python rather than javaScript.

So then this post is a getting started post on python, and unlike with javaScript I am now writing about getting started with python from the perspective of someone who is still pretty new to the language. That was not the case when I started writing about javaScript, so in time maybe writing about python will help me in my efforts when it comes to improving my javaScript content. In any case lets start out with the very basics when it comes to getting started with python.

Read More

Hyper Casual Space Shooter canvas example

I have made a few canvas examples so far, but I think it is time to try something new. I started one other canvas example thus far that I have called a kind of hyper casual type game called to the black. The idea that I had in mind for that example was very basic, I just wanted a ship that goes forward threw space at a given rate, and I have an estimate as to how long it would take for the ship to reach Max Safe integer. It was a fun, simple little project that I was able to put together in a sort time frame.

With this canvas example I want to continue with making a collection of games where I just have a very basic general idea as the whole of the example, or as a starting point for something I might put a fair amount of time into. In other words set the bar very low in terms of complexity and therefore have an idea for a game in which I can end up having a working proof of concept in a short time frame. Once I have the basic idea working from that point forward it is just a question of what I need to add in order to make the game more fun.

So then for this next hyper casual canvas example I had an idea to just make a simple, basic game in which I just fly around space and destroy blocks, thats it. So of course I was able to get that up and working in a flash, and now I just need to think in terms of what I want to add moving forward from here. Unlike the to the black example, with this one I put over a month worth of time into, and as such there is much more going on. Still the basic idea was done right away, at this point I am just continuing to pile more features on top of it. I have a half way decent example together now as of v0.25.0 of the example, I might put a little more time into it, but I think I am getting to the point where there really is only so much more to do. The core of the idea is there along with a great deal more, and now I might start some additional examples based off of this.

Read More

Positional Parameters in Linux Bash scripts

This post on bash scripts will quickly cover the topic of positional parameters. What this means is the arguments that are given when the bash script is called from the command line, or another bash script. For example if I call the Linux ls command with the -l option, then the -l option can be thought of as a positional parameter. In nodejs for example these kinds of positional parameters, or arguments if you prefer can be obtained from the process global in nodejs.

When it comes to bash scripts there are actually several sets of parameters to be aware of. There is the set of parameters that have to do with the bash command itself, there are a number of special parameters to work with, and then there is the set of parameters for the script that is called with bash. I have wrote a post on bash parameters in general, however in this post the focus will be just on positionals alone.

So In this post I will be going over a few quick examples of Linux bash scripts that make use of one or more arguments in the form of positional parameters that are given at the command line, or wherever the script is called.

Read More