how to reference a YAML “setting” from elsewhere in the same YAML file?

I have the following YAML: paths: patha: /path/to/root/a pathb: /path/to/root/b pathc: /path/to/root/c How can I “normalise” this, by removing /path/to/root/ from the three paths, and have it as its own setting, something like: paths: root: /path/to/root/ patha: *root* + a pathb: *root* + b pathc: *root* + c Obviously that’s invalid, I just made it … Read more

How do I pass multiple parameters in Objective-C?

I have read several of the post about Objective-C method syntax but I guess I don’t understand multiple names for a method. I’m trying to create a method called getBusStops with NSString and NSTimeInterval parameters and a return type of NSMutableArray. This is how I have constructed the method but it obviously gets errors at … Read more

Using multiple arguments for string formatting in Python (e.g., ‘%s … %s’)

I have a string that looks like ‘%s in %s’ and I want to know how to seperate the arguments so that they are two different %s. My mind coming from Java came up with this: ‘%s in %s’ % unicode(self.author), unicode(self.publication) But this doesn’t work so how does it look in Python? 8 Answers … Read more

What is `1..__truediv__` ? Does Python have a .. (“dot dot”) notation syntax?

I recently came across a syntax I never seen before when I learned python nor in most tutorials, the .. notation, it looks something like this: f = 1..__truediv__ # or 1..__div__ for python 2 print(f(8)) # prints 0.125 I figured it was exactly the same as (except it’s longer, of course): f = lambda … Read more

Putting an if-elif-else statement on one line?

I have read the links below, but it doesn’t address my question. Does Python have a ternary conditional operator? (the question is about condensing if-else statement to one line) Is there an easier way of writing an if-elif-else statement so it fits on one line? For example, if expression1: statement1 elif expression2: statement2 else: statement3 … Read more