Author Topic: Learning Python  (Read 1107 times)

0 Members and 1 Guest are viewing this topic.

Offline iViscosity

  • Hero Member
  • *****
  • Posts: 675
  • Karma: 34
    • View Profile
    • iViscosity Gaming
Learning Python
« on: January 07, 2017, 08:59:35 PM »
So I'm sure many of you here are familiar at least with other programming languages, and I'm looking to learn something new. Python is one of the first things that I thought of because it seemed interesting to learn. Currently I'm using "The Hitchhikers Guide to Python" to learn some of the basics, but was wondering if anyone had any suggestions of a language I should learn or they think is interesting, or something like that. Or, if there's a better place to learn how to use Python or something like that.
I'm iViscosity. I like gaming and programming. Need some help? Shoot me a PM or Join my Discord!.
--==[ Links ]==--
Steam
YouTube
Steam Group (feel free to join!)
Forums
Public Discord
Teamspeak

Quote from: Steve Jobs
Your work is going to fill a large part of your life, and the only way to be truly satisfied is to do what you believe is great work. And the only way to do great work is to love what you do. If you haven't found it yet, keep looking. Don't settle. As with all matters of the heart, you'll know when you find it. And, like any great relationship, it just gets better and better as the years roll on. So keep looking until you find it. Don't settle.

Offline BlueNova

  • Jr. Member
  • **
  • Posts: 61
  • Karma: 7
  • The most powerful force in the universe.
    • View Profile
    • Steam Profile
Re: Learning Python
« Reply #1 on: January 07, 2017, 09:42:23 PM »
If you haven't used these yet then you could try the succinctly e-books. I use them for mostly any programming language I'm interested in learning.

Here's a link to Python Succinctly if you're interested in them.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 7707
  • Karma: 350
  • Sertafide Ulysses Jenius
    • View Profile
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Learning Python
« Reply #2 on: January 07, 2017, 10:14:37 PM »
If you're wanting server-side code, PHP is fun.
Though python can be used, and has lots of framworks for, server-side stuff, I've always thought PHP is better, totally IMO.
However, I wish I knew more python - I run a plex server, and so many python apps have been created for it's API that I wish I knew more/was more comfortable with it for how to make new/fix existing stuff for it.
The price one pays for pursuing any profession or calling is an intimate knowledge of its ugly side. - James Baldwin

Offline roastchicken

  • Respected Community Member
  • Sr. Member
  • *****
  • Posts: 480
  • Karma: 84
  • I write code
    • View Profile
Re: Learning Python
« Reply #3 on: January 09, 2017, 12:01:00 PM »
I second JamminR's suggestion of PHP, it's a pretty neat language. I only have minimal knowledge of it, but it's probably the most used language in terms of server-side scripting. If you ever plan on doing web development it's a useful skill to have.

However you should definitely stick with Python for the time being unless you're infinitely more interested in web technologies, as Python seems to have more applications than PHP.

I've always wanted to learn more languages, as right now I only have a rudimentary grasp of JavaScript in addition to my knowledge of Lua. Learning C++ is one of my goals, but it's such a shift from a lightweight scripting language such as Lua.
Give a man some code and you help him for a day; teach a man to code and you help him for a lifetime.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2554
  • Karma: 391
    • View Profile
    • |G4P| Gman4President
Re: Learning Python
« Reply #4 on: January 09, 2017, 12:21:48 PM »
I also agree with the above. PHP is nice and most serverside web applications use it. Python is nice, but it's not as widely used.

PHP is pretty powerful as well, you can do quite a bit with it.

Offline Stickly Man!

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 1251
  • Karma: 162
  • open(my $file, "<README") or die;
    • View Profile
    • XGUI
Re: Learning Python
« Reply #5 on: January 10, 2017, 09:26:10 AM »
Having used PHP professionally for a few years all I can say is.. PHP is a mess and avoid it if at all possible. :P  The following rant is, well, a rant, but it brings up some very good TECHNICAL reasons why PHP is inconsistent. Also note that it is a bit dated- some concerns have been addressed especially as of PHP 7
https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/

However, it is nice in that you can get something up and running with fairly minimal effort. PHP is very beginner friendly, and they have built in libraries and functions that cover most of the common needs in web development. Plus, it is widely used in the industry, so as bad as it may be, it's useful to know.

(On topic) We also use Python at work, and while I haven't been working on projects that use it, I've heard good things, especially form Zyklus. :)
« Last Edit: January 10, 2017, 09:50:20 AM by Stickly Man! »
"The stupidity of an individual on the Internet is generally matched only the by size of their ego, unless the individual in question is unaware of both." - Me

Offline Stickly Man!

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 1251
  • Karma: 162
  • open(my $file, "<README") or die;
    • View Profile
    • XGUI
Re: Learning Python
« Reply #6 on: January 10, 2017, 09:49:52 AM »
Double post, but I wanted to keep this very separate.

PHP pop (trick) quiz! The following snag happened at my workplace, in a much larger and more complex block of code. Look at the following PHP code and write down what you think the result of (a) (b) and (c) should be, without running the code directly. Now check your results with the actual results below, and run the code yourself if you don't believe me. Can you figure out what when wrong and why?
Code: PHP
  1. $a = ['one', 'two', 'three'];
  2.  
  3. foreach ($a as &$number) {
  4.   if ($number == 'one') {
  5.     $number = 'test';
  6.   }
  7. }
  8.  
  9. // (a) What is the value of $a?
  10.  
  11. foreach ($a as $number) {
  12.   // (b) What is the value of each item in array $a?
  13.   var_dump($number);
  14. }
  15.  
  16. // (c) What is the value of $a again? (Sanity check)

Actual results! Copy the following lines to a separate text editor:

(a) = ['test', 'two', 'three']
(b) = "test", then "two", then "two" ..?
(c) = ['test', 'two', 'two'] ...?


Answer and explanation:

(a) is as we expect, because the point of the first loop is to replace any string "one" with "test".
(b) Now we do a "read only" foreach of $a to print each value separately, but specifically, our last value changed from "three" to "two"! How did that happen?
(c) After doing that "read only" foreach, our original array has been modified with the bad value. Why?

This is all caused by PHP's lack of proper variable scope, made worse by variable references.

On the first foreach, note that we use a reference for $number, as noted by the ampersand &. This makes it so when we set $number directly in the line below, the change gets passed along to the original array. If we didn't have that ampersand, the first foreach would effectively do nothing.

Now, since there is no function scope, PHP treats that &$number variable as if it were created at the top of the entire block of code. This means when we reuse the variable $number in the second foreach, it's stuck as being a reference to the last object in the array (where it was left at after the first foreach completed). So, as PHP internally sets $number throughout the second foreach, it's actually modifying the last value of array $a.

The best solution? Change the variable name of $number in the second foreach to something else. Yup. Thanks PHP.

« Last Edit: January 10, 2017, 10:05:23 AM by Stickly Man! »
"The stupidity of an individual on the Internet is generally matched only the by size of their ego, unless the individual in question is unaware of both." - Me

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 7707
  • Karma: 350
  • Sertafide Ulysses Jenius
    • View Profile
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Learning Python
« Reply #7 on: January 10, 2017, 06:52:52 PM »
I can see root cause of whatever your answers may be expecting without even looking at your/testing my actual answers.
I'll leave one hint for anyone else coming along (and to show I think I know what I'm talking about)
Summed up in one word: SCOPE
Another word? : POINTERS
Good/bad/indifferent - PHP's use/mis-use of those two words can be confusing to the uninitiated and experienced alike.
I consider myself novice.
The price one pays for pursuing any profession or calling is an intimate knowledge of its ugly side. - James Baldwin

Offline roastchicken

  • Respected Community Member
  • Sr. Member
  • *****
  • Posts: 480
  • Karma: 84
  • I write code
    • View Profile
Re: Learning Python
« Reply #8 on: January 17, 2017, 10:24:34 AM »
I'm a bit late, but I'd hazard to say that most web languages are going to be inconsistent due to the need for backward compatibility and the huge scope of devices and services they must serve. JavaScript is also (in my opinion) disgustingly inconsistent, but it's the best (if not only) solution for browser client side scripting.
Give a man some code and you help him for a day; teach a man to code and you help him for a lifetime.

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 723
  • Karma: 114
  • :)
    • View Profile
    • My Homepage
Re: Learning Python
« Reply #9 on: January 17, 2017, 12:36:13 PM »
I'm a bit late, but I'd hazard to say that most web languages are going to be inconsistent due to the need for backward compatibility and the huge scope of devices and services they must serve. JavaScript is also (in my opinion) disgustingly inconsistent, but it's the best (if not only) solution for browser client side scripting.
Same with PHP for the serverside.
You're not going to find many languages more supported universally than PHP. Apache has a module, Nginx has FastCGI support. Web hosts are going to have it enabled and running for every client. As for NodeJS, Rails, Python, etc? You'll be lucky if they even have it installed, let alone configured correctly. Their control panel may not have sufficient control over the module, you may not be able to install certain packages, etc. What then?

Sure, PHP is a quirky language. So is JS. So is Python. So is Java.
Backwards compatibility is a pain, but a requirement. Implementation and choosing what to drop is a different story, and I can fault the PHP developers for that, but with PHP 7 it's becoming a lot more sane.

Truthfully, any language has its faults. But the majority of them aren't game-breaking, and programmers can and must work around them in any language. It's up to the skill of the programmer to make something beautiful regardless of the language they're using.
bw81@ulysses-forums ~ % whoami
Homepage

I have 10 more Keybase invites! PM me for more information or to request one!
An easy intro to PGP and public-key cryptography

Offline iViscosity

  • Hero Member
  • *****
  • Posts: 675
  • Karma: 34
    • View Profile
    • iViscosity Gaming
Re: Learning Python
« Reply #10 on: January 17, 2017, 01:22:16 PM »
I feel like being mean and locking the topic just so no more replies haha

I won't though... Yet




EDIT-JamminR - watch the language
« Last Edit: January 17, 2017, 03:36:31 PM by JamminR »
I'm iViscosity. I like gaming and programming. Need some help? Shoot me a PM or Join my Discord!.
--==[ Links ]==--
Steam
YouTube
Steam Group (feel free to join!)
Forums
Public Discord
Teamspeak

Quote from: Steve Jobs
Your work is going to fill a large part of your life, and the only way to be truly satisfied is to do what you believe is great work. And the only way to do great work is to love what you do. If you haven't found it yet, keep looking. Don't settle. As with all matters of the heart, you'll know when you find it. And, like any great relationship, it just gets better and better as the years roll on. So keep looking until you find it. Don't settle.

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 723
  • Karma: 114
  • :)
    • View Profile
    • My Homepage
Re: Learning Python
« Reply #11 on: January 17, 2017, 03:39:04 PM »
-SNIP- I'm silly.
« Last Edit: January 17, 2017, 04:13:20 PM by Bytewave »
bw81@ulysses-forums ~ % whoami
Homepage

I have 10 more Keybase invites! PM me for more information or to request one!
An easy intro to PGP and public-key cryptography

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 7707
  • Karma: 350
  • Sertafide Ulysses Jenius
    • View Profile
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Learning Python
« Reply #12 on: January 17, 2017, 03:44:59 PM »
bytewave, iviscosity is not a mod. I placed that there so he knew who said it.
The price one pays for pursuing any profession or calling is an intimate knowledge of its ugly side. - James Baldwin

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 723
  • Karma: 114
  • :)
    • View Profile
    • My Homepage
Re: Learning Python
« Reply #13 on: January 17, 2017, 04:11:20 PM »
bytewave, iviscosity is not a mod. I placed that there so he knew who said it.
Ooh, I should probably read the "last edit" indicator. :P
bw81@ulysses-forums ~ % whoami
Homepage

I have 10 more Keybase invites! PM me for more information or to request one!
An easy intro to PGP and public-key cryptography

Offline iViscosity

  • Hero Member
  • *****
  • Posts: 675
  • Karma: 34
    • View Profile
    • iViscosity Gaming
Re: Learning Python
« Reply #14 on: January 17, 2017, 04:52:47 PM »
bytewave, iviscosity is not a mod. I placed that there so he knew who said it.
Nono they don't need to know that haha :D

Also sorry :(

Sent from my XT1080 using Tapatalk
I'm iViscosity. I like gaming and programming. Need some help? Shoot me a PM or Join my Discord!.
--==[ Links ]==--
Steam
YouTube
Steam Group (feel free to join!)
Forums
Public Discord
Teamspeak

Quote from: Steve Jobs
Your work is going to fill a large part of your life, and the only way to be truly satisfied is to do what you believe is great work. And the only way to do great work is to love what you do. If you haven't found it yet, keep looking. Don't settle. As with all matters of the heart, you'll know when you find it. And, like any great relationship, it just gets better and better as the years roll on. So keep looking until you find it. Don't settle.