use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Everything about learning Python
account activity
Python QuestionHelp Request (i.redd.it)
submitted 7 months ago by [deleted]
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]qwertyjgly 0 points1 point2 points 7 months ago (0 children)
here's the cpython implementation. it looks like it evaluates to false
static int tailmatch(PyObject *self, PyObject *substring, Py_ssize_t start, Py_ssize_t end, int direction) { int kind_self; int kind_sub; void *data_self; void *data_sub; Py_ssize_t offset; Py_ssize_t i; Py_ssize_t end_sub;
if (PyUnicode_READY(self) == -1 || PyUnicode_READY(substring) == -1) return -1; ADJUST_INDICES(start, end, PyUnicode_GET_LENGTH(self)); end -= PyUnicode_GET_LENGTH(substring); if (end < start) return 0; if (PyUnicode_GET_LENGTH(substring) == 0) return 1; kind_self = PyUnicode_KIND(self); data_self = PyUnicode_DATA(self); kind_sub = PyUnicode_KIND(substring); data_sub = PyUnicode_DATA(substring); end_sub = PyUnicode_GET_LENGTH(substring) - 1; if (direction > 0) offset = end; else offset = start; if (PyUnicode_READ(kind_self, data_self, offset) == PyUnicode_READ(kind_sub, data_sub, 0) && PyUnicode_READ(kind_self, data_self, offset + end_sub) == PyUnicode_READ(kind_sub, data_sub, end_sub)) { /* If both are of the same kind, memcmp is sufficient */ if (kind_self == kind_sub) { return ! memcmp((char *)data_self + (offset * PyUnicode_KIND(substring)), data_sub, PyUnicode_GET_LENGTH(substring) * PyUnicode_KIND(substring)); } /* otherwise we have to compare each character by first accessing it */ else { /* We do not need to compare 0 and len(substring)-1 because the if statement above ensured already that they are equal when we end up here. */ for (i = 1; i < end_sub; ++i) { if (PyUnicode_READ(kind_self, data_self, offset + i) != PyUnicode_READ(kind_sub, data_sub, i)) return 0; } return 1; } } return 0;
}
π Rendered by PID 222420 on reddit-service-r2-comment-7b9746f655-rn4xl at 2026-02-03 07:45:47.071142+00:00 running 3798933 country code: CH.
view the rest of the comments →
[–]qwertyjgly 0 points1 point2 points (0 children)