News for hackers. Stuff that matters.
Re:What Pythonistas Think of Ruby by arockwell on Wednesday February 03, 2010 @10:39AM (#1097921)
Python doesn't have multiline lambdas, so there is no way to create an api similar to rake's:

  task :name do |t|
   # do stuff
  end
I'm not sure what's the closest equivalent syntax you could create in python.
Re:What Pythonistas Think of Ruby by tsuraan on Wednesday February 03, 2010 @10:43AM (#1097930)
Python's answer to blocks tends to be the with statement, so your example would look like

  with task('name') as t:
    # do stuff with t
It's not really the same; the task object doesn't have control over whether the block is actually run, but sometimes it is sufficient.
Re:What Pythonistas Think of Ruby by fuzzyman on Wednesday February 03, 2010 @11:01AM (#1097985)
You could almost certainly achieve that with the implementation of blocks provided by this package:

http://pypi.python.org/pypi/withhacks/

Re:What Pythonistas Think of Ruby by tsuraan on Wednesday February 03, 2010 @11:27AM (#1098062)
Wow, I've never seen that before. I'm also not sure I'd say a solution that uses bytecode rewriting is really working within the language, but that's a pretty interesting package anyhow.
Re:What Pythonistas Think of Ruby by fuzzyman on Wednesday February 03, 2010 @12:10PM (#1098209)
Well, normally I would agree - but if its entirely abstracted away in a library (and the library is well written) then it might sort-of-kind-of-maybe be ok.

Python itself does varying degrees of bytecode optimisation depending on which version you're using.

Re:What Pythonistas Think of Ruby by bad_user on Wednesday February 03, 2010 @11:16AM (#1098038)
that's cool, thanks ... I was wondering about that
Re:What Pythonistas Think of Ruby by tghw on Wednesday February 03, 2010 @11:33AM (#1098079)
Why do you need lambdas to do this? Why wouldn't an inline function work?
Re:What Pythonistas Think of Ruby by grandalf on Wednesday February 03, 2010 @02:42PM (#1098628)
This is correct, it would work. People who harp on this probably don't actually use Python for anything.
Re:What Pythonistas Think of Ruby by viraptor on Wednesday February 03, 2010 @11:07AM (#1098007)
Not sure what this snippet does, but if it creates a block that is registered as a task named "name", then you can do the same with decorators:

    def task(f):
       register_task(f.__name__, f)
       return f
    
    @task
    def name(t)
       .....
or similar.
Re:What Pythonistas Think of Ruby by algorias on Wednesday February 03, 2010 @11:51AM (#1098150)
Exactly. I fail to understand why people are so dismissive of languages/approaches that do things slightly differently and don't implement equivalent things in the exact same way. What's so special about the rake syntax?
Re:What Pythonistas Think of Ruby by jashkenas on Wednesday February 03, 2010 @11:57AM (#1098171)
Another CoffeeScript snippet, if you're working with Node.js or the like:

    task 'name', (t) ->
      # do multiline stuff