Sunday, March 19, 2017

Python: Airing of Grievances

Although this list focuses on the negative aspects of Python, I am publishing it so I can use it as a reference in an upcoming essay about my positive experiences with Python 3.6. Update: This is referenced by my post, "JavaScript vs. Python in 2017."

I am excited by many of the recent improvements in Python, but here are some of my outstanding issues with Python (particularly when compared to JavaScript):

PEP-8

What do you get when you combine 79-column lines, four space indents, and snake case? Incessant line-wrapping, that's what! I prefer 100 cols and 2-space indents for my personal Python projects, but every time a personal project becomes a group project and  true Pythonista joins the team, they inevitably turn on PEP-8 linting with its defaults and reformat everything.

Having to declare self as the first argument of a method

As someone who is not a maintainer of Python, there is not much I could do to fix this, but I did the next best thing: I complained about it on Facebook. In this case, it worked! That is, I provoked Łukasz Langa to add a check for this (it now exists as B902 in flake8-bugbear), so at least when I inevitably forget to declare self, Nuclide warns me inline as I'm authoring the code.

.pyc files

These things are turds. I get why they are important for production, but I'm tired of seeing them appear in my filetree, adding *.pyc to .gitignore every time I create a new project, etc.

Lack of a standard docblock

Historically, Python has not had a formal type system, so I was eager to document my parameter and return types consistently. If you look at the top-voted answer to “What is the standard Python docstring format?” on StackOverflow, the lack of consensus extremely dissatisfying. Although Javadoc has its flaws, Java's documentation story is orders of magnitude better than that of Python's.

Lack of a Good, free graphical debugger

Under duress, I use pdb. I frequently edit Python on a remote machine, so most of the free tools do not work for me. I have not had the energy to try to set up remote debugging in PyCharm, though admittedly that appears to be the best commercial solution. Instead, I tried to lay the groundwork for a Python debugger in Nuclide, which would support remote development by default. I need to find someone who wants to continue that effort.

Whitespace-delimited

I'm still not 100% sold on this. In practice, this begets all sorts of subtle annoyances. Code snippets that you copy/paste from the Web or an email have to be reformatted before you can run them. Tools that generate Python code incur additional complexity because they have to keep track of the indent level. Editors frequently guess the wrong place to put your cursor when you introduce a new line whereas typing } gives it the signal it needs to un-indent without further interaction. Expressions that span a line frequently have to be wrapped in parentheses in order to parse. The list goes on and on.

Bungled rollout of Python 3

Honestly, this is one of the primary reasons I didn't look at Python seriously for awhile. When Python 3 came out, the rhetoric I remember was: “Nothing substantially new here. Python 2.7 works great for me and the 2to3 migration tool is reportedly buggy. No thanks.” It's rare to see such a large community move forward with such a poorly executed backwards-compatibility story. (Presumably this has contributed to the lack of a default Python 3 installation on OS X, which is another reason that some software shops stick with Python 2.) Angular 2 is the only other similar rage-inducing upgrade in recent history that comes to mind.

I don't understand how imports are resolved

Arguably, this is a personal failure rather than a failure of Python. That said, compared to Java or Node, whatever Python is doing seems incredibly complicated. Do I need an __init__.py file? Do I need to put something in it? If I do have to put something in it, does it have to define __all__? For a language whose mantra is “There's only one way to do it,” it is frustrating that the answer to all of these questions is “it depends.”

Busted Scoping Rules

For a language with built-in map() and filter() functions that underscore the support for first-order functions, I am perplexed with how bad the support for closures is in Python. Apparently your options are (1) lambda (which is extremely limited), or (2) a bastardized closure. Borrowing an example from an article that explains the new nonlocal keyword in Python 3, consider the following code in JavaScript:
function outside() {
  let msg = 'Outside!';
  console.log(msg);
  let inside = () => {
    msg = 'Inside!';
    console.log(msg);
  };
  inside();
  console.log(msg);
}
If you ran outside(), you would get the following output (which you would expect from a lexically scoped language like JavaScript):
Outside!
Inside!
Inside!
Whereas if you wrote this Python code:
def outside():
    msg = 'Outside!'
    print(msg)
    def inside():
        msg = 'Inside!'
        print(msg)
    inside()
    print(msg)
and ran outside(), you would get the following:
Outside!
Inside!
Outside!
In Python 2, the only way to emulate the JavaScript behavior is to use a mutable container type (which is gross):
def outside():
    msg_holder = ['Outside!']
    print(msg_holder[0])
    def inside():
        msg_holder[0] = 'Inside!'
        print(msg_holder[0])
    inside()
    print(msg_holder[0])
Though apparently Python 3 has a new nonlocal keyword that makes this less distasteful:
def outside():
    msg = 'Outside!'
    print(msg)
    def inside():
        nonlocal msg
        msg = 'Inside!'
        print(msg)
    inside()
    print(msg)
I realize that JavaScript generally forces you to type more with its var, let and const qualifiers, but I find this to be a small price to pay in exchange for unambiguous variable scopes.

67 comments:

  1. Engage with our agents and Book a Flight With Turkish Airlines, get best deals and offers. We provide best suggestion on baggage, tickets.

    ReplyDelete
  2. We care the best for our customers for Delta Airlines Flights. Get a flight of safety with prompt Delta Airlines Flights Status with Coronavirus updates.

    ReplyDelete
  3. Looking for your insurance plan information and need some help? Reach Progressive Insurance provider and get the best help and available round the clock.

    ReplyDelete
  4. If you want to make changes in your ticket type and not able to access your British Airways Manage Booking then contact us. We are available 24/7.

    ReplyDelete
  5. If you are searching for someone for your Printer Setup, then we assure you that we are always available for you. You can reach us at any time.

    ReplyDelete
  6. If you are facing issues with available Wi-Fi networks while setting Canon Wireless Printer Setup. Contact us at our toll-free number and get instant help.

    ReplyDelete
  7. Call at Auto Locksmith Near Me and one of our professional automotive locksmiths will be there to manage your lock-related requirements. Call now!!

    ReplyDelete
  8. If you are looking for the best help for Brother Printer Setup. We are always available for you to get the best services. We have experts in our team. Call Now!!

    ReplyDelete
  9. Require technical help for Epson Printer Setup at your home or office? Connect with our professional team of technicians. They are available 24/7. Call Now!!

    ReplyDelete
  10. "Nice Blog!!
    Norton login is one of the easiest platform that allows you to manage products download Norton antivirus and protect your device from online threats.
    Norton Account
    Norton Setup"

    ReplyDelete
  11. Good Post!!
    AOL Mail serve all the emails in your account, with aol email will get all updates on your mails promptly by creating aol account.
    AOL Account
    AOL Gold Download

    ReplyDelete
  12. Thanks for the informative blog. But, pests nowadays are a big problem. People suffer a lot of pests at home and office. We can get you the best price and quotes with Cooks Pest Control. If you want to contact them, call at our toll free number for immediate help.

    ReplyDelete
  13. This comment has been removed by the author.

    ReplyDelete
  14. Tired of dealing with pests? Reach out to Moxie Pest Control, the experts available will instantly assist you and will help in resolving the issue. If you want to contact them, call at our toll free number for immediate help.

    ReplyDelete
  15. Edge pest control is one of the leading bug control service providers in the area. It is in process since a long time now and it is the first choice for every bug or pest relate issue any resident of the area has. The company works on some specific grounds to make their services more accurate and qualified. Edge pest control follows these factors that actually determine the quality of your experience of our bug control services with Edge pest control company.

    ReplyDelete
  16. Our team present at helpdesk for Rodent Control, Cook’s Pest Control team will help you to remove rodents from your place instantly with long term guarantee, so you don’t need to get worried over it. If you are stuck with pests for a long time and unable to reach the experts, then take a breath and feel relaxed because we are there for you.

    ReplyDelete
  17. In order to get rid of pests issues, the team of Hawx Pest Control will provide you significant services throughout the areas you require according to your convenience. The team of Hawx Pest Control will inspect your home from the top to bottom and from every corner to check the presence of the pests. The team of Hawx Pest Control always provide you the detailed view about the service and their activities.

    ReplyDelete
  18. If you are facing trouble related to pests and bugs, then you are at the right place. Aptive Pest Control innovative approach and safe advanced technology will help you to get away pests and bugs from your house. Pests can enter your stead through many ways like they can enter through windows, rooftop holes, rotten food in dustbin, standing water around buildings etc.

    ReplyDelete
  19. Tired of dealing with pests? Reach out to Moxie Pest Control, the experts available will instantly assist you and will help in resolving the issue. If you want to contact them, call at our toll free number for immediate help.

    ReplyDelete
  20. Terminix Pest Control is the best and leading pest control companies in the industry and includes some of the nation’s top specialists and professionals with all the graduate and PhD-level entomologists and certified members of the Entomological Society of United State of America.

    ReplyDelete
  21. When it comes to your career prospects and bright future, Assignment Help takes the onus on itself to promote your growth in the right direction. So, that way you wouldn’t have to think twice before trusting us with your academic papers. Place an order with us now and reap the rewards of brilliantly written academic papers today. Assignment help, one of the leading academic solution providers in Australia, understands the challenges and extends a helping hand to the aspiring engineers who are willing to land a job in Australia.
    Sydney Assignment Help

    ReplyDelete
  22. Nowadays students from the school, college and universities look for Essay Help UK and Essay Helper UK services from the experts who can help them in solving their assignment in a manner that is required in college and universities.

    ReplyDelete
  23. Terminix Pest Control is the best and leading pest control companies in the industry and includes some of the nation’s top specialists and professionals with all the graduate and PhD-level entomologists and certified members of the Entomological Society of United State of America.

    ReplyDelete
  24. Assignment help in Saudi Arabia allows students to finish their papers on time without having any mistakes. If you want to submit error-free papers in your universities, you must think about Online Assignment help in Saudi Arabia.

    ReplyDelete
  25. Nowadays students from the school, college and universities look for My Assignment Help Singapore and MyAssignmentHelp Singapore services from the experts who can help them in solving their assignment in a manner that is required in college and universities.

    ReplyDelete
  26. Nowadays students from the school, college and universities look for My Assignment Help UK and MyAssignmentHelp UK services from the experts who can help them in solving their assignment in a manner that is required in college and universities.

    ReplyDelete
  27. Thanks for sharing this post. But, pests nowadays are a big problem. People suffer a lot of pests at home and office. We can get you the best price and quotes with Fox Pest Control. If you want to contact them, reach their at toll free number for instant help.

    ReplyDelete
  28. Thanks for sharing this post. But, pests nowadays are a big problem. People suffer a lot of pests at home and office. We can get you the best price and quotes with Braman Pest Control. If you want to contact them, reach their at toll free number for instant help.

    ReplyDelete
  29. Nowadays students from the school, college and universities look for Assignment Help Experts Singapore and Assignment Experts Singapore services from the experts who can help them in solving their assignment in a manner that is required in college and universities.

    ReplyDelete
  30. Thanks for sharing this post. But, pests nowadays are a big problem. People suffer a lot of pests at home and office. We can get you the best price and quotes with Ehrlich Pest Control. If you want to contact them, reach their at toll free number for instant help.

    ReplyDelete
  31. Nowadays students from the school, college and universities look for Programming Assignment Help Canada and Programming Help Canada services from the experts who can help them in solving their assignment in a manner that is required in college and universities.

    ReplyDelete
  32. Very interesting article, someone in needs of python tutorials must read this blog specially when you are completing your term paper and in need of term paper help.

    ReplyDelete
  33. Nowadays students from the school, college and universities look for MyAssignmentServices and My Assignment Services services from the experts who can help them in solving their assignment in a manner that is required in college and universities.

    ReplyDelete
  34. Nowadays students from the school, college and universities look for Maths Homework Help and Maths Homework Help Singapore services from the experts who can help them in solving their assignment in a manner that is required in college and universities.

    ReplyDelete
  35. Booking with great fares call at American Airlines Customer Service number. Get a good number of deals on your booking visit 24/7.

    ReplyDelete
  36. Nowadays students from the school, college and universities look for thesis help and thesis help Malaysia services from the experts who can help them in solving their assignment in a manner that is required in college and universities.

    ReplyDelete
  37. Nowadays students from the school, college and universities look for Coursework Help and Online Coursework Help Malaysia services from the experts who can help them in solving their assignment in a manner that is required in college and universities.

    ReplyDelete
  38. Whether or not you're in primary school or following a Doctor of Philosophy, we tend to square measure capable of delivering quality assignment services australia facilitate you.

    ReplyDelete
  39. If you want to reinstall the operating system or upgrade your device, you can use a flash file. This file helps to get back your phone in factory format. It can fix software issues, Boot loop issues, IMEI issues, and dead issues. These files are unique for every phone.y51l volte

    ReplyDelete
  40. Assignment help in Malaysia
    Thetutorshelp.com has been providing premium quality help with essay assignments in Malaysia for a decade so that students can excel in their academics. Our company is the top choice of every student who wants to avail of essay assignment help See more- https://www.thetutorshelp.com/malaysia.php

    ReplyDelete
  41. Facing terrible issues of pests from a long time in your place? If you want to remove Pests, Turner Pest Control is always there to ensure that you will not encounter them again in the future.

    ReplyDelete
  42. Tired of dealing with pests? Reach out to Cook's Pest Control, the experts available will instantly assist you and will help in resolving the issue. If you want to contact them, call at our toll free number for immediate help.

    ReplyDelete
  43. Interesting programming experience in this language, thanks. I think that this language is good, of course I also like javascript better, but python contains at least some typing and heaps of libraries allow you to write complex things out of the box without really thinking about how to do it. Python as they are known to be focused on improving developer productivity, code readability and quality, as well as ensuring the portability of programs written in it. The syntax of the core of the language is minimalistic, due to which, in practice, it is rarely necessary to refer to the documentation. Python is also known as an interpreted language and is also used as a scripting language. The disadvantage of the language is that programs written in it often operate at a lower speed compared to similar code written in C or C ++. I advise you to also look for posts on Instagram in which the authors share their impressions of programming in this language and give valuable advice for writing code in it productively. I managed to find about a hundred posts on this topic there, and I noticed that most often such posts were posted on accounts to which about 60 thousand subscribers were subscribed! I am sure that in order to reach such figures, the owners of these channels have repeatedly used the services of https://soclikes.com/buy-instagram-followers to acquire subscribers.

    ReplyDelete
  44. Increasing prevalence of bleeding disorders and growing severity with the genetic evolution globally is anticipated to drive overall haemophilia treatment market growth. Increasing R&D initiatives especially on identifying therapeutic agents is one of the major factors expected to positively impact haemophilia treatment market growth.

    ReplyDelete
  45. Best assignment experts provide their customers with the best service and best assignment help in the sector of solving academic assignments and projects. It supports its customer’s views and interest by providing them with value for money services. Best assignment help

    ReplyDelete
  46. Best assignment experts provide their customers with the best service and Best assignment help in the sector of solving academic assignments and projects. It supports its customer’s views and interest by providing them with value for money services.

    ReplyDelete
  47. Finance is the study of money, revenue, investments etc. Students who study finance at college, come across many issues during their scholastic years. One of the toughest tasks which students face during their course is to make assignments on Finance. Writing a good assignment is an inevitable part of the university curriculum. You can either let every fun element pass and do your finance assignment or you can pay someone for finance assignment help.

    ReplyDelete
  48. Apoyo sobre las mejores Trabajar en Bali oportunidades de inversión en Bali y asesoramiento sobre cómo gestionar tus ahorros en el país

    ReplyDelete
  49. Kami adalah salah satu media Info Kerja Bali online terkemuka di Bali.
    Membantu memfasilitasi pencocokan dan komunikasi peluang kerja antara pencari kerja dan pemberi kerja, di Bali, Denpasar, Legian, Seminyak, Canggu, Sanur, Nusa Dua, Tuban, Jimbaran.

    ReplyDelete
  50. Website Developer Bali adalah seorang Freelancer Website Developer Bali, dia sangat menyukai hobbynya dalam menelusuri setiap blok yang Anda di internet. Dia memiliki banyak pengetahuan tentang Digital Marketing dan bagaimana penerapan dalam bisnis.

    ReplyDelete
  51. On your place I would make a video how to use Python for tiktok because I know from this site https://www.computertechreviews.com/online-promotion-on-tiktok/ how to get many views for tiktok video

    ReplyDelete
  52. Are you a student of Business Management or MBA? If yes, then learning accountings is so important. Perdisco provides help to students with taxation, census, and a lot more. Perdisco Assignment Help at my perdisco help will help you to score an A+ grade in the assignment.

    ReplyDelete
  53. I am Alice Addy, a Corporate Sales Specialist operating in the Latin American region. We are experts in Market Research (Mercado Latinoamericano de Titanato de Bario). We provide market reports across various industry verticals and also help with procurement and supply chain intelligence. By giving you better insights, we help you make informed business decisions.

    ReplyDelete
  54. I am Alice Addy, a Corporate Sales Specialist operating in the Latin American region. We are experts in Market Research (Mercado Mexicano de la Gelatina). We provide market reports across various industry verticals and also help with procurement and supply chain intelligence. By giving you better insights, we help you make informed business decisions.

    ReplyDelete
  55. Deadlines are scaring you, yet in addition our writers. Our writers work throughout each and every day to finish the assignment and convey before the cutoff times. You can enlist us regardless of whether the paper is expected for later. cheap assignment help
    write my assignment

    ReplyDelete