« first day (719 days earlier)      last day (1469 days later) » 

4:24 AM
0
Q: Noob Python API Call

user97315I will preface this with the disclaimer that I am a total programming noob. I'm just trying to write a basic Python script that will make an API call using a key and a "secret" (HMAC-SHA512). In my beginner, rudimentary code I'm just trying to figure out how to authenticate using the key/secret. ...

 
 
3 hours later…
7:33 AM
0
Q: caching decorator

EugeneI came up with a caching decorator for pure functions. Is it ok? Could it be better/simpler/faster? def cached(f): def _(*args): if args in _._cache: return _._cache[args] else: result = f(*args) _._cache[args] = result ...

0
Q: multirange iterator

EugeneI'm doing some boring math with lot of sums over lot of variables. So, instead of nesting for loops I have decided to use something like this: def combo(*limits): if len(limits) == 1: for l in range(limits[0]): yield [l] else: for l in range(limits[0]): ...

 
 
3 hours later…
10:20 AM
0
Q: Optimise code to search words in a string

Abhishek BhatiaI'm writing a program to split the words contained in an hashtag. For example I want to split the hashtags: #Whatthehello #goback into: What the hello go back import re,pdb words = [] # corncob_lowercase.txt contains a list of dictionary words with open('corncob_lowercase.txt', 'rb') as ...

 
11:09 AM
0
Q: Rock-Paper-Scissors Game - Learning purposes

mschlindweinJust want your opinions about my code. How could I improve it? Is there a better method to do it? I'm learning python and I appreciate your opinions, thanks. from sys import exit from random import randint print "Welcome to the PIN Game 1!" print "Tell me your name" user = raw_input('> ') #as...

 
11:52 AM
0
Q: Get Next Valid Number Problem (Python)

BryanDunkleyI recently came across a email bot that would give you random problems to solve. Here is the problem. Please write a function in python which receives a natural decimal N-digit number (1 to 15 digits long) as an input and returns the minimal next N-digit number with the same sum of digits or...

 
 
1 hour later…
1:14 PM
-2
Q: Noob help with Python API call

user97315I'm trying to write a simple script to validate that I am making an API call correctly, and then I plan to build out a more complex program from there. The error response I am receiving is: {"error":"Invalid API key\/secret pair."} The API documentation for what I'm working on can be found at:...

 
 
1 hour later…
2:20 PM
-2
Q: Reversing a Word

Cubestormer IvI am a complete beginner. Here's code I wrote to print a word backwards. It just prints the last letter thrice def rev(string): reversed_string = '' for letter in (len(string)-1,-1.-1): reversed_string = reversed_string + string[letter] print reversed_string def main(): s...

 
2:53 PM
0
Q: Is it a common pattern in Python to have instance variables assigned in a constructor start with an underscore?

Jules MazurI recently started using UtilSnips, a Vim plugin allowing for a certain level of automation while coding by using template-like code snippets for common code fragments (class and function definitions, for example). When using a popular snippet pack with Python, I noticed that snippets used when ...

 
 
6 hours later…
8:49 PM
0
Q: Django session control - What to know

Lucas RezendeI am new to programming and I choose Python/Django. I'm thinking about creating a medical appointment software as a learning project and before starting I was thinking about some conceptual issues I will face, but I actually don't what I must know and thus I don't know what/how to ask. Let's im...

 

« first day (719 days earlier)      last day (1469 days later) »