ruby « string « Python Data Type Q&A

Home
Python Data Type Q&A
1.array
2.date
3.dictionary
4.Format
5.integer
6.List
7.numpy
8.regex
9.string
10.tuple
Python Data Type Q&A » string » ruby 

1. How do I emulate Python's named printf parameters in Ruby?    stackoverflow.com

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 ...

2. Ruby String Translation    stackoverflow.com

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. ...

3. Print space after each word    stackoverflow.com

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 ...

4. Objective-C string manipulation    stackoverflow.com

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 ...

5. Python string templater    stackoverflow.com

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 ...

6. Python equivalent of ruby's StringScanner?    stackoverflow.com

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.

7. Find the longest common starting substring in a set of strings    stackoverflow.com

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

8. Ruby version of to String method    stackoverflow.com

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 ...

9. Ruby string strip defined characters    stackoverflow.com

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 ...

10. String Interpolation in Python    stackoverflow.com

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 ...

11. What is the equivalent of ruby's string inspect() in python    stackoverflow.com

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" ...

12. Add custom method to string object    stackoverflow.com

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
 ...

13. difflib on Ruby    stackoverflow.com

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?

14. Techniques for categorising natural language strings?    stackoverflow.com

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 ...

15. Base36 Encode a String?    stackoverflow.com

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=

16. Is string interning really useful?    stackoverflow.com

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 ...

17. Convert Hex Chars into a String of Bits (Python or Ruby)    stackoverflow.com

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 ...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.