Skip to content

Python3.5.1: type().startswith() #71204

Description

@VertigoRay
BPO 27017
Nosy @pfmoore, @tjguk, @stevendaprano, @zware, @zooba

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2016-05-14.07:08:56.599>
created_at = <Date 2016-05-14.06:55:39.965>
labels = ['type-bug', 'invalid', 'OS-windows']
title = 'Python3.5.1: type().startswith()'
updated_at = <Date 2016-05-14.07:44:39.784>
user = 'https://bugs.python.org/VertigoRay'

bugs.python.org fields:

activity = <Date 2016-05-14.07:44:39.784>
actor = 'steven.daprano'
assignee = 'none'
closed = True
closed_date = <Date 2016-05-14.07:08:56.599>
closer = 'SilentGhost'
components = ['Windows']
creation = <Date 2016-05-14.06:55:39.965>
creator = 'VertigoRay'
dependencies = []
files = []
hgrepos = []
issue_num = 27017
keywords = []
message_count = 3.0
messages = ['265505', '265506', '265508']
nosy_count = 7.0
nosy_names = ['paul.moore', 'tim.golden', 'steven.daprano', 'SilentGhost', 'zach.ware', 'steve.dower', 'VertigoRay']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue27017'
versions = ['Python 3.5']

Activity

  1. VertigoRay commented on May 14, 2016

    VertigoRaymannequin
    MannequinAuthor

    This doesn't look like proper functionality

        Python 3.5.1 (v3.5.1:37a07cee5969, Dec  6 2015, 01:54:25) [MSC v.1900 64 bit (AMD64)] on win32
        Type "help", "copyright", "credits" or "license" for more information.
        >>> type('')
        <class 'str'>
        >>> type('').startswith('s')
        Traceback (most recent call last):
          File "<stdin>", line 1, in <module>
        TypeError: startswith() takes at least 1 argument (0 given)
        >>> type('').startswith('s', 's')
        True
  2. SilentGhost commented on May 14, 2016

    SilentGhostmannequin
    Mannequin

    This is exactly how methods on Python object have been behaving for year: any method can be called either as method on instance, or as method on class, with instance passed as the first argument.

  3. stevendaprano commented on May 14, 2016

    @stevendaprano
    Member

    To explain in more detail: type('s').startswith is the same as str.startswith, which is an unbound method in Python 2 and a regular function in Python 3. Either way, it expects two arguments: a string which becomes "self", and a second string argument, which is the prefix being tested for.

    So type('any string').startswith('alphabet', 'al') is a long way of writing 'alphabet'.startswith('al').

  4. transferred this issue fromon Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    OS-windowstype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions