ruby

Why are Python and Ruby so slow, while Lisp implementations are fast?

Why are Python and Ruby so slow, while Lisp implementations are fast? Question: I find that simple things like function calls and loops, and even just loops incrementing a counter take far more time in Python and Ruby than in Chicken Scheme, Racket, or SBCL. Why is this so? I often hear people say that …

Total answers: 4

Integer division by negative number

Integer division by negative number Question: What should integer division -1 / 5 return? I am totally confused by this behaviour. I think mathematically it should be 0, but python and ruby are returning -1. Why are different languages behaving differently here? Please someone explain. Thanks. | Language | Code | Result | |———–+—————-+——–| | …

Total answers: 2

Ruby equivalent for Python's "try"?

Ruby equivalent for Python's "try"? Question: I’m trying to convert some Python code into Ruby. Is there an equivalent in Ruby to the try statement in Python? Asked By: thatonegirlo || Source Answers: begin some_code rescue handle_error ensure this_code_is_always_executed end Details: http://crodrigues.com/try-catch-finally-equivalent-in-ruby/ Answered By: zengr Use this as an example: begin # "try" block puts …

Total answers: 3

The simplest possible reverse proxy

The simplest possible reverse proxy Question: I’m looking for a way to simply set up a proxy locally that connects to a remote site. I don’t want to install anything in the system proper. If I could call it with a single command-line call rather than mucking with even a single config file, that would …

Total answers: 1

How to integrate a standalone Python script into a Rails application?

How to integrate a standalone Python script into a Rails application? Question: I’ve got a program that has a small file structure going on and is then ran using python do_work.py foo bar I want my Rails users to press a button and have this happen for them, with the result either uploaded somewhere or …

Total answers: 5

Can't start foreman in Heroku Tutorial using Python

Can't start foreman in Heroku Tutorial using Python Question: I have been attempting to complete this tutorial, but have run into a problem with the foreman start line. I am using a windows 7, 64 bit machine and am attempting to do this in the git bash terminal provided by the Heroku Toolbelt. When I …

Total answers: 4

Simple file server to serve current directory

Simple file server to serve current directory Question: I’m looking for a dead simple bin that I can launch up in the shell and have it serve the current directory (preferably not ..), with maybe a -p for specifying port. As it should be a development server, it should by default allow connections from localhost …

Total answers: 4

Do Python regular expressions have an equivalent to Ruby's atomic grouping?

Do Python regular expressions have an equivalent to Ruby's atomic grouping? Question: Ruby’s regular expressions have a feature called atomic grouping (?>regexp), described here, is there any equivalent in Python’s re module? Asked By: Alex Gaynor || Source Answers: from http://docs.python.org/2/library/re.html#regular-expression-syntax (?P<name>…) Similar to regular parentheses, but the substring matched by the group is accessible …

Total answers: 5

benchmarks: does python have a faster way of walking a network folder?

benchmarks: does python have a faster way of walking a network folder? Question: I need to walk through a folder with approximately ten thousand files. My old vbscript is very slow in handling this. Since I’ve started using Ruby and Python since then, I made a benchmark between the three scripting languages to see which …

Total answers: 2

Recompile MacPort's version of MacVim with Python, Ruby & Perl

Recompile MacPort's version of MacVim with Python, Ruby & Perl Question: Linux guy making the switch to Mac (10.8). Because I’m lazy… I used MacPorts to install MacVim. It seemed to install without error. I just need python, ruby and perl support in mvim. $ /opt/local/bin/mvim –version | egrep ‘patches|python|ruby|perl’ Included patches: 1-244, 246-646 +multi_lang …

Total answers: 2