Re: Comparison with False - something I don't understand

2010-12-02 Thread Paul Rubin
Steven D'Aprano writes: >> There are better ways to handle errors than Python's exception system. > I'm curious -- what ways would they be? > I'm aware of three general exception handling techniques: ... > What else is there? The Erlang approach is to chop the application into a lot of very light

Re: three column dataset - additions and deletions

2010-12-02 Thread draeath
The only reason I want the hash is that I don't want a copy of this string laying around. I also don't need to know what it is, I just need to know if it's different. Think of this as a tripwire - if someone's user access level is changed, we find out. I still think using a separate database (s

Re: Comparison with False - something I don't understand

2010-12-02 Thread Steven D'Aprano
On Thu, 02 Dec 2010 16:35:08 +, Mark Wooding wrote: >> 3. Philosophically I think exception handling is the wrong approach to >> error management. > > There are better ways to handle errors than Python's exception system. I'm curious -- what ways would they be? I'm aware of three general ex

Re: Comparison with False - something I don't understand

2010-12-02 Thread Tim Harig
On 2010-12-03, Harishankar wrote: > On Thu, 02 Dec 2010 16:52:57 +, Tim Harig wrote: > >> If you are having that issue, then you are likely placing the try blocks >> at too low of a level in your code. In general you will find that most >> systems have a gateway function as an entry point to

Re: three column dataset - additions and deletions

2010-12-02 Thread John Nagle
On 12/2/2010 5:06 PM, draeath wrote: On Thu, 02 Dec 2010 22:55:53 +, Tim Harig wrote: Thanks for taking the time to check in on this, Tim! I realize this could likely all be done from inside the database itself - but altering the DB itself is not an option (as the product vendor is very t

Re: To Thread or not to Thread....?

2010-12-02 Thread John Nagle
On 12/1/2010 1:24 AM, Antoine Pitrou wrote: On Wed, 1 Dec 2010 02:45:50 + Jack Keegan wrote: Hi there, I'm currently writing an application to control and take measurements during an experiments. This is to be done on an embedded computer running XPe so I am happy to have python available

Re: Comparison with False - something I don't understand

2010-12-02 Thread Harishankar
On Thu, 02 Dec 2010 16:52:57 +, Tim Harig wrote: > If you are having that issue, then you are likely placing the try blocks > at too low of a level in your code. In general you will find that most > systems have a gateway function as an entry point to the system. If > there is not one already

Re: Comparison with False - something I don't understand

2010-12-02 Thread Harishankar
On Fri, 03 Dec 2010 08:06:35 +1100, Ben Finney wrote: > Raise exceptions for exceptional cases, and define the function > interface so that it's doing one clear job only. Often that involves > breaking a complicated function into several collaborating functions > with simpler interfaces. This is

Re: three column dataset - additions and deletions

2010-12-02 Thread draeath
On Fri, 03 Dec 2010 02:19:54 +, Tim Harig wrote: > a whole bunch of useful stuff Certainly some good points for me to chew on... thanks! -- http://mail.python.org/mailman/listinfo/python-list

Re: three column dataset - additions and deletions

2010-12-02 Thread Tim Harig
On 2010-12-03, MRAB wrote: > On 03/12/2010 01:42, Tim Harig wrote: >> On 2010-12-03, draeath wrote: >>> On Thu, 02 Dec 2010 22:55:53 +, Tim Harig wrote: >>> >>> Thanks for taking the time to check in on this, Tim! >>> So, basically, you want to store a local copy of the data and sync it

Re: three column dataset - additions and deletions

2010-12-02 Thread MRAB
On 03/12/2010 01:42, Tim Harig wrote: On 2010-12-03, draeath wrote: On Thu, 02 Dec 2010 22:55:53 +, Tim Harig wrote: Thanks for taking the time to check in on this, Tim! So, basically, you want to store a local copy of the data and sync it to the original. In a way. I only need to store

Re: three column dataset - additions and deletions

2010-12-02 Thread Tim Harig
On 2010-12-03, draeath wrote: > On Thu, 02 Dec 2010 22:55:53 +, Tim Harig wrote: > > Thanks for taking the time to check in on this, Tim! > >> So, basically, you want to store a local copy of the data and sync it to >> the original. > In a way. I only need to store one copy of the data, and ma

Re: Comparison with False - something I don't understand

2010-12-02 Thread Aahz
In article , Harishankar wrote: > >There are some reasons why I hate exceptions but that is a different >topic. However, in short I can say that personally: > >1. I hate try blocks which add complexity to the code when none is >needed. Try blocks make code much more unreadable in my view and I

Re: Google AI challenge: planet war. Lisp won.

2010-12-02 Thread Ian
On Dec 2, 5:59 pm, tivrfoa wrote: > On Dec 2, 3:06 pm, Xah Lee wrote: > > > > > discovered this rather late. > > > Google has a AI Challenge: planet wars.http://ai-contest.com/index.php > > > it started sometimes 2 months ago and ended first this month. > > > the winner is Gábor Melis, with his c

Re: three column dataset - additions and deletions

2010-12-02 Thread draeath
On Thu, 02 Dec 2010 22:55:53 +, Tim Harig wrote: Thanks for taking the time to check in on this, Tim! > So, basically, you want to store a local copy of the data and sync it to > the original. In a way. I only need to store one copy of the data, and make note of changes between it and the cu

Re: aggregation for a nested dict

2010-12-02 Thread chris
I very appreciate all responses. It's incredible how fast it is! Cheers Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: Changing ' to " in printed representation of dictionaries

2010-12-02 Thread MRAB
On 02/12/2010 23:06, Burton Samograd wrote: Hello, I was wondering if there was a way to change the quote character for keys in string representation of dictionaries, so that they will be JSON equivalent. For example: x = { 'x': 1, 'y': 2 } { 'x': 1, 'y': 2 } `x` "{ 'x': 1, 'y': 2 }" # clos

m2crypto, base64, quoted-printable, xml

2010-12-02 Thread Milan Petrasek
Hi, I have encrypted signed smime message with xml file. Messages are constructed: 1) xml file is embedded to MIME message as attacment (Content-Disposition: attachment;). 2) over whole content MIME message is signed by PKCS#7 and encoded Base64. 3) This message is encrypted by public key. I use

Re: Changing ' to " in printed representation of dictionaries

2010-12-02 Thread Terry Reedy
On 12/2/2010 6:06 PM, Burton Samograd wrote: Hello, I was wondering if there was a way to change the quote character for keys in string representation of dictionaries, so that they will be JSON equivalent. For example: x = { 'x': 1, 'y': 2 } { 'x': 1, 'y': 2 } `x` "{ 'x': 1, 'y': 2 }" # clo

Re: How to send an IP packet in Python?

2010-12-02 Thread Nobody
On Thu, 02 Dec 2010 03:12:42 -0800, yegorov-p wrote: > I have sniffed some packet and now I would like to send it with the > help of python. > But for some reason python send that: > As you can see, python ignores my headers and creates its own. It isn't Python doing that, but the OS. At least

Re: Changing ' to " in printed representation of dictionaries

2010-12-02 Thread Emile van Sebille
On 12/2/2010 3:06 PM Burton Samograd said... Hello, I was wondering if there was a way to change the quote character for keys in string representation of dictionaries, so that they will be JSON equivalent. For example: x = { 'x': 1, 'y': 2 } { 'x': 1, 'y': 2 } `x` "{ 'x': 1, 'y': 2 }" # clo

Re: Python 3 encoding question: Read a filename from stdin, subsequently open that filename

2010-12-02 Thread Nobody
On Thu, 02 Dec 2010 12:17:53 +0100, Peter Otten wrote: >> This was actually a critical flaw in Python 3.0, as it meant that >> filenames which weren't valid in the locale's encoding simply couldn't be >> passed via argv or environ. 3.1 fixed this using the "surrogateescape" >> encoding, so now it'

[Fwd: Re: Uso de variable Global]

2010-12-02 Thread craf
- Mensaje reenviado > De: Peter Otten <__pete...@web.de> > Para: python-list@python.org > Asunto: Re: Uso de variable Global > Fecha: Thu, 02 Dec 2010 23:06:25 +0100 > Grupos de noticias: comp.lang.python > > craf wrote: > > > Hola. > > > > > > Estoy probando Tkinter y escribí

Changing ' to " in printed representation of dictionaries

2010-12-02 Thread Burton Samograd
Hello, I was wondering if there was a way to change the quote character for keys in string representation of dictionaries, so that they will be JSON equivalent. For example: >>> x = { 'x': 1, 'y': 2 } { 'x': 1, 'y': 2 } >>> `x` "{ 'x': 1, 'y': 2 }" # close but not quite a JSON string >>> `x`.re

[Fwd: Re: Uso de variable Global]

2010-12-02 Thread cristian abarzúa
- Mensaje reenviado > De: Peter Otten <__pete...@web.de> > Para: python-list@python.org > Asunto: Re: Uso de variable Global > Fecha: Thu, 02 Dec 2010 23:06:25 +0100 > Grupos de noticias: comp.lang.python > > craf wrote: > > > Hola. > > > > > > Estoy probando Tkinter y escribí

Re: three column dataset - additions and deletions

2010-12-02 Thread Tim Harig
On 2010-12-02, draeath wrote: > The idea is that this script will run periodically, pulling the table, > and comparing the data gathered at that run to that stored by the > previous, acting on changes made, and storing the current data back (to > be referenced against in the next invocation) S

three column dataset - additions and deletions

2010-12-02 Thread draeath
I'm going to be writing a utility that will be pulling three fields from a MySQL table. I've already got a sample dataset - there's a long int (which is a db key), a short string, and a looong string. Many rows. As it is, receive this data from the DB interface as a rather large tuple of tuples

Re: Comparison with False - something I don't understand

2010-12-02 Thread John Nagle
On 12/2/2010 10:13 AM, Terry Reedy wrote: Aside from the other issues raised, I will just note that is more common to return None when there is no answer (for whatever reason) rather than False and explicitly compare 'is None' than 'is False'. The basic problem is that the original design of

Re: Uso de variable Global

2010-12-02 Thread Peter Otten
craf wrote: > Hola. > > > Estoy probando Tkinter y escribí este pequeño código el cual crea un > formulario con un textbox y un botón. Al ingresar un dato en el textbox > y presionar el botón, se imprime en la consola el valor. > > > ---CODE > > from Tkinter import * > >

Re: [Python-es] Uso de variable Global

2010-12-02 Thread Pau Cervera
Ni idea de Tkinter, pero ¿no puedes almacenar *valor* en una variable de instancia de App y convertir la función *muestra* en un método de la classe App que teng aceso a las variables de instancia de App? - Pau Python..., what else? 2010/12/2 craf > Hola. > > > Estoy probando Tkinter y es

Uso de variable Global

2010-12-02 Thread craf
Hola. Estoy probando Tkinter y escribí este pequeño código el cual crea un formulario con un textbox y un botón. Al ingresar un dato en el textbox y presionar el botón, se imprime en la consola el valor. ---CODE from Tkinter import * def muestra(): print(valor.get

Re: Comparison with False - something I don't understand

2010-12-02 Thread Ben Finney
Harishankar writes: > On Thu, 02 Dec 2010 22:19:25 +1100, Ben Finney wrote: > > > More details of the problem you're trying to solve would help with > > giving specific advice. > > I'm writing functions with multiple points of failure exits. I use > return False as a way to flag the error conditi

Re: Comparison with False - something I don't understand

2010-12-02 Thread Tim Harig
On 2010-12-02, Paul Rubin wrote: > Tim Harig writes: >> I am not talking about what setjmp() has to do, I am talking about what >> *you* have to do after setjmp() returns. If you have allocated memory in >> intermediate functions and you don't have a reference to them outside of >> the functions

Re: aggregation for a nested dict

2010-12-02 Thread Tim Chase
On 12/02/2010 01:49 PM, MRAB wrote: On 02/12/2010 19:01, chris wrote: i would like to parse many thousand files and aggregate the counts for the field entries related to every id. extract_field grep the identifier for the fields with regex. result = [ { extract_field("id", line) : [extract_fie

Re: Comparison with False - something I don't understand

2010-12-02 Thread Tim Harig
On 2010-12-02, MRAB wrote: > On 02/12/2010 19:15, Tim Harig wrote: >> On 2010-12-02, Paul Rubin wrote: >>> Tim Harig writes: > longjmp. Alternatively you can have an auxiliary stack of cleanup > records that the longjmp handler walks through. Of course if you do Only if you a

Re: Comparison with False - something I don't understand

2010-12-02 Thread Paul Rubin
Tim Harig writes: > I am not talking about what setjmp() has to do, I am talking about what > *you* have to do after setjmp() returns. If you have allocated memory in > intermediate functions and you don't have a reference to them outside of > the functions that longjmp() bypasses from returning

Re: aggregation for a nested dict

2010-12-02 Thread Peter Otten
chris wrote: > Hi, > > i would like to parse many thousand files and aggregate the counts for > the field entries related to every id. > > extract_field grep the identifier for the fields with regex. > > result = [ { extract_field("id", line) : [extract_field("field1", > line),extract_field("fi

Re: aggregation for a nested dict

2010-12-02 Thread Chris Rebert
On Thu, Dec 2, 2010 at 11:01 AM, chris wrote: > Hi, > > i would like to parse many thousand files and aggregate the counts for > the field entries related to every id. > > extract_field grep the identifier for the fields with regex. > > result = [ { extract_field("id", line) : [extract_field("fiel

Re: Comparison with False - something I don't understand

2010-12-02 Thread MRAB
On 02/12/2010 19:15, Tim Harig wrote: On 2010-12-02, Paul Rubin wrote: Tim Harig writes: longjmp. Alternatively you can have an auxiliary stack of cleanup records that the longjmp handler walks through. Of course if you do Only if you already have pointers to *all* of the data structures

Re: Comparison with False - something I don't understand

2010-12-02 Thread Steve Holden
On 12/2/2010 1:31 PM, Terry Reedy wrote: > It turns out that try block are computationally lighter weight (faster) > for normal execution ;-) Though that alone would hardly be sufficient reason to use them. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atl

Re: aggregation for a nested dict

2010-12-02 Thread MRAB
On 02/12/2010 19:01, chris wrote: Hi, i would like to parse many thousand files and aggregate the counts for the field entries related to every id. extract_field grep the identifier for the fields with regex. result = [ { extract_field("id", line) : [extract_field("field1", line),extract_field

Re: Comparison with False - something I don't understand

2010-12-02 Thread Tim Harig
On 2010-12-02, Paul Rubin wrote: > Tim Harig writes: >>> longjmp. Alternatively you can have an auxiliary stack of cleanup >>> records that the longjmp handler walks through. Of course if you do >> >> Only if you already have pointers to *all* of the data structures at >> the point where you pu

Re: Comparison with False - something I don't understand

2010-12-02 Thread Paul Rubin
Tim Harig writes: >> longjmp. Alternatively you can have an auxiliary stack of cleanup >> records that the longjmp handler walks through. Of course if you do > > Only if you already have pointers to *all* of the data structures at > the point where you put your setjmp(). The setjmp point only h

aggregation for a nested dict

2010-12-02 Thread chris
Hi, i would like to parse many thousand files and aggregate the counts for the field entries related to every id. extract_field grep the identifier for the fields with regex. result = [ { extract_field("id", line) : [extract_field("field1", line),extract_field("field2", line)]} for line in FIL

Re: Comparison with False - something I don't understand

2010-12-02 Thread Tim Harig
On 2010-12-02, Paul Rubin wrote: > Tim Harig writes: >>> That's called longjmp. >> >> The problem is that you might have partially allocated data structures >> that you need to free before you can go anywhere. > > Alloca can help with that since the stack stuff gets released by the > longjmp. Al

Re: DBF (VFP) to XLS (Excel) in pure Python

2010-12-02 Thread Ethan Furman
kirby.ur...@gmail.com wrote: Some ideas: for (i, name) in enumerate(thedbf.field_names): sheet1.write(0, i, name, header_style) thetype = thedbf.type(name) thelen, thedec = thedbf.size(name) if thetype == "M": thelen = 100 elif thelen == 0:

hai this is kate, im staing near u, date with me for free... girls and boyz...

2010-12-02 Thread kate for free dating
hai this is kate, im staing near u, date with me for free... girls and boyz... http://x2c.eu/5i http://x2c.eu/5i http://x2c.eu/5i http://x2c.eu/5i -- http://mail.python.org/mailman/listinfo/python-list

Re: Comparison with False - something I don't understand

2010-12-02 Thread MRAB
On 02/12/2010 18:09, Paul Rubin wrote: MRAB writes: When writing the C code for the new regex module I thought that it would've been easier if I could've used exceptions to propagate errors and unwind the stack, instead of having to return an error code which had to be checked by the caller, an

Re: Comparison with False - something I don't understand

2010-12-02 Thread Grant Edwards
On 2010-12-02, Paul Rubin wrote: > MRAB writes: >> When writing the C code for the new regex module I thought that it >> would've been easier if I could've used exceptions to propagate errors >> and unwind the stack, instead of having to return an error code which >> had to be checked by the call

Re: Comparison with False - something I don't understand

2010-12-02 Thread Paul Rubin
Tim Harig writes: >> That's called longjmp. > > The problem is that you might have partially allocated data structures > that you need to free before you can go anywhere. Alloca can help with that since the stack stuff gets released by the longjmp. Alternatively you can have an auxiliary stack o

Re: Comparison with False - something I don't understand

2010-12-02 Thread Terry Reedy
On 12/2/2010 9:56 AM, Harishankar wrote: There are some reasons why I hate exceptions but that is a different topic. However, in short I can say that personally: 1. I hate try blocks which add complexity to the code when none is needed. Try blocks make code much more unreadable in my view and I

Re: How can I define class methods outside of the class?

2010-12-02 Thread Jeremy
On Dec 2, 10:26 am, "bruno.desthuilli...@gmail.com" wrote: > On 2 déc, 15:45, Jeremy wrote: > > > > > > > On Dec 1, 10:47 pm, James Mills wrote: > > > > On Thu, Dec 2, 2010 at 3:36 PM, Jeremy wrote: > > > > I have some methods that I need (would like) to define outside of the > > > > class.  I

Re: Comparison with False - something I don't understand

2010-12-02 Thread Tim Harig
On 2010-12-02, Paul Rubin wrote: > MRAB writes: >> When writing the C code for the new regex module I thought that it >> would've been easier if I could've used exceptions to propagate errors >> and unwind the stack, instead of having to return an error code which >> had to be checked by the call

Re: Some syntactic sugar proposals

2010-12-02 Thread Tim Chase
On 12/02/2010 10:39 AM, Mark Dickinson wrote: On Nov 15, 12:46 pm, Tim Chase wrote: On 11/15/2010 12:39 AM, Dmitry Groshev wrote: x in range optimisation I've often thought this would make a nice O(1)-test lookup on an xrange() generator. An O(1) test for 'x in' is implemented in Python 3

Re: Comparison with False - something I don't understand

2010-12-02 Thread Terry Reedy
Aside from the other issues raised, I will just note that is more common to return None when there is no answer (for whatever reason) rather than False and explicitly compare 'is None' than 'is False'. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Comparison with False - something I don't understand

2010-12-02 Thread Paul Rubin
MRAB writes: > When writing the C code for the new regex module I thought that it > would've been easier if I could've used exceptions to propagate errors > and unwind the stack, instead of having to return an error code which > had to be checked by the caller, and then have the caller explicitly

Re: Comparison with False - something I don't understand

2010-12-02 Thread MRAB
On 02/12/2010 16:12, Tim Harig wrote: On 2010-12-02, Harishankar wrote: I understand that the error vs exception debate is quite a big one in the programming community as a whole and I don't consider myself very Actually, I thought that debate was resolved years ago. I cannot think of a sing

Re: Get frame object of last called function

2010-12-02 Thread Aahz
In article , moerchendiser2k3 wrote: > >Hi, is there any chance to get the frame object of the previous called >function? sys._current_frames(), sys._getframe() -- Aahz (a...@pythoncraft.com) <*> http://www.pythoncraft.com/ "Think of it as evolution in action." --Tony Rand -

Re: Comparison with False - something I don't understand

2010-12-02 Thread Jean-Michel Pichavant
Harishankar wrote: As I said before, the way exceptions are caught seem to me to be the most confusing bit. Non-atomic operations always worry me. What if my function which is wrapped inside a try block has two different statements that raised the same exception but for different reasons? With

Re: How can I define class methods outside of the class?

2010-12-02 Thread bruno.desthuilli...@gmail.com
On 2 déc, 15:45, Jeremy wrote: > On Dec 1, 10:47 pm, James Mills wrote: > > > > > On Thu, Dec 2, 2010 at 3:36 PM, Jeremy wrote: > > > I have some methods that I need (would like) to define outside of the > > > class.  I know this can be done by defining the function and then > > > setting it equ

Re: How can I define class methods outside of the class?

2010-12-02 Thread bruno.desthuilli...@gmail.com
On 2 déc, 06:36, Jeremy wrote: > I have some methods that I need (would like) to define outside of the > class.  I know this can be done by defining the function and then > setting it equal to some member "assignement" or "binding" might be the terms you were looking for here ;) Also in Python

pyOpenGL Error unable to detect undefined names

2010-12-02 Thread Ron
Hello, I am trying to use pyOpenGL and I keep getting the following errors: Traceback (most recent call last): File "C:\Temp\Python\OpenGL_Test.py", line 10, in from OpenGL.GLU import * File "C:\Python26\lib\site-packages\OpenGL\GLU\__init__.py", line 4, in from OpenGL.raw.GLU impor

Google AI challenge: planet war. Lisp won.

2010-12-02 Thread Xah Lee
discovered this rather late. Google has a AI Challenge: planet wars. http://ai-contest.com/index.php it started sometimes 2 months ago and ended first this month. the winner is Gábor Melis, with his code written in lisp. Congrats lispers! Gábor wrote a blog about it here http://quotenil.com/Pl

Re: Unicode thing that causes a traceback in 2.6 and 2.7 but not in 2.5, and only when writing to a pipe, not to the terminal

2010-12-02 Thread Piet van Oostrum
Dan Stromberg writes: > What is this about? It's another n~ thing, but this time in 2.x. > All I'm doing is printing a str containing a character > 127. > > It works fine in 2.5, to a terminal or to a pipe. In 2.6 and 2.7, it > fails when writing to a pipe but works fine writing to my terminal

Re: Comparison with False - something I don't understand

2010-12-02 Thread Tim Harig
On 2010-12-02, Harishankar wrote: >> Actually, finer grained error handling commonly covers up bugs. If you >> want to find bugs, you want to make the program prone to crashing if a >> bug is present. It is all too easy to accidently mistake the return >> value of a function as error condition a

Re: Comparison with False - something I don't understand

2010-12-02 Thread Mark Wooding
Harishankar writes: > There are some reasons why I hate exceptions but that is a different > topic. However, in short I can say that personally: > > 1. I hate try blocks which add complexity to the code when none is > needed. Try blocks make code much more unreadable in my view and I use it >

Re: multiple modules from single c extension

2010-12-02 Thread Robert Kern
On 12/2/10 10:39 AM, Eric Frederich wrote: Can you explain how to do this with distutils then? Would I need a separate setup.py for SpamABC and SpamXYZ? How would I get them included in the parent module Spam? Please consult the distutils documentation. http://docs.python.org/distutils/index

Re: Some syntactic sugar proposals

2010-12-02 Thread Mark Dickinson
On Nov 15, 12:46 pm, Tim Chase wrote: > On 11/15/2010 12:39 AM, Dmitry Groshev wrote: > > > x in range optimisation > > I've often thought this would make a nice O(1)-test lookup on an > xrange() generator. An O(1) test for 'x in ' is implemented in Python 3.2, at least provided that x has type '

Re: multiple modules from single c extension

2010-12-02 Thread Eric Frederich
Can you explain how to do this with distutils then? Would I need a separate setup.py for SpamABC and SpamXYZ? How would I get them included in the parent module Spam? Could you explain what you mean when you say "The Python import mechanism will be looking for an appropriately-named .pyd file for

Re: DBF (VFP) to XLS (Excel) in pure Python

2010-12-02 Thread kirby.ur...@gmail.com
On Dec 1, 10:28 pm, "kirby.ur...@gmail.com" wrote: > Playing around with arcane tools to read those pesky DBF files (with > memo fields), like floating wine barrels cast off the sinking VFP > ship. > Although it's true I don't know that I'm getting "in memory" DBF reads, the bulk of the time in t

Re: string find/replace

2010-12-02 Thread Piet van Oostrum
Carlo writes: > On 2010-12-01, Peter Otten <__pete...@web.de> wrote: > import re > re.compile("([a-z])([A-Z])").sub(r"\1 \2", "camelCase") >> 'camel Case' > > Very simple if you know it. Thank you! And almost as cryptic as Perl!! -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP

Re: Comparison with False - something I don't understand

2010-12-02 Thread Harishankar
On Thu, 02 Dec 2010 15:53:49 +, Tim Harig wrote: > If you are using exceptions to try to catch bug then you are using them > improperly. Exceptions (with the exception (no pun intended) of > AssertionError) are designed to catch error conditions, not bugs. I agree. But more specifically some

Re: Comparison with False - something I don't understand

2010-12-02 Thread Tim Harig
On 2010-12-02, Harishankar wrote: > I understand that the error vs exception debate is quite a big one in the > programming community as a whole and I don't consider myself very Actually, I thought that debate was resolved years ago. I cannot think of a single recently developed programming la

Re: strange TypeError exception in function compiled from a string

2010-12-02 Thread Piet van Oostrum
nelson writes: > Hi all, > I have this function, defined in a string and ecetuted through ad > exec call > > def cell1(d): > > x=d.get('x') > print x > > import y > return y.add(y.add(self.adf0(x),self.adf0(x)),self.adf0(x)) > What is self in line 7? -- Piet van Oostrum WWW:

Re: Comparison with False - something I don't understand

2010-12-02 Thread Harishankar
On Thu, 02 Dec 2010 07:35:18 -0800, Stephen Hansen wrote: > Exceptions aren't about "error management"; they are about exceptional > conditions: some are errors, others are entirely normal situations you > know are going to happen (such as reaching the end of a sequence as you > iterate over it: t

Re: Comparison with False - something I don't understand

2010-12-02 Thread Tim Harig
On 2010-12-02, Harishankar wrote: > I am also wary of using larger catch-all try blocks or try blocks with > multiple exception exits (which seem to make tracking subtle bugs > harder). I prefer the philosophy of dealing with errors immediately as If you are using exceptions to try to catch bu

Re: Comparison with False - something I don't understand

2010-12-02 Thread Harishankar
On Thu, 02 Dec 2010 15:25:55 +, Tim Harig wrote: >... >... > > Perhaps you should take a look at how Erlang appoaches exception > handling. Being message passing and concurrency oriented, Erlang > encourages ignoring error conditions within worker processes. Errors > instead cause the worker

Re: Comparison with False - something I don't understand

2010-12-02 Thread Stephen Hansen
On 12/2/10 6:56 AM, Harishankar wrote: > On Thu, 02 Dec 2010 08:44:11 -0600, Tim Chase wrote: > >> On 12/02/2010 08:18 AM, Harishankar wrote: >>> Here I'm using it to compare the result of a function where I >>> specifically return False on error condition, >> >> This sounds exactly like the reaso

Re: Comparison with False - something I don't understand

2010-12-02 Thread Grant Edwards
On 2010-12-02, Steve Holden wrote: > On 12/2/2010 9:13 AM, Harishankar wrote: >> >> if not result: >> # error condition >> >> Now above I first realized that the function can also return an empty >> list under some conditions and so changed it to >> >> if result == False: >> # error co

Re: Comparison with False - something I don't understand

2010-12-02 Thread Harishankar
On Thu, 02 Dec 2010 10:19:35 -0500, Steve Holden wrote: > On 12/2/2010 9:13 AM, Harishankar wrote: >> On Thu, 02 Dec 2010 22:19:25 +1100, Ben Finney wrote: >> >>> More details of the problem you're trying to solve would help with >>> giving specific advice. >> >> I'm writing functions with multi

Re: Comparison with False - something I don't understand

2010-12-02 Thread Tim Harig
On 2010-12-02, Harishankar wrote: > There are some reasons why I hate exceptions but that is a different > topic. However, in short I can say that personally: > > 1. I hate try blocks which add complexity to the code when none is > needed. Try blocks make code much more unreadable in my view and

Re: Comparison with False - something I don't understand

2010-12-02 Thread Steve Holden
On 12/2/2010 9:56 AM, Harishankar wrote: > 3. Philosophically I think exception handling is the wrong approach to > error management. I have never grown up programming with exceptions in C > and I couldn't pick up the habit with python either. Did I mention that I > detest try blocks? try blocks

Re: Comparison with False - something I don't understand

2010-12-02 Thread Steve Holden
On 12/2/2010 9:13 AM, Harishankar wrote: > On Thu, 02 Dec 2010 22:19:25 +1100, Ben Finney wrote: > >> More details of the problem you're trying to solve would help with >> giving specific advice. > > I'm writing functions with multiple points of failure exits. I use return > False as a way to fl

Re: Comparison with False - something I don't understand

2010-12-02 Thread Harishankar
On Thu, 02 Dec 2010 08:44:11 -0600, Tim Chase wrote: > On 12/02/2010 08:18 AM, Harishankar wrote: >> Here I'm using it to compare the result of a function where I >> specifically return False on error condition, > > This sounds exactly like the reason to use exceptions...you have an > exceptional

Re: How can I define class methods outside of the class?

2010-12-02 Thread Jeremy
On Dec 1, 10:47 pm, James Mills wrote: > On Thu, Dec 2, 2010 at 3:36 PM, Jeremy wrote: > > I have some methods that I need (would like) to define outside of the > > class.  I know this can be done by defining the function and then > > setting it equal to some member of an instance of the class.  

Re: How to initialize each multithreading Pool worker with an individual value?

2010-12-02 Thread Valery
On Dec 1, 3:24 am, James Mills wrote: > I assume you are talking about multiprocessing > despite you mentioning "multithreading" in the mix. yes, sorry. > Have a look at the source code for multiprocessing.pool > and how the Pool object works and what it does > with the initializer argument. I'

Re: Comparison with False - something I don't understand

2010-12-02 Thread Tim Chase
On 12/02/2010 08:18 AM, Harishankar wrote: Here I'm using it to compare the result of a function where I specifically return False on error condition, This sounds exactly like the reason to use exceptions...you have an exceptional error condition. -tkc -- http://mail.python.org/mailman/lis

Re: Comparison with False - something I don't understand

2010-12-02 Thread Harishankar
On Thu, 02 Dec 2010 02:49:50 -0800, Stephen Hansen wrote: >... >... >... > * P.S. I'm not saying its never right to use "is" outside of The > Singletons. Just that its probably not, for most people, what they > actually should do in most code. There are numerous counter-examples, of > course. Its j

Re: Comparison with False - something I don't understand

2010-12-02 Thread Harishankar
On Thu, 02 Dec 2010 22:19:25 +1100, Ben Finney wrote: > More details of the problem you're trying to solve would help with > giving specific advice. I'm writing functions with multiple points of failure exits. I use return False as a way to flag the error condition rather than raising exception

[Fwd: Re: Decorate un Frame with window managers title bar, etc en Tkinter 8.5]

2010-12-02 Thread craf
- Mensaje reenviado > De: Eric Brunel > Para: python-list@python.org > Asunto: Re: Decorate un Frame with window managers title bar, etc en > Tkinter 8.5 > Fecha: Thu, 02 Dec 2010 10:21:49 +0100 > Grupos de noticias: comp.lang.python > > In article , > craf wrote: > > > Hi. >

Re: Comparison with False - something I don't understand

2010-12-02 Thread Ben Finney
Harishankar writes: > When I run pychecker through my modules I get the message that > comparisons with "False" is not necessary and that it might yield > unexpected results. Good advice. > Yet in some situations I need to specifically check whether False was > returned or None was returned. Wh

Re: Python 3 encoding question: Read a filename from stdin, subsequently open that filename

2010-12-02 Thread Peter Otten
Nobody wrote: > This was actually a critical flaw in Python 3.0, as it meant that > filenames which weren't valid in the locale's encoding simply couldn't be > passed via argv or environ. 3.1 fixed this using the "surrogateescape" > encoding, so now it's only an annoyance (i.e. you can recover the

How to send an IP packet in Python?

2010-12-02 Thread yegorov-p
Hello. I have sniffed some packet and now I would like to send it with the help of python. It's some simple IGMP packet with VLAN tag. (01 00 5E 00 43 67 00 02 B3 C8 7F 44 81 00 00 DE 08 00 46 00 00 20 00 01 00 00 01 02 36 4C C0 A8 00 7B EA 00 43 67 94 04 00 00 16 00 BC 97 EA 00 43 67) At first I

Re: Comparison with False - something I don't understand

2010-12-02 Thread Stephen Hansen
On 12/2/10 2:02 AM, Harishankar wrote: > On Thu, 02 Dec 2010 00:15:42 -0800, Alice Bevan–McGregor wrote: >> The bool type is a subclass of int! (Run those lines in a Python >> interpreter to see. ;) >> >>> if var == False: >> >> if var is False: … > > So "var is False" is safer to use when I wan

Re: Comparison with False - something I don't understand

2010-12-02 Thread Harishankar
On Thu, 02 Dec 2010 09:58:18 +, Nobody wrote: > If you want to test specifically for True, False or None, use "is" > rather than an equality check. This eliminates the warning and doesn't > risk misleading someone reading the code. Thanks so much for this very specific answer. I guess "is" is

Re: Comparison with False - something I don't understand

2010-12-02 Thread Harishankar
On Thu, 02 Dec 2010 00:15:42 -0800, Alice Bevan–McGregor wrote: > Howdy! Good day to you! > (False == 0) is True > (True == 1) is True I see. Thanks for this. I suspected this, but wasn't sure. > The bool type is a subclass of int! (Run those lines in a Python > interpreter to see. ;) > >>

Re: Comparison with False - something I don't understand

2010-12-02 Thread Nobody
On Thu, 02 Dec 2010 07:28:30 +, Harishankar wrote: > When I run pychecker through my modules I get the message that > comparisons with "False" is not necessary and that it might yield > unexpected results. > > Yet in some situations I need to specifically check whether False was > returned

Re: Decorate un Frame with window managers title bar, etc en Tkinter 8.5

2010-12-02 Thread Eric Brunel
In article , craf wrote: > Hi. > > I use python 3.1 and Tkinter 8.5 in Ubuntu 9.10 > > I would like to turn a frame into a toolbox, > ,and for that I read that you can use the command wm manage (window) > > The information can be found at: > http://www.tcl.tk/man/tcl8.5/TkCmd/wm.htm#M39 >

Re: Comparison with False - something I don't understand

2010-12-02 Thread Alice Bevan–McGregor
Howdy! When I run pychecker through my modules I get the message that comparisons with "False" is not necessary and that it might yield unexpected results. Comparisons against False -are- dangerous, demonstrated below. Yet in some situations I need to specifically check whether False was ret