In Python, you can do this:
print "Hi! I'm %(name)s, and I'm %(age)d years old." % ({"name":"Brian","age":30})
What's the closest, simplest Ruby idiom to replicate this behavior? (No monkeypatching the String ... |
I want to find the successor of each element in my encoded string. For example K->M A->C etc.
string.each_char do |ch|
dummy_string<< ch.succ.succ
end
However this method translates y->aa. ... |
what is an easy/effective way to combine an array of words together with a space in between, but no space before or after?
I suppose it is possible to remove the space ... |
Currently I am working on a piece of software, which is currently written 100% in Objective-C using the iPhone 3.0 SDK.
I have come to a cross roads where I need to ... |
I'm using this REST web service, which returns various templated strings as urls, for example:
"http://api.app.com/{foo}"
In Ruby, I can then use
url = Addressable::Template.new("http://api.app.com/{foo}").expand('foo' => 'bar')
to get
"http://api.app.com/bar"
Is there any way to do ... |
Is there a python class equivalent to ruby's StringScanner class? I Could hack something together, but i don't want to reinvent the wheel if this already exists.
|
This is a challenge to come up with the most elegant JavaScript, Ruby or other solution to a relatively trivial problem.
This problem is a more specific case of the |
|
This question is about formatting ruby's strings.
In Python, built-in data structures have a built-in to-string method, and so when a variable is printed, the string is conveniently formatted to be reflective ... |
in Python, we can e.g.
"[foo ]".strip(" []") # -> "foo"
how do we do this in Ruby? string strip method is stripping only whitespace ..
UPDATE
stripping is not deleting! : )
"[ foo ...
|
I'm a novice coder and have a (hopefully) simple question.
Is there a Python equivalent to Ruby's string interpolation?
Ruby example:
name = "Spongebob Squarepants"
puts "Who lives in a Pineapple under the sea? \n#{name}."
Whilst ... |
I apologize up front for the dumbness of this question, but I can't figure it out and its driving me crazy.
In ruby I can do:
irb(main):001:0> s = "\t\t\n"
=> "\t\t\n" ...
|
Possible Duplicate:
Can I add custom methods/attributes to built-in Python types?
In Ruby you can override any built-in object class with custom method, like this:
class String
...
|
Is there a library similar to Python's difflib on Ruby?
Particularly, I need one that has a method similar to difflib.get_close_matches. Any recommendations?
|
What is available in terms of libraries / open source software for processing and categorising natural language? I've got a database full of strings which are user descriptions of a particular ... |
I've been looking online, but can't find a solution to this. In Python, Ruby, or Java, how can I base 36 encode the following string: nOrG9Eh0uyeilM8Nnu5pTywj3935kW+5=
|
I was having a conversation about strings and various languages a while back, and the topic of string interning came up. Apparently Java and the .NET framework do ... |
I have a microcontroller that returns a status response like this from an HTTP API:
<response><BS>026219AAF80F440206025019AAF816A944274480</BS></response>
The last two characters, in this case 80, represent a hexadecimal value that I need to convert ... |