Last month I mentioned a utility library inspired by Underscore.js for Swift providing numerous helps for working with collections.
Here’s an open source library based on Python’s standard library providing numerous helpers for working with strings, numbers, and more called Pythonic.swift.
Here’s an example from the readme showing off some of the features of Pythonic.swift:
if re.search("^foo", "foobar") {
println(["foo", "bar", "zonk"].index("foo")) // 0
println(["foo", "bar", "zonk"].count("bar")) // 1
println(["foo", "bar", "zonk"].count("zoo")) // 0
}
if any(["foo", "bar", "zonk"]) {
println(chr(ord("a"))) // a
}
var strings = ["foo", "bar"]
println(":".join(strings)) // foo:bar
if strings {
println(strings[0]) // foo
}
if len(strings) == 2 {
println(strings[1].upper()) // BAR
println(strings[1].split("a")) // ["b", "r"]
}
var greeting = " hello pythonista "
if greeting.strip().startswith("hello") {
println(greeting.strip().title()) // Hello Pythonista
}
var numbers = [1, 2, 3, 4, 5]
println(sum(numbers)) // 15
println(max(numbers)) // 5
You can find Pythonic.swift on Github here.
A nice python inspired addition to Swift.
- Open Source Functional Programming Toolbelt For Swift Inspired By The Underscore.js Library
- An Rspec Inspired Behavior Driven Testing Framework For Swift
- An Extensive Open Source iOS Library For Working With The Twitter API Written In Swift
- An Open Source Swift Library For Easily Creating Much More Useful Logging Statements
- Open Source Tool Adding A Number Of Extra Useful Commands To The Debugging Console
Original article: Extensive Swift Utility Library Inspired By Python’s Standard Library
©2014 iOS App Dev Libraries, Controls, Tutorials, Examples and Tools. All Rights Reserved.




