Re: User input masks - Access Style

2010-12-26 Thread flebber
On Dec 27, 6:01 pm, Tim Harig wrote: > On 2010-12-27, flebber wrote: > > > Is there anyay to use input masks in python? Similar to the function > > found in access where a users input is limited to a type, length and > > format. > > > So in my case I want to ensure that numbers are saved in a bas

Re: User input masks - Access Style

2010-12-26 Thread Tim Harig
On 2010-12-27, Tim Harig wrote: > ... if re.match(r'''^[0-9]{2}:[0-9]{2}:[0-9]{2}$''', timeInput) == None: [SNIP] > Currency works the same way using validating it against: > r'''[0-9]+\.[0-9]{2}''' Sorry, you need to check to make sure that there are no trailing characters as in the example abov

Re: How to pop the interpreter's stack?

2010-12-26 Thread Ethan Furman
Steven D'Aprano wrote: ... > I think critics of my position have forgotten what it's like to learning the language. One of the most valuable skills to learn is to *ignore parts of the traceback* -- a skill that takes practice and familiarity with the library or function in use. To those who a

Re: User input masks - Access Style

2010-12-26 Thread Tim Harig
On 2010-12-27, flebber wrote: > Is there anyay to use input masks in python? Similar to the function > found in access where a users input is limited to a type, length and > format. > > So in my case I want to ensure that numbers are saved in a basic > format. > 1) Currency so input limited to 000

Re: string u'hyv\xe4' to file as 'hyvä'

2010-12-26 Thread Mark Tolonen
"gintare" wrote in message news:83dc3076-9ddc-42bd-8c33-6af96b263...@l32g2000yqc.googlegroups.com... Hello, STILL do not work. WHAT to be done. import codecs item=u'hyv\xe4' F=codecs.open('/opt/finnish.txt', 'w+', 'utf8') F.writelines(item.encode('utf8')) F.close() In file i find 'hyv\xe4' i

Re: string u'hyv\xe4' to file as 'hyvä'

2010-12-26 Thread gintare
Hello, STILL do not work. WHAT to be done. import codecs item=u'hyv\xe4' F=codecs.open('/opt/finnish.txt', 'w+', 'utf8') F.writelines(item.encode('utf8')) F.close() In file i find 'hyv\xe4' instead of hyvä. (Sorry for mistyping in previous letter about 'latin-1'. I was making all possible combin

Re: How to pop the interpreter's stack?

2010-12-26 Thread Steven D'Aprano
On Sun, 26 Dec 2010 17:12:50 -0800, misno...@gmail.com wrote: > On Dec 23, 3:22 am, Steven D'Aprano +comp.lang.pyt...@pearwood.info> wrote: >> You seem to have completely missed that there will be no bug report, >> because this isn't a bug. (Or if it is a bug, the bug is elsewhere, >> external to

Re: How to pop the interpreter's stack?

2010-12-26 Thread Steven D'Aprano
On Sun, 26 Dec 2010 09:15:32 -0800, Ethan Furman wrote: > Steven D'Aprano wrote: >> Right. But I have thought of a clever trick to get the result KJ was >> asking for, with the minimum of boilerplate code. Instead of this: >> >> >> def _pre_spam(args): >> if condition(args): >> raise

Re: __delitem__ "feature"

2010-12-26 Thread Steven D'Aprano
On Sun, 26 Dec 2010 18:49:55 +, kj wrote: > In Ian Kelly > writes: > >>On 12/26/2010 10:53 AM, kj wrote: >>> P.S. If you uncomment the commented-out line, and comment out the last >>> line of the __init__ method (which installs self._delitem as >>> self.__delitem__) then *all* the deletion

User input masks - Access Style

2010-12-26 Thread flebber
Is there anyay to use input masks in python? Similar to the function found in access where a users input is limited to a type, length and format. So in my case I want to ensure that numbers are saved in a basic format. 1) Currency so input limited to 000.00 eg 1.00, 2.50, 13.80 etc For sports tim

Re: IDLE GUI not working

2010-12-26 Thread Grant Andrew
On Sun, Dec 26, 2010 at 4:33 PM, Python Programming wrote: > Hello all, > > Newbie here so go easy on me. I've been trying to get the IDLE GUI to > work on my machine, but have been unsuccessful so far. I have an IBM > Thinkpad running Windows XP and it has an older version of Python > running (

Re: How to pop the interpreter's stack?

2010-12-26 Thread Carl Banks
On Dec 25, 2:49 pm, Steven D'Aprano wrote: > On Sat, 25 Dec 2010 09:17:27 -0500, Robert Kern wrote: > > On 12/24/10 5:14 PM, Ethan Furman wrote: > > >> There are also times when I change the exception being raised to match > >> what python expects from that type of object -- for example, from > >>

Re: How to pop the interpreter's stack?

2010-12-26 Thread Carl Banks
On Dec 26, 11:09 am, kj wrote: > In writes: > > >Except that the *caller* never gets the traceback (unless if it deliberately > >inspects the stack for some metaprogramming reason). It gets the exception, > >and > >that is the same no matter what you do. The developer/user gets the > >tracebac

Re: How to pop the interpreter's stack?

2010-12-26 Thread misno...@gmail.com
On Dec 23, 3:22 am, Steven D'Aprano wrote: > You seem to have completely missed that there will be no bug report, > because this isn't a bug. (Or if it is a bug, the bug is elsewhere, > external to the function that raises the exception.) It is part of the > promised API. The fact that the excepti

Re: How to pop the interpreter's stack?

2010-12-26 Thread Steve Holden
On 12/26/2010 2:14 PM, kj wrote: > In Ethan Furman > writes: > >> You failed to mention that cleverness is not a prime requisite of the >> python programmer -- in fact, it's usually frowned upon. > > That's the party line, anyway. I no longer believe it. I've been > crashing against one bit

IDLE GUI not working

2010-12-26 Thread Python Programming
Hello all, Newbie here so go easy on me. I've been trying to get the IDLE GUI to work on my machine, but have been unsuccessful so far. I have an IBM Thinkpad running Windows XP and it has an older version of Python running (2.2, I believe). When I try to use the shortcut to open the IDLE GUI n

Re: string u'hyv\xe4' to file as 'hyvä'

2010-12-26 Thread MRAB
On 26/12/2010 22:43, gintare wrote: Could you please help me with special characters saving to file. I need to write the string u'hyv\xe4' to file. I would like to open file and to have line 'hyvä' import codecs word= u'hyv\xe4' F=codecs.open(/opt/finnish.txt, 'w+','Latin-1') This opens the f

Need urllib.urlretrieve and urllib2.OpenerDirector together

2010-12-26 Thread Juanlu_001
Hello everyone. I'm writing a script in Python 2.7 which uses a urllib2.OpenerDirector instance via urllib2.build_opener() to take advantage of the urllib2.HTTPCookieProcessor class, because I need to store and re-send the cookies I get: opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(co

Re: inspect.getsource bug?

2010-12-26 Thread Ciccio
On 26 Dic, 19:24, Ciccio wrote: > Try this: > 1) define a function 'foo' in a script > 2) runfile the script from a shell > 3) do 'inspect.getsource(foo)' > 4) change the source of 'foo' > 5) runfile the script from the same shell > 6) do 3 again > > On my 2.6.6 getsource returns twice the same co

string u'hyv\xe4' to file as 'hyvä'

2010-12-26 Thread gintare
Could you please help me with special characters saving to file. I need to write the string u'hyv\xe4' to file. I would like to open file and to have line 'hyvä' import codecs word= u'hyv\xe4' F=codecs.open(/opt/finnish.txt, 'w+','Latin-1') F.writelines(item.encode('Latin-1')) F.writelines(item.

Re: lxml etree question

2010-12-26 Thread Stefan Behnel
Jim, 26.12.2010 00:32: On Dec 25, 5:33 am, Stefan Behnel wrote: lxml knows about this special case, so you can write {http://www.w3.org/XML/1998/namespace}lang and lxml will take care of using the right prefix. Stefan, thank you for the software, which has helped me a great deal. I

Re: __delitem__ "feature"

2010-12-26 Thread Christian Heimes
Am 26.12.2010 19:49, schrieb kj: > How do you know this? Is this documented? Or is this a case of > Monday-night quarterbacking? Please stop bitching around. You know that by carefully reading the documentation: http://docs.python.org/reference/datamodel.html#special-method-lookup-for-new-style-

Re: Trying to parse a HUGE(1gb) xml file

2010-12-26 Thread Tim Harig
On 2010-12-26, Stefan Behnel wrote: > Tim Harig, 26.12.2010 10:22: >> On 2010-12-26, Stefan Behnel wrote: >>> Tim Harig, 26.12.2010 02:05: On 2010-12-25, Nobody wrote: > On Sat, 25 Dec 2010 14:41:29 -0500, Roy Smith wrote: >> Of course, one advantage of XML is that with so much redund

Re: Python Web App

2010-12-26 Thread Sean
@Katie Thank you I considered this option until I realized it wouldn't let me do anything other than ping from the command line. The rest of you all make valid points after doing a little more research on my own I found some really nice web based text editors but they didn't have any testing abili

A Brief Illustrated Guide To Understanding Islam Home

2010-12-26 Thread go.g...@hotmail.com
A Brief Illustrated Guide To Understanding Islam Home http://www.islam-guide.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: How to pop the interpreter's stack?

2010-12-26 Thread John Nagle
On 12/25/2010 2:50 PM, Steven D'Aprano wrote: On Fri, 24 Dec 2010 10:51:32 -0800, John Nagle wrote: On 12/24/2010 3:24 AM, Carl Banks wrote: On Dec 24, 1:24 am, Steven D'Aprano wrote: All I'm suggesting is that there should be a way of reducing the boilerplate needed for this idiom: de

Re: How to pop the interpreter's stack?

2010-12-26 Thread kj
In Ethan Furman writes: >You failed to mention that cleverness is not a prime requisite of the >python programmer -- in fact, it's usually frowned upon. That's the party line, anyway. I no longer believe it. I've been crashing against one bit of cleverness after another in Python's unificat

Re: How to pop the interpreter's stack?

2010-12-26 Thread kj
In writes: >Except that the *caller* never gets the traceback (unless if it deliberately >inspects the stack for some metaprogramming reason). It gets the exception, >and >that is the same no matter what you do. The developer/user gets the traceback, >and those implementation details *are* of

Re: Keeping track of the N largest values

2010-12-26 Thread Stefan Sonnenberg-Carstens
Am 25.12.2010 16:42, schrieb Roy Smith: I'm processing a stream of N numbers and want to keep track of the K largest. There's too many numbers in the stream (i.e. N is too large) to keep in memory at once. K is small (100 would be typical). > From a theoretical point of view, I should be able

Re: __delitem__ "feature"

2010-12-26 Thread kj
In Ian Kelly writes: >On 12/26/2010 10:53 AM, kj wrote: >> P.S. If you uncomment the commented-out line, and comment out the >> last line of the __init__ method (which installs self._delitem as >> self.__delitem__) then *all* the deletion attempts invoke the >> __delitem__ method, and are there

Re: type(d) != type(d.copy()) when type(d).issubclass(dict)

2010-12-26 Thread kj
In Duncan Booth writes: >kj wrote: >> Watch this: >> > class neodict(dict): pass >> ... > d = neodict() > type(d) >> > type(d.copy()) >> >> >> >> Bug? Feature? Genius beyond the grasp of schlubs like me? >Feature. >In (almost?) all cases any objects constructed by a s

Re: type(d) != type(d.copy()) when type(d).issubclass(dict)

2010-12-26 Thread kj
"John O'Hagan" writes: >IMO one of the benefits of subclassing is that you can just "bolt on" >additional behaviour without having to know all the inner workings of the >superclass, a benefit that is somewhat defeated by this behaviour of builtins. I agree. I've read the old post/articles b

Re: __delitem__ "feature"

2010-12-26 Thread Christian Heimes
Am 26.12.2010 18:53, schrieb kj: > It means that, for both subclasses, del fails to trigger the > dynamically installed instance method __delitem__. Magic methods like __delitem__ are looked up on the type, not on the instance. You can't change the behaviour on instances. > If I replace dict with

inspect.getsource bug?

2010-12-26 Thread Ciccio
Try this: 1) define a function 'foo' in a script 2) runfile the script from a shell 3) do 'inspect.getsource(foo)' 4) change the source of 'foo' 5) runfile the script from the same shell 6) do 3 again On my 2.6.6 getsource returns twice the same code. I couldn't find very much about this, is there

Re: __delitem__ "feature"

2010-12-26 Thread Ian Kelly
On 12/26/2010 10:53 AM, kj wrote: P.S. If you uncomment the commented-out line, and comment out the last line of the __init__ method (which installs self._delitem as self.__delitem__) then *all* the deletion attempts invoke the __delitem__ method, and are therefore blocked. FWIW. Because subcl

__delitem__ "feature"

2010-12-26 Thread kj
When I execute this file: #-- def nodelfactory(klass): class nodel(klass): def _delitem(self, _): raise TypeError("can't delete") # __delitem__ = _delitem def __init__(self, *a, **k):

Re: How to pop the interpreter's stack?

2010-12-26 Thread Ethan Furman
Steven D'Aprano wrote: Right. But I have thought of a clever trick to get the result KJ was asking for, with the minimum of boilerplate code. Instead of this: def _pre_spam(args): if condition(args): raise SomeException("message") if another_condition(args): raise Anoth

Re: How to pop the interpreter's stack?

2010-12-26 Thread Ethan Furman
Steven D'Aprano wrote: On Sat, 25 Dec 2010 09:17:27 -0500, Robert Kern wrote: On 12/24/10 5:14 PM, Ethan Furman wrote: There are also times when I change the exception being raised to match what python expects from that type of object -- for example, from WhatEverException to KeyError for a d

Re: How to pop the interpreter's stack?

2010-12-26 Thread Ethan Furman
Carl Banks wrote: Python is not, and never has been, about hiding internal details. It's about openness, and there's no reason a traceback should hide internal details any more than a class should--in fact hiding information in the traceback is far worse, because you're suppressing information th

Re: Keeping track of the N largest values

2010-12-26 Thread Roy Smith
In article , n00m wrote: > from bisect import insort_left > > K = 5 > top = [] > while 1: > x = input() > if len(top) < K: > insort_left(top, x) > elif x > top[0]: > del top[0] > insort_left(top, x) > print top > > > will be enough Hmmm, that's an int

Re: Design Ideals Goals Python 3 - Forest for the trees

2010-12-26 Thread Jean-Paul Calderone
On Dec 26, 5:34 am, Alice Bevan–McGregor wrote: > > I've never really attempted to use JIT optimizers due to the fact that > all of my development and production environments are 64-bit, and I > haven't found one yet that supports 64-bit properly.  Relying on dead > projects, however, is an issue

Re: Keeping track of the N largest values

2010-12-26 Thread n00m
from bisect import insort_left K = 5 top = [] while 1: x = input() if len(top) < K: insort_left(top, x) elif x > top[0]: del top[0] insort_left(top, x) print top will be enough -- http://mail.python.org/mailman/listinfo/python-list

Re: Keeping track of the N largest values

2010-12-26 Thread Peter Otten
Roy Smith wrote: > In article , > Duncan Booth wrote: > >> Roy Smith wrote: >> >> > >> > I'm processing a stream of N numbers and want to keep track of the K >> > largest. There's too many numbers in the stream (i.e. N is too large) >> > to keep in memory at once. K is small (100 would be

Re: GUI Tools for Python 3.1

2010-12-26 Thread Hans-Peter Jansen
On Friday 24 December 2010, 03:58:15 Randy Given wrote: > Lots of stuff for 2.6 and 2.7 -- what GUI tools are there for 3.1? PyQt4 of course. http://www.riverbankcomputing.com Pete -- http://mail.python.org/mailman/listinfo/python-list

Re: Trying to parse a HUGE(1gb) xml file

2010-12-26 Thread Stefan Behnel
Tim Harig, 26.12.2010 10:22: On 2010-12-26, Stefan Behnel wrote: Tim Harig, 26.12.2010 02:05: On 2010-12-25, Nobody wrote: On Sat, 25 Dec 2010 14:41:29 -0500, Roy Smith wrote: Of course, one advantage of XML is that with so much redundant text, it compresses well. We typically see gzip compr

Re: Design Ideals Goals Python 3 - Forest for the trees

2010-12-26 Thread Alice Bevan–McGregor
So do the new changes(to the GIL) nullify concerns raised by David Beazely here http://dabeaz.com/python/UnderstandingGIL.pdf Ah, good catch. I had watched the recorded presentation some time ago. Yes, the rewritten GIL should alleviate those problems. Instead of simply releasing and re-acqu

Re: Trying to parse a HUGE(1gb) xml file

2010-12-26 Thread Tim Harig
On 2010-12-26, Stefan Behnel wrote: > Tim Harig, 26.12.2010 02:05: >> On 2010-12-25, Nobody wrote: >>> On Sat, 25 Dec 2010 14:41:29 -0500, Roy Smith wrote: Of course, one advantage of XML is that with so much redundant text, it compresses well. We typically see gzip compression ratios

Re: Trying to parse a HUGE(1gb) xml file

2010-12-26 Thread Tim Harig
On 2010-12-26, Nobody wrote: > On Sun, 26 Dec 2010 01:05:53 +, Tim Harig wrote: > >>> XML is typically processed sequentially, so you don't need to create a >>> decompressed copy of the file before you start processing it. >> >> Sometimes XML is processed sequentially. When the markup footpr

Re: Trying to parse a HUGE(1gb) xml file

2010-12-26 Thread Stefan Behnel
Tim Harig, 26.12.2010 02:05: On 2010-12-25, Nobody wrote: On Sat, 25 Dec 2010 14:41:29 -0500, Roy Smith wrote: Of course, one advantage of XML is that with so much redundant text, it compresses well. We typically see gzip compression ratios of 20:1. But, that just means you can archive them e

Re: lxml etree question

2010-12-26 Thread Carl Banks
On Dec 24, 10:17 am, Adam Tauno Williams wrote: > On Fri, 2010-12-24 at 20:48 +0530, Nitin Pawar wrote: > > On Fri, Dec 24, 2010 at 8:40 PM, Jim wrote: > >         Hello,  I wonder if someone knows about lxml.etree and > >         namespaces? > > Yes, and don't. He's using lxml.etree (which is a

Re: How to pop the interpreter's stack?

2010-12-26 Thread Carl Banks
On Dec 25, 6:21 am, Robert Kern wrote: > On 12/24/10 4:24 AM, Steven D'Aprano wrote: > > > On Thu, 23 Dec 2010 22:38:05 -0800, Carl Banks wrote: > >> OTOH, going the extra mile to hide useful information from a user is > >> asinine. As a user, I will decide for myself how I want to use > >> implem

Re: How to pop the interpreter's stack?

2010-12-26 Thread Carl Banks
On Dec 25, 2:49 pm, Steven D'Aprano wrote: > But that's a separate issue from what is being discussed here. What we're > discussing here is the idea that a function should be able to delegate > work to private subroutines without the caller being aware of that fact. I can't fathom any possible re