First  |  Prev |  Next  |  Last
Pages: 1 2 3 4 5 6 7 8 9 10 11 12
re.sub and variables
I have a function that I am attempting to call from another file. I am attempting to replace a string using re.sub with another string. The problem is that the second string is a variable. When I get the output, it shows the variable name rather than the value. Is there any way to pass a variable into a regex? I... 12 Aug 2010 22:26
Floating numbers
Hi all. Is there a way I can keep my floating point number as I typed it? For example, I want 34.52 to be 34.52 and NOT 34.5200000002. -- Bradley J. Hintze Graduate Student Duke University School of Medicine 801-712-8799 ... 13 Aug 2010 17:56
Decompressing a file retrieved by URL seems too complex
(Repost with better indentation) I'm reading a URL which is a .gz file, and decompressing it. This works, but it seems far too complex. Yet none of the "wrapping" you might expect to work actually does. You can't wrap a GzipFile around an HTTP connection, because GzipFile, reasonably enough, needs random a... 12 Aug 2010 23:31
EXOR or symmetric difference for the Counter class
I find myself needing to calculate the difference between two Counters or multisets or bags. I want those items that are unique to each bag. I know how to calculate it: b = Counter(a=1, b=2) c = Counter(a=3, b=1) diff = (b - c) + (c - b) (b - c) Counter({'b': 1}) ... 13 Aug 2010 19:03
Decompressing a file retrieved by URL seems too complex
I'm reading a URL which is a .gz file, and decompressing it. This works, but it seems far too complex. Yet none of the "wrapping" you might expect to work actually does. You can't wrap a GzipFile around an HTTP connection, because GzipFile, reasonably enough, needs random access, and tries to do "seek" and ... 12 Aug 2010 16:58
Inserting/Deleting newline(s) in very large text files
On Thursday 12 August 2010, it occurred to Dlanor Slegov to exclaim: Hi, I am dealing with very large text files (a few million lines) and would like to check and modify them according to a well defined format. The format requires ONLY ONE NEWLINE (followed by some sort of text) on top of the file an... 13 Aug 2010 01:41
inline exception handling in python
Hi! I have on a few occasions now wanted to have inline-exception handling, like the inline if/else operator. For example, The following might raise ZeroDivisionError: f = n / d So, I can look before I leap (which is okay): f = float("nan") if d == 0 else n/d; But, what I'd like to be able to writ... 13 Aug 2010 02:45
OptParse and Constant values
How do you use OptParse with constants? Example: usage = 'Usage: %prog [OPTIONS]' parser = OptionParser(usage) parser.add_option('-l','--level', action='store_const', default=LOG_INFO, help='Set the log level to inject into syslog (eithe... 12 Aug 2010 14:45
How to parse a sentence using grammars provided by nltk?
Hi, When I define my own production rules for the grammar the code below runs fine. Can anyone tell me how to use the built in grammars of nltk (if there are any)? groucho_grammar = nltk.parse_cfg(""" .... S -> NP VP .... PP -> P NP .... NP -> Det N | Det N PP | 'I' .... VP -> V NP | VP PP .... Det -> ... 12 Aug 2010 12:33
unicode string alteration
HELP!!! I need help with a unicode issue that has me stumped. I must be doing somethingĀ  wrong because I don't believe this condition would have slipped thru testing. Wherever the string u'\udbff\udc00' occurs u'\U0010fc00' or unichr(1113088) is substituted and the file loses 1 character resulting in all trailing c... 12 Aug 2010 13:39
First  |  Prev |  Next  |  Last
Pages: 1 2 3 4 5 6 7 8 9 10 11 12