Re: (easy question) Find and replace multiple items

2006-08-08 Thread Mark Peters
do this. Thanks how about: >>> import string >>> text1 = "foo bar 12 spam joe876" >>> table = string.maketrans("0123456789","uydnwkdfpx") >>> text1.translate(table) 'foo bar yd spam joepfd' Mark Peters -- http://mail.python.org/mailman/listinfo/python-list

Re: Unicode/ascii encoding nightmare

2006-11-06 Thread Mark Peters
> The string below is the encoding of the norwegian word "fødselsdag". > > >>> s = 'f\xc3\x83\xc2\xb8dselsdag' I'm not sure which encoding method you used to get the string above. Here's the result of my playing with the string in IDLE: >>> u1 = u'fødselsdag' >>> u1 u'f\xf8dselsdag' >>> s1 = u1.e

Re: Built-in Exceptions - How to Find Out Possible Errno's

2006-07-05 Thread Mark Peters
10053, 10054, 10055, 10056, 10057, 10058, 10059, 10060, 10061, 10062, 10063, 10064, 10065, 10066, 10067, 10068, 10069, 10070, 10071, 10091, 10092, 10093, 10101] >>> print errno.errorcode[10] ECHILD or >>> import os >>> print os.strerror(10) No child processes Hope this helps, Mark Peters -- http://mail.python.org/mailman/listinfo/python-list

Re: Built-in Exceptions - How to Find Out Possible Errno's

2006-07-05 Thread Mark Peters
Gregory Piñero wrote: > Thanks Mark, that does help, but what is this errno module? I mean, > does it apply to OSError or to IOError or both? My guess is that the IOError will return the underlying operating system error, but that's just a guess (and no time to dig for the answer right now) Mar

Re: Built-in Exceptions - How to Find Out Possible Errno's

2006-07-05 Thread Mark Peters
A quick test: >>> try: f = open("foo","r") except IOError, error: print errno.errorcode[error.errno] ENOENT It looks to me like your if statement should be as simple as: if error.errno == errno.ENOENT: print os.strerror(error.errno) Mark -- http://mail.python.org/mailman/

Re: Simple regex with whitespaces

2006-09-10 Thread Mark Peters
> Which of course does not work. I cannot express the fact: sentence > have 0 or 1 whitespace, separation of group have two or more > whitespaces. > > Any suggestion ? Thanks a bunch ! How about this: >>> import re >>> s = 'hello world how are you' >>> re.split(r"\s{2,}",s) [''

Re: Spliting a string on non alpha characters

2006-09-23 Thread Mark Peters
> I'm relatively new to python but I already noticed that many lines of > python code can be simplified to a oneliner by some clever coder. As > the topics says, I'm trying to split lines like this : > > 'foo bar- blah/hm.lala' -> [foo, bar, blah, hm, lala] > > 'foobbbar.. xyz' -> [foo, bbbar,

Re: python html rendering

2006-10-03 Thread Mark Peters
> Hi, Im looking for a way to display some python code > in html: with correct indentation, possibly syntax hiliting, dealing > correctly with multi-line comment, and... generating valid html code if > the python code itself deals with html (hence manipulates tag litterals. > Thanks for your help!

Re: basic python questions

2006-11-18 Thread Mark Peters
[EMAIL PROTECTED] wrote: > dict = {} As a general rule you should avoid variable names which shadow built in types (list, dict, etc.). This can cause unexpected behavior later on. Also, variable names should be more descriptive of their contents. Try word_dict or some such variant -- htt

Re: 6 Pick Bet Grouping

2006-11-28 Thread Mark Peters
> The totalizator system allows us to merge or group these four bets as > follows: > > 5 + 7 / 3 / 11 / 7 + 14 / 1 / 9 - $50 ($200 total) I'm still trying to get my head around what you're trying to do, but here's some code: ---snip- data = ["5 / 3 / 11 / 7 / 1 / 9 -

Re: TypeError: cannot concatenate 'str' and 'NoneType' objects

2006-12-20 Thread Mark Peters
> # Begin going through the loop > Townshp = Townshps.next() > while Townshps !="": > #Set the output name to be the same as input > outName = outputPath + "/" + Townshp + "land" + ".img" > Output_table = outputPath + "/" + Townshp + "table" + ".dbf" > #For each extract by Mask >

Re: regex question

2007-01-08 Thread Mark Peters
> is there any way i would be successful then, in using raw string inside > my makeRE() function? Why do you think you even need a raw string? Just build and return the string 'a|b|c' (NOTE: DON'T add the quotes to the string) -- http://mail.python.org/mailman/listinfo/python-list

Re: regex question

2007-01-08 Thread Mark Peters
> yes, i suppose you are right. i can't think of a reason i would NEED a > raw string in this situation. It looks from your code that you are trying to remove all occurances of one string from the other. a simple regex way would be to use re.sub() >>> import re >>> a = "abc" >>> b = "debcabbde"

Re: Error message if there is a space in the source directory

2007-06-02 Thread Mark Peters
> When using a source like this on line 5: > > source = [r'C:\test\test 2\\'] > > which has a space in the title, the program will not work. Try wrapping that argument in double quotes when you build the command -- http://mail.python.org/mailman/listinfo/python-list

Re: Probably simple syntax error

2007-07-01 Thread Mark Peters
> **weights_array(randomizing_counter) = small_randomized_int > > The starred line is the one getting the error message: "SyntaxError: > can't assign to function call" > > Now, I do understand what this means. I'm trying to assign to a > function instead of the value that the function shoul