Re: why in returns values for array and keys for dictionary

2008-08-25 Thread Erik Max Francis
++imanshu wrote: Wouldn't it be nicer to have 'in' return values (or keys) for both arrays and dictionaries. Arrays and Dictionaries looked so similar in Python until I learned this difference. It's because dealing with keys makes far more sense, since that's how the dictionary data struc

Re: why in returns values for array and keys for dictionary

2008-08-25 Thread Erik Max Francis
Marc 'BlackJack' Rintsch wrote: On Mon, 25 Aug 2008 19:57:06 -0700, alex23 wrote: On Aug 26, 10:49 am, "++imanshu" <[EMAIL PROTECTED]> wrote: Wouldn't it be nicer to have 'in' return values (or keys) for both arrays and dictionaries. Arrays and Dictionaries looked so similar in Python

mailbox module

2008-08-25 Thread ra9ftm
Hi all. I am trying to use mailbox module, mbox class like this: import mailbox m1 = mailbox.mbox('./ra9ftm2') But it gives the following: ra9ftm:/home/ra9ftm/pyemail# python mbox1.py Traceback (most recent call last): File "mbox1.py", line 2, in ? m1 = mailbox.mbox('./ra9ftm2') AttributeE

Re: File copying from a menu

2008-08-25 Thread Fredrik Lundh
Brandon wrote: I'm attempting to have a file copied from a menu selection. The menu already exists, but it won't even create the menu item. If anyone has any ideas, please let me know. try cutting down your code to a minimal example that illustrates the problem, and post that code (that'l

Re: python xslt library

2008-08-25 Thread Stefan Behnel
Owen Zhang wrote: > Can anyone recommand the best performance python xslt library? lxml. It's based on libxml2/libxslt. http://codespeak.net/lxml Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: rspec for python

2008-08-25 Thread Rustom Mody
Gerhard Haring wrote: > Have you actually used this "rspec" thing in Ruby? I always wonder with > such things. > > Same with all the other hyped technologies of yesteryear. Anybody out > there who really uses model-driven development? > -- Gerhard > Two laws are (the) most fundamental in our f

Non-evil multithreaded WSGI server?

2008-08-25 Thread Gerhard Häring
In a recent experiment I've done this: from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler from wsgiref.simple_server import make_server, demo_app from SocketServer import ThreadingMixIn # Let's make a WSGI server that can use multiple threads. class ThreadedHTTPServer(ThreadingMixIn,

Re: Need help with extension modules built in debug mode

2008-08-25 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: I've come to the conclusion that posting about Embedded Python on the Python forums is a complete waste of time. I hope I can get some useful insights here. (just curious, but what are the "Python forums"? isn't the newsgroup/mailing list *the* Python forum?) --

Re: Equivalents of Ruby's "!" methods?

2008-08-25 Thread mumbler
On Aug 26, 9:47 am, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Mon, 25 Aug 2008 17:04:07 +, Grzegorz Staniak wrote: > > On 25.08.2008, Terry Reedy <[EMAIL PROTECTED]> wroted: > > >> The newish sorted() and reversed() built-ins were meant to complement > >> list.sort and

Re: why in returns values for array and keys for dictionary

2008-08-25 Thread Asun Friere
On Aug 26, 10:49 am, "++imanshu" <[EMAIL PROTECTED]> wrote: > Hi, > > Wouldn't it be nicer to have 'in' return values (or keys) for both > arrays and dictionaries. > NO! When you iterate over a list (or even a array) it is the members of the list in the order they appear that is of interest.

Re: Struct class random access

2008-08-25 Thread castironpi
On Aug 25, 11:47 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Mon, 25 Aug 2008 14:49:14 -0700, castironpi wrote: > > I'm interested in the speed benefit, so you don't have to reconstruct > > the entire 'record' just to read/write one 'field'.  How in ctypes? > > Only the field acces

Re: Launch an application and continue the script's execution

2008-08-25 Thread Gabriel Genellina
--- El lun 25-ago-08, Marian Popa <[EMAIL PROTECTED]> escribió: Please keep posting on the list. Have you tried what other people already suggested? - I need to access a bat file which opens an application that doesn't have COM interface in order to control it from Python; so I just need to a

Re: why in returns values for array and keys for dictionary

2008-08-25 Thread alex23
On Aug 26, 2:30 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > The OP isn't talking about the ``in`` operator but ``in`` as part of > ``for … in …``.  So it's actually the question why ``list(a_dict)`` > doesn't return a list of values but a list of keys. Aaaah! Cheers, Marc, that didn'

smart quotes

2008-08-25 Thread Adrian Smith
Can anyone tell me how to get rid of smart quotes in html using Python? I've tried variations on stuff = string.replace(stuff, "\“", "\""), but to no avail, presumably because they're not standard ASCII. -- http://mail.python.org/mailman/listinfo/python-list

Re: Struct class random access

2008-08-25 Thread Marc 'BlackJack' Rintsch
On Mon, 25 Aug 2008 14:49:14 -0700, castironpi wrote: > I'm interested in the speed benefit, so you don't have to reconstruct > the entire 'record' just to read/write one 'field'. How in ctypes? Only the field accessed is converted. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.o

Re: why in returns values for array and keys for dictionary

2008-08-25 Thread Marc 'BlackJack' Rintsch
On Mon, 25 Aug 2008 19:57:06 -0700, alex23 wrote: > On Aug 26, 10:49 am, "++imanshu" <[EMAIL PROTECTED]> wrote: >>     Wouldn't it be nicer to have 'in' return values (or keys) for >>     both >> arrays and dictionaries. Arrays and Dictionaries looked so similar in >> Python until I learned this d

Need help with extension modules built in debug mode

2008-08-25 Thread bhood2
I've come to the conclusion that posting about Embedded Python on the Python forums is a complete waste of time. I hope I can get some useful insights here. I'm looking for some help with extension modules built using Visual Studio. I'm using the simple extension module example "hello" (taken fro

Re: why in returns values for array and keys for dictionary

2008-08-25 Thread Dan Bishop
On Aug 25, 9:57 pm, alex23 <[EMAIL PROTECTED]> wrote: > On Aug 26, 10:49 am, "++imanshu" <[EMAIL PROTECTED]> wrote: > > >     Wouldn't it be nicer to have 'in' return values (or keys) for both > > arrays and dictionaries. Arrays and Dictionaries looked so similar in > > Python until I learned this

Re: Return a string result with out breaking loop

2008-08-25 Thread castironpi
On Aug 25, 6:37 pm, Andrew <[EMAIL PROTECTED]> wrote: > Hi I was wondering if there is anyway with XML RPC to send a string of > text from the server to the client with out calling return thus breaking >   my loop > > for example > >   def somefunc(): >        for action, files in results: >      

File copying from a menu

2008-08-25 Thread Brandon
I'm attempting to have a file copied from a menu selection. The menu already exists, but it won't even create the menu item. If anyone has any ideas, please let me know. -- http://mail.python.org/mailman/listinfo/python-list

Re: SocketServer max connections

2008-08-25 Thread Guilherme Polo
On Mon, Aug 25, 2008 at 7:20 AM, Ken Seehart <[EMAIL PROTECTED]> wrote: > I'm using SocketServer to implement a local server that serves comet > long-polling connections. > > How do I increase the maximum number of open connections? Currently it is > limited to about 8 I think. More than that and

RE: The Importance of Terminology's Quality

2008-08-25 Thread Phil Runciman
>On Thu, 21 Aug 2008 02:36:39 +, sln wrote: >>>Whats os interresting about all this hullabaloo is that nobody has coded >>>machine code here, and know's squat about it. >>> >>>I'm not talking assembly language. Don't you know that there are >>>routines that program machine code? Yes, burned

Re: why in returns values for array and keys for dictionary

2008-08-25 Thread alex23
On Aug 26, 12:57 pm, alex23 <[EMAIL PROTECTED]> wrote: > By 'arrays' do you mean lists? tuples? My apologies, there actually -is- an array type in Python. I've just honestly never had any cause to use it :) I'm still not entirely sure what you would like 'in' to do, though. -- http://mail.pytho

Re: why in returns values for array and keys for dictionary

2008-08-25 Thread alex23
On Aug 26, 10:49 am, "++imanshu" <[EMAIL PROTECTED]> wrote: >     Wouldn't it be nicer to have 'in' return values (or keys) for both > arrays and dictionaries. Arrays and Dictionaries looked so similar in > Python until I learned this difference. By 'arrays' do you mean lists? tuples? I'm not sur

Re: Return a string result with out breaking loop

2008-08-25 Thread alex23
On Aug 26, 12:14 pm, Andrew <[EMAIL PROTECTED]> wrote: > I run the server then execute the client. From the client I execute the > function key.watchos() > Sorry if I posted to much code :-) The problem is the Python implementation of XML-RPC _can't_ send generators (which is what the 'unable to m

SocketServer max connections

2008-08-25 Thread Ken Seehart
I'm using SocketServer to implement a local server that serves comet long-polling connections. How do I increase the maximum number of open connections? Currently it is limited to about 8 I think. More than that and it seems to block on opening more connections until one of the other connect

Re: Enhanced property decorator

2008-08-25 Thread Ben Finney
Daniel <[EMAIL PROTECTED]> writes: > I've often been frustrated by the inability of the built-in property > descriptor to handle anything other than a read-only property when > used as a decorator. The fact that the 'property' function works as a decorator (in, as you point out, some cases only)

Re: Return a string result with out breaking loop

2008-08-25 Thread Andrew
I run the server then execute the client. From the client I execute the function key.watchos() My goal is an administration tool and this is just a function in my goal :-) Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp. C:\Documents and Settings\Maboroshi>pyt

Python-URL! - weekly Python news and links (Aug 26)

2008-08-25 Thread Gabriel Genellina
QOTW: "A quick rule of thumb for Python: if your code looks ugly or strained or awkward, it's probably also wrong." - John Machin http://groups.google.com/group/comp.lang.python/msg/90893abfe9a181de Barry Warsaw announces the third (and last) beta releases of Python 2.6 and P

Re: Enhanced property decorator

2008-08-25 Thread Daniel
On 25 Aug, 21:52, Benjamin <[EMAIL PROTECTED]> wrote: > ... I think Python 2.6 may have > want you want: > > class A(object): > >     @property >     def my_prop(): return self._prop > >     @my_prop.setter >     def my_prop(prop): self._prop = prop > >     @my_prop.deleter >     def my_prop(): del

Re: Return a string result with out breaking loop

2008-08-25 Thread cnb
ok post exactly what you do when this hapens: ault: :cannot marshal objects"> it complains you are trying to marshal a generator object rather than the file you are yielding. also, something I am not sure about: >>> def f(x): try: open("C:/ruby/progs/blandat/infixtoprefix.rb") or open

Re: Enhanced property decorator

2008-08-25 Thread Benjamin
On Aug 25, 8:45 pm, Daniel <[EMAIL PROTECTED]> wrote: > I've often been frustrated by the inability of the built-in property > descriptor to handle anything other than a read-only property when > used as a decorator. Furthermore, read/write/delete properties take > their doc-string and property def

Enhanced property decorator

2008-08-25 Thread Daniel
I've often been frustrated by the inability of the built-in property descriptor to handle anything other than a read-only property when used as a decorator. Furthermore, read/write/delete properties take their doc-string and property definition at a non-intuitive and awkward place (after the getter

SocketServer and long-polling connections

2008-08-25 Thread Ken Seehart
I apologize if this message is a repeat. It looks like didn't get received. I'm using SocketServer to implement a local server that serves comet long-polling connections. How do I increase the maximum number of open connections? Currently it is limited to about 8 I think. More than that an

Re: Return a string result with out breaking loop

2008-08-25 Thread Andrew
Yes I found many examples similiar to that but Yield still produces that error Sorry if I sound Novice but I have no formal education in programming so understanding something takes me a bit longer than most of you guys :-D Ive included a bit more of the function How ever unimportant it may

Re: Usual practice: running/testing modules in a package

2008-08-25 Thread Gabriel Genellina
--- El dom 24-ago-08, Medardo Rodriguez (Merchise Group) <[EMAIL PROTECTED]> escribió: (please keep posting on this list) On Sun, Aug 24, 2008 at 1:18 AM, Gabriel Genellina <[EMAIL PROTECTED]> wrote: I think you misunderstood the comment. I didn't. The problem is my bad English :( I'm n

Programmatically exit the REPL

2008-08-25 Thread Matthew Fitzgibbons
I've got a pretty complex interactive command line program. Instead of writing my own REPL, I'm using the Python interpreter (an infinitely better solution). This program has two threads, a background thread and the REPL thread. When you call quit() or sys.exit() in the REPL thread, everything

Re: Return a string result with out breaking loop

2008-08-25 Thread cnb
On Aug 26, 2:50 am, cnb <[EMAIL PROTECTED]> wrote: > def somefunc(): >        for action, files in results: >                full_filename = os.path.join(path_to_watch, files) >                theact = ACTIONS.get(action, "Unknown") >                yield  str(full_filename) +  " " + str(theact) >

Re: Date Comparison and Manipulation Functions?

2008-08-25 Thread W. eWatson
[EMAIL PROTECTED] wrote: check out Pyfdate: http://www.ferg.org/pyfdate from pyfdate import * t = Time().add(hours=14) print "It is now", t.wdt datestring1 = "2005/10/05" #year,month,day datestring2 = "2002/09/22" #year,month,day datestring3 = "2007/11/11" #year,month,day year,month,day = num

Re: Mutability, copying lists but not sharing?

2008-08-25 Thread Alan G Isaac
cnb wrote: And there isn't a .copy function so I have to "new = [] for element in list: new.append(element)"? You can do new = list(old) which I like for being explicit, or just new = old[:] and what is the difference between extend and + on lists? >>> a = range(3) >>> b = a

Re: Return a string result with out breaking loop

2008-08-25 Thread cnb
def somefunc(): for action, files in results: full_filename = os.path.join(path_to_watch, files) theact = ACTIONS.get(action, "Unknown") yield str(full_filename) + " " + str(theact) ? Here is an example if that doesn't work, using yield, to

why in returns values for array and keys for dictionary

2008-08-25 Thread ++imanshu
Hi, Wouldn't it be nicer to have 'in' return values (or keys) for both arrays and dictionaries. Arrays and Dictionaries looked so similar in Python until I learned this difference. Thanks, ++imanshu -- http://mail.python.org/mailman/listinfo/python-list

Mutability, copying lists but not sharing?

2008-08-25 Thread cnb
Is it not possible to have mutability without this? I know I can use sorted and list(reversed) instead of .sort and .reverse but if I want to copy a list and then change that list without changing the first one? And there isn't a .copy function so I have to "new = [] for element in list: new.append

Re: Return a string result with out breaking loop

2008-08-25 Thread Benjamin Kaplan
On Mon, Aug 25, 2008 at 8:19 PM, Andrew <[EMAIL PROTECTED]> wrote: > Hi Ive been trying with yield all day and other different things :D > > but I always get the same result using yield > > Fault: :cannot marshal 'generator' > > objects"> > > I'm not sure exactly what I am doing wrong as this is

Re: Return a string result with out breaking loop

2008-08-25 Thread Andrew
Hi Ive been trying with yield all day and other different things :D but I always get the same result using yield Fault: :cannot marshal 'generator' > objects"> I'm not sure exactly what I am doing wrong as this is the first time Ive used yield Any suggestions on how to fix this error Cheer

Re: Why do all my loggers start auto-disabled?

2008-08-25 Thread Vinay Sajip
Calling fileConfig() disables any loggers existing at the time of the call. Make sure you call fileConfig() before instantiating any loggers; after that you can instantiate as many as you like, and they will all be enabled. Make sure you don't call fileConfig() again, as in that call all loggers wh

Re: Private attribute

2008-08-25 Thread Steven D'Aprano
On Mon, 25 Aug 2008 19:47:38 +0100, Ken Starks wrote: > I have a class with an attribute called 'gridsize' and I want a derived > class to force and keep it at 0.8 (representing 8mm). > > Is this a correct, or the most pythonic approach? Others have already suggested using a property, but I'll s

Re: Return a string result with out breaking loop

2008-08-25 Thread Christian Heimes
Andrew wrote: Hi I was wondering if there is anyway with XML RPC to send a string of text from the server to the client with out calling return thus breaking my loop for example def somefunc(): for action, files in results: full_filename = os.path.join(path_to_watch, fil

Re: Replace reduce with listcomprehension?

2008-08-25 Thread Steven D'Aprano
On Tue, 26 Aug 2008 00:53:35 +0200, Diez B. Roggisch wrote: >> So it seems only reduce will be eliminated. > > Nope. From the link you provided yourself: > > """ > Only reduce will be removed from the 3.0 standard library. You can > import it from functools. > """ functools isn't in the standar

Re: Equivalents of Ruby's "!" methods?

2008-08-25 Thread Steven D'Aprano
On Mon, 25 Aug 2008 17:04:07 +, Grzegorz Staniak wrote: > On 25.08.2008, Terry Reedy <[EMAIL PROTECTED]> wroted: > >> The newish sorted() and reversed() built-ins were meant to complement >> list.sort and list.reverse, not replace them. > > BTW, is there a reason why sorted() on a list retur

Re: Struct class random access

2008-08-25 Thread castironpi
On Aug 25, 4:49 pm, castironpi <[EMAIL PROTECTED]> wrote: > On Aug 25, 4:25 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > > > > > On Mon, 25 Aug 2008 13:03:09 -0700, castironpi wrote: > > > struct.Struct lets you encode Python objects into structured memory. It > > > accepts a format st

Return a string result with out breaking loop

2008-08-25 Thread Andrew
Hi I was wondering if there is anyway with XML RPC to send a string of text from the server to the client with out calling return thus breaking my loop for example def somefunc(): for action, files in results: full_filename = os.path.join(path_to_watch, files)

Re: swig or ctypes , under the gun and need help

2008-08-25 Thread Diez B. Roggisch
Sells, Fred schrieb: Diez wrote... I don't know swig, but if all you have is a real C-API, try & use ctypes. It's much easier to create bindings for, keeps you fully in the warm and cozy womb of python programming and doesn't need no compilation to create the actual binding. You're right th

Re: Replace reduce with listcomprehension?

2008-08-25 Thread bearophileHUGS
Luis M. González, citing Guido: > A. I'm not killing reduce() because I hate functional programming; I'm > killing it because almost all code using reduce() is less readable > than the same thing written out using a for loop and an accumulator > variable. (So reduce is now in itertools). Try to pr

Re: Replace reduce with listcomprehension?

2008-08-25 Thread Diez B. Roggisch
Luis M. González schrieb: Correction: I guess the link I provided above is old news... In the more recent Python 3000 FAQ, GvR says: Q. If you're killing reduce(), why are you keeping map() and filter()? A. I'm not killing reduce() because I hate functional programming; I'm killing it because a

Re: Replace reduce with listcomprehension?

2008-08-25 Thread Luis M . González
Correction: I guess the link I provided above is old news... In the more recent Python 3000 FAQ, GvR says: Q. If you're killing reduce(), why are you keeping map() and filter()? A. I'm not killing reduce() because I hate functional programming; I'm killing it because almost all code using reduce(

Re: python - firefox dom/xpath question/issue

2008-08-25 Thread Diez B. Roggisch
bruce schrieb: Hi. Got a test web page, that basically has two " . . . I've simplified things a bit... but basically, the 1st "html/body" is empty, with the 2nd containing the data/nodes I need. If that's your document, it is invalid XML - XML only allows *one* root. Thus the parsers

Re: Replace reduce with listcomprehension?

2008-08-25 Thread Diez B. Roggisch
ssecorp schrieb: GvR wants to eliminate all the functional stuff (lambda map reduce filter) which kind of makes sense for Python, listcomprehensions are more efficient(at least as implemented inpython) from what i have gathered and they can express everything map/reduce/filter with crippled lambd

Re: Replace reduce with listcomprehension?

2008-08-25 Thread Luis M . González
Actually, GvR announced that "lambda, filter and map will stay (the latter two with small changes, returning iterators instead of lists). Only reduce will be removed from the 3.0 standard library. You can import it from functools." Check the full article here: http://www.artima.com/weblogs/viewpo

ANN: TZMud-0.5, a Python MUD server

2008-08-25 Thread Lee Harr
TZMud is a Python MUD server. http://tzmud.googlecode.com/ A MUD is a text-based virtual environment accessed via telnet, or with a specialized MUD client. TZMud development is still in early stages, focusing on API and server stability. TZMud uses several high-quality Python libraries to facil

Re: I can't fetch dom node in svg file with getElementById method (module minidom and libxml2dom)

2008-08-25 Thread Paul Boddie
On 25 Aug, 14:56, KLEIN Stéphane <[EMAIL PROTECTED]> wrote: > [DOM implementations, identifiers and validation] > Thanks ! It work. I've since updated libxml2dom to support validation and provide a more reliable getElementById method. Unfortunately, I can't seem to make the example document vali

Re: Private attribute

2008-08-25 Thread Ken Starks
Marc 'BlackJack' Rintsch wrote: On Mon, 25 Aug 2008 21:44:49 +0100, Ken Starks wrote: def __getattr__(self,attrname): if attrname == 'gridsize': return 0.8 def __setattr__(self,attrname,value): if attrname == 'gridsize':

Replace reduce with listcomprehension?

2008-08-25 Thread ssecorp
GvR wants to eliminate all the functional stuff (lambda map reduce filter) which kind of makes sense for Python, listcomprehensions are more efficient(at least as implemented inpython) from what i have gathered and they can express everything map/reduce/filter with crippled lambdas can. but what a

Re: Struct class random access

2008-08-25 Thread castironpi
On Aug 25, 4:25 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Mon, 25 Aug 2008 13:03:09 -0700, castironpi wrote: > > struct.Struct lets you encode Python objects into structured memory. It > > accepts a format string, and optionally a buffer and offset to/from > > which to read/write

Re: Private attribute

2008-08-25 Thread Marc 'BlackJack' Rintsch
On Mon, 25 Aug 2008 21:44:49 +0100, Ken Starks wrote: >>> >>> >>> def __getattr__(self,attrname): >>> if attrname == 'gridsize': >>> return 0.8 >>> >>> def __setattr__(self,attrname,value): >>> if attrname == 'gridsize': >>>

Re: Struct class random access

2008-08-25 Thread Marc 'BlackJack' Rintsch
On Mon, 25 Aug 2008 13:03:09 -0700, castironpi wrote: > struct.Struct lets you encode Python objects into structured memory. It > accepts a format string, and optionally a buffer and offset to/from > which to read/write the structure. What do you think of random access > for the results? > > (un

Re: How to get PyTypeObject from PyObject?

2008-08-25 Thread Hrvoje Niksic
chris <[EMAIL PROTECTED]> writes: > I want to check the type of an object, right now I am doing > strcmp( object->ob_type->tp_name, "MyClass") > > Which seems slow, is there a way I can find the pointer to the > global PyTypeObject for MyClass, and then just call > PyObject_TypeCheck? Simply get

How to get PyTypeObject from PyObject?

2008-08-25 Thread chris
I want to check the type of an object, right now I am doing strcmp( object->ob_type->tp_name, "MyClass") Which seems slow, is there a way I can find the pointer to the global PyTypeObject for MyClass, and then just call PyObject_TypeCheck? Thanks -- http://mail.python.org/mailman/listinfo/python

Re: signal and threading

2008-08-25 Thread ~levon
this seems to be the solution: http://code.activestate.com/recipes/496735/ On Aug 25, 3:37 pm, "~levon" <[EMAIL PROTECTED]> wrote: > Hello group, > > in following example, a signal handler is registered and a thread > started. if I call self.doSomethin() directly > the code works as I would expect

Re: Private attribute

2008-08-25 Thread Ken Starks
André wrote: On Aug 25, 3:47 pm, Ken Starks <[EMAIL PROTECTED]> wrote: I have a class with an attribute called 'gridsize' and I want a derived class to force and keep it at 0.8 (representing 8mm). Is this a correct, or the most pythonic approach? def __getattr__(self

Re: iterparse and unicode

2008-08-25 Thread Fredrik Lundh
George Sakkis wrote: It depends on what you mean by "compatible"; e.g. you can't safely do [s.decode('utf8') for s in strings] if you have byte strings mixed with unicode. why would you want to decode strings given to you by a library that returns decoded strings? if you meant to write "enc

Re: Unexpected global variable behaviour

2008-08-25 Thread Fredrik Lundh
RgeeK wrote: I'm seeing something which make me think I'm missing something about how global var's behave. I've defined a global string, right at the start of my .py file. outXMLfile = "abc" I define a class and do a bunch of stuff below that. Then I have another class, and in it, there

python xslt library

2008-08-25 Thread Owen Zhang
Can anyone recommand the best performance python xslt library? Have anyboday used 4Suite? How do you feel about performance? -- http://mail.python.org/mailman/listinfo/python-list

extract text from ods TableCell using odfpy

2008-08-25 Thread frankentux
Hi there, I'm losing hair trying to figure out how I can actually get the text out of an existing .ods file. Currently I have: #!/usr/bin/python from odf.opendocument import Spreadsheet from odf.opendocument import load from odf.table import TableRow,TableCell from odf import text doc = load("/tmp

Re: iterparse and unicode

2008-08-25 Thread George Sakkis
On Aug 24, 1:12 am, Stefan Behnel <[EMAIL PROTECTED]> wrote: > George Sakkis wrote: > > On Aug 21, 1:48 am, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > > >> George Sakkis wrote: > >>> It's interesting that the element text attributes after a successful > >>> parse do not necessarily have the same ty

Unexpected global variable behaviour

2008-08-25 Thread RgeeK
I'm seeing something which make me think I'm missing something about how global var's behave. I've defined a global string, right at the start of my .py file. outXMLfile = "abc" I define a class and do a bunch of stuff below that. Then I have another class, and in it, there is a method 'de

Re: Private attribute

2008-08-25 Thread André
On Aug 25, 3:47 pm, Ken Starks <[EMAIL PROTECTED]> wrote: > I have a class with an attribute called 'gridsize' and I want > a derived class to force and keep it at 0.8 (representing 8mm). > > Is this a correct, or the most pythonic approach? > > > >      def __getattr__(self,at

Struct class random access

2008-08-25 Thread castironpi
struct.Struct lets you encode Python objects into structured memory. It accepts a format string, and optionally a buffer and offset to/from which to read/write the structure. What do you think of random access for the results? (unproduced) >>> packer= struct.Struct( 'IIIf255p' ) >>> packer.pack_i

python - firefox dom/xpath question/issue

2008-08-25 Thread bruce
Hi. Got a test web page, that basically has two " . . . I've simplified things a bit... but basically, the 1st "html/body" is empty, with the 2nd containing the data/nodes I need. In using xpath("/html/body/form"), the app returns nothing/crashes.. I've tried to do something like xpath("

Re: Private attribute

2008-08-25 Thread castironpi
On Aug 25, 2:09 pm, Ken Starks <[EMAIL PROTECTED]> wrote: > Ken Starks wrote: > > I have a class with an attribute called 'gridsize' and I want > > a derived class to force and keep it at 0.8 (representing 8mm). > > > Is this a correct, or the most pythonic approach? > > > > >

Re: os.popen() interferes with os.fork()?

2008-08-25 Thread Hrvoje Niksic
JohnMudd <[EMAIL PROTECTED]> writes: > On Linux I get a "close failed: [Errno 10] No child processes" msg > for each fork. But only if I have a pipe open. I don't understand > the connection between the popen and the forks. Am I doing > something wrong? Yes: don't use sys.exit, use os._exit.

Re: Private attribute

2008-08-25 Thread Ken Starks
Ken Starks wrote: I have a class with an attribute called 'gridsize' and I want a derived class to force and keep it at 0.8 (representing 8mm). Is this a correct, or the most pythonic approach? def __getattr__(self,attrname): if attrname == 'gridsize':

os.popen() interferes with os.fork()?

2008-08-25 Thread JohnMudd
On Linux I get a "close failed: [Errno 10] No child processes" msg for each fork. But only if I have a pipe open. I don't understand the connection between the popen and the forks. Am I doing something wrong? #! /usr/bin/env python import os import sys import time p = os.popen('top -b -d1')

Private attribute

2008-08-25 Thread Ken Starks
I have a class with an attribute called 'gridsize' and I want a derived class to force and keep it at 0.8 (representing 8mm). Is this a correct, or the most pythonic approach? def __getattr__(self,attrname): if attrname == 'gridsize': return 0.8

Re: Interrupt python thread

2008-08-25 Thread Gabriel Genellina
En Mon, 25 Aug 2008 05:00:07 -0300, BlueBird <[EMAIL PROTECTED]> escribi�: On Aug 24, 8:35 pm, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:         The only safe way to "abort" a thread is by having it exit on its own. This means one needs a means of setting an attribute that each thread pe

RE: swig or ctypes , under the gun and need help

2008-08-25 Thread Sells, Fred
Diez wrote... > I don't know swig, but if all you have is a real C-API, try & > use ctypes. > It's much easier to create bindings for, keeps you fully in > the warm and > cozy womb of python programming and doesn't need no > compilation to create > the actual binding. > You're right the ctypes

RE: python/xpath issue..

2008-08-25 Thread bruce
never mind... it was an issue with the targeted site... it's sending screwed up html the times when i get an err... thanks though! -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of bruce Sent: Monday, August 25, 2008 4:49 AM To: python-list@python.org Subjec

Re: py2exe importing a package not in library.zip

2008-08-25 Thread mypetslug
On Aug 20, 4:48 pm, [EMAIL PROTECTED] wrote: > Hi, > I'm sorry if this has been asked before, but I can't seem to find an > answer to this anywhere and so far, trial and error hasn't gotten me > far either. > > Using python 2.4, I've created a testing application.  When the app > starts up, I do a

Re: generate methods at runtime, but the wrong one gets called

2008-08-25 Thread Marc 'BlackJack' Rintsch
On Mon, 25 Aug 2008 12:52:44 +0200, Maric Michaud wrote: > In other OOP language I would encourage you to implement this logic in > some sort of singleton, but in python we don't like this construct, > module level variables and function do perfectly the job, simple as > they are. Modules are som

Re: Equivalents of Ruby's "!" methods?

2008-08-25 Thread Fredrik Lundh
Grzegorz Staniak wrote: BTW, is there a reason why sorted() on a list returns a list, while reversed() on the same list returns an iterator? the algorithm required to sort a sequence is something entirely different from the algorithm required to loop over a sequence in reverse. we went thro

Micro-threading PEP proposal announcement

2008-08-25 Thread Bruce Frederiksen
I wanted to make everybody aware that I've posted a (rather long and involved) PEP proposal for adding micro-threading to Python on python-ideas for feedback and review. In a nutshell, this proposal implements the Twisted Deferred/Reactor at the C level so that the Python programmer gets the advan

Re: Why do all my loggers start auto-disabled?

2008-08-25 Thread Peter Otten
jonfroehlich wrote: > I am a relative newbie to Python and its logging infrastructure; > however, I have programmed extensively with Java/C# and log4j and > log4net. That, I suppose, could be the root of my problem :) > > I am trying to setup one logger per module (as this is roughly > analogous

Re: Equivalents of Ruby's "!" methods?

2008-08-25 Thread Grzegorz Staniak
On 25.08.2008, Terry Reedy <[EMAIL PROTECTED]> wroted: > The newish sorted() and reversed() built-ins were meant to complement > list.sort and list.reverse, not replace them. BTW, is there a reason why sorted() on a list returns a list, while reversed() on the same list returns an iterator? GS

Re: The Importance of Terminology's Quality

2008-08-25 Thread norseman
Arne Vajhøj wrote: Paul Wallich wrote: Martin Gregorie wrote: On Fri, 22 Aug 2008 22:56:09 +, sln wrote: On Thu, 21 Aug 2008 09:11:48 -0500, [EMAIL PROTECTED] (Rob Warnock) wrote: [EMAIL PROTECTED]> wrote: ...(snip) I thought microcode was relative well defined as being the software

Re: Equivalents of Ruby's "!" methods?

2008-08-25 Thread Terry Reedy
Paul McGuire wrote: Pythonistically speaking, even though a dict is a mutable thing, I'm learning that the accepted practice for methods like this is not so much to update in place as it is to use generator expressions to construct a new object. I disagree. The convention is that mutation m

Re: QT 4.4 and timedelta

2008-08-25 Thread Mohamed Yousef
I'm not very sure about this , but it's logicallay enough to be said i think the QTableView ordering mechanism must provide some overriding functionality through accepting a comparing function from you check it On Mon, Aug 25, 2008 at 7:48 PM, admoore <[EMAIL PROTECTED]> wrote: > Maybe I'm missing

QT 4.4 and timedelta

2008-08-25 Thread admoore
Maybe I'm missing something obvious, but is there a QT object to represent time intervals, a la datetime.timedelta? I'm working on a utility that displays database query results from a postgres database (using psycopg2) in a QTableView. For columns created using "age(some_date_column)", I get a d

ANN: Leo 4.5 beta 4 released

2008-08-25 Thread Edward K Ream
Leo 4.5 beta 4 is now available at: http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106 This beta 4 release will likely be the last release before Leo 4.5 final. Leo 4.5 contains many important new features. See below for details. Leo is a text editor, data organizer, pr

Re: Python String Immutability Broken!

2008-08-25 Thread Terry Reedy
Ken Seehart wrote: Hendrik van Rooyen wrote: ... Actually, I am not complaining - I am asking for advice on the side effects of what I am doing, which is replacing a bunch of bits in what is essentially an output bit field with the corresponding input bits at the same addresses read back fr

How to setup environment for python?

2008-08-25 Thread Robert Dailey
Hi, I'm running on Linux and I'm executing a python script as a subversion post-commit hook. I'm finding that I'm running into a lot of random issues, and I'm guessing this has to do with my environment not being properly setup. From what I've gathered, the environment is not setup when the script

  1   2   >