[issue9574] allow whitespace around central '+' in complex constructor

2010-08-31 Thread Jervis Whitley
Jervis Whitley added the comment: Here is a patch to document string argument requirements. -- keywords: +patch Added file: http://bugs.python.org/file18686/complex_doc.diff ___ Python tracker <http://bugs.python.org/issue9

[issue9574] allow whitespace around central '+' in complex constructor

2010-08-28 Thread Jervis Whitley
Jervis Whitley added the comment: I can write a documentation patch for this: http://docs.python.org/library/functions.html?highlight=complex#complex to highlight the expected format of the string argument. As others have pointed out here, there are a number of other options available to

[issue9574] complex does not parse strings containing decimals

2010-08-12 Thread Jervis Whitley
Jervis Whitley added the comment: It hadn't occurred to me to try this without spaces. Thank you for pointing this out. Agreed that the enhancement is not essential. -- ___ Python tracker <http://bugs.python.org/i

[issue9574] complex does not parse strings containing decimals

2010-08-12 Thread Jervis Whitley
New submission from Jervis Whitley : complex() raises ValueError when parsing a string argument containing both real and imaginary where one of the real or imaginary is a decimal. To reproduce: >>> complex("1.1 + 2.1j") ValueError: complex() arg is a malformed string >&

[issue1714448] if something as x:

2009-03-14 Thread Jervis Whitley
Jervis Whitley added the comment: > Matthew suggested ~= instead of -> or "as". Try the patch, you can make changes (for those that aren't aware) by changing the token in Grammar/Grammar to whatever you wish. It is easy to do and you need only recompile after this step.

[issue1714448] if something as x:

2009-03-14 Thread Jervis Whitley
Jervis Whitley added the comment: > Regarding the proposed syntax: > if (f() == 'spam') -> name: > newname = name.replace('p', 'h') > Surely that should assign the *bool* result of comparing f() > with 'spam' to name? Doing anythin

[issue1714448] if something as x:

2009-03-14 Thread Jervis Whitley
Jervis Whitley added the comment: > If we allow this, how many of the following will be allowed? > if expr as name: > while expr as name: > expr as name # alternative to "name = expr" This patch implements your final point: expr as name (albeit with a nominal '

[issue1714448] if something as x:

2009-03-14 Thread Jervis Whitley
Jervis Whitley added the comment: Hi, I like this idea. I've put together a short patch that will implement inline assignment. if f() -> name: use(name) or more powerfully: if f() -> name == 'spam': usespam(name) the old syntax if something as x: is still avai

[issue4540] typo in a module describes utf-8 as uft-8

2009-03-10 Thread Jervis Whitley
Jervis Whitley added the comment: I can still reproduce on py3 >>> help("modules anything") Traceback (most recent call last): ... This patch works (on Py3.1a1). Amaury, are you still o.k with catching Exception rather than just (SyntaxError, UnicodeDecodeError, Impo

[issue4847] csv fails when file is opened in binary mode

2009-03-08 Thread Jervis Whitley
Jervis Whitley added the comment: Hi all, This patch takes the approach of assuming utf-8 format encoding for files opened with 'rb' directive. That is: 1. Check if each line is Unicode Or Bytes Type. 2. If Bytes, get char array reference to internal buffer. 3. use PyUnicode_Fro

[issue5455] csv module no longer works as expected when file opened in binary mode

2009-03-08 Thread Jervis Whitley
Jervis Whitley added the comment: Hi Skip, Currently, once we are sure the lineobj is a unicode obj we then get it's internal buffer using: line = PyUnicode_AsUnicode(lineobj); for the purpose of iterating through the line. is there an opportunity to use: line = PyBytes_AsString(li

[issue5455] csv module no longer works as expected when file opened in binary mode

2009-03-08 Thread Jervis Whitley
Jervis Whitley added the comment: in _csv.c, the check is done here: lineobj = PyIter_Next(self->input_iter); if (lineobj == NULL) { /* End of input OR exception */ if (!PyErr_Occurred() && self->field_len != 0) PyErr_Format(error_obj, "ne

[issue5455] csv module no longer works as expected when file opened in binary mode

2009-03-08 Thread Jervis Whitley
Changes by Jervis Whitley : -- nosy: +jdwhitley nosy_count: 1.0 -> 2.0 ___ Python tracker <http://bugs.python.org/issue5455> ___ ___ Python-bugs-list mai

[issue1818] Add named tuple reader to CSV module

2009-03-08 Thread Jervis Whitley
Jervis Whitley added the comment: Updated version of docs for 2.7 and 3k. -- message_count: 29.0 -> 30.0 Added file: http://bugs.python.org/file13274/ntreader6_py3.diff ___ Python tracker <http://bugs.python.org/iss

[issue1818] Add named tuple reader to CSV module

2009-03-08 Thread Jervis Whitley
Changes by Jervis Whitley : Added file: http://bugs.python.org/file13275/ntreader6_py27.diff ___ Python tracker <http://bugs.python.org/issue1818> ___ ___ Python-bug

[issue1818] Add named tuple reader to CSV module

2009-03-08 Thread Jervis Whitley
Changes by Jervis Whitley : Removed file: http://bugs.python.org/file13268/ntreader5_py3_1.diff ___ Python tracker <http://bugs.python.org/issue1818> ___ ___ Python-bug

[issue1818] Add named tuple reader to CSV module

2009-03-08 Thread Jervis Whitley
Jervis Whitley added the comment: Antoine> I don't understand why NamedTupleReader requires the Antoine> fieldnames array Antoine> rather than the namedtuple class itself. If you could pass it Antoine> the namedtuple class, users could choose whatever namedtuple Antoi

[issue1818] Add named tuple reader to CSV module

2009-03-08 Thread Jervis Whitley
Jervis Whitley added the comment: Jervis> in csv.rst removed reference to reader.next() as a public method. Skip> Because? I've not seen any discussion in this issue or in any Skip> other forums Skip> (most certainly not on the c...@python.org mailing list) which would S

[issue1818] Add named tuple reader to CSV module

2009-03-07 Thread Jervis Whitley
Jervis Whitley added the comment: Added a patch against py3k branch. in csv.rst removed reference to reader.next() as a public method. Added file: http://bugs.python.org/file13263/ntreader4_py3_1.diff ___ Python tracker <http://bugs.python.org/issue1

[issue1818] Add named tuple reader to CSV module

2009-02-26 Thread Jervis Whitley
Jervis Whitley added the comment: Skip> Let me be more explicit. I don't know how it implements it, but I think Skip> you really need to give the user the option of specifying the field Skip> names and not reading/writing headers. It can't be implicit as I Skip> int

[issue1818] Add named tuple reader to CSV module

2009-02-10 Thread Jervis Whitley
Jervis Whitley added the comment: Updated NamedTupleReader to give a rename=False keyword argument. rename is passed directly to the namedtuple factory function to enable automatic handling of invalid fieldnames. Two new tests for the rename keyword. Cheers, Added file: http

[issue1818] Add named tuple reader to CSV module

2009-02-09 Thread Jervis Whitley
Jervis Whitley added the comment: An implementation of a namedtuple reader and writer. Created a writer for the case where user would like to specify desired field names and default values on missing field names. e.g. mywriter = NamedTupleWriter(f, fieldnames=['f1',