TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: How do you memorize syntax?

1 pointsby joanna_almost 6 years ago
I am learning Python, and having hard a time with concentrating and retaining syntax, and semantics.<p>What to do to memorize and retain the grammar of Python?

5 comments

tylerFowleralmost 6 years ago
+1 on learning by doing. And for me at least it&#x27;s definitely a &quot;use it or lose it&quot; kind of thing. If I don&#x27;t work with a given language for more than a month, when I get back to it I&#x27;ll have to look up basic syntax for a few days until I pick it back up. Though I find this is less of an issue as you learn more and more languages.
watergatormanalmost 6 years ago
You don&#x27;t, at least if the syntax&#x2F;semantics is as complex as Python!<p>Recommendation:<p>Find a subset grammar for Python, by doing a search on computer science classes on university sites. You will find the published Python subset grammars probably too small for your purposes, but they are a start.<p>See if any of those subset grammars meet your needs.<p>IF not, remove from the published official Python grammar, various features that you do not need or are not easily understood. I recommend you keep the production rule for &quot;class&quot;<p>When you get a subset grammar that meets your needs, it will have to be well-formed, meaning it passes reachability, derivability, and non-circularity tests, has no undefined non-terminals, and is complete with a start (i.e., goal symbol.<p>You should then remove left-recursion and left-factor the grammar so it is LL(1).<p>Run your grammar through some of the on-line syntax checking sites to be sure the grammar is unambigous and is LL(1). You can use the online Grammophone tool from the University of Calgary to check your subset grammar.<p>After the grammar passes the LL(1) tests, find a top-down, predictive, compiler-generator that generates recursive-descent parsers, and not tables. The compiler-generator will also perform tests on your grammar and let you know what needs fixing.<p>I forgot to mention that you will also need to define the lexical tokens needed for the scanner portion before you can generate your scanner and parser modules.<p>After you generate the scanner, parser, and a main module to call them, you will have created a fast syntax checker for your subset grammar.<p>Run the fast syntax checker, preferably within a program editor or IDE, as you write your Python programs<p>You can also create &quot;template editing macros&quot; that will insert into your editor, portions of a Python program, but with portions elided, that you gradually fill-in. Also, you can add syntax-highlighting to your editor.
simonblackalmost 6 years ago
Usage. The more you use something consistently, the more you remember it.<p>However .... One thing I learned very early on is that in today&#x27;s world, it&#x27;s probably silly to try to clutter up your limited memory with stuff that you rarely use.<p><i>You can never remember everything. BUT ... you should know where to find it.</i><p>You have a computer with you, so use that as a source of reference.<p>Even today, after using C for decades, I will often do things like &quot;man strtok&quot; while programming.
fetus8almost 6 years ago
By writing code. The more I write, the more I get familiar with the syntax and semantics of the language.
评论 #20451745 未加载
ashwanidausodiaalmost 6 years ago
Practice. A lot of practice