Re: pythonize this!
"Lie Ryan" wrote in message news:4c18a...@dnews.tpgi.com.au... > Probably bending the rules a little bit: > sum(x**2 - 8*x - 20 for x in range(1, 2010, 5)) > 536926141 Or, letting Python do the algera for you: >>> from sympy import var, sum >>> dummy = var('j k') >>> k = (5 * j) + 1 >>> t = (k)**2 + (k + 1)**2 + (k + 2)**2 - (k + 3)**2 - (k + 4)**2 >>> sum(t, (j, 0, 401)) 536926141 -- http://mail.python.org/mailman/listinfo/python-list
Re: Drawing Multigraphs
"geremy condra" wrote in message news:mailman.825.1275414239.32709.python-l...@python.org... > On Tue, Jun 1, 2010 at 9:42 AM, Nima wrote: >> Hi there, >> Is it possible to draw an (undirected) multigraph using a python library? >> I need to write a program that finds an Eulerian circuit in a graph >> (which might obviously be a multigraph). As the output of the program, >> I should draw the graph and print out the solution. > > We use Dot in Graphine, and it works well. It's also very easy to > output to. NetworkX apparently has dot bindings built-in, although I've not used it, so I think one should just be able to export to it. -- http://mail.python.org/mailman/listinfo/python-list
Re: subtraction is giving me a syntax error
"Joel Pendery" wrote in message news:56597268-3472-4fd9-a829-6d9cf51cf...@e7g2000yqf.googlegroups.com... >> y_diff = y_diff-H > > Syntaxerror: Non-ASCII character '\x96' in file on line 70, but no > encoding declared. That's likely an en-dash, not a minus sign. -- http://mail.python.org/mailman/listinfo/python-list
Re: String is ASCII or UTF-8?
"C. Benson Manica" wrote in message news:98375575-1071-46af-8ebc-f3c817b47...@q23g2000yqd.googlegroups.com... >The strings come from the same place, i.e. they're exclusively > normal ASCII characters. In this case then converting them to/from UTF-8 is a no-op, so it makes no difference at all. -- http://mail.python.org/mailman/listinfo/python-list
Re: Docstrings considered too complicated
"Ed Keith" wrote in message news:mailman.215.1267639293.23598.python-l...@python.org... > That has always puzzled me to. ETX and EOT were well established, > why no use one of them? I'd love to know what they were thinking. It goes back to ancient PDP operating systems, so may well predate Unix, depending which exact OS was the first to use it. -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there a better way to do this?
"Matt Mitchell" wrote in message news:mailman.65.1267464765.23598.python-l...@python.org... > My initial idea was to make a list of all the different > ways "project" has been capitalized in my repo and try each one. The > code looks like this: I would use pysvn.Client.list to get a list of files at whatever directory level you require. Then you can do a case insensitive compare or whatever else. -- http://mail.python.org/mailman/listinfo/python-list
Re: Docstrings considered too complicated
"Andreas Waldenburger" wrote in message news:20100226173907.55676...@geekmail.invalid... >> Reminiscent of: >> >> mov AX,BX ; Move the contents of BX into AX >> > Well, there might be some confusion there as to what gets moved where, > wouldn't you say? Depends on what assembler you're used to. I certainly find having the operands that way round confusing. -- http://mail.python.org/mailman/listinfo/python-list
Re: basic Class in Python
"bartc" wrote in message news:xl_4n.28001$ym4.5...@text.news.virginmedia.com... > Any particular reason why two, and not one (or three)? In some fonts it's > difficult to > tell how many as they run together. It follows the C convention for reserved identifers. -- http://mail.python.org/mailman/listinfo/python-list
Re: Raw string substitution problem
"Alan G Isaac" wrote in message news:qemdnrut0jvj1lfwnz2dnuvz_vqdn...@rcn.net... > Naturally enough. So I think the right answer is: > > 1. this is a documentation bug (i.e., the documentation >fails to specify unexpected behavior for raw strings), or > 2. this is a bug (i.e., raw strings are not handled correctly >when used as replacements) There is no raw string. A raw string is not a distinct type from an ordinary string in the same way byte strings and Unicode strings are. It is a merely a notation for constants, like writing integers in hexadecimal. >>> (r'\n', u'a', 0x16) ('\\n', u'a', 22) -- http://mail.python.org/mailman/listinfo/python-list
Re: Logic operators with "in" statement
"Mr.SpOOn" wrote in message news:mailman.492.1258380560.2873.python-l...@python.org... > In [13]: ('b3' and '5') in l or ('3' and 'b3') in l > Out[13]: True For anything more than the simplest cases, you might want use sets. That might be the correct data type from the start, depending on whether the ordering is important anywhere. -- http://mail.python.org/mailman/listinfo/python-list
Re: Passing values from html to python
"Albert Hopkins" wrote in message news:mailman.1851.1256208328.2807.python-l...@python.org... > On Thu, 2009-10-22 at 10:44 +0200, Ahmed Barakat wrote: >> Hi guys, >> >> I am playing with google app engine, I have this situation: >> >> I have a text box in an html page, I want to get the value in it and >> pass it to the python script to process it > > You need a web server: something that speaks the HTTP protocol. Google's servers will probably be able to handle his requirements for the time being ;) It's going in at the deep end a bit, going straight to App Engine but webapp or cgi is what you need. Or we could discuss what the best Python web framework is again... http://code.google.com/appengine/docs/python/runtime.html#Requests_and_CGI -- http://mail.python.org/mailman/listinfo/python-list
Re: struct curiosity
"pjcoup" wrote in message news:b1537079-6e3a-43e1-814b-7ccf185fb...@v15g2000prn.googlegroups.com... > I would have expected calcsize('BB') to be either 10 or 12 > (padding), but 11? Is there a simple explanation of what is going > on here? The purpose of the padding is to align the words 'naturally'. That is, when reading two bytes, to start at an even number. B X B h1 h1 h1h1 h2 h2 h2h2 h3 h3 h3h3 h4 h4 h4h4 B B Y The padding at X lines up h1-h4. There isn't any point putting padding at Y. -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there a way to specify a superclass at runtime?
"Chris Colbert" wrote in message news:mailman.868.1254748945.2807.python-l...@python.org... > I am trying to abstract this machinery in a single class called > Controller which I want to inherit from either SimController or > RealController based on whether a module level flag SIMULATION is set > to True or False. At first sight, that seems kind of odd. Wouldn't it be simpler to have SimController and RealController inherit from Controller? -- http://mail.python.org/mailman/listinfo/python-list
Re: Pyserial non-standard baud rate
"oyinbo55" wrote in message news:2feb36fc-106c-4d7c-a697-db59971dc...@a7g2000yqo.googlegroups.com... > Using the standard 19200 baud results in gobbledegook from the > multimeter. You aren't going to notice a 0.1% clock skew within 1 byte. Forget about the difference between 19200 and 19230. If you have a scope handy, see what the output waveform looks like, and check the timings. If not play around with the rates, parity etc., until you find something that works. -- http://mail.python.org/mailman/listinfo/python-list
Re: obscure problem using elementtree to make xhtml website
"Stefan Behnel" wrote in message news:4aa01462$0$31340$9b4e6...@newsspool4.arcor-online.net... >>Not a bug in IE (this time), which is correctly parsing the file as html. > > ... which is obviously not the correct thing to do when it's XHTML. It isn't though; it's HTML with a XHTML DOCTYPE, and the compatibility rules in Appendix C of the XHTML recommendation apply. http://www.w3.org/TR/xhtml1/#C_3 -- http://mail.python.org/mailman/listinfo/python-list
Re: Code formatting question: conditional expression
"John Posner" wrote in message news:mailman.26.1250604346.2854.python-l...@python.org... > if total > P.BASE: > excessblk = Block(total - P.BASE, srccol, carry_button_suppress=True) > else: > excessblk = None I wonder if it is appropriate to replace the None sentinel with one that is an instance of Block() e.g. size = total - P.BASE excessblk = Block(size, srccol, carry_button_suppress=True, empty_block=(size <= 0) ) -- http://mail.python.org/mailman/listinfo/python-list
Re: Character encoding & the copyright symbol
"Robert Dailey" wrote in message news:f64f9830-c416-41b1-a510-c1e486271...@g19g2000vbi.googlegroups.com... > As you can see, I am trying to load the file with encoding 'cp1252' > which, according to the python 3.1 docs, translates to windows-1252. I > also tried 'latin_1', which translates to ISO-8859-1, but this did not > work either. Am I doing something else wrong? Probably it's just the debugging print that has a problem, and if you opened an output file with an encoding specified it would be fine. When you get a UnicodeEncodingError, it's conversion _from_ Unicode that has failed. -- http://mail.python.org/mailman/listinfo/python-list
Re: Character encoding & the copyright symbol
"Robert Dailey" wrote in message news:29ab0981-b95d-4435-91bd-a7a520419...@b15g2000yqd.googlegroups.com... > UnicodeEncodeError: 'charmap' codec can't encode character '\xa9' in > position 1650: character maps to > > The file is defined as ASCII. That's the problem: ASCII is a seven bit code. What you have is actually ISO-8859-1 (or possibly Windows-1252). The different ISO-8859-n variants assign various characters to to '\xa9'. Rather than being Western-European centric and assuming ISO-8859-1 by default, Python throws an error when you stray outside of strict ASCII. -- http://mail.python.org/mailman/listinfo/python-list
Re: strange python scripting error
"Diez B. Roggisch" wrote in message news:7crfjof29e4g...@mid.uni-berlin.de... > They have different line-ending-conventions. Not sure if and why that makes > a difference. Depends on your setup. Shells can be a bit dumb about it, so it will likely break simple cgi-style hosting. -bash: ./python.py: /usr/bin/python^M: bad interpreter: -- http://mail.python.org/mailman/listinfo/python-list
Re: gett error message: "TypeError: 'int' object is not callable"
"Tom Kermode" wrote in message news:mailman.2903.1247155607.8015.python-l...@python.org... > Do you know a good way to avoid running into this problem? It > makes sense to suggest not calling variables the same names as > built-in functions, but that's hard for a new python programmer who > doesn't already know what all the built-in functions are. No, but not redefining the ones you actually use is a good start. Learning to understand the traceback is the more important lesson, IMHO. It takes a while to tune into what error messages are trying to tell you; even when you stop making newbie mistakes, you're going to have to deal with runtime errors from time to time. -- http://mail.python.org/mailman/listinfo/python-list
Re: gett error message: "TypeError: 'int' object is not callable"
"Nick" wrote in message news:e54c4461-c0b7-42fb-8542-cefd7bf5f...@h18g2000yqj.googlegroups.com... > file = open(prefix1) > text = file.readlines() > len = len(text) You have redefined two built-in functions "file" and "len" in the first three lines. This is usually considered poor practice. Stick to meaningless variable names, it's safer (only joking). TypeError: 'int' object is not callable". This means that something you thought was a function is in fact an integer. It's helpful to post/look at the line number of the error; "how is this line failing", is much easier to answer than "how is my program failing". print len(fields) Here len is an integer, because you redefined it in line 3. I'm guessing this is the problem. -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP 376
"Joachim Strömbergson" wrote in message news:mailman.2422.1246418400.8015.python-l...@python.org... > Even so, choosing md5 in 2009 for something that (hopefully) will be > used in years is a bad design decision. It creates a dependency for to > an algorithm that all sensible recommendations point you to move away > from. Why not write the field as algorithm:value? e.g. sha1:8590b685654367e3eba70dc00df7e45e88c21da4 Installers can fallback to using hashlib.new(), so you can plug in a new algorithm without changing the PEP or the installer code. -- http://mail.python.org/mailman/listinfo/python-list
Re: Funny xmlrpc / linux problem
"Hans Müller" wrote in message news:4a37b18d$0$3283$8e6e7...@newsreader.ewetel.de... > Small addition: > > While tracing the network data I found the server to be the problem, > the answer to a request is beeing delayed by about 180ms - no idea why. Nagle's algorithm: you've unintentionally produced a textbook demonstration. -- http://mail.python.org/mailman/listinfo/python-list
Re: "TypeError: 'int' object is not callable"
"Visco Shaun" wrote in message news:mailman.966.1243852864.8015.python-l...@python.org... > when I was executing the below code I got "TypeError: 'int' object is > not callable" exception. Why is it so? > > if type(c) == type(ERROR): You've probably assigned to type somewhere in your code. What does print repr(type) give? -- http://mail.python.org/mailman/listinfo/python-list
Re: urllib2 slow for multiple requests
"Tomas Svarovsky" wrote in message news:747b0d4f-f9fd-4fa6-bb6d-0a4365f32...@b1g2000vbc.googlegroups.com... > This is a good point, but then it would manifest regardless of the > language used AFAIK. And this is not the case, ruby and php > implementations are working quite fine. What I meant was: not reading the data and leaving the connection open is going to force the server to handle all 100 requests concurrently. I'm guessing that's not what your other implementations do. What happens to the timing if you call response.read(), response.close() ? -- http://mail.python.org/mailman/listinfo/python-list
Re: urllib2 slow for multiple requests
"cgoldberg" wrote in message news:9ae58862-1cb2-4981-ae6a-0428c7684...@z5g2000vba.googlegroups.com... > you aren't doing a read(), so technically you are just connecting to > the web server and sending the request but never reading the content > back from the socket. > > But that is not the problem you are describing... It might be, if the local server doesn't scale well enough to handle 100 concurrent requests. -- http://mail.python.org/mailman/listinfo/python-list
Re: thc v0.3 - txt to html converter - better code?
"Stefan Behnel" wrote in message news:4a008996$0$31862$9b4e6...@newsspool3.arcor-online.net... >language_map = {'English': 'EN', 'Deutsch': 'DE'} >strict_or_transitional = {True: 'Transitional', False: 'Strict'} > ># this will raise a KeyError for unknown languages >language = language_map[ self.cmboBoxLang.currentText() ] > ># this assumes that isChecked() returns True or False >spec = strict_or_transitional[self.rdioBtnTransitional.isChecked()] > >doctype = '\n' % ( >spec, language) Incidentally, the language in an HTML DOCTYPE refers to the language of the DTD, not the document. It's never correct to use //DE in an HTML page, unless you have a custom (German) DTD. So the code can be improved further by cutting that part out. strict_or_transitional = {True: 'Transitional', False: 'Strict'} # this assumes that isChecked() returns True or False spec = strict_or_transitional[self.rdioBtnTransitional.isChecked()] doctype = '\n' % spec -- http://mail.python.org/mailman/listinfo/python-list
Re: Thread-killing, round 666 (was Re: Lisp mentality vs. Python mentality)
"Vsevolod" wrote in message news:42cebb2b-0361-416c-8932-9371da50a...@y6g2000prf.googlegroups.com... > There's a common unification library -- bordeaux-threads -- > that abstracts away implementation specifics. It's API includes > the function destroy-thread. Which is deprecated, like the Java one. It's not hard to provide a kill thread call, if you don't mind it having undefined semantics. -- http://mail.python.org/mailman/listinfo/python-list
Re: ValueError: filedescriptor out of range in select()
"Laszlo Nagy" wrote in message news:mailman.2032.1237300298.11746.python-l...@python.org... > This method is called after the connection has been closed. Is is possible > that somehow > the file handles are leaking? If I understand correctly, you call shutdown() but not close() in response to a remote disconnect. That is likely to leak handles. Check with lsof (or one of the Sysinternals tools on Windows). -- http://mail.python.org/mailman/listinfo/python-list
Re: error after upgrade
"jonsoons" wrote in message news:3102ef22-b5e6-466d-a3f3-8648ccb5a...@p11g2000yqe.googlegroups.com... >from binascii import hexlify as _hexlify > ImportError: ld.so.1: python: fatal: relocation error: file /opt/csw/ > lib/libpython2.5.so.1.0: symbol libintl_gettext: referenced symbol not > Does anyone know what I need to rewrite here? Your upgrade policy? You seem to have a bad Python install, or conflict between the system Python and a local version. -- http://mail.python.org/mailman/listinfo/python-list
Re: Response codes and \r\n
"Catherine Heathcote" wrote in message news:n3nrl.2951$lc7.2...@text.news.virginmedia.com... = > I am reading an XML file (code at the end if it helps) and all goes well > except I am > getting the http response code printed. I suggest you comment out line 22. The status shouldn't be in the data. > Also everything I get has "\r\n" in it, which atm I am getting rid of with > strip(), is > that the best way? I would use and XML parser such as Elementtree, and let it handle it. Resist the temptation to think "it's a simple format, I'll parse it myself". Otherwise strip() or rstrip('\r\n') is fine, depending how much whitespace matters. > conn.close Note that statement does nothing, it's not the same as conn.close() -- http://mail.python.org/mailman/listinfo/python-list
Re: Python AppStore / Marketplace
"Rhodri James" wrote in message news:mailman.615.1235436896.11746.python-l...@python.org... > A souq is a bazaar :-) > Maybe I've just read too much arabic-themed fiction, but I was surprised not > to find the word in my trusty Chambers. Try under 'souk'. Transliterating to the Roman 'q' seems to have become popular relatively recently. -- http://mail.python.org/mailman/listinfo/python-list
Re: Will multithreading make python less popular?
"sturlamolden" wrote in message news:d544d846-15ac-446e-a77f-cede8fcf9...@m40g2000yqh.googlegroups.com... > The GIL does not matter before crunching numbers on the CPU > becomes the bottleneck. And when you finally get there, perhaps it is > time to look into some C programming? Or numpy on a 512 core GPGPU processor, because using the CPU for crunching numbers is just *so* dated. ;) -- http://mail.python.org/mailman/listinfo/python-list
Re: v = json.loads("{'test':'test'}")
"Steven D'Aprano" wrote in message news:018d0300$0$20629$c3e8...@news.astraweb.com... > Supposedly "every browser" (what, all of them?) already support a de > facto extension to the JSON standard, allowing more flexible quoting. That's a consequence of JSON being a subset of Javascript syntax, so you can just call eval() on it, if you're willing. When you use a library, it's pot luck whether it accepts JSON-soup or not. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why no lexical scoping for a method within a class?
"walterbyrd" wrote in message news:518b9dd9-69c5-4d5b-bd5f-ad567be62...@b38g2000prf.googlegroups.com... > However in the methods are within a class, the scoping seems to work > differently. Not really, self is a formal parameter to the function. It would be a strange language where a function's own arguments weren't in scope. >def b(self): >print self.x Try changing it to: def b(somethingotherthanself): print self.x -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 3.0 automatic decoding of UTF16
"J Kenneth King" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > It probably means what it says: that the input file contains characters > it cannot read using the specified encoding. That was my first thought. However it appears that there is an off by one error somewhere in the intersection of line ending/codec processing. Half way through the codec starts byte-flipping characters. -- http://mail.python.org/mailman/listinfo/python-list
Re: time
"Gabriel Rossetti" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] . > I'm a UTC/GMT +1, I tried obtaining the UTC time, it says it's 2 hours > earlier than the > current time (14:59). I tried various other methods, I still get the wrong > time. Does > anyone have an idea with what is wrong? It would be helpful to specify a named timezone. 2 hours earlier would be expected for central Europe, it being summer. Sorry if that's obvious. -- http://mail.python.org/mailman/listinfo/python-list
Re: Installing pySerial
"Joe G (Home)" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I have installed Python for windows today from the python web site .I also > installed > pySerial using the Windows installer from the sourceforge web site. You need to read the pySerial smallprint, where it says: "The files in this package are 100% pure Python. They depend on non standard but common packages on Windows (pywin32) and Jython (JavaComm). POSIX (Linux, BSD) uses only modules from the standard Python distribution)" -- http://mail.python.org/mailman/listinfo/python-list
Re: md5 differences
"Python" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > here's an example: > [EMAIL PROTECTED]:~% echo "hello" | md5 > b1946ac92492d2347c6235b4d2611184 > How do I get the same results? Checksum the same string. >>> md5.new("hello\n").hexdigest() 'b1946ac92492d2347c6235b4d2611184' -- http://mail.python.org/mailman/listinfo/python-list
Re: URLs and ampersands
"Steven D'Aprano" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I could just do a string replace, but is there a "right" way to escape > and unescape URLs? The right way is to parse your HTML with an HTML parser. URLs are not exempt from the normal HTML escaping rules, although there are an awful lot of pages that get this wrong. You didn't post any code, so it's hard to tell but maybe something like ElementTree or lxml would be a better tool than the ones you are currently using. -- http://mail.python.org/mailman/listinfo/python-list
Re: 32 bit or 64 bit?
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >That was suggested. Problem is, that sometimes the velocities are near >zero. So this solution, by itself, is not general enough. Maybe working in p, and delta-p would be more stable. -- http://mail.python.org/mailman/listinfo/python-list
Re: cgi, parse_header and semi-colon
"Sylvain" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > If we upload a file with a semi-colon (i.e : "C:/my;file.jpg") : > cgi.FieldStorage.filename returns only "my" everything after the semi- > colon is missing > > Is it a bug or i'm missing something ? I doubt it's bug in parse_header, since it's meant to split on semicolons. Whether it's a bug in one of its callers, or the client not escaping sufficiently, I couldn't say offhand. -- http://mail.python.org/mailman/listinfo/python-list
Re: Unicode chr(150) en dash
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I think I understand the unicode basic principles, what confuses me is the > usage > different applications > make out of it. > > For example, I got that EN DASH out of a web page which states > at the beggining. That's why I > did go for > that > encoding. But if the browser can properly decode that character using that > encoding, > how come > other applications can't? Browsers tend to guess what the author intended a lot. In particular, they fudge the difference between ISO8859-1 and Windows-1252. http://en.wikipedia.org/wiki/Windows-1252 -- http://mail.python.org/mailman/listinfo/python-list
Re: Serving binary content (images, etc) using BasteHTTPServer
<[EMAIL PROTECTED]> wrote in message news:556871d3-1fea-40f2-9cc6- >s.end_headers A bare method name (without parentheses) won't get called. -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem with PARAGRAPH SEPARATOR
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Would that mean that the string "myString" is an ascii-string or what? It would mean it was a byte encoded string already, yes. When you try to encode it, Python tries to coerce it to Unicode and it's equivalent to: myString.decode('ascii').encode('iso-8859-1','ignore') That wouldn't explain why printing it gave errors though. -- http://mail.python.org/mailman/listinfo/python-list
Re: %x unsigned?
"Hrvoje Niksic" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > The %x conversion specifier is documented in > http://docs.python.org/lib/typesseq-strings.html as "Unsigned > hexadecimal (lowercase)." What does "unsigned" refer to? It's obsolete, a fallout of int/long int unification. See http://www.python.org/dev/peps/pep-0237/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Regarding coding style
"K Viltersten" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > 1. When writing English, Strunk and White apply. Do they? I've never seen them ;) > 2. You should use two spaces after a sentence-ending period. > > For heavens sake, why? Most people find it easier to type two spaces than one and a half. -- http://mail.python.org/mailman/listinfo/python-list
Re: Eurosymbol in xml document
"Robert Bossy" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > If the file is declared as latin-1 and contains an euro symbol, then the file > is > actually invalid since euro is not defined of in iso-8859-1. Paradoxical would be a better description than invalid, if it contains things that it can't contain. If you decoded iso-8859-15 as if it were iso-8859-1, you would get u'\xa4' (Currency Sign) instead of the Euro. From the original error: "UnicodeEncodeError: 'charmap' codec can't encode character u'\xa4' in position 11834: character maps to " that seems to be what happened, as you said. -- http://mail.python.org/mailman/listinfo/python-list
Re: XML expat error
"dirkheld" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > xml.parsers.expat.ExpatError: not well-formed (invalid token): line > 554, column 20 > > I guess that the element I try to read or the XML(which would be > strange since they have been created with the same code) can't ben > retrieved. It's fairly easy to write non-robust XML generating code, and also quick to test if one file is always bad. Drop it into a text editor or Firefox, and take a quick look at line 554. Most likely some random control character has sneaked in; it only takes (for example) one NUL to make the document ill-formed. -- http://mail.python.org/mailman/listinfo/python-list
Re: keyword 'in' not returning a bool?
"c james" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] 't' in sample == True > False It's comparison operator chaining: 't' in sample == True is like 't' == sample == True and is equivalent to 't' in sample and sample == True -- http://mail.python.org/mailman/listinfo/python-list
Re: serving html from a python script in IE
"bluegray" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > print "Content-Type: application/xhtml+xml That's your problem. You can't use that Mime type because IE doesn't support XHMTL. No "appendix C" hair splitting comments, please. -- http://mail.python.org/mailman/listinfo/python-list
Re: Convert string to command..
"Matimus" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I think several people have given you the correct answer, but for some > reason you aren't getting it. Instead of saving the string > representation of a dictionary to the database... Mind you, if this were Jeopardy, "Store a binary pickle of a denormalized table back in the database" would be a tough one. -- http://mail.python.org/mailman/listinfo/python-list
Re: Dictionary invalid token error
"brad" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Why does 09 cause an invalid token while 9 does not? 9 isn't a valid octal digit. You probably want to use strings for storing telephone number like codes, if leading zeroes are significant. -- http://mail.python.org/mailman/listinfo/python-list
Re: File handle not being released by close
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I'm guessing the garbage collector is causing the file to be written, > but shouldn't close do this? Only if you call it ;) -- http://mail.python.org/mailman/listinfo/python-list
Re: Parsing XML with ElementTree (unicode problem?)
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > so what's the difference? how comes parsing is fine > in the first case but erroneous in the second case? You may have guessed the encoding wrong. It probably wasn't utf-8 to start with but iso8859-1 or similar. What actual byte value is in the file? > 2. there is another problem that might be similar I get a similar > error if the content of the (locally saved) xml have special > characters such as '&' Either the originator of the XML has messed up, or whatever you have done to save a local copy has mangled it. -- http://mail.python.org/mailman/listinfo/python-list
Re: file open default location
"T. Crane" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > As an aside, I forgot to mention above that I'm using Windows XP. Any other > ideas or > possible reasons that it would not choose my script location as the default > location to > save something? If you open a DOS window and run Python from there, it will write the files in whatever directory you were in when you typed the command. If you are running Python directly from Windows, or from an IDE, it's up to the OS or the IDE to decide what your default directory is. Often it will be the home directory from your user profile. -- http://mail.python.org/mailman/listinfo/python-list
Re: Unicode to HTML entities
"Clodoaldo" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >I was looking for a function to transform a unicode string into >htmlentities. >>> u'São Paulo'.encode('ascii', 'xmlcharrefreplace') 'São Paulo' -- http://mail.python.org/mailman/listinfo/python-list
Re: just a bug (was: xml.dom.minidom: how to preserve CRLF's inside CDATA?)
"Neil Cerutti" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Web browsers are in the very business of reasonably rendering > ill-formed mark-up. It's one of the things that makes > implementing a browser take forever. ;) For HTML, yes. it accepts all sorts of garbage, like most browsers; I've never, before now, seen it accept an invalid XML document though. -- http://mail.python.org/mailman/listinfo/python-list
Re: just a bug (was: xml.dom.minidom: how to preserve CRLF's inside CDATA?)
"Marc 'BlackJack' Rintsch" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > How did you verified that it is well formed? It appears to have a more fundamental problem, which is that it isn't correctly encoded (presumably because the CDATA is truncated in mid-character). I'm surprised Mozilla lets it slip by. -- http://mail.python.org/mailman/listinfo/python-list
Re: q: how to output a unicode string?
"Frank Stajano" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I find the encode/decode terminology somewhat confusing, because arguably > both sides are > "encoded". For example, a unicode-encoded string (I mean a sequence of > unicode code > points) should count as "decoded" in the terminology of this framework, right? Yes. Unicode is the one true Universal Character Set, and everything else (including ASCII and UTF-8) is a mere encoding. Once you've got your head round that, things may make more sense. -- http://mail.python.org/mailman/listinfo/python-list
Re: setDaemon problem.
"Michael Hoffman" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >> Neither is particularly intuitive; it just depends whether you are more >> familiar with the Posix terminology or the Java one. I personally prefer >> detached but there is little chance of a name change now. > > Why not? That's what Python 3.0 is for. I think you need a better reason than: "it's mildly confusing to people, if they don't read the manual" for an API change; but that's just my opinion. -- http://mail.python.org/mailman/listinfo/python-list
Re: setDaemon problem.
"Ramashish Baranwal" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I was also wondering about "daemonizing" a thread, but I interpreted > that it would daemonize the process which it didn't. I think setDaemon > should be renamed to setDetached or something similar. Neither is particularly intuitive; it just depends whether you are more familiar with the Posix terminology or the Java one. I personally prefer detached but there is little chance of a name change now. -- http://mail.python.org/mailman/listinfo/python-list
Re: Arrays, Got Me Confused
"Robert Rawlins - Think Blue" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Wider fragments of code don't really exists at this moment in time No but specifying the problem too narrowly tends to get you an unidiomatic solution. > Basically I'm trying to create a class that contains an array of MAC > address, these look something like this 'FD:E4:55:00:FG:A9. You rarely want to use 'array' in the standard library; there are some use cases for it but they are rare. More often you want to use the list type. However, here you really want to use a set: having decided that, the code is so trivial, it's hardly worth making a new class. >>> s = set() >>> s.add('FD:E4:55:00:FG:A9') >>> s.remove('FD:E4:55:00:FG:A9') >>> s = set() >>> s.add('FD:E4:55:00:FG:A9') >>> 'FD:E4:55:00:FG:A9' in s True >>> s.remove('FD:E4:55:00:FG:A9') >>> 'FD:E4:55:00:FG:A9' in s False >>> s.clear() Of course, you might want to add sanity checks like 'G' is not a hex digit in a real implementation. -- http://mail.python.org/mailman/listinfo/python-list
Re: Stack experiment
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >> There is a stray leading space in it. > > Nah, I'd say there's a stray ([^0-9]) after the space. If you regard the spaces as being a required part of the postfix grammar, it would be simpler. But who would design a language where white space was significant ;) -- http://mail.python.org/mailman/listinfo/python-list
Re: Stack experiment
<[EMAIL PROTECTED]> wrote in message >There may be something wrong with the "re" code in your example, >but I don't know enough about that to help in that area. There is a stray leading space in it. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python / Socket speed
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Seems like sockets are about 6 times faster on OpenSUSE than on > Windows XP in Python. > > http://pyfanatic.blogspot.com/2007/02/socket-performance.html > > Is this related to Python or the OS? It's 6 times faster even when not using Python, so what do you think? It's probably 'just' tuning though, the default window sizes are in the same ratio. -- http://mail.python.org/mailman/listinfo/python-list
Re: basic jython question
"Gerard Flanagan" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I have a 'logger' module which is essentially just a facade over the > 'logging' standard module. Can this be called from jython, and how is > this acheived? This is a colleague's question but I have no knowledge > of jython or java, and I can't install them at present in order to > figure it out. Since the CPython module is heavily influenced by the native Java logging framework (and/or log4j), I would have thought that it would be easier to create a Jython wrapper for those. -- http://mail.python.org/mailman/listinfo/python-list
Re: Inconsistent list/pointer problem
"Doug Stell" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I call the function, passing in a list as the input data. The function > must manipulate and operate on a copy of that list's data, without > altering the list in the calling routine. Then you will want to make a copy: listB = copy.deepcopy( listA) -- http://mail.python.org/mailman/listinfo/python-list
Re: Bizarre floating-point output
"Nick Maclaren" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > x = (1.234567890125, 1.2345678901255) > print x > print x[0], x[1] > (1.234567890124, 1.2345678901254999) 1.23456789012 1.23456789013 > > Is there a rational reason, or is that simply an artifact of the way > that the code has evolved? It is clearly not a bug :-) print x[0] gives the same result as printing str(x[0]), the value of x formatted as a string (rounded to a sensible number of places). x[0] at the command prompt gives the same result as printing repr(x), the representation of the text value as a string. When you do print on a tuple it doesn't recursively call str(), so you get the repr representations. You can get similar results with anything where the str() and repr() values are different. e.g. x = ( u'a', u'b') -- http://mail.python.org/mailman/listinfo/python-list
Re: merits of Lisp vs Python
"Alex Mizrahi" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > heh, do you have "standard numeric packages" for everything? maybe then we'll > make > standard programs for everything -- that will obsolete "slow" "custom > scripts" and we'll > just use shell to select what program we want to run? No, I was observing that, faced with a matrix multiplication problem, most sensible Python developers would do "apt-get install python-numeric" or equivalent. Trying to do it in pure Python would be the wrong tool for the job. If you think that's a weakness of Python compared to Lisp, then so be it. -- http://mail.python.org/mailman/listinfo/python-list
Re: merits of Lisp vs Python
"Mark Tarver" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > seems to show that Python is a cut down (no macros) version of Lisp > with a worse performance. Performance claims are always controversial. So, Python is much slower doing array multiplication, when you hand roll it, instead of using the standard numerical packages available. I see that the effbot has already responded the first part. -- http://mail.python.org/mailman/listinfo/python-list
Re: len(var) is [CONSTANT] equal to len(var) == [CONSTANT]?
"Tor Erik Soenvisen" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > which executes fine. Hence, 0- is okey... But this is a relatively > small range, and sooner or later you probably get two numbers with the same > id... Thoughts anyone? I think you are confusing yourself unnecessarily. The obvious way to implement unique ids is to return the address of the object. It's very unlikely that two different objects share the same address. -- http://mail.python.org/mailman/listinfo/python-list
Re: Yield
"Danny Colligan" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I absoultely agree. Thanks for pointing me out to some real-world > code. However, the function you pointed me to is not a generator > (there is no yield statement... it just returns the entire list of > primes). Oops, should have looked at the code more closely. Another example would be os.walk() in the standard library. -- http://mail.python.org/mailman/listinfo/python-list
Re: Yield
"Danny Colligan" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Now that we're on the subject, what are the advantages of using > generators over, say, list comprehensions or for loops? It seems to me > that virtually all (I won't say everything) the examples I've seen can > be done just as easily without using generators. The more trivial the example, the harder it is to see the advantage. Suppose you wanted to sum the first 1 primes. A quick Google fins you Wensheng Wang's recipe: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/366178 Just add print sum(primes(1)), and you're done. -- http://mail.python.org/mailman/listinfo/python-list
Re: Tertiary Operation
"abcd" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >x = None > result = (x is None and "" or str(x)) > > ...what's wrong with the first operation I did with x? I was expecting > "result" to be an empty string, not the str value of None. Your evil tertiary hack has failed you because the empty string counts as false in a boolean context. Please learn to love the new conditional expression syntax: http://docs.python.org/whatsnew/pep-308.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Python component model
"Edward Diener No Spam" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > "Thinking in Java or C++" as opposed to Python does not mean anything to me > as a general > statement. I am well aware of the difference between statically and > dynamically typed > languages but why this should have anything to do with RAD programming is > beyond me. Do > you care to elucidate this distinction ? I think this blog entry http://osteele.com/archives/2004/11/ides provides some insight into the point of view expressed. -- http://mail.python.org/mailman/listinfo/python-list
Re: HOST - Assembla Inc. Breakout - Copyright Violation by Mr. Andy Singleton
"Diez B. Roggisch" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > This is on the same level of interest to the communities of python, ruby & > java as the > color of my socks this morning - a deep black with cute little skulls > imprinted. I did find Andy's claim that he expected contributors to sing a copyright transfer agreement somewhat unreasonable. It would depend on the tune though, I guess. -- http://mail.python.org/mailman/listinfo/python-list
Re: Best way to handle large lists?
"Chaz Ginger" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Each item in the list is a fully qualified domain name, e.g. > foo.bar.com. The order in the list has no importance. So you don't actually need to use lists at all, then. You can just use sets and write: newSet = bigSet - littleSet -- http://mail.python.org/mailman/listinfo/python-list
Re: How do I converted a null (0) terminated string to a Python string?
"Marc 'BlackJack' Rintsch" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I would spell it: > > if strg.endswith('\0'): >strg = strg[:-1] I would just go with: strg = strg.rstrip('\0') -- http://mail.python.org/mailman/listinfo/python-list
Re: Are Python's reserved words reserved in places they dont need to be?
"metaperl" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Why isn' t the parser smart enough to see that class followed by an > identifier is used for class definition but class followed by equals is > a simple assignment? Because it's simpler to reserve words than worry about possible ambiguities in all past and future use cases. If you could use it as an identifier, it wouldn't be a reserved word by the normal definition of the term. -- http://mail.python.org/mailman/listinfo/python-list
Re: getting quick arp request
"Steve Holden" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Is it relevant to point out that the ARP protocol is a connectionless > network-layer > protocol. Not really, since the program uses normal TCP socket connections. The feature is working exactly as designed - to slow down TCP scans. The arp requests are just a consequence of the TCP scan. -- http://mail.python.org/mailman/listinfo/python-list
Re: threading support in python
"km" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > True, since smartness is a comparison, my friends who have chosen java > over python for considerations of a true threading support in a > language are smarter, which makes me a dumbo ! :-) No, but I think you making unwise assumptions about performance. You have to ask yourself: is Amdahl's law really hurting me? In some situations Python could no doubt benefit from fine grained locking. However, it's likely that scientific programming is not typically one of them, because most of the heavy lifting is done in C or C++ extensions which can run in parallel if they release the GIL. Or you are going to use a compute farm, and fork as many worker processes as you have cores. You might find these slides from SciPy 2004 interesting: http://datamining.anu.edu.au/~ole/pypar/py4cfd.pdf -- http://mail.python.org/mailman/listinfo/python-list
Re: threading support in python
"km" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I know many of my friends who did not choose python for obvious reasons > of the nature of thread execution in the presence of GIL which means > that one is wasting sophisticated hardware resources. It would probably be easier to find smarter friends than to remove the GIL from Python. -- http://mail.python.org/mailman/listinfo/python-list
Re: threading support in python
"km" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > if GIL doesnt go then does it mean that python is useless for > computation intensive scientific applications which are in need of > parallelization in threading context ? No. -- http://mail.python.org/mailman/listinfo/python-list
Re: windows pagfile utilization
"Tim Chase" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > "Thanks for putting 4 gigs of ram in your machine. How about I let you use 2 > of 'em > while I underutilize the other 2 gigs?" > > Sounds silly, IMHO. Well, for a lot of scenarios, it's going to be the 2GB limit on system space that is more of an issue. It's 2GB per process for user space, whereas your whole filesystem cache, for example, is likely to have to fit into that 2GB system space. Having said that, tweaking the limit to 3GB, say, is a bit like rearranging the deckchairs on the Titanic. DEC was doing much the same with big iron VAX machines in '93. If you need that much space today, just use a 64-bit system and get over it, unless you really are locked in. -- http://mail.python.org/mailman/listinfo/python-list
Re: windows pagfile utilization
"djoefish" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > My program still crashes at 2g (according to the task manager). Do I > need to inform python that the pagefile has a new size? How do I check > that python is utilizing the full pagefile? It won't. You'll hit the 2Gb user virtual address space limit first. -- http://mail.python.org/mailman/listinfo/python-list
Re: List match
"OriginalBrownster" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I know this probably is a very easy thing to do in python, but i wanted > to compare 2 lists and generate a new list that does not copy similar > entries. An example below > > list= ["apple", "banana", "grape"] > list2=["orange","banana", "pear"] Other people have already posted solutions but I'll add a couple of comments: 1. Avoid calling lists 'list', you will break the list built-in function. 2. You don't specify whether the lists are ordered. If there is no significance to the order of the items, it may be more appropriate to use sets throughout. Then the answer is just: set3 = set1 | set2. -- http://mail.python.org/mailman/listinfo/python-list
Re: help parsing this
"a" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > mx.DateTime.RangeError at /podcasts > Failed to parse "31 Apr 2006 20:19:00 -0400": day out of range: 31 > Python /usr/lib/python2.4/site-packages/mx/DateTime/Parser.py in > DateTimeFromString, line 608 > > how to parse this date > thanks There isn't a 31st of April. -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie - How to iterate list or scalar ?
"Andy Dingley" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > pluginVersionNeeded is a parameter passed into a method and it can > either be a simple scalar variable, or it can be a list of the same > variables. The obvious question would be, "is there a good reason why you don't change the API to always require a list?" Then you can just write: myFunction( [scalarParameter] ) when you have only one variable. -- http://mail.python.org/mailman/listinfo/python-list
Re: ElementTree and Unicode
"Sébastien Boisgérault" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] element = Element("string", value=u"\x00") I'm not as familiar with elementtree.ElementTree as I perhaps should be. However, you appear to be trying to insert a null character into an XML document. Should you succeed in this quest, the resulting document will be ill-formed, and any conforming parser will choke on it. -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows vs. Linux
"Gerhard Fiedler" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >With the same reasoning one could say that the Unix creators should have > used the VMS (or any other existing) form. Only if they used Guido's time machine. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python strings outside the 128 range
"Gerhard Fiedler" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > If I understand you correctly, you are saying that if I distribute a file > with the following lines: > > s = "é" > print s > > I basically need to distribute also the information how the file is encoded > and every user needs to use the same (or a compatible) encoding for reading > this file? > > Is there a standard way to do this? Use Unicode strings, with an explicit encoding. Say no to ISO-8859-1 centrism. See: http://www.amk.ca/python/howto/unicode particularly the "Unicode Literals in Python Source Code" section. -- http://mail.python.org/mailman/listinfo/python-list
Re: Illegal instruction or undefined symbol from import
"Mathias Waack" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > BTW, does anybody know why the c-lib offers both log and log1p? So you can get a sensible answer computing log(1 + 10 ^ -30). There's a lot of somewhat obscure mathematical stuff that got into the standard C lib. How often do you need Bessel functions? -- http://mail.python.org/mailman/listinfo/python-list
Re: Having problems with strings in HTML
"Sion Arrowsmith" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >>By the way, you _do_ realize that your "&" characters should be escaped >>as "&", don't you? > > No they shouldn't. They part of the url, which is (IIRC) a CDATA > attribute of the A element, not PCDATA. It is CDATA but ampersands still need to be escaped. -- http://mail.python.org/mailman/listinfo/python-list
Re: serial port servo control
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > 1) How should I write to the serial port with python? I found the > module "pyserial": I don't think there is any need to hunt for anything better. > In C I'd do this by sending 3 char's, as they're only 1 byte, > but i'm not exactly sure how to do it in Python. Use a string type. output = chr(x) + chr(y) + chr(z) for example. There is no restriction on null bytes in strings, so they are appropriate for binary data. -- http://mail.python.org/mailman/listinfo/python-list
Re: not quite 1252
"Anton Vredegoor" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Yes my header also says UTF-8. However some kind person send me an e-mail > stating that > since I am getting \x94 and such output when using repr (even if str is > giving correct > output) there could be some problem with the XML-file not being completely > UTF-8. Or is > there some other reason I'm getting these \x94 codes? Well that rather depends on what you are doing. If you take utf-8, decode it to Unicode, then re-encode it as cp1252 you'll possibly get \x94. OTOH, if you see '\x94' in a Unicode string, something is wrong somewhere. -- http://mail.python.org/mailman/listinfo/python-list
Re: How protect proprietary Python code? (bytecode obfuscation?, what better?)
"bruno at modulix" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Do they ask the same thing for Java or .NET apps ?-) If you Google for "bytecode obfuscation", you'll find a large number of products already exist for Java and .Net -- http://mail.python.org/mailman/listinfo/python-list
Re: Cannot import htmllib
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > As far as I can see, the files formatter.py and htmllib.py are where > they are supposed to be, in /usr/lib/python2.4/. You probably have aliased it by calling your main program formatter.py, or something similar. -- http://mail.python.org/mailman/listinfo/python-list
Re: urllib.urlencode wrongly encoding � character
"Fredrik Lundh" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I'm obviously missing some context here, but "encoding ± to %B1 on any > platform" is exactly what urlencode does: > >>>> import urllib >>>> urllib.urlencode([("key", chr(0xb1))]) >'key=%B1' Yeah but you're cheating by using the platform independent chr(0xb1) instead of a literal '±' in an unspecified encoding. -- http://mail.python.org/mailman/listinfo/python-list
Re: cgi error
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > It works fine when i run it in python , but it won't run when i run my > cgi script. > > It says AttributeError: 'module' object has no attribute 'FTPHost' > what could be a possible cause? thanks. Perhaps you called your script 'ftputil'. If so, 'import ftputil' won't import the standard library version. -- http://mail.python.org/mailman/listinfo/python-list