None in comparison

2008-07-17 Thread r . grimm
Hello, I'm a little confused about None in comparison. >>> id ( None ) 3086100672L >>> id ( 1 ) 134541104 >>> None < 1 True >>> I thought, the id of the object is the last comparison criterion. Therefore, None must be greater then 1. Where is the behaviour of the comparison defined?. In the __cmp

Re: How to process a very large (4Gb) tarfile from python?

2008-07-17 Thread Uwe Schmitt
On 17 Jul., 22:21, Lars Gustäbel <[EMAIL PROTECTED]> wrote: > > > Maybe we should post this issue to python-dev mailing list. > > Parsing large tar-files is not uncommon. > > This issue is known and was fixed for Python 3.0, > seehttp://bugs.python.org/issue2058. The proposed patch does not avoid

Re: storing references instead of copies in a dictionary

2008-07-17 Thread John Machin
On Jul 18, 4:26 pm, castironpi <[EMAIL PROTECTED]> wrote: > I delicately ask for an example in natural language and daily life in > which we change what object a name refers to, her, him, it, ... i.e. any pronoun -- http://mail.python.org/mailman/listinfo/python-list

Re: interpreter vs. compiled

2008-07-17 Thread castironpi
On Jul 17, 11:39 pm, Kay Schluehr <[EMAIL PROTECTED]> wrote: > On 18 Jul., 01:15, castironpi <[EMAIL PROTECTED]> wrote: > > > > > On Jul 17, 5:37 pm, I V <[EMAIL PROTECTED]> wrote: > > > > On Thu, 17 Jul 2008 15:08:17 -0700, castironpi wrote: > > > > The Python disassembly is baffling though. > > >

Re: storing references instead of copies in a dictionary

2008-07-17 Thread castironpi
On Jul 17, 7:36 pm, bgeddy <[EMAIL PROTECTED]> wrote: > bgeddy wrote: > > castironpi wrote: > >> On Jul 17, 10:05 am, mk <[EMAIL PROTECTED]> wrote: > def f2(arg): >     return "f2 "+arg > def f1(arg): >     return "f1 "+arg > a={"1":"f1","2":"f2"} > print [eval(x[1])(x

Re: % sign in python?

2008-07-17 Thread Tim Roberts
Steven Howe <[EMAIL PROTECTED]> wrote: >Terry Reedy wrote: >> >> korean_dave wrote: >>> What does this operator do? Specifically in this context >>> >>> test.log( "[[Log level %d: %s]]" % ( level, msg ), description ) > >I thought, in this contexted, it was mapping operator. What?? Python does

Re: How can i use a variable without define it ?

2008-07-17 Thread Tim Roberts
zhw <[EMAIL PROTECTED]> wrote: >Ben Finney <[EMAIL PROTECTED]> >wrote: >> >> What problem are you trying to solve? > >I an sorry, I can't tell you. That's nonsense. No one is asking you to reveal the design of your company's next product. However, you have some overall problem you are trying to

Re: singletons

2008-07-17 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Craig Allen wrote: > On Jul 16, 7:01 pm, Lawrence D'Oliveiro <[EMAIL PROTECTED] > central.gen.new_zealand> wrote: >> >> >>> class TehLibrary(object) : >> >> ... @classmethod >> ... def __new__(self, cls) : >> ... return self >> >> >>> s = TehLibrary(

Re: Converting from local -> UTC

2008-07-17 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Gabriel Genellina wrote: > Note that I used %s everywhere (it's just a placeholder, not a format) ... >From /usr/lib64/python2.5/site-packages/MySQLdb/cursors.py, lines 150-151: if args is not None: query = query % db.literal(args) -- http://mail.pytho

paypal wholesale men jordans 13 (paypal accept)(www goodsaler com

2008-07-17 Thread cheaplv
paypal wholesale men jordans (paypal accept)(www goodsaler com paypal wholesale men jordans 1 (paypal accept)(www goodsaler com paypal wholesale men jordans 2 (paypal accept)(www goodsaler com paypal wholesale men jordans 3 (paypal accept)(www goodsaler com paypal wholesale men jordans 4 (pa

wholesale p u m a sneaker(paypal accept)(www goodsaler com)paypal

2008-07-17 Thread 14789
wholesale p u m a sneaker(paypal accept)(www goodsaler com)paypal wholesale p u m a sneaker(paypal accept)(www goodsaler com)paypal wholesale p u m a sneaker(paypal accept)(www goodsaler com)paypal wholesale p u m a sneaker(paypal accept)(www goodsaler com)paypal wholesale p u m a sneaker(paypal ac

wholesale n i k e sneaker(paypal accept)(www all-wholesaler com)paypal

2008-07-17 Thread 14789
wholesale n i k e sneaker(paypal accept)(www all-wholesaler com)paypal wholesale n i k e sneaker(paypal accept)(www all-wholesaler com)paypal wholesale n i k e sneaker(paypal accept)(www all-wholesaler com)paypal wholesale n i k e sneaker(paypal accept)(www all-wholesaler com)paypal wholesale n i k

Re: Problem with MySQLdb and mod_python

2008-07-17 Thread John Nagle
Cyril Bazin wrote: Thanks for your reply The apache log contains lines like : [Tue Jul 15 23:31:01 2008] [notice] mod_python (pid=11836, interpreter='www.toto.fr'): Importing module '/usr/local/apache2/htdocs/intranet/courrier/test.py' [Tue Jul 15 23:31:02 2008] [notice] child pid 11836 exit si

Re: interpreter vs. compiled

2008-07-17 Thread Kay Schluehr
On 18 Jul., 01:15, castironpi <[EMAIL PROTECTED]> wrote: > On Jul 17, 5:37 pm, I V <[EMAIL PROTECTED]> wrote: > > > > > On Thu, 17 Jul 2008 15:08:17 -0700, castironpi wrote: > > > The Python disassembly is baffling though. > > > y= 3 > > dis.dis('x=y+1') > > > You can't disassemble string

RELEASED Python 2.6b2 and 3.0b2

2008-07-17 Thread Barry Warsaw
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On behalf of the Python development team and the Python community, I am happy to announce the second beta releases of Python 2.6 and Python 3.0. Please note that these are beta releases, and as such are not suitable for production environments

Re: storing references instead of copies in a dictionary

2008-07-17 Thread John Machin
On Jul 18, 10:36 am, bgeddy <[EMAIL PROTECTED]> wrote: [snip] > the OP's post revolved around having a rewritable > set of "labels" - which could be recorded at one time and when re > referenced the new definitions of those labels would be used. For > example a "collection" (list,dictionary,tuple)

Re: interpreter vs. compiled

2008-07-17 Thread Terry Reedy
castironpi wrote: On Jul 17, 5:37 pm, I V <[EMAIL PROTECTED]> wrote: Oh. How is the stack represented? As usual, as successive locations in memory. I have the impression that CPython uses the same stack C does. While conceptually, CPython may put objects on the stack, I am pretty sure it

Re: storing references instead of copies in a dictionary

2008-07-17 Thread bgeddy
bgeddy wrote: castironpi wrote: On Jul 17, 10:05 am, mk <[EMAIL PROTECTED]> wrote: def f2(arg): return "f2 "+arg def f1(arg): return "f1 "+arg a={"1":"f1","2":"f2"} print [eval(x[1])(x[0]) for x in a.items()] def f2(arg): return "New f2 "+arg print [eval(x[1])(x[0]) for x in a.items

Re: storing references instead of copies in a dictionary

2008-07-17 Thread bgeddy
castironpi wrote: On Jul 17, 10:05 am, mk <[EMAIL PROTECTED]> wrote: def f2(arg): return "f2 "+arg def f1(arg): return "f1 "+arg a={"1":"f1","2":"f2"} print [eval(x[1])(x[0]) for x in a.items()] def f2(arg): return "New f2 "+arg print [eval(x[1])(x[0]) for x in a.items()] Neat trick

Re: Pickle and wx.TextCtrl

2008-07-17 Thread Gabriel Genellina
En Thu, 17 Jul 2008 09:40:29 -0300, <[EMAIL PROTECTED]> escribi�: The way you read the file is rather strange -mixing calls to readline and pickle.load- I'd write the data using pickle.dump calls *only* and then read it using pickle.load calls *only*. I used 13.1.7 Example of the Python Library

Re: x, = y (???)

2008-07-17 Thread alex23
On Jul 18, 8:01 am, DaveM <[EMAIL PROTECTED]> wrote: > On Thu, 17 Jul 2008 17:32:30 -0400, Terry Reedy <[EMAIL PROTECTED]> wrote: > > >>> *x, = [3] > > >>> x > >[3] > > What does *x signify? Mostly that Terry is using Python 3.0. See: http://www.python.org/dev/peps/pep-3132/ -- http://mail.pytho

Re: Converting from local -> UTC

2008-07-17 Thread Gabriel Genellina
En Wed, 16 Jul 2008 15:00:50 -0300, Keith Hughitt <[EMAIL PROTECTED]> escribi�: Thanks Gabriel! That helps clear things up for me. The above method works very well. I only have one remaining question: How can I pass a datetime object to MySQL?' So far, what I've been doing is building the qu

Re: interpreter vs. compiled

2008-07-17 Thread castironpi
On Jul 17, 5:37 pm, I V <[EMAIL PROTECTED]> wrote: > On Thu, 17 Jul 2008 15:08:17 -0700, castironpi wrote: > > The Python disassembly is baffling though. > > y= 3 > dis.dis('x=y+1') > > You can't disassemble strings of python source (well, you can, but, as > you've seen, the results are n

Importing different versions of a module

2008-07-17 Thread mercado mercado
I have two versions of a script on my machine. One version is for new development and the other version is a production version. This script imports a module from a different directory, and this module again has two versions (a development version and a production version). What I want is for the

Re: interpreter vs. compiled

2008-07-17 Thread I V
On Thu, 17 Jul 2008 15:08:17 -0700, castironpi wrote: > The Python disassembly is baffling though. > y= 3 dis.dis('x=y+1') You can't disassemble strings of python source (well, you can, but, as you've seen, the results are not meaningful). You need to compile the source first: >>> co

Re: singletons

2008-07-17 Thread Craig Allen
On Jul 17, 2:15 am, Uwe Schmitt <[EMAIL PROTECTED]> wrote: > On 17 Jul., 00:20, Craig Allen <[EMAIL PROTECTED]> wrote: > > > > > I have several classes in our system which need to act like > > singletons, they are libraries of data classifications, and other such > > libraries of configurations for

Re: % sign in python?

2008-07-17 Thread Jordan
On Jul 17, 3:42 pm, Terry Reedy <[EMAIL PROTECTED]> wrote: > korean_dave wrote: > > What does this operator do? Specifically in this context > > > test.log( "[[Log level %d: %s]]" % ( level, msg ), description ) > > > (Tried googling and searching, but the "%" gets interpreted as an > > operation a

Re: Using Tcl extensions with Python?

2008-07-17 Thread Guilherme Polo
On Thu, Jul 17, 2008 at 6:48 PM, C Martin <[EMAIL PROTECTED]> wrote: > How do you setup a Tcl extension to be accessible through Python? I > understand that I'll have to use native Tcl calls to use it (tk.call() > etc), but I can't figure out where to put the files or how to > initialize them so I

interpreter vs. compiled

2008-07-17 Thread castironpi
I'm curious about some of the details of the internals of the Python interpreter: I understand C from a hardware perspective. x= y+ 1; Move value from place y into a register Add 1 to the value in the register Move the addition's result to place x The Python disassembly is baffling though. >>>

Re: x, = y (???)

2008-07-17 Thread DaveM
On Thu, 17 Jul 2008 17:32:30 -0400, Terry Reedy <[EMAIL PROTECTED]> wrote: > >>> *x, = [3] > >>> x >[3] What does *x signify? DaveM -- http://mail.python.org/mailman/listinfo/python-list

Re: Converting from local -> UTC

2008-07-17 Thread M.-A. Lemburg
On 2008-07-17 22:43, Dennis Lee Bieber wrote: On Thu, 17 Jul 2008 19:55:44 +0200, "M.-A. Lemburg" <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: Use binding parameters and it should work: query = "INSERT INTO image VALUES(%d, %d, %s, '%s')" If this is MySQLdb inter

Re: Babelfish translation ...

2008-07-17 Thread Stef Mientki
thanks Stefan, both lxml and threading works perfect. One small problem, "with_tail" was not recognized as a valid keyword. cheers, Stef Stefan Behnel wrote: Stef Mientki gmail.com> writes: Although it works functionally, it can take lots of time waiting for the translation. What I basic

Using Tcl extensions with Python?

2008-07-17 Thread C Martin
How do you setup a Tcl extension to be accessible through Python? I understand that I'll have to use native Tcl calls to use it (tk.call() etc), but I can't figure out where to put the files or how to initialize them so I can call them. The package I would like to use is TkPNG: http://www.muonics

Re: x, = y (???)

2008-07-17 Thread Terry Reedy
kj wrote: I just came across an assignment of the form x, = y where y is a string (in case it matters). 1. What's the meaning of the comma in the LHS of the assignment? 2. How could I have found this out on my own? 1.Experiment with the interactive interpreter. It is sooo easy. >>> x

Re: unpacking with default values

2008-07-17 Thread Terry Reedy
McA wrote: Do you know the "protocol" used by python while unpacking? Is it a direct assingnment? Or iterating? In CPython, at least, both, just as with normal unpack and multiple assignment. The iterable is unpacked into pieces by iterating (with knowledge of the number of targets and wh

Re: How to process a very large (4Gb) tarfile from python?

2008-07-17 Thread Lars Gustäbel
On Thu, Jul 17, 2008 at 10:39:23AM -0700, Uwe Schmitt wrote: > On 17 Jul., 17:55, Terry Carroll <[EMAIL PROTECTED]> wrote: > > On Thu, 17 Jul 2008 06:14:45 -0700 (PDT), Uwe Schmitt > > > > <[EMAIL PROTECTED]> wrote: > > >I had a look at tarfile.py in my current Python 2.5 installations > > >lib pat

Re: x, = y (???)

2008-07-17 Thread Duncan Booth
kj <[EMAIL PROTECTED]> wrote: > I still don't get it. If we write > > y = 'Y' > x, = y > > what's the difference now between x and y? And if there's no > difference, what's the point of performing such "unpacking"? None whatsoever when the string has only one character, but with 2 char

Re: decorating a method in multiple child classes

2008-07-17 Thread Duncan Booth
[EMAIL PROTECTED] wrote: > I wish to decorate all of the CX.func() in the same way. One way to > do this is to add a decorator to each of the derived classes. But > this is tedious and involves modifying multiple files. > > Is there a way to modify the parent class and have the same effect? > O

Re: x, = y (???)

2008-07-17 Thread Matthew Woodcraft
kj wrote: > I still don't get it. If we write > > y = 'Y' > x, = y > > what's the difference now between x and y? And if there's no > difference, what's the point of performing such "unpacking"? If y really is is a string, I think it's likely that the line you came across was a typo. In the

XML Parsing: Expat Error

2008-07-17 Thread Gerth, William D
Hey all, I'm simply trying to get my feet wet with XML parsing, and I tried to just do something simple with ElementTree, just throw the XML tags from a file into a list. The code is as follows (and may be wrong): import glob import xml.etree.ElementTree as ET tree = ET.parse('nameofFileh

Re: % sign in python?

2008-07-17 Thread Steven Howe
Terry Reedy wrote: korean_dave wrote: What does this operator do? Specifically in this context test.log( "[[Log level %d: %s]]" % ( level, msg ), description ) (Tried googling and searching, but the "%" gets interpreted as an operation and distorts the search results) Having seen a number

Re: x, = y (???)

2008-07-17 Thread Jonathan Gardner
On Jul 17, 12:55 pm, kj <[EMAIL PROTECTED]> wrote: > what's the point of performing such "unpacking"? record = [name, address, telephone] ... name, address, telephone = record -- http://mail.python.org/mailman/listinfo/python-list

Re: x, = y (???)

2008-07-17 Thread Jonathan Gardner
On Jul 17, 12:55 pm, kj <[EMAIL PROTECTED]> wrote: > I still don't get it.  If we write > >   y  = 'Y' >   x, = y > > what's the difference now between x and y?  And if there's no > difference, what's the point of performing such "unpacking"? > Try: y = "abc" x, = y You were unpacking y into

Re: x, = y (???)

2008-07-17 Thread Chris Mellon
On Thu, Jul 17, 2008 at 2:55 PM, kj <[EMAIL PROTECTED]> wrote: > In <[EMAIL PROTECTED]> Erik Max Francis <[EMAIL PROTECTED]> writes: > >>kj wrote: > >>> I just came across an assignment of the form >>> >>> x, = y >>> >>> where y is a string (in case it matters). >>> >>> 1. What's the meaning of t

decorating a method in multiple child classes

2008-07-17 Thread 1x7y2z9
Say, we have a (parent) class P. It has N child classes C1(P), C2(P) ... CN(P) Each of the child classes defines (differently) a method func(). I wish to decorate all of the CX.func() in the same way. One way to do this is to add a decorator to each of the derived classes. But this is tedious

Re: x, = y (???)

2008-07-17 Thread kj
In <[EMAIL PROTECTED]> Erik Max Francis <[EMAIL PROTECTED]> writes: >kj wrote: >> I just came across an assignment of the form >> >> x, = y >> >> where y is a string (in case it matters). >> >> 1. What's the meaning of the comma in the LHS of the assignment? >It's unpacking a 1-tuple: >

RE: properly delete item during "for item in..."

2008-07-17 Thread Reedick, Andrew
> -Original Message- > From: [EMAIL PROTECTED] [mailto:python- > [EMAIL PROTECTED] On Behalf Of Ratko > Sent: Thursday, July 17, 2008 12:27 PM > To: python-list@python.org > Subject: properly delete item during "for item in..." > > Say you have something like this: > > for item in myLis

Re: % sign in python?

2008-07-17 Thread Terry Reedy
korean_dave wrote: What does this operator do? Specifically in this context test.log( "[[Log level %d: %s]]" % ( level, msg ), description ) (Tried googling and searching, but the "%" gets interpreted as an operation and distorts the search results) Having seen a number of comments like thi

Re: properly delete item during "for item in..."

2008-07-17 Thread Ratko
> > For dictionaries we can just iterate over values() or items() as > > opposed to itervalues() or iteritems() since that's technically a copy > > of values or items in the dict, right? > > No! In fact the whole point of iteritems and itervalues and iterkeys is > that they *DO NOT* make copies, s

Re: storing references instead of copies in a dictionary

2008-07-17 Thread castironpi
On Jul 17, 10:05 am, mk <[EMAIL PROTECTED]> wrote: > > def f2(arg): > >     return "f2 "+arg > > > def f1(arg): > >     return "f1 "+arg > > > a={"1":"f1","2":"f2"} > > print [eval(x[1])(x[0]) for x in a.items()] > > def f2(arg): > >     return "New f2 "+arg > > print [eval(x[1])(x[0]) for x in a.i

Re: x, = y (???)

2008-07-17 Thread Erik Max Francis
kj wrote: I just came across an assignment of the form x, = y where y is a string (in case it matters). 1. What's the meaning of the comma in the LHS of the assignment? 2. How could I have found this out on my own? (Regarding (2) above, I consulted the index of several Python reference boo

wholesale air bape sneaker(paypal accept)(www all-wholesaler com)paypal

2008-07-17 Thread hyh_david
paypal wholesale air bape sneaker(paypal accept)(www all-wholesaler com)paypal wholesale air bape sneaker(paypal accept)(www all-wholesaler com)paypal wholesale air bape sneaker(paypal accept)(www all-wholesaler com)paypal wholesale air bape sneaker(paypal accept)(www all-wholesaler com)paypal whol

wholesale adidas sneaker(paypal accept)(www all-wholesaler com)paypal

2008-07-17 Thread hyh_david
paypal wholesale adidas sneaker(paypal accept)(www all-wholesaler com)paypal wholesale adidas sneaker(paypal accept)(www all-wholesaler com)paypal wholesale adidas sneaker(paypal accept)(www all-wholesaler com)paypal wholesale adidas sneaker(paypal accept)(www all-wholesaler com)paypal wholesale ad

wholesale n i k e sneaker(paypal accept)(www all-wholesaler com)paypal

2008-07-17 Thread hyh_david
paypal wholesale n i k e sneaker(paypal accept)(www all-wholesaler com)paypal wholesale n i k e sneaker(paypal accept)(www all-wholesaler com)paypal wholesale n i k e sneaker(paypal accept)(www all-wholesaler com)paypal wholesale n i k e sneaker(paypal accept)(www all-wholesaler com)paypal wholesal

x, = y (???)

2008-07-17 Thread kj
I just came across an assignment of the form x, = y where y is a string (in case it matters). 1. What's the meaning of the comma in the LHS of the assignment? 2. How could I have found this out on my own? (Regarding (2) above, I consulted the index of several Python reference books but I c

Re: Rotating a cube

2008-07-17 Thread norseman
J-Burns wrote: Hello. Need some help here. I have a 4*4 cube. So the equation of the cube becoming: x + 4*y + 16*z Now i want to rotate this cube 90 degrees anticlockwise( a right rotation). How can i do that? The rotation must take place with the a

Re: Rotating a cube

2008-07-17 Thread Ryan Smith
Have you taken the time to solve the problem for the 2D case? I can't say my code is correct or even good python, but this was my attempt at the 2D case, maybe it will give you some ideas. http://code.google.com/p/rs-wxpython-nooberdev/source/browse/rectangle.py For the rest of c.l.p, criticism

Re: Need Python Programmer (preferentially in Los Angeles)

2008-07-17 Thread robnhood00
Fair enough. All details of the project will be disclosed so a proper bid can be put in place. I just need an experienced Python Programmer and I'll put you in direct contact with the client and I won't even take a referral fee. I just want the project completed. Thanks again, Rob On Jul 16, 6:0

Re: properly delete item during "for item in..."

2008-07-17 Thread Gary Herron
Ratko wrote: On Jul 17, 9:57 am, mk <[EMAIL PROTECTED]> wrote: Gary Herron wrote: You could remove the object from the list with del myList[i] if you knew i. HOWEVER, don't do that while looping through the list! Changing a list's length will interact badly with the for loop's indexin

Re: unpacking with default values

2008-07-17 Thread Gary Herron
McA wrote: On 17 Jul., 18:33, Gary Herron <[EMAIL PROTECTED]> wrote: In Python 2.x, you can't do that directly, but you should be able to create a function that lengthens or shortens an input tuple of arguments to the correct length so you can do: a,c,b = fix(1,2) d,e,f = fix(1,2,3,4) H

Re: Converting from local -> UTC

2008-07-17 Thread M.-A. Lemburg
On 2008-07-16 20:00, Keith Hughitt wrote: Thanks Gabriel! That helps clear things up for me. The above method works very well. I only have one remaining question: How can I pass a datetime object to MySQL?' So far, what I've been doing is building the query as a string, for example: query = "I

RE: Unusual Exception Behaviour

2008-07-17 Thread Robert Rawlins
>> That's seriously weird. What's your Python version and platform? On my >> Windows and Linux machines, with more recent Python versions the above >> trick works flawlessly. >> >> Check your environment, namely PYTHON* variables. There may be >> something causing this behaviour. Unset them. >>

Re: How to process a very large (4Gb) tarfile from python?

2008-07-17 Thread Uwe Schmitt
On 17 Jul., 17:55, Terry Carroll <[EMAIL PROTECTED]> wrote: > On Thu, 17 Jul 2008 06:14:45 -0700 (PDT), Uwe Schmitt > > <[EMAIL PROTECTED]> wrote: > >I had a look at tarfile.py in my current Python 2.5 installations > >lib path. The iterator caches TarInfo objects in a list > >tf.members . If you o

Re: bad recursion, still works

2008-07-17 Thread mdsherry
On Jul 17, 8:27 am, Jeff <[EMAIL PROTECTED]> wrote: > Thanks, that made things very clear.  I like that technique for adding > memoization via the parameter.  That is clever.  It would be nice if > there were a way to have multiple functions close over a shared local > variable in Python, like let-

Re: property getter with more than 1 argument?

2008-07-17 Thread Roy H. Han
I don't understand what you're trying to do here. On Thu, Jul 17, 2008 at 10:57 AM, mk <[EMAIL PROTECTED]> wrote: > > It seems like getter is defined in such way that it passes only 'self': > > > class FunDict(dict): >def __init__(self): >self.fundict = dict() > >d

Re: unpacking with default values

2008-07-17 Thread McA
On 17 Jul., 18:33, Gary Herron <[EMAIL PROTECTED]> wrote: > > In Python 2.x, you can't do that directly, but you should be able to > create a function that lengthens or shortens an input tuple of arguments > to the correct length so you can do: > > a,c,b = fix(1,2) > d,e,f = fix(1,2,3,4) > > Ho

Re: properly delete item during "for item in..."

2008-07-17 Thread Duncan Booth
mk <[EMAIL PROTECTED]> wrote: > Iterating over a copy may _probably_ work: > > >>> t=['a', 'c', 'b', 'd'] > >>> > >>> for el in t[:]: > del t[t.index(el)] > > > >>> t > [] > > > However, is it really safe? Defining safe as "works reliably in every > corner case for every indexable

RE: Unusual Exception Behaviour

2008-07-17 Thread Robert Rawlins
> That's seriously weird. What's your Python version and platform? On my > Windows and Linux machines, with more recent Python versions the above > trick works flawlessly. > > Check your environment, namely PYTHON* variables. There may be something > causing this behaviour. Unset them. > > Check

Re: Unusual Exception Behaviour

2008-07-17 Thread mk
http://linux.byexamples.com/archives/365/python-convey-the-exception-traceba ck-into-log-file/ if __name__=="__main__": try: main() except: print "Trigger Exception, traceback info forward to log file." traceback.print_exc(file=open("errlog.txt","a"))

Re: properly delete item during "for item in..."

2008-07-17 Thread Ratko
On Jul 17, 9:57 am, mk <[EMAIL PROTECTED]> wrote: > Gary Herron wrote: > > You could remove the object from the list with > > del myList[i] > > if you knew i. HOWEVER, don't do that while looping through the list! > > Changing a list's length will interact badly with the for loop's > > indexing t

Re: properly delete item during "for item in..."

2008-07-17 Thread mk
Gary Herron wrote: You could remove the object from the list with del myList[i] if you knew i. HOWEVER, don't do that while looping through the list! Changing a list's length will interact badly with the for loop's indexing through the list, causing the loop to mis the element following the

RE: Unusual Exception Behaviour

2008-07-17 Thread Robert Rawlins
Hi MK, >>Robert Rawlins wrote: >> >> I certainly like that implementation for logging the exceptions, however, at >> the moment I don't even know where the exceptions are occurring, or what >> type they are, could I still use this method to log any and all exceptions >> raised in the application?

Re: properly delete item during "for item in..."

2008-07-17 Thread Gary Herron
Ratko wrote: Say you have something like this: for item in myList: del item Would this actually delete the item from the list or just decrement the reference counter because the item in myList is not associated with name "item" anymore (but still is with myList[itemIndex])? In other words, i

Re: properly delete item during "for item in..."

2008-07-17 Thread Marc 'BlackJack' Rintsch
On Thu, 17 Jul 2008 09:27:27 -0700, Ratko wrote: > for item in myList: >del item > > Would this actually delete the item from the list or just decrement > the reference counter because the item in myList is not associated > with name "item" anymore (but still is with myList[itemIndex])? In >

Re: Python Behind a Squid Corporate Proxy on Windows

2008-07-17 Thread Larry Hale
Err, the line above should be: proxy_handler = urllib2.ProxyHandler( { "http": "http:// myusername:[EMAIL PROTECTED]:3128" } ) (Sorry! :) -- http://mail.python.org/mailman/listinfo/python-list

Re: unpacking with default values

2008-07-17 Thread Gary Herron
McA wrote: Hi all, probably a dumb question, but I didn't find something elegant for my problem so far. In perl you can unpack the element of a list to variables similar as in python (a, b, c = [0, 1, 2]), but the number of variables need not to fit the number of list elements. That means, if yo

properly delete item during "for item in..."

2008-07-17 Thread Ratko
Say you have something like this: for item in myList: del item Would this actually delete the item from the list or just decrement the reference counter because the item in myList is not associated with name "item" anymore (but still is with myList[itemIndex])? In other words, is "item" a temp

Re: Unusual Exception Behaviour

2008-07-17 Thread mk
Robert Rawlins wrote: I certainly like that implementation for logging the exceptions, however, at the moment I don't even know where the exceptions are occurring, or what type they are, could I still use this method to log any and all exceptions raised in the application? Sure. I'm a little

Python Behind a Squid Corporate Proxy on Windows

2008-07-17 Thread Larry Hale
Greetings, Pythonistas! My employer has a Squid Proxy between my Python programs and The Internet. I've searched high-and-low, and can only find examples online of how to do basic authentication to connect TO an external Web Server, but not how to go THROUGH a (corporate) Proxy, thus my question

unpacking with default values

2008-07-17 Thread McA
Hi all, probably a dumb question, but I didn't find something elegant for my problem so far. In perl you can unpack the element of a list to variables similar as in python (a, b, c = [0, 1, 2]), but the number of variables need not to fit the number of list elements. That means, if you have less l

RE: Unusual Exception Behaviour

2008-07-17 Thread Robert Rawlins
Hi Mk, > Why not capture exceptions themselves to a log file? > > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/466332 Thanks for the reply mate, I appreciate you getting back to me so quickly. I certainly like that implementation for logging the exceptions, however, at the moment I do

Re: How to process a very large (4Gb) tarfile from python?

2008-07-17 Thread Terry Carroll
On Thu, 17 Jul 2008 06:14:45 -0700 (PDT), Uwe Schmitt <[EMAIL PROTECTED]> wrote: >I had a look at tarfile.py in my current Python 2.5 installations >lib path. The iterator caches TarInfo objects in a list >tf.members . If you only want to iterate and you are not interested >in more functionallity

Re: Unusual Exception Behaviour

2008-07-17 Thread mk
I have looked through the application for any unusual or bare try/except blocks that don’t actually do anything with the except just in case any of them are causing the issue but can’t seem to see any. Why not capture exceptions themselves to a log file? http://aspn.activestate.com/ASPN/Cookbo

Unusual Exception Behaviour

2008-07-17 Thread Robert Rawlins
Hello Chaps, I have an unusual situation with my application which I've also seen once or twice in the past but never found a solution too. Basically the application stops properly reporting Exceptions when they are thrown. My application logs extensively to a file using the python logging

Re: Javascript - Python RSA encryption interoperability

2008-07-17 Thread Paul Rubin
Evren Esat Ozkan <[EMAIL PROTECTED]> writes: > I'm trying to encrypt a string with RSA. But it needs to be compitable > with Dave's JavaScript RSA implementation*. What exactly are you trying to do? That Javascript implementation looks like bad news. If you're trying to secure a web page, use S

Re: storing references instead of copies in a dictionary

2008-07-17 Thread mk
def f2(arg): return "f2 "+arg def f1(arg): return "f1 "+arg a={"1":"f1","2":"f2"} print [eval(x[1])(x[0]) for x in a.items()] def f2(arg): return "New f2 "+arg print [eval(x[1])(x[0]) for x in a.items()] Neat trick, if probably dangerous in some circumstances. Anyway, thanks, I

Re: Good HTML Parser

2008-07-17 Thread Stefan Behnel
Chris wrote: > Can anyone recommend a good HTML/XHTML parser, similar to > HTMLParser.HTMLParser or htmllib.HTMLParser, but able to intelligently > know that certain tags, like , are implicitly closed? I need to > iterate through the entire DOM, building up a DOM path, but the stdlib > parsers aren

Re: how to debug python's extend module written in c/c++ on windows

2008-07-17 Thread fang
Dear Diez: I see. I appreciate your help really. best regards fang -- http://mail.python.org/mailman/listinfo/python-list

Re: Python embedding question (2).

2008-07-17 Thread Carl Banks
On Jul 17, 9:57 am, Thomas Troeger <[EMAIL PROTECTED]> wrote: > > I'd say that PyGame could be a solution. > > > Or otherwise you could do your own audio/graphics programming (you don't > > tell us which OS you use, but there exist python modules that allow you > > to do barebones graphics & sound

property getter with more than 1 argument?

2008-07-17 Thread mk
It seems like getter is defined in such way that it passes only 'self': class FunDict(dict): def __init__(self): self.fundict = dict() def fget(self, fun): return fundict[fun.func_name] def fset(self, newfun): self.fundic

Re: storing references instead of copies in a dictionary

2008-07-17 Thread mk
Uwe Schmitt wrote: Python stores references in dictionaries and does not copy ! (unless you explicitly use the copy module) ! In your case the entry in the dictionary is a reference to the same object which f1 references, that is the object at 0xb7f0ba04. If you now say "f1=...:" then f1 refere

Re: storing references instead of copies in a dictionary

2008-07-17 Thread bgeddy
mk wrote: Calvin Spealman wrote: To your actual problem... Why do you wanna do this anyway? If you want to change the function in the dictionary, why don't you simply define the functions you'll want to use, and change the one you have bound to the key in the dictionary when you want to change i

twistedmatrix

2008-07-17 Thread Białystok
Hi. I'm newbie in Twisted. Can anyone explain how does twisted server work? What happens after reactor.listenTCP running? I've got many connections from one client (one connection-one socket), each of them is served by class serve(Protocol). every protocol owns transport every transport owns sock

Re: % sign in python?

2008-07-17 Thread Roy H. Han
The percent sign is a placeholder. For example, if level = 1 msg = 'look' Then '[[Log level %d: %s]]' % ( level, msg ) becomes '[[Log level 1: look]]' %d means insert an integer %s means insert a string You can also use dictionaries. d = {'string1': 'hey', 'string2': 'you'} Then '%(string1)s %(

Re: how to debug python's extend module written in c/c++ on windows

2008-07-17 Thread Diez B. Roggisch
fang wrote: > Dear Diez: > > It is attaching a C-debugger to python. I can attach python- > debugger(for example:wingIDE) to c-debugger(for example:VS2008), but I > cannot attach VS2008 to wingIDE. I need both python statement and c > statement can be single-step debugged. AFAIK that's not possi

Re: % sign in python?

2008-07-17 Thread Robert Bossy
korean_dave wrote: What does this operator do? Specifically in this context test.log( "[[Log level %d: %s]]" % ( level, msg ), description ) (Tried googling and searching, but the "%" gets interpreted as an operation and distorts the search results) It's the string formatting operator: h

% sign in python?

2008-07-17 Thread korean_dave
What does this operator do? Specifically in this context test.log( "[[Log level %d: %s]]" % ( level, msg ), description ) (Tried googling and searching, but the "%" gets interpreted as an operation and distorts the search results) -- http://mail.python.org/mailman/listinfo/python-list

Re: Babelfish translation ...

2008-07-17 Thread Stefan Behnel
Stef Mientki gmail.com> writes: > Although it works functionally, > it can take lots of time waiting for the translation. > > What I basically do is, after selecting a new string to be translated: > > kwds = { 'trtext' : line_to_be_translated, 'lp' :'en_nl'} > soup = BeautifulSoup (urlop

Re: Python embedding question (2).

2008-07-17 Thread Thomas Troeger
I'd say that PyGame could be a solution. Or otherwise you could do your own audio/graphics programming (you don't tell us which OS you use, but there exist python modules that allow you to do barebones graphics & sound programming on linux...). After some more reading I've stumbled over pygle

Re: storing references instead of copies in a dictionary

2008-07-17 Thread mk
Calvin Spealman wrote: To your actual problem... Why do you wanna do this anyway? If you want to change the function in the dictionary, why don't you simply define the functions you'll want to use, and change the one you have bound to the key in the dictionary when you want to change it? In other

  1   2   >