Search Results

Search found 5 results on 1 pages for 'wpeters'.

Page 1/1 | 1 

  • Searching for simple variable names like 'c' or 'x' in Emacs.

    - by wpeters
    I often wish to search for variables that are simply called 'c' or 'count'. For example int c, count; Unfortunately when I use an incremental search for 'c' or 'count' I get a lot of unnecessary hits like the 'c' in 'choice', or the 'count' in 'wordcount' which do not interest me. I know Emacs can do i-searches with regular expressions but I don't know the correct regular expression needed to match just 'c' and 'count'. These words are often surrounded by any number of white spaces. Anyone know the regex I can use to narrow my search?

    Read the article

  • Copy and pasting code into the Python interpreter

    - by wpeters
    There is a snippet of code that I would like to copy and paste into my Python interpreter. Unfortunately due to Python's sensitivity to whitespace it is not straightforward to copy and paste it a way that makes sense. (I think the whitespace gets mangled) Is there a better way? Maybe I can load the snippet from a file. This is just an small example but if there is a lot of code I would like to avoid typing everything from the definition of the function or copy and pasting line by line. class bcolors: HEADER = '\033[95m' OKBLUE = '\033[94m' OKGREEN = '\033[92m' WARNING = '\033[93m' FAIL = '\033[91m' ENDC = '\033[0m' def disable(self): self.HEADER = '' # I think stuff gets mangled because of the extra level of indentation self.OKBLUE = '' self.OKGREEN = '' self.WARNING = '' self.FAIL = '' self.ENDC = ''

    Read the article

  • Python: Picking an element without replacement

    - by wpeters
    I would like to slice random letters from a string. Given s="howdy" I would like to pick elements from 's' without replacement but keep the index number. For example >>> random.sample(s,len(s)) ['w', 'h', 'o', 'd', 'y'] is close to what I want, but I would actually prefer something like [('w',2), ('h',0), ('o',1), ('d',3), ('y',4)] with letter-index pairs. This is important because the same letter appears in 's' more than once. ie) "letter" where 't' appears twice but I need to distinguish the first 't' from the 'second'. Ideally I actually only need to pick letters as I need them but scrambling and calculating all the letters in a list (as shown above) is ok.

    Read the article

1