Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
byte types
#6
whatever you want to call it, accepting a variety of types for an argument and then doing what makes sense with the mix of the semantics of that argument and the semantics of the type that is given is something i have done for years, found to be well understood, benefitted the projects, and i expect to continue. why would Python programmers be any less capable of understanding it and working with it? an example of a function i have been thinking about is one that i would define as "counting the number of character encodings in a sequence containing byte codes". the len() function (notice, just one name for all types) used on such a sequence would not give the number of characters encoded, but rather, the number of codes present to make up that coding. but, in most cases involving text processing, the number of characters is what is useful. i might call this function clen(). i would code it to accept as many sequence types as i can. this would at least be bytes, bytearray, string, list, and tuple (for Python3). ints could be the codes for a list or tuple. the user (of my function, the coder of the app calling my function) would not need to check the type they have to figure out which of at least 5 different function names they have; they just call clen() with whatever they have and get an answer. the check for an unaccepted type would then be except TypeError: (or a value configured to be returned in such a case by that calling program).

yes, i have read a bunch of opinions (posts, blogs) by a bunch of people saying not to use dynamic typing. but they tend to be specifically opposed to dynamic typing and dynamic data, so i generally dismiss them. they seem to be as numerous in Python as in Pike even though dynamic typing is not the default in Pike (coders have to specify mixed as the type of the variable, so dynamic typing is easy to avoid). they tend to be less numerous for C since in C you don't have dynamic typing at all without adding it on.

i am no longer open minded about dynamic typing. i have made my decision and i embrace dynamic typing. that decision, made years before i started using Python, is a major reason i got into coding in Python.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Messages In This Thread
byte types - by Skaperen - Oct-31-2018, 10:44 PM
RE: byte types - by wavic - Nov-01-2018, 05:03 AM
RE: byte types - by Gribouillis - Nov-01-2018, 09:18 AM
RE: byte types - by Skaperen - Nov-01-2018, 06:22 PM
RE: byte types - by Gribouillis - Nov-01-2018, 08:08 PM
RE: byte types - by Skaperen - Nov-02-2018, 12:05 AM
RE: byte types - by Gribouillis - Nov-02-2018, 05:45 AM
RE: byte types - by Skaperen - Nov-02-2018, 02:48 PM
RE: byte types - by wavic - Nov-02-2018, 06:06 PM
RE: byte types - by Skaperen - Nov-04-2018, 09:32 PM
RE: byte types - by ichabod801 - Nov-05-2018, 02:24 AM
RE: byte types - by Skaperen - Nov-06-2018, 12:55 AM
RE: byte types - by wavic - Nov-05-2018, 07:58 AM
RE: byte types - by Gribouillis - Nov-06-2018, 08:01 AM
RE: byte types - by Skaperen - Nov-07-2018, 04:03 AM
RE: byte types - by Gribouillis - Nov-07-2018, 09:19 PM
RE: byte types - by Skaperen - Nov-07-2018, 09:26 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020