Tagged Questions
5
votes
8answers
3k views
Python conditional assignment operator
Does it exist a python equivalent to the ruby ||= operator (set the variable if the variable is not set) ?
Example in Ruby :
=====
variable_not_set ||= 'bla bla'
variable_not_set == 'bla bla'
...
2
votes
5answers
427 views
How to do conditional character replacement within a string
I have a unicode string in Python and basically need to go through, character by character and replace certain ones based on a list of rules. One such rule is that a is changed to ö if a is after n. ...
3
votes
1answer
681 views
Makefile conditional with automake/autoconf
can anybody tell me if there is a way to insert a conditional block to Makefile.am so that it will be passed further to a Makfile created by autotools?
Here is an example:
ifeq "$(SOMEVAR)" ""
...
3
votes
2answers
451 views
Does Ruby support conditional regular expressions
Just a language feature question, I know there's plenty of ways to do this outside of regexes (or with multiple regexes).
Does ruby support conditional regular expressions? Basically, an ...
2
votes
3answers
80 views
Conditionally merge lists
Say I have two lists
[16, 0, 0, ';', 17, 0, 2, ';', 0, 2, 1, ';']
[-1, 0, ';', 0, -2, ';', -2, -1, ';']
Is there a simpler way to merge these list elements conditionally on meeting the ';' ...
0
votes
3answers
66 views
How to find whether a value is not contains in a List or Dist in Python
I can use dist.__ contains__ (value) to know whether a value is included or not in a List or Dist.But I need to return True if a value is not included in dist or list.
I tried If !dist._contains ...