1
vote
1answer
197 views

Populate snippets from a list of values in Sublime Text 2

I have a list of values I'd like to use as an input for snippets I have created a basic snippet which has placeholder variables I have a list of values as Python list (can be a list of strings, or ...
1
vote
3answers
89 views

Understanding the python code snippet

Please help me understand the following code snippet :- def any(l): "whether any number is known from list l" s = set(list(l)[0]) for x in l: s.intersection_update(set(x)) return ...
5
votes
2answers
182 views

Verify my interpretation of this python code snippet is correct

I'm analyzing a set of python scripts and came across this snippet. I'm not sure if my interpretation is correct, since I haven't come across any similar C or Java code and I don't know Python. for ...
4
votes
4answers
444 views

Python Code Shortening

I was trying to solve this problem here :- https://www.spoj.pl/problems/PHIVAL/ The questions asks you to output as many decimal digits of the golden ratio (1+sqrt(5))/2 as possible and also try to ...
11
votes
2answers
231 views

Is there a script to manage/search python snippets which understands python code like nullege.com?

I have a folder full of python snippets and want to search it in a more intelligent way than grep. Is there already a script which parses python snippets to AST and lets you search it, like ...
3
votes
3answers
277 views

Intentionally Buggy Code (Python)

This is a strange request but I'm looking for buggy Python code. I want to learn more about bugs and debuggers and I need some buggy code to work with. Unfortunately, all the code I've written is ...
0
votes
1answer
89 views

Personal archive tool, looking for suggestions on improving the code

i've written a tool in python where you enter a title, content, then tags, and the entry is then saved in a pickle file. it was mainly designed for copy-paste functionality (you spot a piece of code ...
3
votes
1answer
138 views

Convert a Python snippet to PHP?

Can anyone translate my small Python snippet to PHP? I'm not a familiar with both languages. :( matches = re.compile("\"cap\":\"(.*?)\"") totalrewards = re.findall(matches, contents) print ...
27
votes
8answers
7k views

Reusable library to get human readable version of file size?

There are various snippets on the web that would give you a function to return human readable size from bytes size: >>> human_readable(2048) '2 bytes' >>> But is there a Python ...
29
votes
22answers
7k views

Short (and useful) python snippets [closed]

In spirit of the existing "what's your most useful C/C++ snippet" - thread: Do you guys have short, monofunctional Python snippets that you use (often) and would like to share with the StackOverlow ...
3
votes
7answers
2k views

Short Python Code to say “Pick the lower value”?

What I mean is, I'm looking for really short code that returns the lower value. for example: a=[1,2,3,4,5,6,7,8,9,10] b=[1,2,3,4,5,6,7,8] len(a) = 10 len(b) = 8 if (fill-this-in): ...