Questions tagged [built-in]

Built-in functions, modules and classes are standard parts of a programming language or framework.

Built-in functions, modules and classes are standard parts of a programming language or framework.

Generally, all parts of a programming language or framework that don't require the installation of additional components are considered built-in.

1177 questions
41
votes
2 answers

Why does Python have a format function as well as a format method

The format function in builtins seems to be like a subset of the str.format method used specifically for the case of a formatting a single object. eg. >>> format(13, 'x') 'd' is apparently preferred over >>> '{0:x}'.format(13) 'd' and IMO it does…
jamylak
  • 128,818
  • 30
  • 231
  • 230
40
votes
7 answers

Difference between nameof and typeof

Correct me if I am wrong, but doing something like var typeOfName = typeof(Foo).Name; and var nameOfName = nameof(Foo); should give you exactly the same output. One of the understandable reasons according to this source:…
user1400995
39
votes
2 answers

Built-in binary search tree in Python?

Are there any self-balancing binary search tree (RED-BLACK, AVL or others) built-in types in Python 2.7 or Python 3.x? I am looking for something equivalent to Java's TreeMap or TreeSet. If there are no such built-ins, why have they been ommited? Is…
Alexandru Chirila
  • 2,274
  • 5
  • 29
  • 40
37
votes
2 answers

How are methods, `classmethod`, and `staticmethod` implemented in Python?

At what point do methods in Python acquire a get property? —As soon as they're defined in the class? Why does Python let me define a method without any arguments (not even a first self argument)? I know how to use classmethod and staticmethod, and…
Neil G
  • 32,138
  • 39
  • 156
  • 257
35
votes
2 answers

What does the name of the ord() function stand for?

The official Python documentation explains ord(c) ord(c): Given a string representing one Unicode character, return an integer representing the Unicode code point of that character. For example, ord('a') returns the integer 97 and ord('€') (Euro…
AbstProcDo
  • 19,953
  • 19
  • 81
  • 138
33
votes
1 answer

Enable Query Logging in SQLite 3

Is there any built-in function to enable query log in SQLite. I'm familiar with Trace API, but I want to know if there is any predefined function for it.
AnonGeek
  • 7,408
  • 11
  • 39
  • 55
32
votes
4 answers

itertools.ifilter Vs. filter Vs. list comprehensions

I am trying to become more familiar with the itertools module and have found a function called ifilter. From what I understand, it filters and iterable based on the given function and returns an iterator over a list containing the elements of the…
inspectorG4dget
  • 110,290
  • 27
  • 149
  • 241
32
votes
9 answers

How to split a list into equal sized lists in Groovy?

If I have this: def array = [1,2,3,4,5,6] Is there some built-in which allows me to do this ( or something similar ): array.split(2) and get: [[1,2],[3,4],[5,6]] ?
Geo
  • 93,257
  • 117
  • 344
  • 520
32
votes
4 answers

PHP array function that returns a subset for given keys

I'm looking for an array function that does something like this: $myArray = array( 'apple'=>'red', 'banana'=>'yellow', 'lettuce'=>'green', 'strawberry'=>'red', 'tomato'=>'red' ); $keys = array( 'lettuce', 'tomato' ); $ret =…
user1517081
  • 965
  • 2
  • 11
  • 30
30
votes
3 answers

How to convert an existing assembly to a ms unit test assembly?

In Visual Studio 2010 Pro, how can I easily convert a classic assembly to a ms unit test assembly ? It there a flag to activate in the .csproj file ?
Patrice Pezillier
  • 4,476
  • 9
  • 40
  • 50
29
votes
4 answers

Difference between r-base and r-recommended packages

Can anyone tell me what is the difference between base and recommended packages. If there is link where base and recommended packages are mentioned please provide the links.
jan5
  • 1,129
  • 3
  • 17
  • 28
29
votes
2 answers

User defined __mul__ method is not commutative

I wrote a class to represent vectors in Python (as an exercise) and I'm having problems with extending the built-in operators. I defined a __mul__ method for the vector class. The problem is that in the expression x * y the interpreter calls the…
smackcrane
  • 1,379
  • 2
  • 10
  • 17
29
votes
7 answers

In bash, how to get the current status of set -x?

I would like to set -x temporarily in my script and then return in to the original state. Is there a way to do it without starting new subshell? Something like echo_was_on=....... ... ... if $echo_was_on; then set -x; else set +x; fi
jmster
  • 943
  • 1
  • 12
  • 25
28
votes
3 answers

MSVC equivalent to __builtin_popcount?

What is the equivalent to __builtin_popcount as found in GCC and Clang, for MSVC-10?
Matt Joiner
  • 112,946
  • 110
  • 377
  • 526
28
votes
5 answers

Are there builtin functions for elementwise boolean operators over boolean lists?

For example, if you have n lists of bools of the same length, then elementwise boolean AND should return another list of that length that has True in those positions where all the input lists have True, and False everywhere else. It's pretty easy to…
bshanks
  • 1,238
  • 2
  • 12
  • 24
1 2
3
78 79