Search
Searching for multiple words only shows matches that contain all words.
Search Results
Search finished, found 109 pages matching the search query.
- BaseExceptionGroup.split (Python method, in Built-in Exceptions)
- bytearray.split (Python method, in Built-in Types)
- bytes.split (Python method, in Built-in Types)
- os.path.split (Python function, in
os.path
— Common pathname manipulations) - re.Pattern.split (Python method, in
re
— Regular expression operations) - re.split (Python function, in
re
— Regular expression operations) - shlex.split (Python function, in
shlex
— Simple lexical analysis) - str.split (Python method, in Built-in Types)
- Regular Expression HOWTO
...ttern?”, or “Is there a match for the pattern anywhere in this string?”. You can also use REs to modify a string or to split it apart in various ways. Regular expression patterns are compiled into a series of bytecodes which are then execu...
- bytearray.rsplit (Python method, in Built-in Types)
- bytearray.splitlines (Python method, in Built-in Types)
- bytes.rsplit (Python method, in Built-in Types)
- bytes.splitlines (Python method, in Built-in Types)
- os.path.splitdrive (Python function, in
os.path
— Common pathname manipulations) - os.path.splitext (Python function, in
os.path
— Common pathname manipulations) - os.path.splitroot (Python function, in
os.path
— Common pathname manipulations) - PyUnicode_RSplit (C function, in Unicode Objects and Codecs)
- PyUnicode_RSplit.maxsplit (C function parameter, in Unicode Objects and Codecs)
- PyUnicode_Split (C function, in Unicode Objects and Codecs)
- PyUnicode_Split.maxsplit (C function parameter, in Unicode Objects and Codecs)
- PyUnicode_Splitlines (C function, in Unicode Objects and Codecs)
- shlex.shlex.whitespace_split (Python attribute, in
shlex
— Simple lexical analysis) - str.rsplit (Python method, in Built-in Types)
- str.splitlines (Python method, in Built-in Types)
- urllib.parse.SplitResult (Python class, in
urllib.parse
— Parse URLs into components) - urllib.parse.SplitResultBytes (Python class, in
urllib.parse
— Parse URLs into components) - urllib.parse.urlsplit (Python function, in
urllib.parse
— Parse URLs into components) - urllib.parse.urlunsplit (Python function, in
urllib.parse
— Parse URLs into components) argparse
— Parser for command-line options, arguments and subcommands...prefix_chars='-+') >>> parser.add_argument('+f') >>> parser.add_argument('++bar') >>> parser.parse_args('+f X ++bar Y'.split()) Namespace(bar='Y', f='X') The prefix_chars= argument defaults to '-'. Supplying a set of characters that does...
cmd
— Support for line-oriented command interpreters...a file: PLAYBACK rose.cmd' self.close() with open(arg) as f: self.cmdqueue.extend(f.read().splitlines()) def precmd(self, line): line = line.lower() if self.file and 'playback' not in line:...
codecs
— Codec registry and base classes...+FEFF had a second purpose as a ZERO WIDTH NO-BREAK SPACE: a character that has no width and doesn’t allow a word to be split. It can e.g. be used to give hints to a ligature algorithm. With Unicode 4.0 using U+FEFF as a ZERO WIDTH NO-BREAK...
configparser
— Configuration file parser...ur application does not need values with empty lines, you should consider disallowing them. This will make empty lines split keys every time. In the example above, it would produce two keys, key and this. default_section, default value:...
decimal
— Decimal fixed-point and floating-point arithmetic...Here is a small decimal floating-point flying circus: >>> data = list(map(Decimal, '1.34 1.87 3.45 2.35 1.00 0.03 9.25'.split())) >>> max(data) Decimal('9.25') >>> min(data) Decimal('0.03') >>> sorted(data) [Decimal('0.03'), Decimal('1.00')...
difflib
— Helpers for computing deltas...itespace characters (a blank or tab; it’s a bad idea to include newline in this!). >>> diff = ndiff('one\ntwo\nthree\n'.splitlines(keepends=True), ... 'ore\ntree\nemu\n'.splitlines(keepends=True)) >>> print(''.join(diff), end="...
dis
— Disassembler for Python bytecode...oolean result of the test. Added in version 3.11. CHECK_EG_MATCH Performs exception matching for except*. Applies split(STACK[-1]) on the exception group representing STACK[-2]. In case of a match, pops two items from the stack and pu...
email.header
: Internationalized headers...as the default for subsequent append() calls. The maximum line length can be specified explicitly via maxlinelen. For splitting the first line to a shorter value (to account for the field header which isn’t included in s, e.g. Subject) pa...
email.message.Message
: Representing an email message using thecompat32
API...the message’s Content-Type parameters, as a list. The elements of the returned list are 2-tuples of key/value pairs, as split on the '=' sign. The left hand side of the '=' is the key, while the right hand side is the value. If there is n...
email.policy
: Policy Objects...ader_factory. Folding of a header object is done by calling its fold method with the current policy. Source values are split into lines using splitlines(). If the value is not to be refolded, the lines are rejoined using the linesep from...
email
: Examples...# use a generic bag-of-bits type. ctype = 'application/octet-stream' maintype, subtype = ctype.split('/', 1) with open(path, 'rb') as fp: msg.add_attachment(fp.read(),...
getopt
— C-style parser for command line options...ward compatibility. An example using only Unix style options: >>> import getopt >>> args = '-a -b -cfoo -d bar a1 a2'.split() >>> args ['-a', '-b', '-cfoo', '-d', 'bar', 'a1', 'a2'] >>> optlist, args = getopt.getopt(args, 'abc:d:') >>> op...
gettext
— Multilingual internationalization services...for the languages variable. The environment variables should contain a colon separated list of languages, which will be split on the colon to produce the expected list of language code strings. find() then expands and normalizes the languag...
imaplib
— IMAP4 protocol client...of “.SILENT”. For example, to set the delete flag on all messages: typ, data = M.search(None, 'ALL') for num in data[0].split(): M.store(num, '+FLAGS', '\\Deleted') M.expunge() Note Creating flags containing ‘]’ (for example: “[test]”...
itertools
— Functions creating iterators for efficient looping...te, seq seq[0], seq[1], until predicate fails takewhile(lambda x: x<5, [1,4,6,3,8]) → 1 4 tee() it, n it1, it2, … itn splits one iterator into n zip_longest() p, q, … (p[0], q[0]), (p[1], q[1]), … zip_longest('ABCD', 'xy', fillvalue='-'...
operator
— Standard operators as functions...return tuple(resolve_attr(obj, attr) for attr in items) return g def resolve_attr(obj, attr): for name in attr.split("."): obj = getattr(obj, name) return obj operator.itemgetter(item) operator.itemgetter(*items)...
optparse
— Parser for command line options...n for creating Option instances; currently it is an alias for the Option constructor. A future version of optparse may split Option into several classes, and make_option() will pick the right class to instantiate. Do not instantiate Optio...
os.path
— Common pathname manipulations...Return the base name of pathname path. This is the second element of the pair returned by passing path to the function split(). Note that the result of this function is different from the Unix basename program; where basename for '/foo/ba...
os
— Miscellaneous operating system interfaces...'\\' for Windows. Note that knowing this is not sufficient to be able to parse or concatenate pathnames — use os.path.split() and os.path.join() — but it is occasionally useful. Also available via os.path. os.altsep An alternative cha...
pdb
— The Python Debugger...ds in a line that is passed to the Python parser.) No intelligence is applied to separating the commands; the input is split at the first ;; pair, even if it is in the middle of a quoted string. A workaround for strings with double semicol...
platform
— Access to underlying platform’s identifying data...if "ID_LIKE" in info: # ids are space separated and ordered by precedence ids.extend(info["ID_LIKE"].split()) return ids Added in version 3.10. Android Platform platform.android_ver(release='', api_level=0,...
pprint
— Data pretty printer...hon project', 'version': '1.2.0'} Additionally, maximum character width can be suggested. If a long object cannot be split, the specified width will be exceeded: >>> pprint.pp(project_info, depth=1, width=60) {'author': 'The Python Packa...
random
— Generate pseudo-random numbers...>>> choice(['win', 'lose', 'draw']) # Single random element from a sequence 'draw' >>> deck = 'ace two three four'.split() >>> shuffle(deck) # Shuffle a list >>> deck ['four', 'two', 'ace', 'three'] >>> sample([10,...
re
— Regular expression operations.... Values can be any of the flags variables, combined using bitwise OR (the | operator). Added in version 3.4. re.split(pattern, string, maxsplit=0, flags=0) Split string by the occurrences of pattern. If capturing parentheses are use...
reprlib
— Alternaterepr()
implementation...ted as methods with a name based on the type name. In the method name, TYPE is replaced by '_'.join(type(obj).__name__.split()). Dispatch to these methods is handled by repr1(). Type-specific methods which need to recursively format a valu...
shlex
— Simple lexical analysis...files for Python applications) or for parsing quoted strings. The shlex module defines the following functions: shlex.split(s, comments=False, posix=True) Split the string s using shell-like syntax. If comments is False (the default), the...
smtplib
— SMTP protocol client...rt smtplib def prompt(title): return input(title).strip() from_addr = prompt("From: ") to_addrs = prompt("To: ").split() print("Enter message, end with ^D (Unix) or ^Z (Windows):") # Add the From: and To: headers at the start! lines...
sqlite3
— DB-API 2.0 interface for SQLite databases...always passed a bytes object, no matter the underlying SQLite data type. def convert_point(s): x, y = map(float, s.split(b";")) return Point(x, y) We now need to tell sqlite3 when it should convert a given SQLite value. This is d...
ssl
— TLS/SSL wrapper for socket objects...lk with the server: >>> conn.sendall(b"HEAD / HTTP/1.0\r\nHost: linuxfr.org\r\n\r\n") >>> pprint.pprint(conn.recv(1024).split(b"\r\n")) [b'HTTP/1.1 200 OK', b'Date: Sat, 18 Oct 2014 18:27:20 GMT', b'Server: nginx', b'Content-Type: text/h...
string
— Common string operations...tern matches the template without one of these named groups matching. Helper functions string.capwords(s, sep=None) Split the argument into words using str.split(), capitalize each word using str.capitalize(), and join the capitalized w...
subprocess
— Subprocess management...ote It may not be obvious how to break a shell command into a sequence of arguments, especially in complex cases. shlex.split() can illustrate how to determine the correct tokenization for args: >>> import shlex, subprocess >>> command_line...
textwrap
— Text wrapping and filling...ext, prefix, predicate=None) Add prefix to the beginning of selected lines in text. Lines are separated by calling text.splitlines(True). By default, prefix is added to all lines that do not consist solely of whitespace (including any line...
tokenize
— Tokenizer for Python source...g(). Added in version 3.2. exception tokenize.TokenError Raised when either a docstring or expression that may be split over several lines is not completed anywhere in the file, for example: """Beginning of docstring or: [1, 2, 3...
typing
— Support for type hints...args kwargs Since ParamSpec captures both positional and keyword parameters, P.args and P.kwargs can be used to split a ParamSpec into its components. P.args represents the tuple of positional parameters in a given call and should...
unittest.mock
— mock object library...with call objects and so can also be used in test assertions: class TestStringMethods(unittest.TestCase): def test_split(self): s = 'hello world' self.assertEqual(s.split(), ['hello', ANY]) FILTER_DIR unittest.moc...
unittest
— Unit testing framework...ef test_isupper(self): self.assertTrue('FOO'.isupper()) self.assertFalse('Foo'.isupper()) def test_split(self): s = 'hello world' self.assertEqual(s.split(), ['hello', 'world']) # check that s.sp...
urllib.parse
— Parse URLs into components...replacement. The use of netloc is continued for backward compatibility. URL Parsing The URL parsing functions focus on splitting a URL string into its components, or on combining URL components into a URL string. urllib.parse.urlparse(ur...
venv
— Creation of virtual environments...e() def install_script(self, context, name, url): _, _, path, _, _, _ = urlparse(url) fn = os.path.split(path)[-1] binpath = context.bin_path distpath = os.path.join(binpath, fn) # Download scrip...
wsgiref
— WSGI Utilities and Reference Implementation...pond): # Get the file name and MIME type fn = os.path.join(path, environ["PATH_INFO"][1:]) if "." not in fn.split(os.path.sep)[-1]: fn = os.path.join(fn, "index.html") mime_type = mimetypes.guess_file_type(fn)[0]...
xml.sax.handler
— Base classes for SAX handlers...eport each chunk of character data. SAX parsers may return all contiguous character data in a single chunk, or they may split it into several chunks; however, all of the characters in any single event must come from the same external entity...
- 1. Whetting Your Appetite
...omain than Awk or even Perl, yet many things are at least as easy in Python as in those languages. Python allows you to split your program into modules that can be reused in other Python programs. It comes with a large collection of standa...
- 2. Lexical analysis
...t. A backslash does not continue a token except for string literals (i.e., tokens other than string literals cannot be split across physical lines using a backslash). A backslash is illegal elsewhere on a line outside a string literal....
- 6. Modules
...it with that file as input instead. This is known as creating a script. As your program gets longer, you may want to split it into several files for easier maintenance. You may also want to use a handy function that you’ve written in se...
- 7. Input and Output
...other='Georg')) The story of Bill, Manfred, and Georg. If you have a really long format string that you don’t want to split up, it would be nice if you could reference the variables to be formatted by name instead of by position. This ca...
- 7. Using Python on iOS
...esults in CC/CPP/LD/AR definitions that include spaces. There is a lot of C ecosystem tooling that assumes that you can split a command line at the first space to get the path to the compiler executable; this isn’t the case when using xcrun...
- 9. Classes
...y for x,y in zip(xvec, yvec)) # dot product 260 >>> unique_words = set(word for line in page for word in line.split()) >>> valedictorian = max((student.gpa, student.name) for student in graduates) >>> data = 'golf' >>> list(data...
- Built-in Exceptions
...included in the result in full. Added in version 3.13: condition can be any callable which is not a type object. split(condition) Like subgroup(), but returns the pair (match, rest) where match is subgroup(condition) and rest is the...
- Built-in Types
...is a third argument, it must be a string, whose characters will be mapped to None in the result. str.partition(sep) Split the string at the first occurrence of sep, and return a 3-tuple containing the part before the separator, the sepa...
- Changelog
...2: The wheel tags supported by each macOS universal SDK option are now documented. gh-46236: C API: Document PyUnicode_RSplit(), PyUnicode_Partition() and PyUnicode_RPartition(). Core and Builtins gh-130163: Fix possible crashes related...
- Design and History FAQ
...gether with a string constant”. Sadly, you aren’t. For some reason there seems to be much less difficulty with having split() as a string method, since in that case it is easy to see that "1, 2, 4, 8, 16".split(", ") is an instruction t...
- Library and Extension FAQ
...rk on any host that supports an SMTP listener. import sys, smtplib fromaddr = input("From: ") toaddrs = input("To: ").split(',') print("Enter message, end with ^D:") msg = '' while True: line = sys.stdin.readline() if not line:...
- Logging Cookbook
...started') webapplib.useful() logger.debug('Request processing finished') def main(): fn = os.path.splitext(os.path.basename(__file__))[0] adhf = argparse.ArgumentDefaultsHelpFormatter ap = argparse.ArgumentPars...
- Module Objects
...“multi-phase initialization”. Extension modules created this way behave more like Python modules: the initialization is split between the creation phase, when the module object is created, and the execution phase, when it is populated. The...
- Programming FAQ
...Is there a scanf() or sscanf() equivalent? Not as such. For simple input parsing, the easiest approach is usually to split the line into whitespace-delimited words using the split() method of string objects and then convert decimal strin...
- PyUnicode_RSplit.sep (C function parameter, in Unicode Objects and Codecs)
- PyUnicode_RSplit.unicode (C function parameter, in Unicode Objects and Codecs)
- PyUnicode_Split.sep (C function parameter, in Unicode Objects and Codecs)
- PyUnicode_Split.unicode (C function parameter, in Unicode Objects and Codecs)
- PyUnicode_Splitlines.keepends (C function parameter, in Unicode Objects and Codecs)
- PyUnicode_Splitlines.unicode (C function parameter, in Unicode Objects and Codecs)
- Sorting Techniques
...g comparisons. For example, here’s a case-insensitive string comparison: >>> sorted("This is a test string from Andrew".split(), key=str.casefold) ['a', 'Andrew', 'from', 'is', 'string', 'test', 'This'] The value of the key parameter shou...
- Unicode Objects and Codecs
...ode_DecodeUTF16Stateful() will not treat trailing incomplete UTF-16 byte sequences (such as an odd number of bytes or a split surrogate pair) as an error. Those bytes will not be decoded and the number of bytes that have been decoded will b...
- urllib.parse.urllib.parse.SplitResult.geturl (Python method, in
urllib.parse
— Parse URLs into components) - What’s New in Python 2.2
...d performance improvements have been made to the SRE engine underlying the re module. For example, the re.sub() and re.split() functions have been rewritten in C. Another contributed patch speeds up certain Unicode character ranges by a f...
- What’s New in Python 2.3
...ted files. Comma-separated format is deceptively simple at first glance: Costs,150,200,3.95 Read a line and call line.split(','): what could be simpler? But toss in string data that can contain commas, and things get more complicated: "Co...
- What’s New in Python 2.4
...rgument for specifying a fill character other than a space. (Contributed by Raymond Hettinger.) Strings also gained an rsplit() method that works like the split() method but splits from the end of the string. (Contributed by Sean Reifschn...
- What’s New in Python 2.5
...at faster. (Implemented by Raymond Hettinger.) The speed of some Unicode operations, such as finding substrings, string splitting, and character map encoding and decoding, has been improved. (Substring search and splitting improvements were...
- What’s New in Python 2.6
...uted by Neal Norwitz.) Unicode strings now use faster code for detecting whitespace and line breaks; this speeds up the split() method by about 25% and splitlines() by 35%. (Contributed by Antoine Pitrou.) Memory usage is reduced by using...
- What’s New in Python 2.7
...stead of using a generalized conversion function that supports arbitrary bases. (Patch by Gawain Bolton; bpo-6713.) The split(), replace(), rindex(), rpartition(), and rsplit() methods of string-like types (strings, Unicode strings, and byt...
- What’s New In Python 3.1
...y(region='West', dept='Sales', _2=419)] (Contributed by Raymond Hettinger; bpo-1818.) The re.sub(), re.subn() and re.split() functions now accept a flags parameter. (Contributed by Gregory Smith.) The logging module now implements a sim...
- What’s New In Python 3.10
...t ‘-n’). User hooks were previously ignored. (Contributed by Ken Hilton in bpo-43008.) Rearrange the settings dialog. Split the General tab into Windows and Shell/Ed tabs. Move help sources, which extend the Help menu, to the Extensions...
- What’s New In Python 3.11
...s it is unusable without the external mailman package. (Contributed by Donghee Na in bpo-35800.) Removed the deprecated split() method of _tkinter.TkappType. (Contributed by Erlend E. Aasland in bpo-38371.) Removed namespace package support...
- What’s New In Python 3.12
...os.path.isjunction() to check if a given path is a junction. (Contributed by Charles Machalow in gh-99547.) Add os.path.splitroot() to split a path into a triad (drive, root, tail). (Contributed by Barney Gale in gh-101000.) pathlib Add...
- What’s New In Python 3.13
...t the correct keyword argument when an incorrect keyword argument is passed to a function. >>> "Better error messages!".split(max_split=1) Traceback (most recent call last): File "<python-input-0>", line 1, in <module> "Better error m...
- What’s New In Python 3.2
...mmand string: >>> cmd = 'deploy sneezy.example.com sleepy.example.com -u skycaptain' >>> result = parser.parse_args(cmd.split()) >>> result.action 'deploy' >>> result.targets ['sneezy.example.com', 'sleepy.example.com'] >>> result.user 'sky...
- What’s New In Python 3.3
...iple driving this change is to allow even generators that are designed to be used with the send and throw methods to be split into multiple subgenerators as easily as a single large function can be split into multiple subfunctions. See als...
- What’s New In Python 3.4
...rmat(instr.opname, instr.opcode)) LOAD_FAST (124) LOAD_CONST (100) BINARY_ADD (23) RETURN_VALUE (83) >>> bytecode.dis().splitlines() [' 1 0 LOAD_FAST 0 (x)', ' --> 3 LOAD_CONST 1 (1)', '...
- What’s New In Python 3.5
...its section proxies. Example: >>> import configparser >>> conv = {} >>> conv['list'] = lambda v: [e.strip() for e in v.split() if e.strip()] >>> cfg = configparser.ConfigParser(converters=conv) >>> cfg.read_string(""" ... [s] ... list = a...
- What’s New In Python 3.7
...II, re.LOCALE and re.UNICODE can be set within the scope of a group. (Contributed by Serhiy Storchaka in bpo-31690.) re.split() now supports splitting on a pattern like r'\b', '^$' or (?=-) that matches an empty string. (Contributed by Serh...
- What’s New In Python 3.8
...syntax into better agreement with normal assignment syntax: >>> def parse(family): lastname, *members = family.split() return lastname.upper(), *members >>> parse('simpsons homer marge bart lisa maggie') ('SIMPSONS', 'home...
- What’s New In Python 3.9
...lton in bpo-43008.) The changes above have been backported to 3.8 maintenance releases. Rearrange the settings dialog. Split the General tab into Windows and Shell/Ed tabs. Move help sources, which extend the Help menu, to the Extensions...