サクサク読めて、アプリ限定の機能も多数!
トップへ戻る
Pixel 9
nedbatchelder.com
Created 17 May 2022, last updated 14 April 2024 This is a summary of what features appeared in which versions of Python. Items with a star were introduced with a __future__ import. The Python release cycle is explained in PEP 602. Each release has its own PEP with specific dates, they are all listed here. The Python Developer’s Guide has a page summarizing the release cycles of Python versions. 3.
Created 22 December 2002, last updated 6 November 2012 This document is also available in Russian. There’s plenty of information out there about how to write code. Here’s some advice on how to delete code. The best way to delete codeThis may seem obvious, but I guess it isn’t, because of the variety of other ways developers have of deleting code. Here’s how to delete code: Select a section of code
I was trying to diagnose a problem with a PDF file we generated yesterday, and suspected that the images were corrupted. To see, I wrote this quick script to extract JPGs from PDF files. It is quick and dirty, with the absolute minimum understanding of PDF files, which can be quite opaque. # Extract jpg's from pdf's. Quick and dirty. import sys pdf = file(sys.argv[1], "rb").read() startmark = "\xf
I continue to notice an unsettling trend: the rise of the GitHub monoculture. More and more, people seem to believe that GitHub is the center of the programming universe. Don’t get me wrong, I love GitHub. It succeeded at capturing and promoting the social aspect of development better than any other site. And git, despite its flaws, is a great version control system. And just to be clear, I am not
Created 6 July 2013, last updated 26 January 2014 This page is also available in Turkish. The behavior of names and values in Python can be confusing. Like many parts of Python, it has an underlying simplicity that can be hard to discern, especially if you are used to other programming languages. Here I’ll explain how it all works, and present some facts and myths along the way. BTW: I worked this
The Rails community has had a few high-profile security issues this week. They are well-summarized, with an alarming list of what follow-ons to expect, by Patrick McKenzie: What the Rails Security Issue Means for Your Startup. tl;dr: Ruby’s YAML parser will execute arbitrary Ruby code,YAML is parsed all over the place in Rails, including for all JSON input,Pretty much every Rails app is going to b
A popular pastime among programmers is to make fun of programming languages, or at least the one you choose not to use. For example, Gary Bernhardt’s 5-minute talk WAT is all about unexpected behavior, mostly in Javascript. Today brought another example of surprising Javascript behavior: > ['10', '10', '10', '10', '10'].map(parseInt) [ 10, NaN, 2, 3, 4 ] I looked at this and thought, like most oth
About a month ago, I found a bad-behavior bug in the tokenize standard library module, and with help from Aron Griffis, submitted a patch to fix it. Yesterday was a Python bug day, and Ezio Melotti merged my change, so I have officially contributed to CPython! The bug in tokenize was an obscure case: if the code ends with a line that starts with non-space, then ends with many spaces, and no newlin
Created 10 March 2012 This is a presentation I gave at PyCon 2012. You can read the slides and text on this page, or open the actual presentation in your browser, or watch the video: Also, clicking the slide images will jump into the full presentation at that point. The Symbola font is included, but will have to be downloaded before some of the special symbols will appear. Hi, I’m Ned Batchelder.
Python has an eval() function which evaluates a string of Python code: assert eval("2 + 3 * len('hello')") == 17 This is very powerful, but is also very dangerous if you accept strings to evaluate from untrusted input. Suppose the string being evaluated is “os.system(‘rm -rf /’)” ? It will really start deleting all the files on your computer. (In the examples that follow, I’ll use ‘clear’ instead
Created 24 April 2012, last updated 19 March 2013 This is a presentation I gave at PyCon 2013. You can read the slides and text on this page, or open the actual presentation in your browser (use right and left arrows to advance the slides), or watch the video: This talk is billed as Beginner, and sounds like a beginner topic, but I prefer to think of it as Fundamental. Plenty of expert Python prog
I’ve been thinking about online Python learners. There have been some cool examples of online code exercises, like Nathan’s Javascript Lessons. These are great because they require absolutely no setup, and can run right on the web page that describes the concepts involved. But of course, it’s easy to run Javascript in a browser. What are the options for doing something similar for Python? CodingBa
I forget what software first set up these associations, but I have .py files registered with Windows so that they can execute directly. The registry defines .py as a Python.File, which has a shell open command of: "C:\Python24\python.exe" "%1" %* My PATHEXT environment variable includes .py, so the command prompt will attempt to execute .py files, using the registry associations to find the execut
Coverage.py Coverage.py is a tool for measuring code coverage of Python programs. It monitors your program, noting which parts of the code have been executed, then analyzes the source to identify code that could have been executed but was not. Coverage measurement is typically used to gauge the effectiveness of tests. It can show which parts of your code are being exercised by tests, and which ar
Created 16 February 2009, last updated 28 January 2021 This is a presentation for PyCon 2009 in Chicago. A video of me presenting it is available on pyvideo.org, or at archive.org, or right here: Python can be extended with extensions written in C. It’s a complex topic, this will be a quick 45 minute introduction. The examples here are toys, meant to demonstrate the structure of an extension. They
Created 10 February 2004, last updated 19 November 2021 An older version of this document is also available in Russian. Cog is a file generation tool. It lets you use pieces of Python code as generators in your source files to generate whatever text you need. This page describes version 3.3.0, released November 19, 2021. The sections below are: What does it do?DesignInstallationWriting the source
Here’s Román Cortés’ Homer, animated to show the structure. I haven’t done anything to Román’s amazing work other than to annotate the divs with ids and add a bit of jQuery to show them in sequence so that you can see the characters being added one at a time.
I spent some time digging around in the Python code to understand how .pyc files work. It turns out they are fairly simple, then kind of complex. At the simple level, a .pyc file is a binary file containing only three things: A four-byte magic number,A four-byte modification timestamp, andA marshalled code object.The magic number is nothing as cool as cafebabe, it’s simply two bytes that change wi
This page is orignally from http://www.garethrees.org/2001/12/04/python-coverage, which seems to be defunct. I grabbed the text from archive.org, and present it here for posterity. I've updated the links to point to appropriate pages on this site. 1. Introduction The coverage.py Python module provides statement coverage for Python. It accumulates coverage data over many runs; generates coverage re
Created 29 October 2006 Many developers are uneasy about branching and merging, even those who consider source control essential. It can be a very complicated process, but it doesn’t have to be, and it is a very powerful way to manage development. Here’s how to get started with branches in Subversion. PrinciplesBranching produces a split in a code stream: different developers can be working in alt
Created 30 September 2004, last updated 29 December 2012 NOTE: I am no longer updating this page. Michael Bernstein has a copy at Python Parsing Tools that will be easier to keep up-to-date. The python.org wiki also has a page called LanguageParsing.A few years ago, I went looking for Python parsing tools. I spent a long time researching the various options. When I was done, I had a cheat sheet on
このページを最初にブックマークしてみませんか?
『Ned Batchelder』の新着エントリーを見る
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く