RE module question

2008-10-03 Thread aditya shukla
Hello folks : i have a string "-bin-ulockmgr_server:0.99[&&NHX:C=0.195.0]" from which i want to delete [&&NHX:C=0.195.0] . I wrote a regular expression for [&&NHX:C=0.195.0] as \[&&(\w)+:\w=((-)?(\d|\d\d|\d\d\d)\.)+\d\] now when i do p = re.compile('\[&&(\w)+:\w=((-)?(\d|\d\d|\d\d\d)\.)+\d\]') m

Re: Comparing float and decimal

2008-10-03 Thread greg
Mark Dickinson wrote: Option (2) appeals to me, but I can't see how to implement it. It could be implemented for the special case of floats and Decimals by keeping flags in each set indicating whether any elements of those types have been added. But doing this just for those two types would b

Re: Conditionally subclassing based on Import

2008-10-03 Thread Gary Herron
David Pratt wrote: > Hi, just want to conditionally base a class on another if it can be > imported, otherwise base it on object. Does the following look ok > for this? > > try: > import foo.bar > except ImportError: > MyBase = foo.bar.Baz > else: > MyBase = object > > class Somethin

Re: Comparing float and decimal

2008-10-03 Thread greg
Terry Reedy wrote: Documenting the problem properly would mean changing the set documentation ... from their current math set based definitions to implementation based definitions It could be documented that the mathematical definitions hold only if the equality relations between all the elem

Re: What is not objects in Python?

2008-10-03 Thread greg
Gabriel Genellina wrote: Had Python used the more generic size and __size__ from the beginning, we'd be all happy now :) Not necessarily -- len is slightly shorter, and more comfortable to type on a qwerty keyboard. But in any case, size-likers have an easy solution: size = len :-) (BTW

Re: What is not objects in Python?

2008-10-03 Thread greg
Aaron "Castironpi" Brady wrote: How do you have a yellow dog, It's not a yellow dog, it's a dog yellow. Attention pay! :-) -- Ewing Gregory -- http://mail.python.org/mailman/listinfo/python-list

Re: del and sets proposal

2008-10-03 Thread George Sakkis
On Oct 2, 6:20 pm, Larry Bates <[EMAIL PROTECTED]> wrote: > You can do the following: > > a = [1,2,3,4,5] > del a[0] > > and > > a = {1:'1', 2: '2', 3: '3', 4:'4', 5:'5'} > del a[1] > > why doesn't it work the same for sets (particularly since sets are based on a > dictionary)? > > a = set([1,2,3,

Re: Ctypes behave differenty on windows 2000 and windows XP

2008-10-03 Thread Gabriel Genellina
En Thu, 02 Oct 2008 10:17:01 -0300, <[EMAIL PROTECTED]> escribió: Im facing a strange problem with ctypes module on windows 2000. I did not face this problem with the windows Xp. The problem is this code and specifically "c_long" which behave differently on win2000 and winxp from ctypes im

Re: Event-driven framework (other than Twisted)?

2008-10-03 Thread James Mills
On 10/2/08, Phillip B Oldham <[EMAIL PROTECTED]> wrote: > On Oct 2, 1:32 am, "James Mills" <[EMAIL PROTECTED]> wrote: > > http://hg.shortcircuit.net.au/index.wsgi/pymills/file/b7498cd4c6a4/ex... > > Thanks for the example, but its not loading. Sorry my VPS has been down for quite some time today

Re: One class per file?

2008-10-03 Thread greg
Bruno Desthuilliers wrote: OTHO, 'one class per file' is a standard idiom in Java and IIRC in C++ (which both have namespaces one way or another) In Java you don't get a choice, because the compiler assumes a class can be found in the correspondingly named file. While C++ has namespaces, they

Re: 2.6 multiprocessing and pdb

2008-10-03 Thread Gabriel Genellina
En Thu, 02 Oct 2008 18:14:07 -0300, Aaron "Castironpi" Brady <[EMAIL PROTECTED]> escribió: I'm trying to step through a subprocess I launch with multiprocessing. Does anyone know what hack to add? The actual call comes in forking.Popen.__init__, Windows version, forking.py, line 222:

Re: code critique requested - just 60 lines

2008-10-03 Thread Terrence Brannon
On Oct 2, 11:56 am, [EMAIL PROTECTED] wrote: > Terrence Brannon, I suggest you to shorten a lot some of those very > long lines. yes, I wanted to, but was not sure how to continue a line on the next line in Python. -- http://mail.python.org/mailman/listinfo/python-list

Re: Odd Errors

2008-10-03 Thread greg
Steven D'Aprano wrote: "Side-effect" has the technical meaning in functional languages of any change of state that isn't the creation and return of a function result. Actually, the term has that meaning for all programming languages. The main distinguishing feature of functional languages is t

Re: Professional quality scripts/code

2008-10-03 Thread Bruno Desthuilliers
robean a écrit : I have been learning Python for the last 3 months or so and I have a working (but somewhat patchy) sense of the the language. I've been using a couple of the more popular Python books as well as online resources. A question for experienced Python programmers: can you recommend r

Re: tkinter textwidget problem

2008-10-03 Thread Eric Brunel
On Thu, 02 Oct 2008 21:57:01 +0200, kib2 <[EMAIL PROTECTED]> wrote: Hi, In a tkinter TextWidget I would like to retrieve the last typed word. I've tried this with the 'wordstart' Expression [From the effbot site, "wordstart" and "wordend" moves the index to the beginning (end) of the curren

Re: del and sets proposal

2008-10-03 Thread Steven D'Aprano
On Thu, 02 Oct 2008 22:27:04 -0500, Larry Bates wrote: > Maybe dictionaries should have had a .remove method then things would be > more consistent? But why should sets be consistent with dictionaries? There are a few similarities, but also differences. Personally, I'd rather see dictionaries g

Re: code critique requested - just 60 lines

2008-10-03 Thread Gabriel Genellina
En Fri, 03 Oct 2008 05:07:41 -0300, Terrence Brannon <[EMAIL PROTECTED]> escribió: On Oct 2, 11:56 am, [EMAIL PROTECTED] wrote: Terrence Brannon, I suggest you to shorten a lot some of those very long lines. yes, I wanted to, but was not sure how to continue a line on the next line in Pytho

Re: closures and dynamic binding

2008-10-03 Thread greg
jhermann wrote: I didn't see this mentioned in the thread yet: the double-lambda is unnecessary (and a hack). Well, the alternative -- abusing default argument values -- is seen by many to be a hack as well, possibly a worse one. It doesn't work in general, e.g. it fails if the function needs

Re: javascript to python

2008-10-03 Thread lkcl
On Oct 2, 7:42 pm, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > lkcl a écrit : > > > > > On Oct 2, 5:54 pm, Joe Hrbek <[EMAIL PROTECTED]> wrote: > >> Could someone help me translate to something that would close to it in > >> python? The anonymous functions are giving me problems. > > > class

Re: RE module question

2008-10-03 Thread Gabriel Genellina
En Fri, 03 Oct 2008 03:59:18 -0300, aditya shukla <[EMAIL PROTECTED]> escribió: Hello folks : i have a string "-bin-ulockmgr_server:0.99[&&NHX:C=0.195.0]" from which i want to delete [&&NHX:C=0.195.0] . I wrote a regular expression for [&&NHX:C=0.195.0] as \[&&(\w)+:\w=((-)?(\d|\d\d|\d\d\d)\.

Re: What is not objects in Python?

2008-10-03 Thread Marc 'BlackJack' Rintsch
On Fri, 03 Oct 2008 19:10:27 +1200, greg wrote: > But in any case, size-likers have an easy solution: > >size = len > > :-) > > (BTW, try doing that with the x.len() notation!) def size(obj): return obj.len() or size = operator.methodcaller('len') in Python 2.6 and up. :-) Ciao,

Re: del and sets proposal

2008-10-03 Thread Carl Banks
On Oct 2, 8:02 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Thu, 02 Oct 2008 15:39:55 -0700, Chris Rebert wrote: > > On Thu, Oct 2, 2008 at 3:20 PM, Larry Bates <[EMAIL PROTECTED]> > > wrote: > >> a = set([1,2,3,4,5]) > >> del a[1] > > > Sets don't support subscripting, so if you ca

Re: Python arrays and sting formatting options

2008-10-03 Thread Steven D'Aprano
I'm not sure if our views are moving closer together or further apart, but here goes... On Thu, 02 Oct 2008 23:49:16 +, Marc 'BlackJack' Rintsch wrote: > On Thu, 02 Oct 2008 14:51:29 +, Steven D'Aprano wrote: > >> On Wed, 01 Oct 2008 10:38:12 +, Marc 'BlackJack' Rintsch wrote: >>

Re: closures and dynamic binding

2008-10-03 Thread Michele Simionato
On Oct 3, 10:44 am, greg <[EMAIL PROTECTED]> wrote: > So if anything were to be done to the language to > fix this, it really should be focused on fixing the > semantics of the for-loop. Unfortunately, the > fact that the loop variable leaks out of the scope > of the loop is regarded as a feature,

Re: code critique requested - just 60 lines

2008-10-03 Thread Terrence Brannon
On Oct 2, 11:09 am, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Thu, 02 Oct 2008 07:51:30 -0700, Terrence Brannon wrote: > > > Basically, using non-strict dictionary keys can lead to bugs, so that > > worried me. > > What's a "non-strict dictionary key"? > In Perl, you can

Re: del and sets proposal

2008-10-03 Thread Steven D'Aprano
On Fri, 03 Oct 2008 02:18:53 -0700, Carl Banks wrote: > On Oct 2, 11:27 pm, Larry Bates <[EMAIL PROTECTED]> wrote: >> I didn't mean to imply that del a[1] would delete the first thing in >> the set, but rather the item with a value of 1.  Just as when we use it >> on a dictionary: >> >> del a[1] >

Re: What is not objects in Python?

2008-10-03 Thread Bruno Desthuilliers
Boris Borcic a écrit : 42, for instance. Proof : >>> 42 is not object True QED Lol. -- http://mail.python.org/mailman/listinfo/python-list

Re: Inheritance but only partly?

2008-10-03 Thread greg
[EMAIL PROTECTED] wrote: class Mask(object): def m3(self): raise NotImplementedError def m4(self): raise NotImplementedError What's the name of this python design pattern? :-) Don't know. Perhaps we could call it the FigLeaf pattern (covering up what you don't want seen)? There's a

Re: closures and dynamic binding

2008-10-03 Thread Hrvoje Niksic
greg <[EMAIL PROTECTED]> writes: > The root of the problem actually has nothing to do with lambdas or > static vs. non-static scoping. It's the fact that Python's for-loop > doesn't create a new environment for the loop variable each time > around, but re-uses a slot in the containing environment.

Re: Inheritance but only partly?

2008-10-03 Thread Peter Otten
greg wrote: >> class Mask(object): >> def m3(self): raise NotImplementedError >> def m4(self): raise NotImplementedError > >> What's the name of this python design pattern? :-) > > Don't know. Perhaps we could call it the FigLeaf pattern > (covering up what you don't want seen)? Braghettone ;)

Re: Python arrays and sting formatting options

2008-10-03 Thread Marc 'BlackJack' Rintsch
On Thu, 02 Oct 2008 18:15:59 -0700, bearophileHUGS wrote: > What's a range(n)? A function that returns a list of n items, from 0 to > n. This is easy to understand, while xrange(n) is a bit less easy to > understand (a generator or generators). `xrange()` doesn't return a generator or iterator

Re: Python style: exceptions vs. sys.exit()

2008-10-03 Thread Steven D'Aprano
On Fri, 03 Oct 2008 17:09:07 +1200, greg wrote: > Lawrence D'Oliveiro wrote: >> In message <[EMAIL PROTECTED]>, Steven >> D'Aprano wrote: >> >> > (2) Even when the source is available, it is sometimes a legal trap >> > to read it with respect to patents and copyright. >> >> That's not how patent

Re: del and sets proposal

2008-10-03 Thread Carl Banks
On Oct 2, 11:27 pm, Larry Bates <[EMAIL PROTECTED]> wrote: > I didn't mean to imply that del a[1] would delete the first thing in the set, > but rather the item with a value of 1.  Just as when we use it on a > dictionary: > > del a[1] > > doesn't mean delete the first dictionary entry but rather

Re: What is not objects in Python?

2008-10-03 Thread Tim Rowe
2008/9/30 Lie Ryan <[EMAIL PROTECTED]>: > Actually str.len and len(str) is just like saying "the string's length" > and "the length of the string". There is no difference between the two > except for personal preference. (I am no linguist-- not even a native > speaker of English --but I think ther

Re: javascript to python

2008-10-03 Thread Bruno Desthuilliers
lkcl a écrit : On Oct 2, 7:42 pm, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: lkcl a écrit : (snip) for fits and giggles, compile the above python using pyjs.py, the python-to-javascript compiler (seehttp://pyjamas.sf.net) and compare the resultant javascript to your original code-fragment

Re: Python arrays and sting formatting options

2008-10-03 Thread bearophileHUGS
Marc 'BlackJack' Rintsch: > bearophile > while xrange(n) is a bit less easy to > > understand (a generator or generators). I meant "a generator of generators", a typo, sorry. -.- Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: Fun with reverse sorts

2008-10-03 Thread bearophileHUGS
Chris Rebert: > So the improved code is: > your_list.sort(key=lambda elem: (elem[3], elem[2]), reverse=True) Better (untested): from operator import itemgetter ... your_list.sort(key=itemgetter(3, 2), reverse=True) Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: Inheritance but only partly?

2008-10-03 Thread Michele Simionato
On Oct 2, 10:16 pm, process <[EMAIL PROTECTED]> wrote: > Let's say I have a class X which has 10 methods. > > I want class Y to inherit 5 of them. > > Can I do that? Can I do something along the lines of super(Y, exclude > method 3 4 7 9 10) ? Don't use inheritance, use delegation or just copy the

Re: del and sets proposal

2008-10-03 Thread bearophileHUGS
Steven D'Aprano: > Personally, I'd rather see dictionaries grow methods like > symmetric_difference, union, etc. than worry about whether you use del or > remove to remove elements from a set. I have functions for all those operations, so I think they can be useful, but in practice I don't use the

Re: javascript to python

2008-10-03 Thread lkcl
On Oct 3, 10:29 am, Bruno Desthuilliers wrote: > lkcl a écrit :> On Oct 2, 7:42 pm, Bruno Desthuilliers > > <[EMAIL PROTECTED]> wrote: > >> lkcl a écrit : > Not 'mine' - I'm not the OP. whoops, yes - i missed that. sorry! > And as far as I'm concerned, the point is > exactly here : it's doing

Re: Inheritance but only partly?

2008-10-03 Thread Tim Rowe
2008/10/2 process <[EMAIL PROTECTED]>: > Let's say I have a class X which has 10 methods. > > I want class Y to inherit 5 of them. > > Can I do that? As others have said, no. What nobody seems to have said yet is why. If Y descends from X, you are saying that Y is an X; that a Y can be used anywhe

lxml and schema validation

2008-10-03 Thread hrishy
Hi I am validating a xmlfile against a xsd (My.xsd) but i notice that the xsd has a include which includes another xsd (My1.xsd) I have written a simple program that to validate this from lxml import etree xmlschemadoc=etree.parse("My.xsd") xmlschema=etree.XMLSchema(xmlschemadoc) xmldoc=etree.p

Re: windows help files ?

2008-10-03 Thread Stef Mientki
Martin v. Löwis wrote: 1. how can I launch the windows help file (CHM), from python with a keyword as argument ? Run hh.exe. If you want it to navigate to specific page, also pass that page on the command line (finding out the exact syntax is left as an exercise) That's one way, in t

SQLite

2008-10-03 Thread Matthias Huening
Hi, This is probably trivial, but I cannot find a solution right now. With MySQLdb, I could test the success of a deleting action like this: sql = "DELETE FROM table WHERE name='xxx'" res = cur.execute(sql) if res == 1: print 'Okay' else: print 'nothing deleted' This seems not to wor

[BaseHTTPServer/SimpleHTTPServer] Remove "Server:" header

2008-10-03 Thread [EMAIL PROTECTED]
Hello. I'm using SimpleHTTPServer (work well) but it always sends "Server" header in response: "Server: SimpleHTTP/0.6 Python/2.5.1" How can I remove that ? I tried: self.server_version = "" self.sys_version = "" but the header is still sent, empty. I there a way to remove the "Server:" head

Re: Inheritance but only partly?

2008-10-03 Thread Simon Brunning
2008/10/3 Tim Rowe <[EMAIL PROTECTED]>: > As others have said, no. What nobody seems to have said yet is why. If > Y descends from X, you are saying that Y is an X; that a Y can be used > anywhere an X can. If Y doesn't support some methods of X then it is > *not* an X, and *can't* be used anywher

Re: SQLite

2008-10-03 Thread gordyt
Howdy Matthias! The delete operation will set the rowcount member of your cursor. Let's assume you have an sqlite3 database with a table called 'test' with an id column. It does have a record with id=1. It does not have a record with id=2. >>> import sqlite3 >>> connection = sqlite3.connect('te

tkinter question

2008-10-03 Thread [EMAIL PROTECTED]
I saw this (close to this anyway) lieing around on the internet and was wanting to use it to define a start point exc but I need the graphics to stay within a set y coords and I am not realy sure how to do that. I have no idea on how to bind a min/max y to it. (the concept is inspired by the java

Re: del and sets proposal

2008-10-03 Thread Marc 'BlackJack' Rintsch
On Fri, 03 Oct 2008 02:09:09 -0700, Carl Banks wrote: > On Oct 2, 8:02 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: >> Then add subscription access too.  By aliasing `__getitem__()` to >> `__contains__()`.  And `__setitem__()` could be implemented to add or >> remove objects by assignin

processing email with Python on Windows?

2008-10-03 Thread Beliavsky
I work for a financial company where we run Windows XP and read email using Microsoft Outlook 2003. I get daily files that come as email attachments from various counterparties. I save them as h:\firm_name \mmdd.csv . Would Python be a good tool to automate the process of saving reports, or wou

Re: javascript to python

2008-10-03 Thread lkcl
> so, if i do this: > > d = dataListener() > e = dataListener() > > d.data = "fred" > > print f.data duh, duh - that should be print e.data :) -- http://mail.python.org/mailman/listinfo/python-list

execute a function before and after any method of a parent class

2008-10-03 Thread TP
Hi everybody, I would like to be able to specialize an existing class A, so as to obtain a class B(A), with all methods of B being the methods of A preceded by a special method of B called _before_any_method_of_A( self ), and followed by a special method of B called _after_any_method_of_A( self ).

Re: [BaseHTTPServer/SimpleHTTPServer] Remove "Server:" header

2008-10-03 Thread Gary M. Josack
you've got ?self.send_header('Server', self.version_string()) in the send_response method of the BaseHTTPRequestHandler class in the BaseHTTPServer module. Long story, short, it's going to be a lot of work to get rid of. [EMAIL PROTECTED] wrote: Hello. I'm using SimpleHTTPServer (work well)

Re: Python style: exceptions vs. sys.exit()

2008-10-03 Thread Grant Edwards
On 2008-10-03, greg <[EMAIL PROTECTED]> wrote: > Lawrence D'Oliveiro wrote: >> In message <[EMAIL PROTECTED]>, Steven D'Aprano >> wrote: >> >> > (2) Even when the source is available, it is sometimes a legal trap to >> > read it with respect to patents and copyright. >> >> That's not how patents

Re: windows help files ?

2008-10-03 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Lie Ryan wrote: > ...python's docstring viewer has a less-like pager (or was it less) in > Linux ... It invokes whatever you define in $PAGER. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python style: exceptions vs. sys.exit()

2008-10-03 Thread J. Cliff Dyer
On Fri, 2008-10-03 at 09:15 -0500, Grant Edwards wrote: > On 2008-10-03, greg <[EMAIL PROTECTED]> wrote: > > Lawrence D'Oliveiro wrote: > >> In message <[EMAIL PROTECTED]>, Steven D'Aprano > >> wrote: > >> > >> > (2) Even when the source is available, it is sometimes a legal trap to > >> > read i

Re: execute a function before and after any method of a parent class

2008-10-03 Thread Almar Klein
Maybe you can use __getattribute__. I tried it, but got stuck trying to let __getattribute__ work normal without calling itself. class A(object): def foo(self): print "hi" class B(A): def __getattribute__(self,name): try: fun = A.__dict__[name] except K

Re: Python style: exceptions vs. sys.exit()

2008-10-03 Thread Grant Edwards
On 2008-10-03, J. Cliff Dyer <[EMAIL PROTECTED]> wrote: > > On Fri, 2008-10-03 at 09:15 -0500, Grant Edwards wrote: >> On 2008-10-03, greg <[EMAIL PROTECTED]> wrote: >> > Lawrence D'Oliveiro wrote: >> >> In message <[EMAIL PROTECTED]>, Steven D'Aprano >> >> wrote: >> >> >> >> > (2) Even when the s

Re: tkinter textwidget problem

2008-10-03 Thread kib2
Tk/Tkinter apparently considers the position 1.13 to be after the last word in the text. You get the same problem if you set the insertion point just after the word 'two' for example: text.index('insert') returns 1.7 and text.index('insert wordstart') returns 1.7 too... Exactly. My solution w

ABCs -> infix syntax for isinstance() ?

2008-10-03 Thread Boris Borcic
Given the ABC innovation, maybe an infix syntax for isinstance() would be good. Possibilities : - stealing "is" away from object identity. As a motivation, true use cases for testing object identity are rare; forcing the usage of a function or method to test it, would dissuade abuse. - allow

C API type issue

2008-10-03 Thread Rich Henry
Made a simple little test program as im learning to embed python, have a simple script that just sets x=10.0 in test.py and prints type(x). Python prints that x is a float but PyFloat_Check() returns false. If i removed the check and just force it to print the double value, its correct. Any ideas w

Re: ABCs -> infix syntax for isinstance() ?

2008-10-03 Thread bearophileHUGS
Boris Borcic: > - combining both keywords to create a third one, eg "is in" A note only on syntax: "isa" seems better for Python. I don't comment how useful it can be. Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: lxml and schema validation

2008-10-03 Thread Stefan Behnel
hrishy wrote: > I am validating a xmlfile against a xsd (My.xsd) but i notice that the xsd > has a include which includes another xsd (My1.xsd) > > I have written a simple program that to validate this > > from lxml import etree > xmlschemadoc=etree.parse("My.xsd") > xmlschema=etree.XMLSchema(xm

Re: lxml and adding a stylesheet

2008-10-03 Thread Stefan Behnel
Sean Davis wrote: > I have an xml document and simply need to add an xml-stylesheet to > it. I am using lxml to parse the xml document and then would like to > insert the xml-stylesheet tag using the etree api. Any suggestions? I assume you are talking about a processing instruction here, not a

Re: lxml question

2008-10-03 Thread Stefan Behnel
Uwe Schmitt wrote: > I have to parse some text which pretends to be XML. lxml does not want > to parse it, because it lacks a root element. > I think that this situation is not unusual, so: is there a way to > force lxml to parse it ? > > My work around is wrapping the text with "..." before > fee

Re: closures and dynamic binding

2008-10-03 Thread Aaron "Castironpi" Brady
On Oct 3, 3:44 am, greg <[EMAIL PROTECTED]> wrote: > jhermann wrote: > > I didn't see this mentioned in the thread yet: the double-lambda is > > unnecessary (and a hack). > > Well, the alternative -- abusing default argument values -- > is seen by many to be a hack as well, possibly a worse one. >

Re: What is not objects in Python?

2008-10-03 Thread Aaron "Castironpi" Brady
On Oct 3, 5:10 am, "Tim Rowe" <[EMAIL PROTECTED]> wrote: > 2008/9/30 Lie Ryan <[EMAIL PROTECTED]>: > > > Actually str.len and len(str) is just like saying "the string's length" > > and "the length of the string". There is no difference between the two > > except for personal preference. (I am no li

Re: do you fail at FizzBuzz? simple prog test

2008-10-03 Thread Chuckk Hubbard
range(1,101), no? On Tue, May 20, 2008 at 4:46 PM, Sells, Fred <[EMAIL PROTECTED]> wrote: > or > for i in range(1,100): > print ('fizz','','')[i%3] + ('buzz','','','','')[i%5] or i > >> > >> > "Write a program that prints the numbers from 1 to 100. But for >> > multiples of three print "Fizz" ins

Re: execute a function before and after any method of a parent class

2008-10-03 Thread Aaron "Castironpi" Brady
On Oct 3, 9:03 am, TP <[EMAIL PROTECTED]> wrote: > Hi everybody, > > I would like to be able to specialize an existing class A, so as to obtain a > class B(A), with all methods of B being the methods of A preceded by a > special method of B called _before_any_method_of_A( self ), and followed by >

Re: SQLite

2008-10-03 Thread Petite Abeille
On Oct 3, 2008, at 2:33 PM, Matthias Huening wrote: This seems not to work with sqlite3. Before going any further... make sure that SQLite's count_change is enabled: PRAGMA count_changes PRAGMA count_changes = 0 | 1 "Query or change the count-changes flag. Normally, when the count- chan

how to get a class instance name during creation?

2008-10-03 Thread dmitrey
hi all, I have a code z = MyClass(some_args) can I somehow get info in MyClass __init__ function that user uses "z" as name of the variable? I.e. to have __init__ function that creates field z.name with value "z". Thank you in advance, D. -- http://mail.python.org/mailman/listinfo/python-list

"Exploding" (**myvariable) a dict with unicode keys

2008-10-03 Thread Devin
So Python can have unicode variable names but you can't "explode" (**myvariable) a dict with unicode keys? WTF? -Devin -- http://mail.python.org/mailman/listinfo/python-list

Re: windows help files ?

2008-10-03 Thread Gabriel Genellina
En Fri, 03 Oct 2008 09:07:21 -0300, Stef Mientki <[EMAIL PROTECTED]> escribió: Martin v. Löwis wrote: 1. how can I launch the windows help file (CHM), from python with a keyword as argument ? Run hh.exe. If you want it to navigate to specific page, also pass that page on the command line (

Re: [BaseHTTPServer/SimpleHTTPServer] Remove "Server:" header

2008-10-03 Thread Gabriel Genellina
[EMAIL PROTECTED] wrote: I'm using SimpleHTTPServer (work well) but it always sends "Server" header in response: How can I remove that ? En Fri, 03 Oct 2008 11:11:34 -0300, Gary M. Josack <[EMAIL PROTECTED]> escribió: you've got ?self.send_header('Server', self.version_string()) in the send

Re: SimpleXMLRPCServer -- turning off request log?

2008-10-03 Thread mh
Vinay Sajip <[EMAIL PROTECTED]> wrote: > Did you try setting logRequests to false? Perfect, that's just what I needed. Thanks Vinay!! Mark -- Mark Harrison Pixar Animation Studios -- http://mail.python.org/mailman/listinfo/python-list

Re: "Exploding" (**myvariable) a dict with unicode keys

2008-10-03 Thread Martin v. Löwis
Devin wrote: > So Python can have unicode variable names but you can't > "explode" (**myvariable) a dict with unicode keys? WTF? That works fine for me. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list

Re: "Exploding" (**myvariable) a dict with unicode keys

2008-10-03 Thread Peter Otten
"Martin v. Löwis" wrote: > Devin wrote: >> So Python can have unicode variable names but you can't >> "explode" (**myvariable) a dict with unicode keys? WTF? > > That works fine for me. The OP probably means >>> def f(a=1): return a ... >>> f(**{"a": 42}) 42 >>> f(**{u"a": 42}) Traceback (most

Re: "Exploding" (**myvariable) a dict with unicode keys

2008-10-03 Thread Devin
On Oct 3, 1:57 pm, Peter Otten <[EMAIL PROTECTED]> wrote: > "Martin v. Löwis" wrote: > > Devin wrote: > >> So Python can have unicode variable names but you can't > >> "explode" (**myvariable) a dict with unicode keys? WTF? > > > That works fine for me. > > The OP probably means > > >>> def f(a=1):

Re: execute a function before and after any method of a parent class

2008-10-03 Thread Gabriel Genellina
En Fri, 03 Oct 2008 11:03:22 -0300, TP <[EMAIL PROTECTED]> escribió: I would like to be able to specialize an existing class A, so as to obtain a class B(A), with all methods of B being the methods of A preceded by a special method of B called _before_any_method_of_A( self ), and followed

Re: "Exploding" (**myvariable) a dict with unicode keys

2008-10-03 Thread Martin v. Löwis
Devin wrote: > On Oct 3, 1:57 pm, Peter Otten <[EMAIL PROTECTED]> wrote: >> "Martin v. Löwis" wrote: >>> Devin wrote: So Python can have unicode variable names but you can't "explode" (**myvariable) a dict with unicode keys? WTF? >>> That works fine for me. >> The OP probably means >> >>>

Cheapest Generic Tramadol

2008-10-03 Thread woodardbgsmallpox
generic tramadol . . . Enough to seek generic tramadol! You've already found the best site where you can buy generic tramadol online for lowest price! Just click our link below and buy cheap generic tramadol. To order generic tramadol without prescription visit link below! *

Re: Python is slow?

2008-10-03 Thread Terry Reedy
greg wrote: Steven D'Aprano wrote: We agree that the restriction is artificial, and I think irrational I think it's irrational for another reason, too -- it's actually vacuous. There's nothing to prevent you creating a set of patches that simply say "Delete all of the original source and repl

[ANN] PyYAML-3.06: YAML parser and emitter for Python

2008-10-03 Thread Kirill Simonov
Announcing PyYAML-3.06 A new bug fix release of PyYAML is now available: http://pyyaml.org/wiki/PyYAML Changes === * setup.py checks whether LibYAML is installed and if so, builds and installs LibYAML bindings. To force or disable

Re: SQLite

2008-10-03 Thread Matthias Huening
Thanks! cursor.rowcount does exactly what I need. Before going any further... make sure that SQLite's count_change is enabled: PRAGMA count_changes PRAGMA count_changes = 0 | 1 "Query or change the count-changes flag. Normally, when the count-changes flag is not set, INSERT, UPDATE and DELET

Re: C API type issue

2008-10-03 Thread Gabriel Genellina
En Fri, 03 Oct 2008 12:27:50 -0300, Rich Henry <[EMAIL PROTECTED]> escribió: Made a simple little test program as im learning to embed python, have a simple script that just sets x=10.0 in test.py and prints type(x). Python prints that x is a float but PyFloat_Check() returns false. If i remov

Tkinter setting alpha

2008-10-03 Thread Jonathan Hayward
I'm trying to make a Tkinter/Python port of the demo at http://wiki.tcl.tk/10515 , which has adjustable alpha under Windows and (I think) MacOS. I'm not quite sure how to port: wm attributes . -alpha [expr {$alphaLevel + 0.05} ] set AlphaLevel [wm attributes . -alpha] The goal is to have

Re: how to get a class instance name during creation?

2008-10-03 Thread Gabriel Genellina
En Fri, 03 Oct 2008 15:04:01 -0300, dmitrey <[EMAIL PROTECTED]> escribió: I have a code z = MyClass(some_args) can I somehow get info in MyClass __init__ function that user uses "z" as name of the variable? I.e. to have __init__ function that creates field z.name with value "z". No. I'd jus

Re: "Exploding" (**myvariable) a dict with unicode keys

2008-10-03 Thread Devin
On Oct 3, 2:29 pm, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: > Devin wrote: > > On Oct 3, 1:57 pm, Peter Otten <[EMAIL PROTECTED]> wrote: > >> "Martin v. Löwis" wrote: > >>> Devin wrote: > So Python can have unicode variable names but you can't > "explode" (**myvariable) a dict with un

Re: javascript to python

2008-10-03 Thread Bruno Desthuilliers
lkcl a écrit : On Oct 3, 10:29 am, Bruno Desthuilliers wrote: lkcl a écrit :> On Oct 2, 7:42 pm, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: lkcl a écrit : And as far as I'm concerned, the point is exactly here : it's doing "a little bit more" than the original code. yeah, i know. a

Re: ABCs -> infix syntax for isinstance() ?

2008-10-03 Thread Bruno Desthuilliers
Boris Borcic a écrit : Given the ABC innovation, maybe an infix syntax for isinstance() would be good. Possibilities : - stealing "is" away from object identity. As a motivation, true use cases for testing object identity are rare; "x is None" is a *very* common test. Using a _marker objec

Re: Stopping a Thread with Time Slicing

2008-10-03 Thread Steve
Hi Todd, Thanks for your suggestions on using the Event condition methods on this thread. Here is my updated code : import time import datetime import threading def log(message): now = datetime.datetime.now().strftime("%H:%M:%S") print "%s : %s" % (now, message) class StoppableThrea

Re: closures and dynamic binding

2008-10-03 Thread Terry Reedy
greg wrote: jhermann wrote: I didn't see this mentioned in the thread yet: the double-lambda is unnecessary (and a hack). Well, the alternative -- abusing default argument values -- is seen by many to be a hack as well, possibly a worse one. I disagree. It is one way to evaluate an express

Re: how to get a class instance name during creation?

2008-10-03 Thread Bruno Desthuilliers
dmitrey a écrit : hi all, I have a code z = MyClass(some_args) can I somehow get info in MyClass __init__ function that user uses "z" as name of the variable? I.e. to have __init__ function that creates field z.name with value "z". This has been debated to hell and back. To make a long story s

Re: Remove "Server:" header

2008-10-03 Thread [EMAIL PROTECTED]
On 3 oct, 20:17, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > > [EMAIL PROTECTED] wrote: > >> I'm using SimpleHTTPServer (work well) but it always sends "Server" > >> header in response: > >> How can I remove that ? > > En Fri, 03 Oct 2008 11:11:34 -0300, Gary M. Josack <[EMAIL PROTECTED]>   >

Tramadol on line

2008-10-03 Thread marquezuieven
tramadol on line . . . Enough to seek Tramadol! You've already found the best site where you can purchase tramadol online for lowest price! Just click our link below and buy cheap tramadol To order tramadol without prescription visit link below! http://med247.us

Re: One class per file?

2008-10-03 Thread Bruno Desthuilliers
greg a écrit : Bruno Desthuilliers wrote: OTHO, 'one class per file' is a standard idiom in Java and IIRC in C++ (which both have namespaces one way or another) In Java you don't get a choice, because the compiler assumes a class can be found in the correspondingly named file. For public cl

Re: processing email with Python on Windows?

2008-10-03 Thread Mike Driscoll
On Oct 3, 9:01 am, Beliavsky <[EMAIL PROTECTED]> wrote: > I work for a financial company where we run Windows XP and read email > using Microsoft Outlook 2003. I get daily files that come as email > attachments from various counterparties. I save them as h:\firm_name > \mmdd.csv . Would Python

help: SIGABRT intermittent crash for threaded website crawleron python 2.4.4c1

2008-10-03 Thread Joey Bersche
I've been experiencing an intermittent crash where no python stacktrace is provided. It happens for a url downloading process that can last up to 12 hours and crawls about 50,000 urls. I'm using urllib2 for the downloads. There are 5-10 downloading threads, and some custom website exploration co

help: SIGABRT intermittent crash for threaded website crawleron python 2.4.4c1

2008-10-03 Thread Joey Bersche
I've been experiencing an intermittent crash where no python stacktrace is provided. It happens for a url downloading process that can last up to 12 hours and crawls about 50,000 urls. I'm using urllib2 for the downloads. There are 5-10 downloading threads, and some custom website exploration co

Re: processing email with Python on Windows?

2008-10-03 Thread Rob Williscroft
Beliavsky wrote in news:d579f554-be4b-4066-acec-49a7bafb1046 @t41g2000hsc.googlegroups.com in comp.lang.python: > I work for a financial company where we run Windows XP and read email > using Microsoft Outlook 2003. I get daily files that come as email > attachments from various counterparties. I

  1   2   >