Al Sweigart

Author
+ Follow
since May 28, 2015
Al likes ...
Python
Author of four Python programming books, which can be read for free online:

https://automatetheboringstuff.com

http://inventwithpython.com
San Francisco, CA, USA
Cows and Likes
Cows
Total received
5
In last 30 days
0
Total given
0
Likes
Total received
2
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Al Sweigart

Yes. In my opinion, Python is the most readable language I've encountered. Not to start a language war, but I would say it is generally more readable than JavaScript, Java, and Perl.
4 years ago
They could either read my Automate book or Manning's The Quick Python Book by Naomi Cedar. Googling for "Python idioms" and "Python gotchas" is a good way of getting up to speed with the stuff that beginners miss out on.

Dive Into Python seems to be a good guide for people who can program already.
4 years ago
I just wanted to also announce that the more-or-less official forum for Automate the Boring Stuff with Python (and my other books on the http://inventwithpython.com site) is at https://www.reddit.com/r/inventwithpython

This is probably much more effective than emailing questions directly to me (which you can do at al@inventwithpython.com )
4 years ago

Joe Ess wrote:I'm sure his answer to your question is "yes".



Yes.



Python is definitely good for games. I've been using Pygame, but Pyglet has come out with a new version that now supports Python 3, so I've been meaning to take a look at it. I haven't looked in a while, so I don't know what's out there for Java and gaming off the top of my head.
4 years ago
Thanks Dave! The crypto book doesn't cover any modern ciphers (except for a textbook implementation of RSA in the last couple of chapters). I was really inspired by "The Cryptoclub" textbook for kids and thought it'd be great to extend it to use programming for the implementations.

Data visualization seems to be a hot topic, though I'm not sure how well Python since the front-end seems to be browser-based (putting it in JavaScript's domain). Though some kind of Python module for generating JavaScript D3 visualizations might be nice. I think that's the aim of this project https://pypi.python.org/pypi/vincent/0.1.4 but it hasn't been updated in a couple years.

I'll take a look into it.

No promo codes unfortunately, though you might be able to snag a free book from this CodeRanch by making on-topics posts on this book this week.
4 years ago
I really couldn't say which is mostly being used. Structured and OOP are popular paradigms. (OOP especially with Java's rise in popularity.) Just in my experience, I think JavaScript has made people more comfortable with anonymous functions or passing functions around as first-class objects. I don't have enough experience with aspect-oriented programming to comment on it.

For me, I tend to use basic structured programming for most of my small scripts, since they don't build up to the complexity where OOP is needed. Once I get into lists-of-dictionaries-of-lists though, I'll tend to start writing classes.
4 years ago
Mohd: Part 2 of the book goes into automating various tasks. Here's the table of contents:

7. Pattern Matching with Regular Expressions
8. Reading and Writing Files
9. Organizing Files
10. Debugging
11. Web Scraping
12. Working with Excel Spreadsheets
13. Working with PDF and Word Documents
14. Working with CSV Files and JSON Data
15. Time, Scheduling Tasks, and Launching Programs
16. Sending Email and Text Messages
17. Manipulating Images
18. Controlling the Keyboard and Mouse with GUI Automation
4 years ago
Compared to other languages:

Python vs Perl - Perl uses cryptic punctuation marks for much of its syntax, resulting in a steeper learning curve and hard-to-read code.

Python vs PHP - PHP has a large set of built-in functions with inconsistent naming conventions.

Python vs Java - Java requires a lot of boiler plate and mandatory OOP paradigm, even for programs where this doesn't make sense.

Essentially, Python as a language has simplicity on its side, which make sit easier to learn, which means more people learn it.
4 years ago
Python has its infamous koans (which you can see by importing the "this" module), one of which is "there should be one, and preferably only one, way to do it. This is a clear shot to Perl's "there's more than one way to do it".

I agree very much with this koan because it has a large effect on the readability of code. With multiple ways to do the same task, programmers have to be familiar with every possible way in order to understand a given Perl script. This is redundant and increases Perl's learning curve.

And Perl's learning curve (and its syntax, which tries to make maximal use of cryptic punctuation marks) was one of its downfalls once easier languages like PHP, Python, and Ruby started gathering steam.
4 years ago
It's not a strong preference of mine either way.
4 years ago
Oh, also, I've released the book under a Creative Commons license. You can read the HTML version of the book at https://automatetheboringstuff.com

(All of my other books are also CC-license, and can be downloaded at http://inventwithpython.com )

You can get the book for about $23 off of Amazon or buy it directly from the publisher at No Starch Press to get the print AND ebooks (in mobi, epub, and pdf formats) for $30.

No Starch gets a bigger cut if you buy it directly from them. If you'd like to help me out, writing an Amazon review of the book is super-helpful: http://www.amazon.com/Automate-Boring-Stuff-Python-Programming/dp/1593275994

Or you can make a direct donation via PayPal or Bitcoin through http://inventwithpython.com
4 years ago
I think this is covered in this topic, but I'd say Python's popularity comes from: a simple syntax that makes it easy to learn (and read), a great community, a large amount of third-party modules, an impressive standard library.

I also got started with Python around 2004-ish. Django is responsible for a big chunk of boosting Python's popularity, but I think a language with a simple syntax was destined to take the place of Perl (which is notoriously hard-to-read and has a bit of a learning curve). This is the time when web apps were becoming more and more popular, and things like PHP and Ruby on Rails were getting the spotlight on them. Python was a bit late to that, but the basics of the language's design has helped it stick around for the long-term.
4 years ago
The book is split into two parts. Part 1 is a general Python tutorial for people who have never programmed before (or never programmed in Python). Part 2 goes into automating various tasks using different modules.

If I were in your shoes, I'd at least read Part 1 and also Chapters 7 through 10 in Part 2. Those cover regular expressions, dealing with files, and Python's debugger. At that point, you'll be ready to jump into any other advanced topic.
4 years ago

Tomas Linhart wrote:
1) I have been programming in different languages for about 15 years, but have no experience with Python. Can I still gain from the book, or should I pick some "Python for XXX programmers" book?



Automate is perfect for you. The book is made for complete beginners and is split up into two parts. Part 1 covers Python basics, while Part 2 covers using various modules to automate different tasks.

So if you've never programmed before (or never programmed in Python), you can start with Part 1. Meanwhile experienced Python developers can start at Part 2.

Tomas Linhart wrote:
2) What's the learning curve for Python if you could compare with other languages?



In my opinion, Python is, without a doubt, the best language for first-time programmers because it has an incredibly gentle learning curve. The syntax is simple, the standard library API isn't that complicated, and there's hardly any boilerplate. You don't need a full-featured IDE with autocomplete to write Python (I use Sublime Text) because you can fit most of the language in your head.

Tomas Linhart wrote:
3) Python seems to be the second language of choice for data scientists (R being the first). Why do you think this is true and do you think learning Python is worthy for someone who wants to start with data science?



I don't have direct experience, but if I had to take a guess it's because data scientists (and scientists in general) are technical people who don't need to become software engineers: they view computers as tools to do practical tasks, which is something Python is excellent for. This is the reason I wrote this book using Python. Most of the time, scientists need scripts that crunch numbers or do some data processing and knowing a lot of computer science isn't really necessary. If you only have to sort a few thousand things, elegant algorithms don't matter: you can use bubble sort and it'll be "good enough" for any modern laptop.

Of course, Python has the sort() method for this, which "just works" in most cases. They aren't writing web apps that need to serve thousands of requests per second, so getting every drop of performance isn't necessary. This is an area where Python excels in. (And, if they do need performance, they can move on to learn how to write C extensions that Python can call.)

I haven't looked at R, but I can say that Python is such a good general language that it can easily fill in the functionality gaps that R doesn't cover.
4 years ago
(Hehehe, it's always great when I hear people's problems and off the top of my head know the chapters that can help.)

This seems like a straightforward problem that can be automated. First, you'll have to get the files. If WebSphere provides a web interface, Chapter 11 tells you how you can download them using Requests. Or, if you need to log into the server, you can control a Firefox browser by using Selenium (also detailed in Chapter 11).

Once you have the files, I assume they're just text files. Chapter 8 explains how you can read these files and search for a particular string. If the string isn't always exact, you can search for a string pattern by using regular expressions (Chapter 7.

You'll probably want this script to run on a regular basis, so you can either use your OS's scheduler (like cron or Scheduled Tasks) to do this: https://automatetheboringstuff.com/schedulers/ but Chapter 15 also has some details on time-related stuff.

And if this check fails, you'll want some sort of notification. Writing to a separate text-based log file is good. But you can also have Python send out an email or SMS text message using the info from Chapter 16.

And, if you don't know Python, Part 1 of the book (chapters 1 to 6) quickly cover the basics of Python.
4 years ago