Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 1135

Python is an interpreted, general-purpose high-level programming language whose design philosophy emphasizes code readability. Use the python tag for all Python related questions. If you believe your question may be even more specific, you can include a version specific tag such as python-3.x.

5 votes

How can I improve my A* algorithm in Python?

a raw_input() or something so you can easily read it - I would suggest a debugger but that's a crutch you can do without at this level) (spoiler) Due to negative indices not raising IndexError's in Python
Thomas's user avatar
  • 357
5 votes
1 answer
358 views

Sparse Bitarray Class in Python (or rather frequently having contiguous elements with the sa...

Sparse is probably the wrong word - this is for encoding arrays of booleans where contiguous values tend to be the same. It'd be great to know a proper name for this data structure so I could read abo …
Thomas's user avatar
  • 357
3 votes

is_palindrome function that ignores whitespace and punctuation

I think we could build up the new string in a nicer way: from string import ascii_letters def is_palindrome(s): new = ''.join(c.lower() for c in s if c in ascii_letters) return new[::-1] == …
Thomas's user avatar
  • 357
5 votes

Converting Roman numerals to integers and vice versa

This uses a Python feature called 'tuple unpacking': for (rom, num) in table: print rom print num Concatenating strings over and over is slower than appending to a list - but that this is something … I personally find continueyes to be an awkward variable name - you could use continue_, following a convention of adding a trailing underscore to avoid a Python keyword. …
Thomas's user avatar
  • 357
1 vote
4 answers
464 views

Echoing back input in uppercase over a socket with Hy, a Python Lisp dialect

I think I'd like to learn Clojure eventually, but at the moment am having fun with Hy, a "dialect of Lisp that's embedded in Python." … Any guidelines for dealing with Python APIs in a lispy way, something that apparently happens a lot in Clojure with Java? …
Thomas's user avatar
  • 357
1 vote

Echoing back input in uppercase over a socket with Hy, a Python Lisp dialect

algernon in freenode/#hy says: Looks lispy enough to me, except for the __getitem__ line. ...and the closing braces. I'm think this is fix for the braces and using get instead of __getitem_ …
Thomas's user avatar
  • 357
1 vote

Echoing back input in uppercase over a socket with Hy, a Python Lisp dialect

As suggested by the Hy docs, I'm trying the threading macro here: (.send c (.upper (.recv c 10000))) becomes (-> (.recv c 10000) (.upper) (c.send)) I'm not sure I like it.
Thomas's user avatar
  • 357