News for hackers. Stuff that matters.
Re:A DSL in 5 Languages: Ruby, Python, PHP, C#, Java by postfuturist on Tuesday August 03, 2010 @01:20PM (#1571906)
Python tip: instead of making the user contstruct a list literal, just use (star)args in the function definition. Python will automatically pack up any number of positional arguments into a list for you!

    def search(*args) : ... # args is a sequence

    search(this, that, the_other_thing)
Edit: found the HN FAQ entry on formatting comments, finally.
Re:A DSL in 5 Languages: Ruby, Python, PHP, C#, Java by CodeMage on Tuesday August 03, 2010 @02:08PM (#1572072)
Just to clarify for anyone who isn't familiar with Python: it's asterisk followed by "args". The problem here is that HN comments system interprets asterisk as italic formatting ;)

Edit: Parent comment fixed by postfuturist.

Re:A DSL in 5 Languages: Ruby, Python, PHP, C#, Java by koenigdavidmj on Wednesday August 04, 2010 @02:12AM (#1573798)
Python 3 lets you have named keyword arguments too. Anything after the star-args is a named keyword argument, and you can have a simple star if you do not want the argument list:

    def search(foo, bar, *, baz):
Then, foo and bar would be named arguments, and baz would need to be passed by keyword.
Re:A DSL in 5 Languages: Ruby, Python, PHP, C#, Java by troels on Tuesday August 03, 2010 @02:33PM (#1572164)
> Edit: found the HN FAQ entry on formatting comments, finally.

Really? Where?

Re:A DSL in 5 Languages: Ruby, Python, PHP, C#, Java by justinl on Tuesday August 03, 2010 @02:38PM (#1572181)
Re:A DSL in 5 Languages: Ruby, Python, PHP, C#, Java by troels on Tuesday August 03, 2010 @02:41PM (#1572189)
Swell! Would you happen to know how to format quotations?
Re:A DSL in 5 Languages: Ruby, Python, PHP, C#, Java by Scriptor on Wednesday August 04, 2010 @02:57AM (#1573858)
As in the "Ask HN" type posts? You can simply enter something into the text field when making a submission. It will then ignore the URL field.
Re:A DSL in 5 Languages: Ruby, Python, PHP, C#, Java by drewolson on Wednesday August 04, 2010 @02:32PM (#1575353)
This is a great point and is something we're planning on adding in an upcoming release of our Python library.
Re:A DSL in 5 Languages: Ruby, Python, PHP, C#, Java by d0mine on Tuesday August 03, 2010 @02:13PM (#1572090)

  def search(*args): ...
Re:A DSL in 5 Languages: Ruby, Python, PHP, C#, Java by andybak on Tuesday August 03, 2010 @01:50PM (#1572006)
and you can be extra nice and accept either a list or positional arguments...