Angelix

Python Programming Language

Recommended Posts

Hi folks,

I am going to be teaching myself Python in the near future.  The main python website looks like an excellent resource but I was wondering if any experienced Python programmers have any advice to share.  I have a very rudimentary knowledge of programming, having delved a little bit into java a few years ago, and a little deeper into Turing Editor about 20 years ago.

As part of my self education I intend to program a simple game, since that will give me an interesting objective to keep me focused as I learn.  My initial progress in programming was significantly aided by such an approach and I think that it will be a fun way to learn the language even if the end state reason for learning it has nothing to do with gaming.  Unlike my previous forays into programming I intend to gain an extremely in depth knowledge of the language and its capabilities so that I can use it in a professional working environment.  

Cheers!

Share this post


Link to post
Share on other sites

Are you looking to use it for powering a User Interface or anything of that sorts?  Or are you wanting to primarily stick to command line types of applications?

If you're looking to do anything with a UI or have any graphical elements I would suggest looking into the Tkinter module for python.  wxPython and pyQT are high up on the list too.  I've heard of, but not used, Pygame (2D game development) and Pyglet (3D game development) as being good as well.

As you'll find out, python has a plethora of modules out there that are almost always open source and largely have minimal documentation because the creators weren't paid for that... if they were paid at all ;)  Some of my favorite go to modules are: NumPy (advanced math functions), SciPy (additional library of algorithms and math tools), matplotlib (very helpful plotting library), SymPy (algebraic eval, differentiation, and such).  However, I'm largely working in a data mining/processing capacity so that's why most of the modules I use are geared towards that.

I came from a scripting background (Matlab mostly) when I first got into python so it wasn't too difficult of a transition.  The biggest thing, by far, is understanding that python is tab delimited when you write code.  That means that nesting code is based on tabs...

line 1
if something
	line 2
	line 3
	line 4
line 5
line 6

So based on the code above, line 2,3,4 only get touched if the if statement is true.  There's no use of "end" or { } to enclose what is tied to the if statement. 

 

With all of that said, I'm sure you've got a good head on your shoulders and will pick it up quick.  I'm happy to help debug if you ever get stuck!  I usually use notepad++ or the Idle GUI for coding in python, really comes down to personal preference.  You could really just write it in a text editor and hope for the best too :)  Part of why I like python so much.

Edited by MadCast: Lurama

Share this post


Link to post
Share on other sites

Thanks Lurama =)

I had read that no brackets were required, which saves on typing anyway.  No end statements is also nice.

The actual job specification at this time is pretty much anyone's guess, as that's not information I'm privy to at the moment =)

I'll probably have a better idea of the intended final application once I've got some experience using Python.  

I'll definitely take a look at your suggestions for graphical UI modules, as well as your favs, once I crack open the books.  Again, thanks!

Share this post


Link to post
Share on other sites

I work for World Wide Technology and right now working on server racks for a company on which i can't name. Sense i do a lot of these unnamed servers and racks, I currently use Python to apply network configurations for me. I took a bit of time to write the Python code that applies the config, but well worth the time as it continues save me hours of work. I love Python! It has tons of uses. 

I'm not sure i can be of any help, but I would love to see some post on your findings and learning as you go! Who knows, you could teach me and some others some neat things. I wish you the best of luck with your studies and final application.

Share this post


Link to post
Share on other sites
Awards

I almost forgot to mention.  CodinGames.com is a great resource that has a game-like feel to the learning.  It does support both Python and Python3, depending on which version you're wanting to learn.  Python3 is the present version and the future of the language but there are still loads of things out there that run on Python2 (aka Python).

Edited by MadCast: Lurama
typo in URL

Share this post


Link to post
Share on other sites

Thanks guys.  I will definitely post my progress here as I go.  Critiques and advice will be extremely welcome =)

I wouldn't be surprised to end up using Python for various purposes including network security / analysis and data mining.  In the meantime, however, I shall enjoy the learning process by diving headlong into the gaming aspect =)

I could even try to incorporate elements of what I expect to need to do professionally into the game itself, with the goal of creating a game that teaches the player.  I will develop a storyline plot for the game, most likely a turn based RTS with sci-fi and fantasy elements (perhaps in a Shadowrun-esque manner), and then incorporate the teaching points into player missions.  It may or may not have a gui depending on how difficult that is to do with the tools available.  I would definitely prefer to have one, but know just how time consuming that can be.

Edited by MadCast: Angelix

Share this post


Link to post
Share on other sites

Just remember that at the end of the day, once you've learned how to program, you can program in any language.  It's just a matter of learning the syntax.  I learned to program in Turbo Pascal (a little dated now) but have landed on contracts that have required me to learn other languages, namely because a lot of programming is having a good understanding of what you intend to do, laying it out well, and then implementing it in a manner that makes it easy to tweak and change later on.

 

Share this post


Link to post
Share on other sites

python is an interesting beast. i will preface this by saying that i have been programming for nearly 7 years, and have achieved fluency in a plethora of languages including c#, c, c++, java, basic, and a series of scripting languages as well including LUA, SQL, HTML + CSS.

I don't know how much experience you have in programming outside of dipping toes in java. if you are rather new to programming i find it hard to recommend python as a place to start. i attempted python as my first language and it was gruelling, and i don't feel like it was the right choice. python has a habit of abandoning standards of languages. its very high level, and it does not seem to write much like other languages and so it was difficult to translate an understanding of python into other languages because it is so different. to this day i don't feel truly fluent in python. personally i would recommend starting out on something a little more standard like c# as a first language to learn as it allows very easy transition to all the "c-type" languages (c c# c++ java etc" which are what you will most likely be encountering on the regular and which are very broad in there uses. (i have written games, user interfaces, netcode, spreadsheet applications small purpose tools and more in c#), once you feel you are very comfortable with programming in general and have established the habits that will benefit you on almost all languages, then python is worth picking up on the side. a good understanding of a c-type language really helps when it comes to getting into the field.

now with that out of the way. if you are adamant on python there is a lot of information and tools out there to help you. 

some sites i recommend include:

https://www.codewars.com mind challenging programming problems in a wide variety of languages to keep you sharp.

https://www.codecademy.com a great place to start with programming any language. a comprehensive hands-on crash course to set you in the right direction

https://codefights.com/ a platform for competitive coding once you are a little more experienced and wish to test your skills against others. also includes dedicated bots for various companies, allowing  you to challenge problems you can expect to run into working for various major companies.

the biggest tip I can give you when it comes to programming in general is to be diligent with your code. don't just make it work, make it optimal and make it readable. that means following naming conventions, camel casing, separating things into modules and classes and functions that make sense. comment everything. and do this always. it may not seem important when you are writing a small 50 line program by yourself, but the point is to create the habits because when you are working collaboratively or even alone on major projects, keeping code clean and smart is of the utmost importance.

it also really helps to keep your most usefull classes and methods in a repository that you can import into future programs, alot of code is very reusable, don't be afraid to recycle it.

another great habit to get into is to write pseudocode before starting. lay out exactly what you want a program to do and how you want to achieve it in great detail, this helps to keep your code clean and consise improving readability and optimisation.

and finally, if things get rough, don't get discouraged, programming can be very very frustrating, but that is what makes it so rewarding, this is one of the most fun and exciting fields in the world, don't lose out on that because of a few nights of lost sleep.

 anyways best of luck, i hope this is helpful, and feel free to hit me up if you need help with anything related to programming or software treat me as a resource when you need it!

Share this post


Link to post
Share on other sites

@MadCast: MasterWonton brings up some good points there.  Most places will draw a line of delineation between "programming" languages and "scripting" languages.  Python is very much a scripting language but it can be used, to an extent, as a programming language.  the 'C' languages would be programming languages and certainly not scripting languages.  It's ultimately going to come down to what your intention to code up is.  That being said, if the reason Python is the choice here is because you've got a pretty good notion that the upcoming job/position will likely require it's use, go for it!

C# with WPF is an awesome jumping off point for developing windows applications and can easily be used to make mobile apps as well.  You'll never realistically be able to do that with Python though.  However, you can develop Python based games.  A really good example is Eve Online.  They used stackless python (it's a lightweight micro-threaded version of python) for all of the scripting, however, all of the graphics and such are done using C/C++ primarily.

In line with what Wonton mentioned about best practices and all that.  A version/revision tracker would be something good to get a handle on as well.  I'm most familiar with Mercurial (aka: TortiseHg) and find it to be pretty easy to pick up.  Ultimately it allows to you commit changes and include notes about what that change did.  But if that really messes things up or you want to remove that "feature" later it allows you to easily go back and pull that code or revert to a version prior to that change when things blew up :P

Edited by MadCast: Lurama
Forgot to mention revision tracking.

Share this post


Link to post
Share on other sites

Thanks for the feedback guys =)

In the past I always commented everything because when I first started teaching myself turing editor in high school 20+ years ago my first game, roughly 50 to 60 pages when printed out, used nothing but loops to separate the various functions which were all written as "if statements", resulting in a significant amount of layering that absolutely required good commenting to keep track of.  My initial poor coding required me to develop good comment practices =)

When I was working with Java I also made certain to type up my program requirements and the "steps" for each part of the program so that it was simply a matter of coding each step.

I will definitely check out a version tracker, great suggestion!  I want to develop good programming practices early as this will allow for more efficient and cleaner production in the long run.

As for Python, it was indeed identified as the language that I should be fluent in, and will therefore be the focus of my efforts.  I did dabble in C# a while back, but even dabbling is a fairly generous term for my forays into that language.

Edited by MadCast: Angelix

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.