What is Python awesome at?

Endgame124

Senior member
Feb 11, 2008
957
669
136
I find myself slogging through learning python - it’s annoying to work on in vim due to the strict white spacing, it is untyped and yet typed in annoying ways, and it feels like a Swiss Army knife language without having any exciting hook to reel me in. In other words, I feel like I’m relearning Perl (a Swiss Army knife language I already know), not because Python does stuff better than Perl, but because it won the school prom popularity contest.

So, talk me into python - what is awesome about it? Bonus points if you can compare to Perl and sell me on the python side of the equation.
 
Reactions: Ken g6

mxnerd

Diamond Member
Jul 6, 2007
6,799
1,101
126
Not a Python or Perl programmer, but I think your problem is the editor.

Use a better IDE like PyCharm , Atom or VS Code, etc. with Python syntax support.

Python also can integrate with web, database, GUI frameworks a lot easier than Perl in addition to text processing which Perl excels at.
 
Last edited:

Endgame124

Senior member
Feb 11, 2008
957
669
136
Not a Python or Perl programmer, but I think your problem is the editor.

Use a better IDE like PyCharm , Atom or VS Code, etc. with Python syntax support.

Python also can integrate with web, database, GUI frameworks a lot easier than Perl in addition to text processing which Perl excels at.
I have used pycharm, but I’ve not been getting much use out of it. I connect to my machines via a double bastion. In other words: Vpn into work network, ssh to bastion 1, ssh to bastion 2, ssh to destination machine. If I need to change a quick value, I could use win scp to the first bastion, scp to the second bastion and then to the target in the chain, or I could just change it directly on the target machine. Now, I could do development on the IDE, and only occasionally copy files, and do quick changes in vim, but what ends up happening in practice is you just end up doing everything on the remote machines in vim or emacs

It’s a bit of a tangent, but it’s also my day to day.
 

Ken g6

Programming Moderator, Elite Member
Moderator
Dec 11, 1999
16,360
4,066
75
I agree with you about Python. About the only interesting thing I've found in the language proper is list comprehensions. Though if you want those in a Perl-like syntax, try Ruby.

I connect to my machines via a double bastion. In other words: Vpn into work network, ssh to bastion 1, ssh to bastion 2, ssh to destination machine.
Off-topic: And if you use SSH port forwarding, you only need to do that once (per day or something.) For instance, if you need to connect to dev-blog, pick a nice port on a bastion. I like using 1337-speak: blog -> 6109

Then something like this:

Code:
ssh -L 6109:bastion1:6109 bastion1 "ssh -L 6109:blog-server:22 bastion2 'while true ; do echo keepalive ; sleep 30 ; done'"

should allow you to connect directly to blog-server, over ssh, by `ssh -p 6109 localhost`. You can also use stuff like scp or FileZilla. Probably some IDEs too, though I prefer ViM myself. You can also add more -L's for more destination servers.
 

Endgame124

Senior member
Feb 11, 2008
957
669
136
I agree with you about Python. About the only interesting thing I've found in the language proper is list comprehensions. Though if you want those in a Perl-like syntax, try Ruby.
The matlab plugin for python, pyplot, is actually kind of cool if you want to graph things. I'm finding it easier to work with than Perl's mod:gdgraph, but all told I never really needed to do graphing work in Perl, so there might be something awesome I haven't used.


Off-topic: And if you use SSH port forwarding, you only need to do that once (per day or something.) For instance, if you need to connect to dev-blog, pick a nice port on a bastion. I like using 1337-speak: blog -> 6109

Then something like this:

Code:
ssh -L 6109:bastion1:6109 bastion1 "ssh -L 6109:blog-server:22 bastion2 'while true ; do echo keepalive ; sleep 30 ; done'"

should allow you to connect directly to blog-server, over ssh, by `ssh -p 6109 localhost`. You can also use stuff like scp or FileZilla. Probably some IDEs too, though I prefer ViM myself. You can also add more -L's for more destination servers.
Yep, I use ssh tunneling to log in once / day (till the VPN kicks me off). Scp has been really funny, though, and doesn't work with any of my attempts at tunneling a file transfer through the bastions - the only path I've found that works flawlessly is to scp to each bastion (yuck).
 

Net

Golden Member
Aug 30, 2003
1,592
2
81
There's more than one thing its good at but I don't want to spend the time to talk about all of them. The one that I'd like to comment on is text processing.

Python is my go to if I need to process some text. Lets say I need to edit or create an excel document for instance.

from openpyxl import Workbook

workbook = Workbook()
sheet = workbook.active

sheet["A1"] = "hello"
sheet["B1"] = "world!"

workbook.save(filename="hello_world.xlsx")

Super simple. This shows the power of the third party packages that many people make for python also. More excel examples: https://realpython.com/openpyxl-excel-spreadsheets-python/
 

mxnerd

Diamond Member
Jul 6, 2007
6,799
1,101
126
TIOBE Index July 2019: Perl hits its lowest popularity


and OP said Python is untyped, meaning OP think Perl is better because it's typed.

Yet
Perl:
$str = "3dfsd";
$int = 4;
print $str + $int;
print "\n";
print $str . $int;
print "\n";
output is

7
3dfsd4

Is this better?
 
Last edited:

Endgame124

Senior member
Feb 11, 2008
957
669
136
TIOBE Index July 2019: Perl hits its lowest popularity


and OP said Python is untyped, meaning OP think Perl is better because it's typed.

Yet
Perl:
$str = "3dfsd";
$int = 4;
print $str + $int;
print "\n";
print $str . $int;
print "\n";
output is

7
3dfsd4

Is this better?
Perl is less popular, but I already know the language and honestly, I don’t know what’s great about Python other than it won the equivalent of the prom popularity contest Back around 2003.

Both languages tend towards Swiss Army knife usage, though CPAN is a better resource for modules than anything I’ve seen from python. To carry forward the Swiss Army knife analogy, I have a red Swiss army knife with the tools in a particular order. Now I’ve been given a blue Swiss Army knife with tools in a different order, and I see no advantage of using the blue one, outside of the fact more people like blue than red.

As for typing, Python is an annoying mix of untyped and typed. Perl is uniform in its untyping. I never get an error that a number extracted from a string can’t be added to an int in Perl.
 

mxnerd

Diamond Member
Jul 6, 2007
6,799
1,101
126
If you are talking about code/module management, Perl is absoultely better.

Python, Javscript and Linux code/module management is a completely mess, all of them are like uncontrolled viruses.
 

beginner99

Diamond Member
Jun 2, 2009
5,231
1,605
136
What's awesome? high level language features with easy integration to low level language and performance.

Theoretically Java and .net are much faster but in python critical libraries usually run in native code. It supports multiple inheritance compared to Java so you can argue if this is good or bad. It can be used for scripting (think jupyter notebooks) or real OOP applications. Plus it has many functional aspects.
 
Feb 25, 2011
16,907
1,552
126
Perl is less popular, but I already know the language and honestly, I don’t know what’s great about Python other than it won the equivalent of the prom popularity contest Back around 2003.

Both languages tend towards Swiss Army knife usage, though CPAN is a better resource for modules than anything I’ve seen from python. To carry forward the Swiss Army knife analogy, I have a red Swiss army knife with the tools in a particular order. Now I’ve been given a blue Swiss Army knife with tools in a different order, and I see no advantage of using the blue one, outside of the fact more people like blue than red.

As for typing, Python is an annoying mix of untyped and typed. Perl is uniform in its untyping. I never get an error that a number extracted from a string can’t be added to an int in Perl.

You're absolutely right.

So it will come down to who is paying you how much to program what in which language.
 

mxnerd

Diamond Member
Jul 6, 2007
6,799
1,101
126
If you have to learn a new language, how about Golang?

It's a Swiss Army knife compiler. and very fast.

No annoying whitespace and static-typed. And a lot of libraries available.

Also found an IDE that's lightweight and fast for Golang :

LiteIDE https://github.com/visualfc/liteide
 

Endgame124

Senior member
Feb 11, 2008
957
669
136
If you have to learn a new language, how about Golang?

It's a Swiss Army knife compiler. and very fast.

No annoying whitespace and static-typed. And a lot of libraries available.

Also found an IDE that's lightweight and fast for Golang :

LiteIDE https://github.com/visualfc/liteide
I do performance and devops type work. Another team has decided on the Linux images that will be used, and within those images I can use what is available. That leaves me with a stripped Perl 5.24 install missing Some core modules like Json:p and no access to add Perl modules, python with a wide number of libraries available, and bash / ksh / csh, etc. I have a lot of legacy Perl around, so it’s not going away (and someone has to support it), but it’s obvious those that created the images want us to use python or shell.
 

mxnerd

Diamond Member
Jul 6, 2007
6,799
1,101
126
Well, if your environment designate it, you have no choice.
 

njdevilsfan87

Platinum Member
Apr 19, 2007
2,331
251
126
No annoying whitespace

The whitespacing of Python is actually a good thing. It ensures code is at least somewhat readable from developer to developer. It's probably one of the reasons Python has gained so much popularity over the years. When I go to Github and look at Python code - it's readable.

Just make sure your IDE converts tabs to spaces so that when you copy/paste it elsewhere it doesn't have formatting issues.

So it will come down to who is paying you how much to program what in which language.

This is the correct answer to the OP.

To expand on it, Python may give you more flexibility on the type of work you get into. You may be able to actually pick what you want to work on. When I first got into Machine Learning years ago - I had a weak background in the subject but because I was a great Python programmer I got the job. Now I'm pretty well versed in ML. Though for the other side of this argument - I've heard that when a programming language becomes obsolete, there's a period where it actually pays more because employers can't find anyone to do the work. I'm not sure if Perl is down that path, but it's something to consider when weighing the options.
 
Last edited:

mxnerd

Diamond Member
Jul 6, 2007
6,799
1,101
126
mxnerd said:
No annoying whitespace

The whitespacing of Python is actually a good thing. It ensures code is at least somewhat readable from developer to developer. It's probably one of the reasons Python has gained so much popularity over the years. When I go to Github and look at Python code - it's readable.

Just make sure your IDE converts tabs to spaces so that when you copy/paste it elsewhere it doesn't have formatting issues.
It's OP's opinion, not mine.

I always like to use white spaces to make program readable.

You can see that even in my forum posting.
 
Last edited:

Endgame124

Senior member
Feb 11, 2008
957
669
136
It's OP's opinion, not mine.

I always like to use white spaces to make program readable.

You can see that even in my forum posting.
My complaint on the white spacing is more this:

You have to make a quick bug fix and add a debug if statement in vim to a loop 6 layers deep on a test driver VM behind 2 bastions. The white spacing is so deep that word wrap is all over the place. You can’t just drop your temporary if (bad condition) block without spacing at the appropriate line.

For general development with an ide, it’s fine. When your troubleshooting something on a less accessible system, it’s annoying. Can’t imagine having to deal with it in a prod down scenario.
 
Reactions: mxnerd

mxnerd

Diamond Member
Jul 6, 2007
6,799
1,101
126
My complaint on the white spacing is more this:

You have to make a quick bug fix and add a debug if statement in vim to a loop 6 layers deep on a test driver VM behind 2 bastions. The white spacing is so deep that word wrap is all over the place. You can’t just drop your temporary if (bad condition) block without spacing at the appropriate line.

For general development with an ide, it’s fine. When your troubleshooting something on a less accessible system, it’s annoying. Can’t imagine having to deal with it in a prod down scenario.
I totally agree with the situation you faced.

By the way, I just looked at the VIM and found it extremely powerful, with its plugin system. I thought it's just a tad better than vi, but it's actually a vastly improved version over original vi.
 
Last edited:

Endgame124

Senior member
Feb 11, 2008
957
669
136
Why are you learning python if you don't like it?
Its obvious that the people creating the Linux images that I must use would prefer that we use python. Additionally, Python seems to be quite popular, so I figured why not give it a shot? As I spent the first couple weeks working on it on and off, though, it felt like it's really just explicit Perl, without an equivalent to CPAN, and without some combination statements and grammatical things I like - ex: print "fun program" unless ($funFactor < 0);

That's what lead to this thread - Python is popular and I figured I haven't hit the "awesome" thing that makes you go "wow, that's why you use Python". Once I find that thing that makes me go "wow", it will be a breeze to spend my own time working on the language.
 

Cogman

Lifer
Sep 19, 2000
10,283
134
106
Oh boy, time to bash some perl

I've done both python and perl programming and I prefer python over perl by a long shot.

So let's go through my subjective opinions on the matter

Python was actually designed to be a programming language. A BIG issue with perl is that programming was really an afterthought. You see this all over in the language. For example, passing parameters to methods. Perl has a lot of conventions about how to do this, it is part of the language in python.

Python has a rational type system. For example, imagine you want a dictionary of lists... In perl you have to come up with some strange incantations of %@$'s to make that work with a hefty understanding of when to correctly introduce pointers. Now imagine you want 2 dimentional lists... YuCk! With python, something like that is dead simple. The fact that you have to understand pointers for doing scripting work is really unforgivable (Well, forgivable because, like I said, perl wasn't designed for programming!).

And then let's get to the crazy functions throughout perl standard library. bless? chomp? glob? Christ, it sounds like a bad fantasy novel.

But then there is all the crazy magic throughout perl. Single letter special functions which do things like "Check if a file exists". That sort of stuff just does not belong in modern programming.

Python isn't without it's warts. the GIL, for example, is a direct result of python not thinking about the threading model. The fact that python can't use better GC algorithms or even a faster interpreter because of it's C api is definitely a problem. However, the language itself is clean and fairly easy to understand.
 

Red Squirrel

No Lifer
May 24, 2003
68,459
12,613
126
www.anyf.ca
Funny I was recently asked at work if I'd be interested in learning python and I actually had that on the back of my mind anyway. Some kind of initiative at my company where they want people within the company to be trained for it and they approached managers.

When it got brought up my manager and his they both immediately thought of me so I was recently asked. Not sure if they plan to have side projects for those of us who get the skillset or something. As long as it does not involve moving down south at any time I'm all for it. My department handles lot of legacy stuff and I don't know if it will be around in 10-20 years so going to jump on this opportunity as it may mean job security depending on what the end goal is.

That said I only briefly used python, and I would not even consider what I did coding as it involved copy and pasting code off the internet and changing it. One thing it appears to be good at is streamlining things that are normally hard to do in C++. In my case it was for serial communication. In C++ it was a huge ordeal trying to do that and there was not much info online and even when I did get it working, the next time I had to with another device, all of a sudden that code did not work because of some weird oddity in that particular device I had to account for. In Python it was like 10 lines of code and no fuss. It's also not proprietary which is nice, so you're not relying on any company like you would if you're using .net or java for example. The way libraries are handled appears easier too. Libraries in say, C++ are not easy to deal with and require lot of leg work to get going.

But yeah it seems to be gaining popularity, so I'm looking forward to see what my company's plans are with giving this training.
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |