Re: Who is your daddy: Can I find what object instantiates another object?

2009-04-13 Thread Diez B. Roggisch
hubritic schrieb: I want to build a parser object that handles two different log file formats. I have an object that handles Connection logs and an object for Filter logs. Each will instantiate a Parser object, passing in the path to individual log files. There are a number of ways I could fig

Re: REG: python c++ bindings

2009-04-13 Thread Diez B. Roggisch
[email protected] schrieb: Hi Please don't reply to existing posts. People read news and mails threaded, and this makes a post appear below other, non-related posts & causes confusion. Create a new thread instead, by directly posting to the group or ML. I need some materia

Re: ctypes - random access to address space

2009-04-14 Thread Diez B. Roggisch
janislaw schrieb: Hi, I am currently doing a project in which I interface to a PCI card. To ease the prototyping, I call the API functions, which map the address space of the card to a process memory. I acquire the location in the process memory mapped to an address space using card API, result

Re: Should we separate business logic and ORM mapping classes?

2009-04-14 Thread Diez B. Roggisch
一首诗 wrote: > Hi, > > ( First, this is not a question about if we should use ORM. It's > question for these who are already using it. ) > > Usually, I only use ORM, like sqlalchemy just as an abstraction layer > of > database. So these mapping objects I wrote only contains data but not > behav

Re: Automatically generating arithmetic operations for a subclass

2009-04-14 Thread Diez B. Roggisch
andrew cooke wrote: > Arnaud Delobelle wrote: >> I do this: >> >> binops = ['add', 'sub', 'mul', 'div', 'radd', 'rsub'] # etc >> unops = ['neg', 'abs', invert'] # etc >> >> binop_meth = """ >> def __%s__(self, other): >> return type(self)(int.__%s__(self, other)) >> """ >> >> unop_meth = """ >

Re: Play sound at wanted frequency

2009-04-14 Thread Diez B. Roggisch
Matteo schrieb: I need to playback a sound on a linux machine of a pre-determined frequency like, say, 440 Hz. How can I do that with python? I found the ossaudiodev package, but it says that the ossaudiodev.write() method accepts data as a raw string. It doesn't explain what the string should be

Re: segmentation fault while using ctypes

2009-04-14 Thread Diez B. Roggisch
sanket schrieb: Hello All, I am dealing with this weird bug. I have a function in C and I have written python bindings for it using ctypes. I can call this function for couple of times and then suddenly it gives me seg fault. But I can call same function from a C code for any number of times.

Re: segmentation fault while using ctypes

2009-04-15 Thread Diez B. Roggisch
> > Thanks Diez, > > I used the gdb but it just crashed and kicked my out of gdb prompt. > how can I get a stack trace? That's odd, has never happened for me before. Can you show us what you do exactly, and what gdb & co say? Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: get text from rogramms runn by subprocess.Popen immediatetly

2009-04-16 Thread Diez B. Roggisch
Rüdiger Ranft schrieb: Hi all, I need to call some programms and catch their stdout and stderr streams. While the Popen class from subprocess handles the call, I get the results of the programm not until the programm finishes. Since the output of the programm is used to generate a progress indic

Re: Question to python C API

2009-04-16 Thread Diez B. Roggisch
it is possible to write C and python code into the same file ? Not as such. And JNI is an atrocity, btw. But what you can do (if you have a pure C-API, no C++) is to completely ditch the C from the equation and go for ctypes. This allows you to easily wrap the C-functions i

Re: Is there any way to find out the definition of a function in a file of C language?

2009-04-16 Thread Diez B. Roggisch
Jebel schrieb: Hi ,everyone. I have the name of a function of C language, and have the source file which the function is defined in. And I want to find out the type and name of the parameters. If I need to analyze the file by myself, or have some way to do it more easily? Google for ctypes and

Re: get text from rogramms runn by subprocess.Popen immediatetly

2009-04-16 Thread Diez B. Roggisch
Rüdiger Ranft schrieb: Diez B. Roggisch schrieb: Rüdiger Ranft schrieb: Hi all, I need to call some programms and catch their stdout and stderr streams. While the Popen class from subprocess handles the call, I get the results of the programm not until the programm finishes. Since the output

Re: setuptools catch 22

2009-04-16 Thread Diez B. Roggisch
Mac schrieb: We've got ActiveState Python 2.6 installed on a Windows XP box, and I pulled down the latest archgenxml package (2.2) in order to get it running under this installation of Python. I unpacked the tarball for the package and tried running `python setup.py build' but got an ImportError

Re: Reading an exact number of characters from input

2009-04-16 Thread Diez B. Roggisch
Paddy O'Loughlin schrieb: Hi, How would I use python to simply read a specific number of characters from standard input? raw_input() only returns when the user inputs a new line (or some other special character). I tried import sys sys.stdin.read(15) and that *returns* up to 15 characters, bu

Re: pyqt4: setText() inside a function

2009-04-16 Thread Diez B. Roggisch
[email protected] schrieb: I'm developing a PyQt4 application. I have created a button: ... self.start_button=QtGui.QPushButton("start simulation", self) ... that is connected to a function: ... self.connect(self.start_button, QtCore.SIGNAL('clicked()'), self.simulate) ... This is the functi

Re: QT , Wxwidgets are not just UI framework ?

2009-04-17 Thread Diez B. Roggisch
Deep_Feelings wrote: > qt include many libraries : network , threading,database ..etc while > Wxwidgets seem similar but with less scope > > my question is : does these frameworks replace python's (or any other > language for that matter) built-in libraries ? or python does not > include that sor

Re: QT , Wxwidgets are not just UI framework ?

2009-04-17 Thread Diez B. Roggisch
Deep_Feelings wrote: > On Apr 17, 1:52 pm, "Diez B. Roggisch" wrote: >> Deep_Feelings wrote: >> > qt include many libraries : network , threading,database ..etc while >> > Wxwidgets seem similar but with less scope >> >> > my question is :

Re: Inheriting dictionary attributes and manipulate them in subclasses

2009-04-17 Thread Diez B. Roggisch
Dominik Ruf wrote: > Hi, > > I just stumbled upon the following behaviour. class base(): > ... dic = {'1':'1', '2':'2'} > ... class child1(base): > ... def __init__(self): > ... self.dic.update({'1':'2'}) > ... class child2(base): > ... pass > ... c1 = child1()

Re: pyqt4 qTableWidget add items help

2009-04-18 Thread Diez B. Roggisch
ookrin schrieb: I've been searching around the internet for an example of how to add a list of items to the qTableWidget for the last few hours with little success. I have a list orders [[34,940,30,50,67], [50,56,35,30,57]] as my example here I built the qTableWidget in designer, so it already

Re: Keyerror addhandler

2009-04-19 Thread Diez B. Roggisch
Steven Macintyre schrieb: Hi all, I'm wondering if anyone can assist me with this as I am very confused about it now. I am getting the following error; Traceback (most recent call last): File "/usr/lib/python2.4/logging/config.py", line 191, in fileConfig logger.addHandler(handlers[hand]

Re: sorting two corresponding lists?

2009-04-20 Thread Diez B. Roggisch
responding > after the sorting. > > Is there an easy/nice/Pythonic way to do this? items = zip(*sorted(zip(values, items)))[1] To better understand this please note that a = [1, 2] b = [3, 4] zip(*zip(a, b)) == a, b or, in other words, zip(*argument) is the inverse of an argument c

Re: Python and GMP.

2009-04-20 Thread Diez B. Roggisch
[email protected] wrote: > There are reasons why Python not used the GMP library for implementing > its long type? Any reason it should? I don't know GMP (only that it exists), but adding binary dependencies is always a tricky and in need of careful weighting thing to do. Diez --

Re: getter and setter and list appends

2009-04-20 Thread Diez B. Roggisch
parent(self, obj): > if obj: > obj._children.append(self) > self._parent = obj > > > now if i make instances and attach children like so > > a = Widget() > b = Widget(a) > c = Widget(a) > d = Widget(c) > > Basically all the

Re: the correct way to install python packages as non root user in non default path

2009-04-21 Thread Diez B. Roggisch
News123 wrote: > Hi Alex, > > > Thanks a lot. Reading the description this sounds to be the right thing. > > > But now I'm stuck installing virtualenv as a user as this seems to be no > ubunbtu package: > > > export PYTHONPATH=/opt/newpymod/lib/python2.5/site-packages > mkdir -p $PYTHONPATH

Re: Export variables

2009-04-21 Thread Diez B. Roggisch
in self.__class__.mro()), [])) for varname in all_variables: yield getattr(self, varname) class A(Base): EXPORTED_VARIABLES = ["a"] a = "A!" class B(Base): EXPORTED_VARIABLES = ["b"] b = "B!" class C(A,B): pass a = A() b = B() c = C() print list(a.get_vars()) print list(b.get_vars()) print list(c.get_vars()) -- http://mail.python.org/mailman/listinfo/python-list

Please help me grok: webserver > python

2009-04-21 Thread Phillip B Oldham
I'm having trouble grok'ing how to get python talking through a webserver. I've got a lot of experience working with nginx+php-fcgi (via a unix socket) and I'd like to know what would be the bare minimum to get python talking in the same way. Now, I've looked at modules like CherryPy but they're a

Re: What is the best framework or module in Python for a small GUI based application development?

2009-04-22 Thread Diez B. Roggisch
srinivasan srinivas wrote: > > Thanks for the info. > My requirement is to write an application which is GUI based has to run on > browsers. Could you tell me which one would be suitable for this? There is no GUI-framework on browsers. There is HTML/CSS + JS, which is produced by servers that ca

Re: Weird lambda behavior

2009-04-22 Thread Diez B. Roggisch
Rüdiger Ranft wrote: > Hi all, > > I want to generate some methods in a class using setattr and lambda. > Within each generated function a name parameter to the function is > replaced by a string constant, to keep trail which function was called. > The problem I have is, that the substituted name

Re: Essential tools for Python development

2009-04-22 Thread Phillip B Oldham
On Apr 22, 5:00 am, Ben Finney wrote: > [snip] and code each module so that the > behaviour is easily introspected and tested from outside the module. If > I'm not able to easily introspect the code at an interactive prompt, > that's a clear sign that the code interface is poorly designed. So I fi

Re: WINXP vs. LINUX in threading.Thread

2009-04-22 Thread Diez B. Roggisch
Kent schrieb: hello all, i want to add a "new update notification" feature to my wxPython appl. The codes below do the job. The logic is simple enough, I don't think it needs to be explained. since sometimes, under windows, proxy setting was a script. and was set in IE. In this case, connecting

Re: Unicode in writing to a file

2009-04-23 Thread Diez B. Roggisch
Carbon Man wrote: > Py 2.5 > Trying to write a string to a file. > self.dataUpdate.write(u"\nentry."+node.tagName+ u" = " + cValue) > cValue contains a unicode character. node.tagName is also a unicode string > though it has no special characters in it. > Getting the error: > UnicodeEncodeError: '

Re: Get objects from ZODB into MySQL

2009-04-27 Thread Diez B. Roggisch
TheIvIaxx schrieb: Hello, I have searched for some solution to getting the object data from a ZODB Data.fs file into something i can work with for MySQL. So far, no such luck. I can open the DB and poke around, but im not sure where or what to even poke :) It was a simple plone site, with main

Re: python segfaulting, MemoryError (PyQt)

2009-04-28 Thread Diez B. Roggisch
Denis L schrieb: Hello, I'm experiencing odd errors on both windows and linux with the following code: import sys from PyQt4.QtCore import * from PyQt4.QtGui import * class Options(QDialog): def __init__(self, values): QDialog.__init__(self) self.values = values

Re: python segfaulting, MemoryError (PyQt)

2009-04-28 Thread Diez B. Roggisch
>> As the documentation of pyqt clearly states, connecting signals doesn't >> increment the refcount on a passed slot, thus >> you need to keep a reference to your slots around. > > But it does increase the refcount for lambda slots. Has that changed? It has been a while, but I've been bitten b

Re: python segfaulting, MemoryError (PyQt)

2009-04-28 Thread Diez B. Roggisch
Phil Thompson wrote: > On Tue, 28 Apr 2009 11:18:31 +0200, "Diez B. Roggisch" > > wrote: >>>> As the documentation of pyqt clearly states, connecting signals doesn't >>>> increment the refcount on a passed slot, thus >>>> you need to

Re: stuck with PyOBEX

2009-04-28 Thread Diez B. Roggisch
alejandro wrote: > So I installed the module and tryed to make it work but... > It gave me: > > Traceback (most recent call last): > File "first.py", line 24, in > client2.connect() > File "C:\Python25\lib\PyOBEX\client.py", line 359, in connect > return Client.connect(self, header_l

Re: stuck with PyOBEX

2009-04-28 Thread Diez B. Roggisch
alejandro wrote: > Can you tell me what is it? Maybe I can search it and pass it in another > way... if it is an address or protocol name I'm not entirely sure, but I guess no, you can't simply pass it in. Unix uses streams as abstraction for a lot of things - all kinds of devices for exampl

Re: Which flag to use in "configure" to Change the Install location?

2009-04-29 Thread Diez B. Roggisch
Omita schrieb: Long story short... I am installing Python 2.6 on OSX. By default the Library is installing here: /Library/Frameworks/Python.framework However, as I am using OSX Server I would ideally like the location to be here: /System/Library/Frameworks/Python.framework/ Why? Do I need

Re: Please explain this strange Python behaviour

2009-04-30 Thread Diez B. Roggisch
Train Bwister wrote: > Please explain: http://python.pastebin.com/m401cf94d > > IMHO this behaviour is anything but the usual straight forward and > obvious way of Python. > > Can you please point out the benefits of this behaviour? http://effbot.org/pyfaq/why-are-default-values-shared-between-

Re: unbinding a global variable in Python

2009-04-30 Thread Diez B. Roggisch
Mark Tarver wrote: > In Lisp this is done so > >> (setq *g* 0) > 0 > >> *g* > 0 > >> (makunbound '*g*) > *g* > >> *g* > error: unbound variable > > How is this done in Python? > > Mark >>> foo = "bar" >>> del foo >>> foo Traceback (most recent call last): File "", line 1, in NameError: n

Re: Dictionary, integer compression

2009-04-30 Thread Diez B. Roggisch
dineshv wrote: > Yes, "integer compression" as in Unary, Golomb, and there are a few > other schemes. > > It is known that for large (integer) data sets, encoding and decoding > the integers will save space (memory and/or storage) and doesn't > impact performance. > > As the Python dictionary is

Re: Help! Can't get program to run.

2009-05-01 Thread Diez B. Roggisch
[email protected] schrieb: I think this is maybe the most basic problem possible, but I can't get even the most basic Python to run on OS X using Terminal or IDLE. I used the IDLE editor to create a file with one line of code print 'text string' and I saved the file as module1.py. When using t

Re: Strange interaction between timeit and recursion

2009-05-03 Thread Diez B. Roggisch
Steven D'Aprano schrieb: I'm seeing a strange interaction between timeit and recursion. sys.getrecursionlimit() 1000 from timeit import Timer setup = """def test(n=1): ... if n < 999: return test(n+1) ... return None ... """ exec setup test() is None True Timer('test()', setup).r

Re: Is it better to use threads or fork in the following case

2009-05-03 Thread Diez B. Roggisch
grocery_stocker schrieb: Let's say there is a new zip file with updated information every 30 minutes on a remote website. Now, I wanna connect to this website every 30 minutes, download the file, extract the information, and then have the program search the file search for certain items. Would i

Re: Is it better to use threads or fork in the following case

2009-05-03 Thread Diez B. Roggisch
grocery_stocker schrieb: On May 3, 1:16 pm, "Diez B. Roggisch" wrote: grocery_stocker schrieb: Let's say there is a new zip file with updated information every 30 minutes on a remote website. Now, I wanna connect to this website every 30 minutes, download the file, extract

Re: Threaded alternatives to smtplib?

2009-05-03 Thread Diez B. Roggisch
Alex Jurkiewicz schrieb: Hi all, I'm writing a Python script to do a "mail merge" style email distribution. I create a few python threads and in each one I call `smtpserver = smtplib.SMTP(our.smtpserver.com)`. However, during the sending process, there seems to be only one connection open to o

Re: Strange interaction between timeit and recursion

2009-05-03 Thread Diez B. Roggisch
namekuseijin schrieb: Recursion is unpythonic. Do not use it. Since when? Says who? Lacking tail-recursion, it's not the choice for loops, but whatever algorithm is recursive can be written as such. Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: Is it better to use threads or fork in the following case

2009-05-04 Thread Diez B. Roggisch
CTO wrote: >> In addition, the zip file format stores the directory at the end of the >> file. So you can't process it until it's completely downloaded. >> Concurrency doesn't help here. > > Don't think that's relevant, if I'm understanding the OP correctly. > Lets say you've downloaded the file

Re: Threaded alternatives to smtplib?

2009-05-04 Thread Diez B. Roggisch
Alex Jurkiewicz wrote: > Gabriel Genellina wrote: >> Try logging the start/stop of your threads. It may be that your >> threads stop before you think. The above code works correctly only if >> you fill the queue before starting any thread - because as soon as a >> thread sees the queue empty, it f

Re: Threaded alternatives to smtplib?

2009-05-04 Thread Diez B. Roggisch
Diez B. Roggisch wrote: > Alex Jurkiewicz wrote: > >> Gabriel Genellina wrote: >>> Try logging the start/stop of your threads. It may be that your >>> threads stop before you think. The above code works correctly only if >>> you fill the queue before sta

Re: How to walk up parent directories?

2009-05-04 Thread Diez B. Roggisch
Snorri H wrote: > On May 4, 5:04 am, Matthew Wilson wrote: >> Is there already a tool in the standard library to let me walk up from a >> subdirectory to the top of my file system? > > > Never seen such a standard tool, yet it can be implemented in a way > like this > > def walkup(path): >

Re: Error in running python -v on Mac ox 10.5.

2009-05-05 Thread Diez B. Roggisch
silverburgh schrieb: Hi, I run 'python -v' on Macos 10.5 but I get this error : # can't create /System/Library/Frameworks/Python.framework/Versions/ 2.5/lib/python2.5/encodings/utf_8.pyc Can you please tell me how to fix it? This looks like a rights-problem to me, and a missing pyc-file. If

Re: Install Python 3.0 dmg to macos 10.5

2009-05-06 Thread Diez B. Roggisch
silverburgh wrote: > Hi, > > If I install python 3.0 dmg, will it wipe out the existing python > installation on macos 10.5 (i don't know how the original python was > installed ( i think it is version 2.5). No. The original is under /System/Library/Frameworks/Python.framework (and should be kep

Re: Pyhton script to call another program

2009-05-06 Thread Diez B. Roggisch
Ben Keshet wrote: > Hi, > > I am trying to write a simple python script to manipulate files and call > other programs. I have a program installed (rocs) which I run using > cygwin on my XP (but is not in python). Can I run the pyhton script and > then call the other program in the same script?

Re: idea

2009-05-07 Thread Diez B. Roggisch
r-w wrote: > Redirect sys.stderr to the log file in ANUGA logging. > This might catch unexpected exceptions. brillant. Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: The Fujitsu Lifebook A6120

2009-05-07 Thread Diez B. Roggisch
> > Does it run Python? > > (sorry, could not resist) You could at least resist to quote the spammers url, so it doesn't get higher pagerank. Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: How should I use grep from python?

2009-05-07 Thread Diez B. Roggisch
Matthew Wilson wrote: > I'm writing a command-line application and I want to search through lots > of text files for a string. Instead of writing the python code to do > this, I want to use grep. > > This is the command I want to run: > > $ grep -l foo dir > > In other words, I want to list al

Re: Which python version do I use with "virtualenv"?

2009-05-07 Thread Diez B. Roggisch
Krishnakant wrote: > I have another question in this same context. > I have python 2.6 and want to set up a vertualenv > in /opt/turbogears/python2.5. > Then use this for all the things a turbogears based application would > need for project execution. > > so I have decided that I will download p

Re: Which python version do I use with "virtualenv"?

2009-05-07 Thread Diez B. Roggisch
Krishnakant wrote: > >> You are confusing virtualenv with a custom-build python. You can of >> course use VE with a custom-build python, but then there isn't as much >> use for it, as you then have a distinct python-instance already - unless >> you are going to share it amongst projects, which th

Re: Updating an Imported Function

2009-05-07 Thread Diez B. Roggisch
Donovan Parks schrieb: Hello, I'm new to Python and have what is probably a very basic question. I am writing a helloWorld() function within a file called helloWorld.py: def helloWorld(): print 'hi' Now, I can import and run this function: import helloWorld helloWorld.helloWorld() Wh

Re: P2P text chat engine

2009-05-07 Thread Diez B. Roggisch
Navanjo schrieb: If you have the source code of a p2p text chat engine please send to me I found that & a pot of gold under my bed. Care to give me your address so that I can send it to you? SCNR, Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: Creating temperory files for a web application

2009-05-08 Thread Diez B. Roggisch
koranthala wrote: > Hi, >I am doing web development using Django. I need to create an image > (chart) and show it to the users - based on some data which user > selects. >My question is - how do I create a temporary image for the user? I > thought of tempfile, but I think it will be delete

Re: How to debug this import problem?

2009-05-08 Thread Diez B. Roggisch
Iwan Vosloo wrote: > Hi there, > > We have a rather complicated program which does a bit of os.chdir and > sys.path manipulations. In between all of this, it imports the decimal > module several times. > > However, it imports a new instance of decimal sometimes. (Which is a > problem, since a

Re: php to python code converter

2009-05-08 Thread Diez B. Roggisch
Dotan Cohen wrote: >> I'm not a big fan of PHP but I don't understand the desireability of >> such a tool.  If you have a good PHP app just run it.  The point of >> Python in my mind is that it is a cleaner syntax and promotes better >> code.  Anything that converts PHP to Python is going to leave

Re: Creating temperory files for a web application

2009-05-09 Thread Diez B. Roggisch
Hi Diez, I think I understood your point now. Is it ? (1) Have a separate URL for the image - update urls.py for that (2) Pass all the GET parameters to that URL again. (3) Recalculate the fields again in that URL (4) Create the image and send back as image/png based on the rece

Re: php to python code converter

2009-05-09 Thread Diez B. Roggisch
Dotan Cohen schrieb: I'm almost 100% sure it won't. The code is machine-generated, thus not easy to the human eye, not idiomatic so you don't learn how to write good python through it. You learn how to jump through hoops to code the same way in python that you do in PHP. I meant for single fun

Re: unicode bit me

2009-05-10 Thread Diez B. Roggisch
[email protected] schrieb: ok that explains it, so unicode(obj) calls __unicode__ on that object and if it isn't there __repr__ is used __repr__ of list by default return a str even if __repr__ of element is unicode so my only solution looks like to use my own list class everywhere i use l

Re: how to consume .NET webservice

2009-05-11 Thread Diez B. Roggisch
namekuseijin schrieb: bav escreveu: question from a python newbie; how can i consume in python language, a .NET web service, passing a string array as parameter in some easy steps? Unless Microsoft extended the standard in any way, then it should be just as you consume any web service, I

Re: how to consume .NET webservice

2009-05-12 Thread Diez B. Roggisch
bav schrieb: question from a python newbie; how can i consume in python language, a .NET web service, passing a string array as parameter in some easy steps? Try accessing the .NET-service using a .NET client, and capture the traffic (it speaks volumes that the apache axis project offers

Re: how to consume .NET webservice

2009-05-12 Thread Diez B. Roggisch
namekuseijin schrieb: Diez B. Roggisch wrote: namekuseijin schrieb: bav escreveu: question from a python newbie; how can i consume in python language, a .NET web service, passing a string array as parameter in some easy steps? Unless Microsoft extended the standard in any way, then it

Re: how to consume .NET webservice

2009-05-12 Thread Diez B. Roggisch
namekuseijin schrieb: > Diez B. Roggisch wrote: >> namekuseijin schrieb: >>> bav escreveu: >>>> question from a python newbie; >>>> >>>> how can i consume in python language, a .NET web service, passing >>>> a string array as p

Re: AssertionError - help me to solve this in a programme with Queue

2009-05-12 Thread Diez B. Roggisch
gganesh wrote: > On May 12, 6:34 pm, MRAB wrote: >> gganesh wrote: >> > Hi all, >> > I'm just learning python ,the code below is found in one of the >> > sites ,it produces an error like >> > Traceback (most recent call last): >> > File "queue.py", line 34, in >> > main() >> > File "queue.py", l

Re: Convert UNIX formated text files to DOS formated?

2009-05-12 Thread Diez B. Roggisch
walterbyrd schrieb: I have about 150 unix formated text files that I would like to convert to dos formated. I am guessing that I loop though each file in the directory, read each line and conver the last character, then save to a file with the same name in another directory. I am not really sur

Re: json vs. simplejson

2009-05-13 Thread Diez B. Roggisch
Thomas Heller wrote: > Python 2.6 contains the json module, which I thought was the renamed (and > improved?) simplejson module that also works on older Python versions. > > However, it seems the json is a lot slower than simplejson. > This little test, run on Python 2.6.2 and WinXP shows a drama

Re: Distributed locking

2009-05-14 Thread Diez B. Roggisch
James schrieb: Hey all, I'm looking for suggestions on how to tackle distributed locking across several Python programs on several different machines. - the objects to be locked are uniquely identified by an integer - I need "one at a time" semantics for the lock: zero or one read- writer at any

Re: Question: Running Python programs in KDE

2009-05-14 Thread Diez B. Roggisch
Grant Ito wrote: > Hello. > > Silly question here. I'd like to find out how to create an icon in KDE to > run my Python scripts. Specs are as follows: > > KDE version 4.1.3 in OpenSuse 11.1. > Some scripts have output to Konsole window, others use Tkinter. > > Thanks in advance, > Grant. Try r

Re: introspection question: get return type

2009-05-14 Thread Diez B. Roggisch
[email protected] wrote: > Hello, > I am wondering if it's possible to get the return value of a method > *without* calling it using introspection? Nope. All that's possible to see if there is a implicit or explicit return through dis.disassemble - if you find "LOAD_CONST None" before any return-

Re: introspection question: get return type

2009-05-14 Thread Diez B. Roggisch
Diez B. Roggisch wrote: > [email protected] wrote: > >> Hello, >> I am wondering if it's possible to get the return value of a method >> *without* calling it using introspection? > > Nope. All that's possible to see if there is a implicit or explicit r

Re: python copy method alters type

2009-05-14 Thread Diez B. Roggisch
Zhenhai Zhang wrote: > Really weired; Here is my code: > > a = ["a", 1, 3, 4] > print "a:", a > > c = copy(a) > c[0] = "c" > c[1] = 2 > print "c:", c > print "a:",a > > output as follows: > > a: ['a', 1, 3, 4] > c: ['c' '2' '3' '4'] > a: ['a', 1, 3, 4] > > Btw,

Re: Assigning a list to a key of a dict

2009-05-14 Thread Diez B. Roggisch
Wells wrote: > Why can't I do this? > > teams = { "SEA": "Seattle Mariners" } > for team, name in teams.items(): > teams[team]["roster"] = ["player1", "player2"] > > I get an error: > > Traceback (most recent call last): > File "./gamelogs.py", line 53, in > teams[team]["roster"]

Re: Returning dictionary from a function

2009-05-14 Thread Diez B. Roggisch
I can query values later. thanks def values(x): diky={} for a in range(x): a=a+100 diky={chr(a):a} print diky return diky b=values(5) print type(b),len(b), b['f'] # gives error print type(b),len(b), b['h'] # does not give error Yo

Re: Appending traceback from exception in child thread

2009-05-16 Thread Diez B. Roggisch
Edd schrieb: Hi folks, I have a some threadpool code that works like this : tp = ThreadPool(number_of_threads) futures = [tp.future(t) for t in tasks] # each task is callable for f in futures: print f.value() # <-- may propagate an exception The idea being that a Future obj

Options for creating a statistics screen on a Mac with Python?

2009-05-16 Thread Phillip B Oldham
I've come into possession of a mac mini and a large LCD tv at the office. I'd like to set it up in the corner to pull statistics from our various servers (load, uptimes, etc) and display them in a graphical format, full-screen, with a reasonable refresh rate (say every 30 seconds). There will be qu

Re: Options for creating a statistics screen on a Mac with Python?

2009-05-16 Thread Diez B. Roggisch
Phillip B Oldham schrieb: I've come into possession of a mac mini and a large LCD tv at the office. I'd like to set it up in the corner to pull statistics from our various servers (load, uptimes, etc) and display them in a graphical format, full-screen, with a reasonable refresh rate

Re: open(os.path.join(os.path.dirname(__file__), '../www/bin/picture.png'), 'rb')

2009-05-16 Thread Diez B. Roggisch
gert schrieb: open(os.path.join(os.path.dirname(__file__),'../www/bin/picture.png'), 'rb') how do you do this on windows (py3) so it still works on linux ? os.path.join("..", "www", "bin", "picture.png") Or use os.sep. Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: Options for creating a statistics screen on a Mac with Python?

2009-05-16 Thread Phillip B Oldham
On May 16, 2:15 pm, "Diez B. Roggisch" wrote: > matplotlib should serve you well. Thanks, I'll check that out. > Or you use some web-based solution with a javascript-based chart library. I'd rather stay away from web-based solutions; since this is going to be runn

Re: Adding a Par construct to Python?

2009-05-17 Thread Diez B. Roggisch
But reduce()? I can't see how you can parallelize reduce(). By its nature, it has to run sequentially: it can't operate on the nth item until it is operated on the (n-1)th item. That depends on the operation in question. Addition for example would work. My math-skills are a bit too rusty to qu

Re: Adding a Par construct to Python?

2009-05-17 Thread Diez B. Roggisch
My math-skills are a bit too rusty to qualify the exact nature of the operation, commutativity springs to my mind. And how is reduce() supposed to know whether or not some arbitrary function is commutative? I don't recall anybody saying it should know that - do you? The OP wants to introdu

Re: Adding a Par construct to Python?

2009-05-17 Thread Diez B. Roggisch
But reduce() can't tell whether the function being applied is commutative or not. I suppose it could special-case a handful of special cases (e.g. operator.add for int arguments -- but not floats!) or take a caller- supplied argument that tells it whether the function is commutative or not. But

Re: Adding a Par construct to Python?

2009-05-18 Thread Diez B. Roggisch
Steven D'Aprano wrote: > On Sun, 17 May 2009 20:34:00 +0200, Diez B. Roggisch wrote: > >>>> My math-skills are a bit too rusty to qualify the exact nature of the >>>> operation, commutativity springs to my mind. >>> >>> And how is re

Re: pydb output vanishes when running nosetests doctests

2009-05-18 Thread Diez B. Roggisch
jcervidae wrote: > Hi Pythonistas: > > When pydb.debugger() is launched from within my code or for some other > reason pydb starts from inside a nosetests or doctest, I do not see > any output from it. It appears the test has hung but it hasn't. If I > type commands pydb obeys them I just can't s

Re: Best library to make XSLT 2.0 transformation

2009-05-19 Thread Diez B. Roggisch
wdveloper wrote: > Hi there, > > I need to make xml transformation using XSLT 2.0 (since i want to use > the powerful tag to produce multiple files). > In your experience, which kind of library out there is better? XSLT is a standard, so if you find a library that implements it, there shouldn't

Re: Subversion commit from Python?

2009-05-19 Thread Diez B. Roggisch
Jack Trades wrote: > On May 19, 3:53 am, Lawrence D'Oliveiro central.gen.new_zealand> wrote: >> In message > >> [email protected]>, Jack Trades wrote: >> > On May 19, 12:26 am, Lawrence D'Oliveiro > > central.gen.new_zealand> wrote: >> >> >> In message <2904e7de-0a8d-4697-

Re: Conceptual flaw in pxdom?

2009-05-19 Thread Diez B. Roggisch
Emanuele D'Arrigo wrote: > On May 19, 6:50 am, Stefan Behnel wrote: >> It's pretty easy to write unmaintainable code that uses the DOM API, >> though. > > I'm finding that at my own expenses... > > Why would anybody want to use the DOM? I suppose the main reason is > that it is one of the most

Re: Adding a Par construct to Python?

2009-05-19 Thread Diez B. Roggisch
Hi Steven, I am impressed by this - it shows the potential speedup that pmap could give. Although the GIL would be a problem as things for speed up of pure Python code. Do Jython and Iron Python include the threading module? Jython does, and AFAIK IronPython also. Jython also has no GIL I thi

Re: Best library to make XSLT 2.0 transformation

2009-05-19 Thread Diez B. Roggisch
John Krukoff schrieb: On Tue, 2009-05-19 at 13:42 +0200, Diez B. Roggisch wrote: wdveloper wrote: Hi there, I need to make xml transformation using XSLT 2.0 (since i want to use the powerful tag to produce multiple files). In your experience, which kind of library out there is better? XSLT

Re: Mock Form Post

2009-05-19 Thread Diez B. Roggisch
Scooter schrieb: On May 19, 3:40 pm, Scooter wrote: Let me qualify this by saying I'm very new to python. I'm doing some work with mod_python and in a function I have defined I am passing in the form and then iterating through the form keys. I'm currently writing my unit tests and I'm trying to

Re: Conceptual flaw in pxdom?

2009-05-20 Thread Diez B. Roggisch
Paul Boddie wrote: > On 19 Mai, 18:16, "Diez B. Roggisch" wrote: >> >> Sorry to say so, but that's nonsense. DOM is not complicated because it >> contains anything superior - the reason (if any) is that it is formulated >> as language-agnostic as p

Re: Trying to understand a very simple class - from the book "dive into python"

2009-05-20 Thread Diez B. Roggisch
walterbyrd wrote: > On May 20, 9:59 am, Marco Mariani wrote: > >> Do you know what a dictionary is? > > Yes, but I thought a dictionary used curly brackets. Is the object a > dictionary? foo = {"key" : "i'm the value of a dictionary"} print foo["key"] I suggest you read the tutorial: http:/

Re: P2P text chat engine

2009-05-20 Thread Diez B. Roggisch
Kirill wrote: > On 7 май, 21:23, "Diez B. Roggisch" wrote: >> Navanjo schrieb: >> >> > If you have the source code of a p2p text chat engine please send to me >> >> I found that & a pot of gold under my bed. Care to give me your address &g

<    26   27   28   29   30   31   32   33   34   35   >