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

2010-08-31 Thread Jervis Whitley
Jervis Whitley jervi...@gmail.com 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 rep...@bugs.python.org http

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

2010-08-28 Thread Jervis Whitley
Jervis Whitley jervi...@gmail.com 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

[issue9574] complex does not parse strings containing decimals

2010-08-12 Thread Jervis Whitley
New submission from Jervis Whitley jervi...@gmail.com: 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 complex

[issue9574] complex does not parse strings containing decimals

2010-08-12 Thread Jervis Whitley
Jervis Whitley jervi...@gmail.com 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 rep...@bugs.python.org http

Re: Introducing Python to others

2009-03-26 Thread Jervis Whitley
class Vector(list): ...   def __add__(self, other): ...     return map(add, self, other) ... x = Vector([1,2]) I've used the complex type for a similar problem (2D Cartesian points) in the past, I saw the suggestion once on the pygame list. x = complex(1,2) x + x (2 + 4j)

Re: Neatest way to do a case insensitive in?

2009-03-19 Thread Jervis Whitley
   if stringA.lower() in stringB.lower():        bla bla bla from string import lower if lower(stringA) in lower(stringB): # was this what you were after? Cheers, Jervis -- http://mail.python.org/mailman/listinfo/python-list

Re: Neatest way to do a case insensitive in?

2009-03-19 Thread Jervis Whitley
On Fri, Mar 20, 2009 at 8:28 AM, Albert Hopkins mar...@letterboxes.org wrote: On Fri, 2009-03-20 at 07:25 +1100, Jervis Whitley wrote:    if stringA.lower() in stringB.lower():        bla bla bla     from string import lower     if lower(stringA) in lower(stringB

Re: Neatest way to do a case insensitive in?

2009-03-19 Thread Jervis Whitley
I agree that it's an alternative. There are a number of alternatives. However the OP was asking for a neater/easier alternative. I argue that introducing an external module/function to do the exact same thing as a built-in type's method doesn't exactly qualify as a neater/easier alternative.

Re: How to do this in Python?

2009-03-18 Thread Jervis Whitley
What I was wondering was whether a similar construct was considered for a while loop or even an if clause, because then the above could be written like this:  if open(filename, 'rb') as f:      while f.read(1000) as buf:          # do something with 'buf' see here, and the associated bug

[issue1714448] if something as x:

2009-03-14 Thread Jervis Whitley
Jervis Whitley jervi...@gmail.com 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 available

[issue1714448] if something as x:

2009-03-14 Thread Jervis Whitley
Jervis Whitley jervi...@gmail.com added the comment: If we allow this, how many of the following will be allowed? if expr as name: block while expr as name: block 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 jervi...@gmail.com 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 anything else is opening the door to a world

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

2009-03-10 Thread Jervis Whitley
Jervis Whitley jervi...@gmail.com 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, ImportError

[issue1818] Add named tuple reader to CSV module

2009-03-08 Thread Jervis Whitley
Jervis Whitley jervi...@gmail.com 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 Skip

[issue1818] Add named tuple reader to CSV module

2009-03-08 Thread Jervis Whitley
Jervis Whitley jervi...@gmail.com 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 Antoine subclass

[issue1818] Add named tuple reader to CSV module

2009-03-08 Thread Jervis Whitley
Changes by Jervis Whitley jervi...@gmail.com: Removed file: http://bugs.python.org/file13268/ntreader5_py3_1.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1818

[issue1818] Add named tuple reader to CSV module

2009-03-08 Thread Jervis Whitley
Changes by Jervis Whitley jervi...@gmail.com: Added file: http://bugs.python.org/file13275/ntreader6_py27.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1818

[issue1818] Add named tuple reader to CSV module

2009-03-08 Thread Jervis Whitley
Jervis Whitley jervi...@gmail.com 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 rep...@bugs.python.org http

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

2009-03-08 Thread Jervis Whitley
Changes by Jervis Whitley jervi...@gmail.com: -- nosy: +jdwhitley nosy_count: 1.0 - 2.0 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5455

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

2009-03-08 Thread Jervis Whitley
Jervis Whitley jervi...@gmail.com 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, newline

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

2009-03-08 Thread Jervis Whitley
Jervis Whitley jervi...@gmail.com 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

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

2009-03-08 Thread Jervis Whitley
Jervis Whitley jervi...@gmail.com 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

[issue1818] Add named tuple reader to CSV module

2009-03-07 Thread Jervis Whitley
Jervis Whitley jervi...@gmail.com 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 rep

[issue1818] Add named tuple reader to CSV module

2009-02-26 Thread Jervis Whitley
Jervis Whitley jervi...@gmail.com 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 interpreted

Re: Pythonic way to determine if one char of many in a string

2009-02-18 Thread Jervis Whitley
What happens when you have hundreds of megabytes, I don't know. I hope I never have to test a word that is hundreds of megabytes long for a vowel :) -- http://mail.python.org/mailman/listinfo/python-list

Re: Pythonic way to determine if one char of many in a string

2009-02-17 Thread Jervis Whitley
This moves the for-loop out of slow Python into fast C and should be much, much faster for very large input. _Should_ be faster. Here is my test on an XP system Python 2.5.4. I had similar results on python 2.7 trunk. WORD = 'g' * 100 WORD2 = 'g' * 50 + 'U' BIGWORD = 'g' * 1 + 'U' def

Re: Avoiding argument checking in recursive calls

2009-02-11 Thread Jervis Whitley
You've merely replaced the 'test n0' with 'not check' at the expense of an additional parameter that has to be passed each time (and the additional test 'n0' for the first iteration). -- http://mail.python.org/mailman/listinfo/python-list I think you have missed the point. The OP stated that

Re: Avoiding argument checking in recursive calls

2009-02-11 Thread Jervis Whitley
You've merely replaced the 'test n0' with 'not check' at the expense of an additional parameter that has to be passed each time (and the additional test 'n0' for the first iteration). -- http://mail.python.org/mailman/listinfo/python-list I think you have missed the point. The OP stated

Re: Avoiding argument checking in recursive calls

2009-02-10 Thread Jervis Whitley
I've done this: def _fact(n): if n = 0: return 1 return _fact(n-1)*n def fact(n): if n 0: raise ValueError return _fact(n) but that's ugly. What else can I do? Hello, an idea is optional keyword arguments. def fact(n, check=False): if not check: if n 0: raise

[issue1818] Add named tuple reader to CSV module

2009-02-10 Thread Jervis Whitley
Jervis Whitley jervi...@gmail.com 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

[issue1818] Add named tuple reader to CSV module

2009-02-09 Thread Jervis Whitley
Jervis Whitley jervi...@gmail.com 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', 'f2

Re: Use list name as string

2009-02-04 Thread Jervis Whitley
On Thu, Feb 5, 2009 at 3:57 AM, Vincent Davis vinc...@vincentdavis.net wrote: Sorry for not being clear I would have something like this x = [1, 2, 3,5 ,6 ,9,234] Then def savedata(dataname): .. savedata(x) this would save a to a file called x.csv This is my problem, getting the

Re: Use list name as string

2009-02-04 Thread Jervis Whitley
On Thu, Feb 5, 2009 at 2:37 PM, Vincent Davis vinc...@vincentdavis.net wrote: Jervis Whitley wrote Although you should really solve your problem by thinking about it from a completely different angle, maybe subclassing your datatype and adding a 'name' attribute ? I'm sure some of the others

Re: Comparing dates?

2009-02-02 Thread Jervis Whitley
Most will have functions like str[pf]time that could be used to similar effect. In mysql this is: str_to_date( '21/02/2008', '%d/%m/%Y') and oracle: to_date( '21/02/2008', 'dd-mm-') Cheers, -- http://mail.python.org/mailman/listinfo/python-list

Re: what IDE is the best to write python?

2009-02-02 Thread Jervis Whitley
On Mon, Feb 2, 2009 at 2:46 PM, Chris Jones cjns1...@gmail.com wrote: On Sun, Feb 01, 2009 at 07:26:24PM EST, Ben Finney wrote: a...@pythoncraft.com (Aahz) writes: Just to register a contrary opinion: I *hate* syntax highlighting On what basis? Real men hate syntax highlighting. --

Re: search speed

2009-01-30 Thread Jervis Whitley
Today this works fine, it saves me a lot of manuall work, but a seach takes around 5 min, so my questin is is there another way of search in a file (Today i step line for line and check) If the files you are searching are located at some other location on a network, you may find that much

Re: problem with program - debugging leading nowhere

2009-01-30 Thread Jervis Whitley
error message: Traceback (most recent call last): File string, line 1, in string IndentationError: expected an indented block (string, line 39) code: http://pastebin.com/f2f971f91 Hi, It looks like you have commented out a line on line 30, you need to place something in here, as

problem with program - debugging leading nowhere

2009-01-30 Thread Jervis Whitley
-- Forwarded message -- From: Jervis Whitley jervi...@gmail.com Date: Sat, Jan 31, 2009 at 10:59 AM Subject: Re: problem with program - debugging leading nowhere To: Matthew Sacks ntw...@gmail.com Cc: python-list@python.org error message: Traceback (most recent call last

Re: verilog like class w/ bitslicing int/long classtype

2009-01-29 Thread Jervis Whitley
On Fri, Jan 30, 2009 at 9:02 AM, mark.sea...@gmail.com wrote: I'm trying to make a script environment with datatypes (or classes) for accessing hardware registers. At the top level, I would like the ability to bitwise ops if bit slice brackets are used, but if no brackets are used, I would

Re: list subsetting

2009-01-21 Thread Jervis Whitley
On Thu, Jan 22, 2009 at 9:09 AM, Jeff McNeil j...@jmcneil.net wrote: On Jan 21, 4:53 pm, culpritNr1 ig2ar-s...@yahoo.co.uk wrote: Hello All, Say I have a list like this: a = [0 , 1, 3.14, 20, 8, 8, 3.14] Is there a simple python way to count the number of 3.14's in the list in

Re: optimizing large dictionaries

2009-01-15 Thread Jervis Whitley
On Fri, Jan 16, 2009 at 8:39 AM, Per Freem perfr...@yahoo.com wrote: hello i have an optimization questions about python. i am iterating through a file and counting the number of repeated elements. the file has on the order of tens of millions elements... for line in file: try: elt

Re: Python DateTime Manipulation

2009-01-15 Thread Jervis Whitley
On Fri, Jan 16, 2009 at 9:19 AM, Kingston kingston...@gmail.com wrote: I have a user input a date and time as a string that looks like: 200901010100 but I want to do a manipulation where I subtract 7 days from it. The first thing I tried was to turn the string into a time with the format

Re: Programming friction

2009-01-13 Thread Jervis Whitley
On Wed, Jan 14, 2009 at 12:29 PM, killsto kilian...@gmail.com wrote: force. So lets say I am slowing down at a rate of -2m/s^2, if I hit 1, the next number will be -1 and I shoot off in the other direction. How do I fix this an still have backwards movement? --

Re: Object help

2009-01-11 Thread Jervis Whitley
On Mon, Jan 12, 2009 at 9:06 AM, killsto kilian...@gmail.com wrote: I would think something like: def newball(): x = last_named_ball + 1 ball_x = ball(size, etc) # this initializes a new ball return ball_x But then that would just name a ball ball_x, not ball_1 or ball_2. Is

Re: embedding python in wxpython

2008-12-30 Thread Jervis Whitley
On Wed, Dec 31, 2008 at 7:21 AM, Stef Mientki stef.mien...@gmail.comwrote: 5lvqbw...@sneakemail.com wrote: Hi, I've looked around for a way to allow a python console from within a wxPython application, but have only found stuff on embedded/ extending python with C/C++ or wxWidgets in C++,