[issue2892] improve cElementTree iterparse error handling

2010-06-11 Thread Fredrik Lundh
Fredrik Lundh fred...@effbot.org added the comment: Note that this was fixed in upstream 1.3 (and verified by the selftests), but the fix and test was apparently lost when that code was merged into 2.7. Since 2.7 is supposed to ship with 1.3, this is a regression, not a feature request

[issue8583] Hardcoded namespace_separator in the cElementTree.XMLParser

2010-05-01 Thread Fredrik Lundh
Fredrik Lundh fred...@effbot.org added the comment: Namespaces are a fundamental part of the XML information model (both xpath and infoset) and all modern XML document formats, so I'm not sure what problem you're trying to solve by pretending that they don't exist. It's a bit like modifying

[issue6488] ElementTree documentation refers to path with no explanation, and inconsistently

2010-04-01 Thread Fredrik Lundh
Fredrik Lundh fred...@effbot.org added the comment: As per PEP 257, “Returns” should become “Return” (it’s a command, not a description). Upstream ET uses JavaDoc conventions, where the conventions are designed by technical writers, not hackers. In JavaDoc, descriptions are 3rd person

[issue6488] ElementTree documentation refers to path with no explanation, and inconsistently

2010-04-01 Thread Fredrik Lundh
Fredrik Lundh fred...@effbot.org added the comment: The missing/extra words in the findtext description is just a case of sloppy copy-editing, most likely after a quick reformatting. Not sure why you're spending all this energy arguing about commas, though

[issue8047] Serialiser in ElementTree returns unicode strings in Py3k

2010-03-21 Thread Fredrik Lundh
Fredrik Lundh fred...@effbot.org added the comment: Hmm. I'm not entirely sure about giving False a meaning when None has traditionally had a different (and documented) meaning. And sleeping on it hasn't convinced me in either direction :-( (well, I'd say no, but the compatibility argument

[issue8047] Serialiser in ElementTree returns unicode strings in Py3k

2010-03-12 Thread Fredrik Lundh
Fredrik Lundh fred...@effbot.org added the comment: 'None' has always been the documented default for the encoding parameter That's probably mostly by accident at least in original ET, but the 1.3 draft docs at effbot.org/elementtree does spell it out explicitly for the 'write' method

[issue8047] Serialiser in ElementTree returns unicode strings in Py3k

2010-03-12 Thread Fredrik Lundh
Fredrik Lundh fred...@effbot.org added the comment: (what's the Python 3 replacement for the array module, btw?) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8047

[issue8047] Serialiser in ElementTree returns unicode strings in Py3k

2010-03-12 Thread Fredrik Lundh
Fredrik Lundh fred...@effbot.org added the comment: Yes, the feature has been implemented deep down in the _encode() helper function, so it impacts the entire serialiser, not only its API Ouch. import locale locale.getpreferredencoding() == utf-8 False from xml.etree.ElementTree import

[issue8047] Serialiser in ElementTree returns unicode strings in Py3k

2010-03-12 Thread Fredrik Lundh
Fredrik Lundh fred...@effbot.org added the comment: I wouldn't raise much opposition against tobytes() as an alias for tostring(), although that sounds more like duplicating an otherwise simple API. Adding an alias would be a way address the 2.X/3.X terminology overlap; string traditionally

[issue8047] Serialiser in ElementTree returns unicode strings in Py3k

2010-03-12 Thread Fredrik Lundh
Changes by Fredrik Lundh fred...@effbot.org: -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8047 ___ ___ Python-bugs-list mailing list

[issue8047] Serialiser in ElementTree returns unicode strings in Py3k

2010-03-12 Thread Fredrik Lundh
Fredrik Lundh fred...@effbot.org added the comment: I wouldn't raise much opposition against tobytes() as an alias for tostring(), although that sounds more like duplicating an otherwise simple API. Adding an alias would be a way address the 2.X/3.X terminology overlap; string traditionally

[issue8047] Serialiser in ElementTree returns unicode strings in Py3k

2010-03-12 Thread Fredrik Lundh
Fredrik Lundh fred...@effbot.org added the comment: Interesting. But isn't the problem with 3.1 that it relies on the standard encoding, which results in code that may or may not work depending on a global platform setting? Who's doing the encoding in the new version? And what ends up

[issue8047] Serialiser in ElementTree returns unicode strings in Py3k

2010-03-12 Thread Fredrik Lundh
Fredrik Lundh fred...@effbot.org added the comment: Oops :) Yeah, that was pretty lousy way to show what encoding I was using for that test: import locale locale.getpreferredencoding() 'cp1252' (Somewhat related, it would be nice if Python actually normalized defaultencoding

[issue7114] HTMLParser doesn't handle ![CDATA[ ... ]]

2010-03-11 Thread Fredrik Lundh
Fredrik Lundh fred...@effbot.org added the comment: And to clarify, XHTML is an reformulation of HTML4 using XML syntax, so you should use an XML parser to parse it, not an HTML parser. The formats are related, but not identical. -- ___ Python

[issue5100] ElementTree.iterparse and Element.tail confusion

2010-03-11 Thread Fredrik Lundh
Fredrik Lundh fred...@effbot.org added the comment: Footnote: iterparse does things this way mostly to keep the implementation simple and fast; due to buffering, the tree builder are usually ahead of the event generation with up to 16k. See the note on this page: http://effbot.org/zone

[issue8047] Serialiser in ElementTree returns unicode strings in Py3k

2010-03-11 Thread Fredrik Lundh
Fredrik Lundh fred...@effbot.org added the comment: if I don't specify an encoding, I get unicode. If I do specify an encoding, I get encoded bytes. You're confusing the XML document encoding with character set encoding. A serialized (unparsed) XML document is a byte stream, not a string

[issue6472] Update ElementTree with upstream changes

2010-03-11 Thread Fredrik Lundh
Fredrik Lundh fred...@effbot.org added the comment: W00t! -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6472 ___ ___ Python-bugs-list mailing

[issue8047] Serialiser in ElementTree returns unicode strings in Py3k

2010-03-11 Thread Fredrik Lundh
Fredrik Lundh fred...@effbot.org added the comment: import array array.array(i, [1, 2, 3]).tostring() b'\x01\x00\x00\x00\x02\x00\x00\x00\x03\x00\x00\x00' -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8047

[issue8047] Serialiser in ElementTree returns unicode strings in Py3k

2010-03-11 Thread Fredrik Lundh
Fredrik Lundh fred...@effbot.org added the comment: So now it's the domain experts against some hypothetical people that might exist? Tricky. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8047

[issue7462] Implement fastsearch algorithm for rfind/rindex

2010-01-04 Thread Fredrik Lundh
Fredrik Lundh fred...@effbot.org added the comment: Thanks Florent! Are there any simple, common cases that are made slower by this patch? The original fastsearch implementation has a couple of special cases to make sure it's faster than the original code in all cases. The reason it wasn't

[issue3475] _elementtree.c import can fail silently

2009-11-08 Thread Fredrik Lundh
Fredrik Lundh fred...@effbot.org added the comment: Note that fail silently is a bit of a misnomer - if the embedded import doesn't work, portions of the library will fail pretty loudly. Feel free to use some variation of the suggested patch, or just wait until the next upstream release gets

[issue7139] ElementTree: Incorrect serialization of end-of-line characters in attribute values

2009-11-02 Thread Fredrik Lundh
Fredrik Lundh fred...@effbot.org added the comment: The real problem here is that XML attributes weren't really designed to hold data that doesn't survive normalization. One would have thought that making it difficult to do that, and easy to store such things as character data, would have made

Re: [Image-SIG] Some issue with easy_install and PIL/Imaging

2009-10-05 Thread Fredrik Lundh
: no egg - worst seen ever, remove it from pypi or provide an egg (jensens, 2009-10-05, 0 points) /F On Wed, Sep 30, 2009 at 6:24 PM, Chris Withers ch...@simplistix.co.uk wrote: Fredrik Lundh wrote: On Fri, Sep 11, 2009 at 3:49 PM, Chris Withers ch...@simplistix.co.uk wrote: Klein Stéphane

Re: [Image-SIG] Some issue with easy_install and PIL/Imaging

2009-09-28 Thread Fredrik Lundh
On Fri, Sep 11, 2009 at 3:49 PM, Chris Withers ch...@simplistix.co.uk wrote: Klein Stéphane wrote: Resume : 1. first question : why PIL package in pypi don't work ? Because Fred Lundh have his package distributions unfortunate names that setuptools doesn't like... It used to support this,

[issue6562] OverflowError in RLock.acquire()

2009-08-04 Thread Fredrik Lundh
Fredrik Lundh fred...@effbot.org added the comment: PIL is completely thread-agnostic, so I not sure there's anything PIL can do to fix this. (and ImageQt is of course an interface to PyQt, which is an interface to Qt, which consists of a *lot* more than 50 lines

[issue6233] ElementTree (py3k) doesn't properly encode characters that can't be represented in the specified encoding

2009-06-24 Thread Fredrik Lundh
Fredrik Lundh fred...@effbot.org added the comment: That's backwards, unless I'm missing something here: charrefs represent Unicode characters, not UTF-8 byte values. The character LATIN SMALL LETTER A WITH TILDE with the character value 227 should be represented as #227; if serialized

[issue5166] ElementTree and minidom don't prevent creation of not well-formed XML

2009-06-24 Thread Fredrik Lundh
Fredrik Lundh fred...@effbot.org added the comment: For ET, that's very much on purpose. Validating data provided by every single application would kill performance for all of them, even if only a small minority would ever try to serialize data that cannot be represented in XML

[issue6266] cElementTree.iterparse ElementTree.iterparse return differently encoded strings

2009-06-21 Thread Fredrik Lundh
Fredrik Lundh fred...@effbot.org added the comment: It should definitely give what's intended (either a Unicode string, or, if the content is plain ASCII, an 8-bit string). What did you get instead? -- ___ Python tracker rep...@bugs.python.org http

[issue6233] ElementTree (py3k) doesn't properly encode characters that can't be represented in the specified encoding

2009-06-21 Thread Fredrik Lundh
Fredrik Lundh fred...@effbot.org added the comment: Umm. Isn't _encode used to encode tags and attribute names? The charref syntax is only valid in CDATA sections and attribute values, which are encoded by the corresponding _escape functions. I suspect this patch will make things blow up

[issue6233] ElementTree (py3k) doesn't properly encode characters that can't be represented in the specified encoding

2009-06-21 Thread Fredrik Lundh
Fredrik Lundh fred...@effbot.org added the comment: Did you look at the 1.3 alpha code base when you came up with this idea? Unfortunately, 1.3's _encode is used for a different purpose... I don't have time to test it tonight, but I suspect that 1.3's escape_data/escape_attrib functions

[issue6266] cElementTree.iterparse ElementTree.iterparse return differently encoded strings

2009-06-20 Thread Fredrik Lundh
Fredrik Lundh fred...@effbot.org added the comment: Converting from UTF-8 to Unicode is the right thing to do, but converting back to Latin-1 is not correct -- note that ET returns a Unicode string, not an 8-bit string. There's a makestring helper that does the right thing in the library

[issue5767] xmlrpclib loads invalid documents

2009-04-16 Thread Fredrik Lundh
Fredrik Lundh fred...@effbot.org added the comment: sgmlop doesn't do much validation; to quote the homepage: [sgmlop] is tolerant, and happily accepts XML-like data that are not well-formed. If you need strictness, use another parser. But given that Python ships with cElementTree these days

[issue1143] Update to latest ElementTree in Python 2.7

2009-04-02 Thread Fredrik Lundh
Fredrik Lundh eff...@users.sourceforge.net added the comment: ET 1.3 is still in alpha, though. Hopefully, that'll sort itself out over the next few weeks. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1143

[issue1538691] Patch cElementTree to export CurrentLineNumber

2009-04-02 Thread Fredrik Lundh
Fredrik Lundh eff...@users.sourceforge.net added the comment: In the upstream 1.0.6, the ParseError exception has a position attribute that contains a (line, column) tuple. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org

[issue1777] ElementTree/cElementTree findtext inconsistency

2009-01-10 Thread Fredrik Lundh
Fredrik Lundh eff...@users.sourceforge.net added the comment: Forgot to mention that this is fixed in the cElementTree trunk (public as of today's 1.0.6 preview release). Will merge with Python trunk when I find the time... ___ Python tracker rep

Re: Official definition of call-by-value (Re: Finding the instance reference...)

2008-11-13 Thread Fredrik Lundh
greg wrote: If you're going to indulge in argument by authority, you need to pick authorities that can be considered, er, authoritative in the field concerned... Like Barbara Liskov, who's won tons of awards for her work on computer science and programming languages, and who was among the

Re: Official definition of call-by-value (Re: Finding the instance reference...)

2008-11-12 Thread Fredrik Lundh
Aahz wrote: There you have it -- call by value is offially defined in terms of assignment. There is no mention in there of copying. So it's perfectly correct to use it in relation to Python. Except, of course, for the fact that it is generally misleading. It's not only misleading, it's

Re: Official definition of call-by-value (Re: Finding the instance reference...)

2008-11-12 Thread Fredrik Lundh
greg wrote: It's not only misleading, it's also a seriously flawed reading of the original text - the Algol 60 report explicitly talks about assignment of *values*. Do you agree that an expression in Python has a value? Do you agree that it makes sense to talk about assigning that value

[issue4100] xml.etree.ElementTree does not read xml-text over page bonderies

2008-11-01 Thread Fredrik Lundh
Fredrik Lundh [EMAIL PROTECTED] added the comment: Roland's right - iterparse only guarantees that it has seen the character of a starting tag when it emits a start event, so the attributes are defined, but the contents of the text and tail attributes are undefined at that point. The same

Re: Using the 'with' statement with cStringIO objects

2008-09-27 Thread Fredrik Lundh
peppergrower wrote: teststring='this is a test' with cStringIO.StringIO(teststring) as testfile: pass umm. what exactly do you expect that code to do? /F -- http://mail.python.org/mailman/listinfo/python-list

Re: How to read a jpg bytearray from a Flash AS3 file

2008-09-27 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: I'm trying to save an image from a Flash AS3 to my server as a jpg file. I found some PHP code to do this, but I want to do this in Python. I'm not quite sure how to convert the following code to Python. It's mainly the $GLOBALS[HTTP_RAW_POST_DATA] part I don't know how

Re: How to get the filename in the right case ?

2008-09-27 Thread Fredrik Lundh
Stef Mientki wrote: I don't think your suggestion is a good one. If a filename has uppercase characters in it, the END-USER has done that for some kind of reason. I explain how pdb works and show you how to solve the specific comparison problem you mentioned in your post, and you start

Re: Regular expression help: unable to search ' # ' character in the file

2008-09-27 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: import re fd = open(file, 'r') line = fd.readline pat1 = re.compile(\#*) while(line): mat1 = pat1.search(line) if mat1: print line line = fd.readline() I strongly doubt that this is

[issue433029] SRE: posix classes aren't supported

2008-09-27 Thread Fredrik Lundh
Fredrik Lundh [EMAIL PROTECTED] added the comment: Yes, this refers to the POSIX character classes as described here: http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap09.html (Ideally, there should be an (internal) API that lets you register class definitions from the Python

Re: Eggs, VirtualEnv, and Apt - best practices?

2008-09-25 Thread Fredrik Lundh
Dmitry S. Makovey wrote: you have just described OS package building ;) I can't speak for everybody, but supporting multiple platforms (PHP, Perl, Python, Java) we found that the only way to stay consistent is to use OS native packaging tools (in your case apt and .deb ) and if you're missing

Re: How to get the filename in the right case ?

2008-09-25 Thread Fredrik Lundh
Stef Mientki wrote: 1. I've a multitab editor. 2. When a breakpoint is reached, 3. I check if the file specified in pdb output, is already open in one of the editor tabs, 4. if not, I open a new tab with the correct file, 5. I focus the correct editor tab and jump to the line specified by

[issue3547] Ctypes is confused by bitfields of varying integer types

2008-09-24 Thread Fredrik Lundh
Fredrik Lundh [EMAIL PROTECTED] added the comment: Looks fine to me, except for the comment in the test suite. Should +# MS compilers do NOT combine c_short and c_int into +# one field, gcc doesn't. perhaps be +# MS compilers do NOT combine c_short and c_int

[issue3547] Ctypes is confused by bitfields of varying integer types

2008-09-24 Thread Fredrik Lundh
Fredrik Lundh [EMAIL PROTECTED] added the comment: Do should be does, right. Not enough coffee today :) ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3547

Re: Why are broken iterators broken?

2008-09-22 Thread Fredrik Lundh
Cameron Simpson wrote: you probably want the consumer thread to block when it catches up with the producer, rather than exit. It sounds like he wants non-blocking behaviour in his consumer. Roy gave an example, he didn't post a requirements specification. A common example is try to

Re: Regex Help

2008-09-22 Thread Fredrik Lundh
Support Desk wrote: the code I am using is regex = r'a href=[|\']([^|\']+)[|\']' that's way too fragile to work with real-life HTML (what if the link has a TITLE attribute, for example? or contains whitespace after the HREF?) you might want to consider using a real HTML parser for this

Re: Here's something interesting: sympy crashes in Python 2.6 (Windows)

2008-09-22 Thread Fredrik Lundh
Robert Kern wrote: No warnings show up when importing the offending module: Python 2.5.1 (r251:54869, Apr 18 2007, 22:08:04) [GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin Type help, copyright, credits or license for more information. from sympy.mpmath import specfun So what

Re: Tkinter 3000 WCK Install Problem

2008-09-22 Thread Fredrik Lundh
garyr wrote: I'm trying to install WCK. I downloaded and installed the Windows executable for my Python version. It appeared to run OK. I then downloaded the demo files but find that none run due to error: ImportError: No module named _tk3draw. I'm using ActivePython 2.3.5 on Windows XP Home.

Re: Not fully OO ?

2008-09-21 Thread Fredrik Lundh
Martin v. Löwis wrote: I don't think he meant that Python is wrong somehow, but that the OO babble of what happens for 2+2 is wrong. The babble said that, when the code is executed, an __add__ message is sent to the 2 object, with another 2 object as the parameter. That statement is incorrect:

Re: How to kill threading.Thread instance?

2008-09-21 Thread Fredrik Lundh
dmitrey wrote: BTW, it should be noticed that lots of threading module methods have no docstrings (in my Python 2.5), for example _Thread__bootstrap, _Thread__stop. things named _Class__name are explicitly marked private by the implementation (using the __ prefix). using them just because

Re: How to kill threading.Thread instance?

2008-09-21 Thread Fredrik Lundh
Diez B. Roggisch wrote: I wonder why something like myThread.exit() or myThread.quit() or threading.kill(myThread) can't be implemented? Is something like that present in Python 3000? Not that I'm aware of it (which doesn't mean to much though). However I *am* aware of the bazillions

Re: Override the '+' symbol

2008-09-21 Thread Fredrik Lundh
Mr.SpOOn wrote: how can I override the '+' symbol (and other math symbols) so that it can have a new behavior when applied to some objects? see Emulating Numeric Types in the language reference: http://www.python.org/doc/ref/numeric-types.html /F --

Re: Why are broken iterators broken?

2008-09-21 Thread Fredrik Lundh
Steven D'Aprano wrote: According to the Python docs, once an iterator raises StopIteration, it should continue to raise StopIteration forever. Iterators that fail to behave in this fashion are deemed to be broken: http://docs.python.org/lib/typeiter.html I don't understand the reasoning

Re: Why are broken iterators broken?

2008-09-21 Thread Fredrik Lundh
Roy Smith wrote: There are plausible examples of collections which grow while you're iterating over them. I'm thinking specifically of a queue in a multi-threaded application. One thread pushes work onto the back of the queue while another pops from the front. The queue could certainly go

Re: Newick parser

2008-09-21 Thread Fredrik Lundh
aditya shukla wrote: Hello folks , i have a .nwk file.I want to parser the tree from that file.I found this python parser for newick trees. http://www.daimi.au.dk/~mailund/newick.html But i don't understand the usage properly.What i wanna do is if i have a file in the location

Re: report a BUG of package setuptools-0.6c8.

2008-09-20 Thread Fredrik Lundh
为爱而生 wrote: File /usr/lib/python2.5/site-packages/setuptools/command/sdist.py, line 98, in entries_finder log.warn(unrecognized .svn/entries format in %s, dirname) NameError: global name 'log' is not defined global name 'log' is not defined to the line 98!!! please report bugs here:

Re: The Python computer language

2008-09-20 Thread Fredrik Lundh
ROSEEE wrote: http://pthoncomputerlanguage.blogspot.com report here: http://tinyurl.com/blogspot-spam /F -- http://mail.python.org/mailman/listinfo/python-list

Re: Not fully OO ?

2008-09-20 Thread Fredrik Lundh
Kay Schluehr wrote: Answer: if you want to define an entity it has to be defined inside a class. If you want to access an entity you have to use the dot operator. Therefore Java is OO but Python is not. you're satirising the quoted author's cargo-cultish view of object orientation, right?

Re: Not fully OO ?

2008-09-20 Thread Fredrik Lundh
Colin J. Williams wrote: foreach: for x in array: statements Loops over the array given by array. On each iteration, the value of the current element is assigned to x and the internal array pointer is advanced by one. This could be a useful addition to Python. for-in could be a useful

Re: How to make a reverse for loop in python?

2008-09-20 Thread Fredrik Lundh
Alex Snast wrote: I'm new to python and i can't figure out how to write a reverse for loop in python e.g. the python equivalent to the c++ loop for (i = 10; i = 0; --i) use range with a negative step: for i in range(10-1, -1, -1): ... or just reverse the range: for i in

Re: How to make a reverse for loop in python?

2008-09-20 Thread Fredrik Lundh
Fredrik Lundh wrote: e.g. the python equivalent to the c++ loop for (i = 10; i = 0; --i) use range with a negative step: for i in range(10-1, -1, -1): ... or just reverse the range: for i in reversed(range(10)): ... (and to include the 10 in the range, add one

Re: NEW GENERATED DLL ERROR FOUND WITHIN f2PY.py

2008-09-20 Thread Fredrik Lundh
Blubaugh, David A. wrote: (no need to shout when filling in the subject line, thanks) I have now been able to generate a .pyd file from a FORTRAN file that I am trying to interface with python. I was able to execute this with an additional insight into how f2py operates. ImportError:

Re: How to Determine Name of the Day in the Week

2008-09-18 Thread Fredrik Lundh
Keo Sophon wrote: I've tried calendar.month_name[0], it displays empty string, while calendar.month_name[1] is January? Why does calendar.month_name's index not start with index 0 as calendar.day_name? the lists are set up to match the values used by the time and datetime modules; see e.g.

Re: PEP proposal optparse

2008-09-18 Thread Fredrik Lundh
James Mills wrote: As you can see (as long as you're reading this in fixed-width fonts) it _is_ very readable. given that it only relies on indentation from the left margin, it's no less readable in a proportional font (unless you're using an font with variable-width spaces, that is ;-).

Re: Twisted vs Python Sockets

2008-09-18 Thread Fredrik Lundh
James Matthews wrote: I am wondering what are the major points of twisted over regular python sockets. I am looking to write a TCP server and want to know the pros can cons of using one over the other. Twisted is a communication framework with lots of ready-made components:

Re: Extracting hte font name from a TrueType font file

2008-09-18 Thread Fredrik Lundh
Steve Holden wrote: Does anyone have a Python recipe for this? from PIL import ImageFont f = ImageFont.truetype(/windows/fonts/verdanai.ttf, 1) f.font.family 'Verdana' f.font.style 'Italic' /F -- http://mail.python.org/mailman/listinfo/python-list

Re: how many objects are loaded for hello world?

2008-09-17 Thread Fredrik Lundh
belred wrote: i just read this blog about how many objects (types) are loaded for a hello world program in C#. http://blogs.msdn.com/abhinaba/archive/2008/09/15/how-many-types-are-loaded-for-hello-world.aspx how can you find out how many are loaded for a python program: print 'hello' types

Re: File Reading related query

2008-09-17 Thread Fredrik Lundh
Usman Ajmal wrote: Is there any function for reading a file while ignoring *\n* occuring in the file? can you be a bit more precise? are we talking about text files or binary files? how do you want to treat any newlines that actually appear in the file? /F --

Re: recursive using the os.walk(path) from the os module

2008-09-17 Thread Fredrik Lundh
A. Joseph wrote: I want to search through a directory and re-arrange all the files into e.g All .doc files go into MS WORD folder, all .pdf files goes into PDF Folder. I`m thinking of doing something with the os.walk(path) method from os module, I need some ideal how the algorithm should

Re: python regex character group matches

2008-09-17 Thread Fredrik Lundh
christopher taylor wrote: my issue, is that the pattern i used was returning: [ '\\uAD0X', '\\u1BF3', ... ] when i expected: [ '\\uAD0X\\u1BF3', ] the code looks something like this: pat = re.compile((\\\u[0-9A-F]{4})+, re.UNICODE|re.LOCALE) #print pat.findall(txt_line) results =

Re: python regex character group matches

2008-09-17 Thread Fredrik Lundh
Steven D'Aprano wrote: Assuming that you want to find runs of \u escapes, simply use non-capturing parentheses: pat = re.compile(u(?:\\\u[0-9A-F]{4})) Doesn't work for me: pat = re.compile(u(?:\\\u[0-9A-F]{4})) it helps if you cut and paste the right line... here's a better

Re: translating ascii to binary

2008-09-17 Thread Fredrik Lundh
Lie wrote: Any advice about this matter would be very appreciated. Thanks in advance. It'd be easier to make a one-char version of ascii2bin then make the string version based on the one-char version. And it'd be a lot easier to read your posts if you trimmed away at least some of the

Re: python-mode problem, doesnt load whole module?

2008-09-17 Thread Fredrik Lundh
cnb wrote: a = parsing.unserialize(C:/users/saftarn/desktop/twok.txt) Traceback (most recent call last): File C:\Python25\lib\pickle.py, line 1126, in find_class klass = getattr(mod, name) when reporting a traceback, please include the error message that follows after the stack

Re: How do I add permanently to Pythons sys.path?

2008-09-16 Thread Fredrik Lundh
cnb wrote: no I can't... Python has supported packages since version 1.4 or so, so I'm pretty sure you can. /F -- http://mail.python.org/mailman/listinfo/python-list

Re: Why some blog entries at MSN Space support rss feed while others don't?

2008-09-14 Thread Fredrik Lundh
liuyuprc wrote: Not sure if this is the place this question should even be raised it isn't. -- http://mail.python.org/mailman/listinfo/python-list

Re: Stuck connection in Python 3.0b2 http.server

2008-09-14 Thread Fredrik Lundh
rs387 wrote: I've encountered a weird issue when migrating a web server to Python 3 - the browser would wait forever without showing a page, displaying Transferring data in the status bar. I tracked it down to a reference cycle in my BaseHTTPRequestHandler descendant - one of the attributes

Re: Is there any nice way to unpack a list of unknown size??

2008-09-14 Thread Fredrik Lundh
srinivasan srinivas wrote: I want to do something like below: 1. first, second, third, *rest = foo 2. for (a,b,c,*rest) in list_of_lists: update to Python 3.0 (as others have pointed out), or just do first, second, third = foo[:3] rest = foo[3:] for item in list_of_lists:

[issue3865] explain that profilers should be used for profiling, not benchmarking

2008-09-14 Thread Fredrik Lundh
Fredrik Lundh [EMAIL PROTECTED] added the comment: (the reason this is extra bad for C modules is that the profilers introduce overhead for Python code, but not for C-level functions. For example, using the standard profiler to benchmark parser performance for xml.etree.ElementTree vs

[issue3865] explain that profilers should be used for profiling, not benchmarking

2008-09-14 Thread Fredrik Lundh
New submission from Fredrik Lundh [EMAIL PROTECTED]: You often see people using the profiler for benchmarking instead of profiling. I suggest adding a note that explains that the profiler modules are designed to provide an execution profile for a given program, not for benchmarking different

Re: XML RPC Problem....

2008-09-13 Thread Fredrik Lundh
Usman Ajmal wrote: Please explain the arguments of send_request. What exactly are the connection, handler and request_body? It will be really helpful if you give an example of how do i call send_request you don't call send_request. you should pass the SecureTransport instance as an

Re: book example confusion

2008-09-13 Thread Fredrik Lundh
byron wrote: Being that each function is an object, a name assignment to (tmp1,tmp2) doesn't actually evaluate or run the function itself until the name is called.. the above would be true if the code had been tmp1, tmp2 = f1, f2 but it isn't. look again. /F --

Re: XML RPC Problem....

2008-09-13 Thread Fredrik Lundh
Usman Ajmal wrote: Where exactly should i call ServerProxy? Following is the code from my client.py ServerProxy is the preferred name. Server is an old alias for the same class. t = SecureTransport() t.set_authorization(ustring, text_ucert) server =

Re: XML RPC Problem....

2008-09-13 Thread Fredrik Lundh
Usman Ajmal wrote: Problem is that when i start client (while the server is already running), i get an error i.e. Error 500 Internal Server Error that's a server error, not a client error. check the server logs (e.g. error.log or similar). /F --

Re: How to run PyOS_InputHook from python code (i.e. yield to event loops)

2008-09-13 Thread Fredrik Lundh
ville wrote: That's tk-specific, right? I'm looking for a snippet that - Would not be tied to tk upstream, you said: My actual use case is to keep a tkinter application responsive /F -- http://mail.python.org/mailman/listinfo/python-list

Re: Checking the boolean value of a collection

2008-09-13 Thread Fredrik Lundh
Marco Bizzarri wrote: class FolderInUse: def true_for(self, archivefolder): return any([instance.forbid_to_close(archivefolder) for instance in self.core.active_outgoing_registration_instances()]) Is this any better? The true_for name does not satisfy me a lot...

Re: code style and readability [was: Re: Checking the boolean value of a collection]

2008-09-13 Thread Fredrik Lundh
Larry Bates wrote: I also have a personal dislike for early returns because I've found it makes it harder insert execution trace logging into the code. in a language that makes it trivial to wrap arbitrary callables in tracing wrappers? /F --

[issue3825] Major reworking of Python 2.5.2 re module

2008-09-13 Thread Fredrik Lundh
Fredrik Lundh [EMAIL PROTECTED] added the comment: A bit more information on the changes to the core engine that are responsible for the 2x speedup (on what?) would be nice to have, I think (especially since you seem to have removed the KMP prefix scanner). (Isn't there a RE benchmark suite

Re: Checking the boolean value of a collection

2008-09-12 Thread Fredrik Lundh
Marco Bizzarri wrote: Can you clarify where I can find any? It seems to me I'm unable to find it... it's a 2.5 addition. to use this in a future-compatible way in 2.3, you can add try: any except NameError: def any(iterable): for element in

Re: Matching horizontal white space

2008-09-12 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: multipleSpaces = re.compile(u'\\h+') importantTextString = '\n \n \n \t\t ' importantTextString = multipleSpaces.sub(M, importantTextString) what's \\h supposed to mean? I would have expected consecutive spaces and tabs to be replaced by M but nothing is being

Re: Checking the boolean value of a collection

2008-09-12 Thread Fredrik Lundh
Marco Bizzarri wrote: I would like to make this available to the whole project. I suspect I could put it in the package __init__.py... in that way, the __builtins__ namespace should have it... am I right? the __init__ module for package foo defines the contents of the foo module; it doesn't

Re: setattr in class

2008-09-12 Thread Fredrik Lundh
Bojan Mihelac wrote: Hi all - when trying to set some dynamic attributes in class, for example: class A: for lang in ['1', '2']: exec('title_%s = lang' % lang) #this work but is ugly # setattr(A, title_%s % lang, lang) # this wont work setattr(A, title_1, x) # this work

Re: Checking the boolean value of a collection

2008-09-12 Thread Fredrik Lundh
D'Arcy J.M. Cain wrote: Is there ever any advantage to having something as a builtin rather than as a regular user method? What difference does it make to the running script? I can see that adding bar from module foo to __builtins__ means that you can use bar() instead of foo.bar(). Is that

Re: lacking follow-through

2008-09-12 Thread Fredrik Lundh
Steve Holden wrote: The defence rests. can you please stop quoting that guy, so we don't have to killfile you as well... /F -- http://mail.python.org/mailman/listinfo/python-list

Re: Which version

2008-09-12 Thread Fredrik Lundh
Don wrote: I'm a reasonably experienced in other languages and have just decided to get my feet wet with Python. But I'm using FC6 which has v2.4.4 installed, is this good enough to start out with or am I likely to encounter bugs that have been fixed in later versions. Python 2.4 is

Re: Which version

2008-09-12 Thread Fredrik Lundh
Eric Wertman wrote: The subprocess module is one though footnote: subprocess works on older versions too, and can be trivially installed along with your application under Python 2.2 and 2.3. binary builds for Windows are available here: http://effbot.org/downloads/#subprocess /F --

Re: I want to use a C++ library from Python

2008-09-11 Thread Fredrik Lundh
Anders Eriksson wrote: I have looked (very briefly) at the three framework you mention but they all need the source code of the C++? No, they need header files and an import library to be able to compile the bindings and link them to your DLL. Do you know enough about C/C++ build issues to

  1   2   3   4   5   6   7   8   9   10   >