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
69
votes
11 answers

How is the 'is' keyword implemented in Python?

... the is keyword that can be used for equality in strings. >>> s = 'str' >>> s is 'str' True >>> s is 'st' False I tried both __is__() and __eq__() but they didn't work. >>> class MyString: ... def __init__(self): ... self.s = 'string' ... …
Srikanth
  • 11,780
  • 23
  • 72
  • 92
69
votes
7 answers

Which version of R is running in my computer?

There are two R directories on my computer: one is /home/R-2.15.2,the other is /home/R-2.15.1, when I input R , I can start R, now I want to know which R is running: 2.15.1 or 2.15.2?
showkey
  • 482
  • 42
  • 140
  • 295
65
votes
1 answer

How to add a builtin function in a GCC plugin?

It is possible for a GCC plugin to add a new builtin function? If so, how to do it properly? GCC version is 5.3 (or newer). The code is compiled and processed by the plugin written in C. It is mentioned in the rationale for GCC plugins at…
Eugene
  • 5,977
  • 2
  • 29
  • 46
62
votes
9 answers

How to use the read command in Bash?

When I try to use the read command in Bash like this: echo hello | read str echo $str Nothing echoed, while I think str should contain the string hello. Can anybody please help me understand this behavior?
Determinant
  • 3,886
  • 7
  • 31
  • 47
61
votes
8 answers

Python sum, why not strings?

Python has a built in function sum, which is effectively equivalent to: def sum2(iterable, start=0): return start + reduce(operator.add, iterable) for all types of parameters except strings. It works for numbers and lists, for example: …
Muhammad Alkarouri
  • 23,884
  • 19
  • 66
  • 101
61
votes
4 answers

Merge two objects in Python

Is there a good way to merge two objects in Python? Like a built-in method or fundamental library call? Right now I have this, but it seems like something that shouldn't have to be done manually: def add_obj(obj, add_obj): for property in…
Chris Dutrow
  • 48,402
  • 65
  • 188
  • 258
60
votes
4 answers

What does "< <(command args)" mean in the shell?

When looping recursively through folders with files containing spaces the shell script I use is of this form, copied from the internet: while IFS= read -r -d $'\0' file; do dosomethingwith "$file" # do something with each file …
stib
  • 3,346
  • 2
  • 30
  • 38
53
votes
9 answers

TypeError: 'builtin_function_or_method' object is not subscriptable

elif(listb[0] == "-test"): run_all.set("testview") listb.pop[0] ERROR: Exception in Tkinter callback Traceback (most recent call last): File "/tools/python/2.7.2/lib/python2.7/lib-tk/Tkinter.py", line 1410, in call return…
Ani
  • 918
  • 1
  • 10
  • 25
51
votes
3 answers

Python built-in function "compile". What is it used for?

I came across a built-in function compile today. Though i read the documentation but still do not understand it's usage or where it is applicable. Please can anyone explain with example the use of this function. I will really appreciate…
demo.b
  • 3,299
  • 2
  • 29
  • 29
51
votes
3 answers

How to restore a builtin that I overwrote by accident?

I accidentally overwrote set by using it as a variable name in an interactive python session - is there any way that I can get access to the original set function without just restarting my session? (I have so much stuff in that session that I'd…
weronika
  • 2,561
  • 2
  • 24
  • 30
47
votes
3 answers

Ruby array each_slice_with_index?

If I have arr = [1, 2, 3, 4] I know I can do the following... > arr.each_slice(2) { |a, b| puts "#{a}, #{b}" } 1, 2 3, 4 ...And... > arr.each_with_index { |x, i| puts "#{i} - #{x}" } 0 - 1 1 - 2 2 - 3 3 - 4 ...But is there a built in way to do…
Drew
  • 15,158
  • 17
  • 68
  • 77
43
votes
7 answers

Override the {...} notation so i get an OrderedDict() instead of a dict()?

Update: dicts retaining insertion order is guaranteed for Python 3.7+ I want to use a .py file like a config file. So using the {...} notation I can create a dictionary using strings as keys but the definition order is lost in a standard python…
fdb
  • 1,998
  • 1
  • 19
  • 20
43
votes
7 answers

How to avoid SQL injection in CodeIgniter?

Is there any method to set in config file to avoid SQL injection? I am using this code for selecting values: $this->db->query("SELECT * FROM tablename WHERE var='$val1'"); And this for inserting values: $this->db->query("INSERT INTO tablename…
42
votes
3 answers

What's the difference between identical(x, y) and isTRUE(all.equal(x, y))?

Is there any difference between testing isTRUE(all.equal(x, y)) and identical(x, y)? The help page says: Don't use 'all.equal' directly in 'if' expressions — either use 'isTRUE(all.equal(....))' or 'identical' if appropriate. but that "if…
mariotomo
  • 9,438
  • 8
  • 47
  • 66
42
votes
4 answers

No module named builtins

I'm trying to convert my .py script into an executable using py2exe. I've had a number of issues so far that have been largely addressed by the "options" in the setup file below. But now I have a problem that I have not been able to find a solution…
Charlie_M
  • 1,281
  • 2
  • 16
  • 20
1
2
3
78 79