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
> 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
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
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
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/
> 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)
[''
> 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,
> 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!
[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
> 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 -
> # 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
>
> 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
> 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"
> 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
> **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
15 matches
Mail list logo