Linked Questions

578 votes
5 answers
380k views

Suppose I have a function like: def myfun(a, b, c): return (a * 2, b + c, c + b) Given a tuple some_tuple = (1, "foo", "bar"), how would I use some_tuple to call myfun? This ...
AkiRoss's user avatar
  • 12.4k
12 votes
2 answers
13k views

I'm trying to use the str.format() method, and having some difficulties when my values are stored within a tuple. For example, if I do: s = "x{}y{}z{}" s.format(1,2,3) Then I get 'x1y2z3' - no ...
soungalo's user avatar
  • 1,278
285 votes
3 answers
256k views

In a function that expects a list of items, how can I pass a Python list item without getting an error? my_list = ['red', 'blue', 'orange'] function_that_needs_strings('red', 'blue', 'orange') # works!...
AP257's user avatar
  • 94.7k
36 votes
6 answers
51k views

Suppose I have a given Object (a string "a", a number - let's say 0, or a list ['x','y'] ) I'd like to create list containing many copies of this object, but without using a for loop: L = ["a", "a", ...
Deniz's user avatar
  • 1,521
20 votes
3 answers
113k views

I am following a tutorial and I don't know why I got this error: <ipython-input-61-d59f7a5a07ab> in extract_featuresets(ticker) 2 tickers, df = process_data_for_labels(ticker) ...
balexander1's user avatar
4 votes
4 answers
2k views

while using the .format() with text filling, I encounter this error. what I have: tuple = ('a', 'b', 'c') text = "Hi {} hello {} ola {}" #command I tried to run text.format(tuple) The output I am ...
user2856069's user avatar
1 vote
2 answers
8k views

I have a ctypes field that is a POINTER(c_char) (it had to be, per the documentation, c_char_p didn't work for my application: https://docs.python.org/3.7/library/ctypes.html#ctypes.c_char_p) For a ...
Tommy's user avatar
  • 13.8k
3 votes
1 answer
6k views

I've already read these 2 questions before asking this one (q1 and q2) but I haven't found any satisfying answer I need to extract two columns from a 2D-array without using pandas or loadtxt, but ...
SAAD's user avatar
  • 789
2 votes
2 answers
2k views

I'm writing a Python program to play Tic Tac Toe, using Numpy arrays with "X" represented by 1 and "O" by 0. The class includes a function to place a mark on the board: import numpy as np class ...
Kurt Peek's user avatar
  • 58.5k
3 votes
1 answer
3k views

Python has the *(...) syntactic sugar. Can you do this in R? t = (2010, 10, 2, 11, 4, 0, 2, 41, 0) dt = datetime.datetime(*t[0:7]) From here: https://stackoverflow.com/a/2238361/1007926 This allows ...
Peter Becich's user avatar
  • 1,061
-1 votes
3 answers
358 views

The class( people ) requires 3 arguments called "name, middle_name and surname" and I am trying to give these arguments like down below: def argument(): name = input("name : ") ...
Dogukan's user avatar
  • 89
3 votes
1 answer
3k views

I have a pandas dataframe that I create from a list (which is created from a spark rdd) by calling: newRdd = rdd.map(lambda row: Row(row.__fields__ + ["tag"])(row + (tagScripts(row), ))).collect() ...
user avatar
0 votes
2 answers
826 views

This should be extremely simple to people who know this, but I am not one of them. I searched a lot about multi-processing, but it makes me even more confused... I need to process about 160 data ...
user3576212's user avatar
  • 3,453
1 vote
1 answer
1k views

I have been trying to build a graph for a project and I have been trying to identify newly added edges after populating it with more information. For instance below you can see its first and second ...
Swan87's user avatar
  • 421
-1 votes
5 answers
115 views

from tkinter import * height = 600 width = 600 root = Tk() canvas = Canvas(root, width = width, height = height, bg = 'red3') canvas.pack() # Code for Fries canvas.create_polygon(150, 100, 160, 250, ...
Tanmay Mane's user avatar

15 30 50 per page