| |
| |
| |
|
Page: 1 2
Comments:
<0> hey! <0> i am thinking of learning python. what greats things can be produced using python? <0> as in applications, etc. <1> Pretty much anything your little heart desires <0> nice <0> :D <0> thanks <2> what is the official channel for python discussions? <3> hmm <4> 'ello <3> helo <4> when using popen2, when you run a command, does it stay active until there's a result code, or...? <5> exoxe, let me see <5> it stay active <5> >>> x = os.popen2("nc -l -p 80")
<5> >>> x[1].read() <5> i was in read() until i got something from netcat <4> cool, thank you :) <5> :P <5> but... <5> if you only set <5> x = os.popen2("nc -l -p 80") <5> you can still run other things <4> okay, good <3> Sure, popen just launches a new process (concurrency implied), connecting its stdin/stdout/stderr to some file descriptors in the caller process <6> hi, are most python books written for use in windows -- or linux? <6> or both? <6> for networking? <7> jksd: most books are written for every platform python can possibly run on <7> there are python books related to networking, xml, etc .. <6> i c <6> eniac_: thanks <8> there is an article for using IronPython in .net <7> FMJaguar: google ! <7> and IronPython is dotnet <9> hi, how can i convert wide character string to multibyte? <9> mmm.. and vice versa <10> I don't get it. A wide character is multibyte. <9> nope <9> wide is unicode <9> mb is mb <10> Can you give an example? <9> Multibyte character sets (MBCSs) are an alternative to Unicode for supporting character sets, like Japanese and Chinese, that cannot be represented in a single byte. <9> Under MBCS, characters are encoded in either 1 or 2 bytes <3> use Unicode strings internally and decode/encode to the character set of your liking when reading/writing ? <11> howdy folks <9> just i got unicode string on input, but the program to which i should forward the string doesn't understand unicode, so i should send it mbcsed <10> sc__: So what you're asking is how to convert a unicode string to an arbitrary non-unicode encoding? <9> mm, something like that <11> if I wanted to find every instance of the piep symbol in a line with re, whats the simplest way to do it? <11> pipeCount = re.match("\|",someText) <3> sc__: u"Foo".encode ("utf-8") or whatever you prefer <11> er, pipe, not piep. <10> http://docs.python.org/lib/standard-encodings.html <10> sc__: For instance myunicodestring.encode("iso2022_jp") <3> EyePulp: if you're just counting, then "foo|bar|baz".count ("|") will do <9> hund, okie thanks, i'll check it out <11> yason: that did it nicely - now how about doing modulus math? know the symbol? <11> % ? <11> it is % <11> =) <3> EyePulp: it's % <10> Yes. And you might want to use divmod(). <11> any reason? <10> "a, b = divmod(x,y)" is the same as "a,b = x/y, x%y". <10> Only faster. <11> ah - I see. No, I'm just looking to verify an even number of pipes in a text line. <11> filtering imported data before it clogs the system - they seem to send us poorly delimited lines. I just realized a very simple way to see if all the columns are properly delimited is to test for an even number of text delimiters. <10> I usually write a simple, but strict parser, and if it ends up raising an exception, the data is per definition not well-formed. <10> I don't know if that applies to your case, though. <11> oh, we're not well formed. it's not a question of that. but it's harder to get the client to clean their export than it is just to pull the bad lines on import. <11> =) <3> is that like a negative bug countered by a positive bug?-) instead of both fixing their part.. <11> naw, my filter just loops through their data, and if something is ill-formed puts it into an exception report. But it then runs the good stuff. <10> Duct tape. ;) <12> Greetings. I want to ask something. What does that [ :-1 ] means ? ( I usually meet it in file IO )
<3> Indy: the beginning of a sequence, except for the last item <11> it also make for a fun emoticon. <12> what do you mean the "beggining" of a sequence ? <3> EyePulp: "careful coder" <3> Indy: Well, as opposed to the ending of a sequence :-) <9> hmm, doesn't seem to work <9> always get UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 0: ordinal <9> not in range(128) <13> that means you're converting a Unicode string to ASCII (perhaps implicitly) <9> on s.encode('gb2312') <13> and the Unicode string has non-ASCII characters <9> but it's chinese <13> yes <13> that won't convert to ASCII <9> sure thing it will not be in 128 range <9> hmm, but how can convert unicode string to multibyte chinese? <13> s.encode('gb2312') is probably fine; the problem is likely that you're doing something like printing the resulting Unicode string on an ASCII terminal <13> check your traceback to see where the error's coming from <9> nope <13> well that's what the error means <13> can't help you without seeing the code and exact traceback <9> it stoppes on this line <9> and i just push this string to another function <13> I told you what the error means, not sure what more I can do <13> you are trying to convert a Unicode string containing non-ASCII characters to an ASCII string, whether you think that's what you're doing or not <9> okey, just this error is on top of call stack <9> i mean the line, where it appears <13> well you haven't shown the code or the traceback <9> hmm, explain me then: my code get a chinese UTF-8 encoded string from the site, then it should push it to irc channel for example, while irc doesn't support unicode i should convert it to gb2312 encoding - it's multibyte <13> I understand what you're trying to do, there's nothing theoretically wrong with that <13> the problem is that you're ALSO converting the Unicode to ASCII at some point and that's failing <13> without seeing code and the exact traceback, it is impossible to help you further <9> http://rafb.net/paste/results/dwDsvl90.html <9> look at this <11> would this return True or False from the single statement? isEmpty = emptyFilter == lineText aternately, is there a ternary operator in Python? <13> yes, the result of the ***ignment will be false <13> no, no conditional operator (at least no substitutions you'd be happy with) <11> what if emptyFilter == lineText - would it return true? <13> sure <11> hrm <13> a == b will return True or False (presuming they're builtin types or well-behaved custom types) <9> xihr, could it happen that i get unicode string, but python things that it's ansi? <9> and that is why this error occurs <13> that's not what the error is <13> I really don't know how to explain what the error means any better than I already have <4> does urllib.urlopen timeout, or will it constantly wait until it gets an EOF (or whatever it looks for)? <4> i.e. if a webserver is pegged out and it opens a connection, will it ever return an error by default? <4> or do I need to use socket <13> I think it will eventually timeout, but it may be a long time <4> well, it ran for a few minutes.. hehe <9> the point u're talking about is _that_ point which i've shown <9> there is no other conversions <9> just got string and convert <9> nothing else <9> just u can specify timeout yourself <9> by importing socket and use setdefaulttimeout() <4> yeah, I already did.. thanks :) <6> what's python like for network programming? <6> pretty decent? <13> yes <13> sc: the point is, you're probably doing an implicit conversion and not realizing <13> without code and traceback, it is IMPOSSIBLE to help you further <13> so either use a pastebin to show us or you might as well drop it ... <13> sheesh <13> heh <13> hey I have a problem I'm trying to solve! could you help me solve it? I won't tell you what the problem is, though <13> you have to guess what the problem is and then give me a solution <11> ooh, let me go first! <1> hehe <13> it kind of surprises me how many people basically REFUSE to be helped <13> "I have problem X" "it's because of issue Y" "no it isn't" <1> *nods* <1> So that was the worst "thai" meal I have ever had
Return to
#python or Go to some related
logs:
goalll cheaters #freebsd #unixhelp #heroin update my crcked windows xp egenera fucked #solaris #computers #politics we can find another car to live in when we get to Darfur
|
|