[issue36756] createcommand memory leak

2019-04-30 Thread Wolfram Kraus
New submission from Wolfram Kraus : When using tk.createcommand you get a memory leak when you don't explicitly call tk.deletecommand to remove this command. See attached file: __del__ never get's called due to the memory leak and because of that calling tk.deletecommand inside __del__ has

Re: substitution of list elements

2008-07-18 Thread Wolfram Kraus
Am 18.07.2008 14:33, antar2 schrieb: I want to replace each first element in list 5 that is equal to the first element of the list of lists4 by the fourth element. I wrote following code that does not work: list4 = [['1', 'a', 'b', 'c'], ['2', 'd', 't', 'e'], ['8', 'g', 'q', 'f']] list5 = ['1',

Re: Sorted list - how to change it

2006-11-09 Thread Wolfram Kraus
On 09.11.2006 10:52, Lad wrote: I have a sorted list for example [1,2,3,4,5] and I would like to change it in a random way e.g [2,5,3,1,4] or [3,4,1,5,2] or in any other way except being ordered. What is the best/easiest way how to do it? Thank you for help L. use random.shuffel:

Re: looping question 4 NEWB

2006-07-06 Thread Wolfram Kraus
On 06.07.2006 12:43, manstey wrote: Hi, I often have code like this: data='asdfbasdf' find = (('a','f')('s','g'),('x','y')) for i in find: if i[0] in data: data = data.replace(i[0],i[1]) is there a faster way of implementing this? Also, does the if clause increase the

Re: How to measure execution time of a program

2006-06-28 Thread Wolfram Kraus
On 28.06.2006 10:01, Girish Sahani wrote: Sorry for spamming again, but please also enlighten me with some way to time a function i.e. to find out how much time each function takes for execution in a big program. Hi all, Can anyone tell me the simplest way to do it (some code snippet that

Re: How to creat a file?

2005-12-02 Thread Wolfram Kraus
sandorf wrote: I'm new to python. Have a simple question. open function can only open an existing file and raise a IOerror when the given file does not exist. How can I creat a new file then? open the new file in write mode: open('foo', 'w') See: help(open) HTH, Wolfram --

Re: How to use a timer in Python?

2005-09-23 Thread Wolfram Kraus
Nico Grubert wrote: Hi there, on a Linux machine running Python 2.3.5. I want to create a file 'newfile' in a directory '/tmp' only if there is no file 'transfer.lock' in '/temp'. A cronjob creates a file 'transfer.lock' in '/temp' directory every 15 minutes while the cronjob is doing

Re: Retrieving and saving images from internet address

2005-07-25 Thread Wolfram Kraus
rock69 wrote: Hi all :) I got this address: http://www.infomedia.it/immagini/riviste/covers/cp/cp137.jpg and I would like to download that image and save it to a local file. How do you do that in Python? Use urllib2: http://docs.python.org/lib/module-urllib2.html

Re: need help with MySQLdb

2005-06-30 Thread Wolfram Kraus
[EMAIL PROTECTED] wrote: Hey there all, i have a question about how to point my python install to my sql database. when i enter this: db = MySQLdb.connect(user=user, passwd=pass, db=myDB) i get this: Traceback (most recent call last): File pyshell#1, line 1, in -toplevel- db =

Re: need help with MySQLdb

2005-06-30 Thread Wolfram Kraus
nephish wrote: [...] Try the following from the shell (NOT the python shell): mysql -u user -p [Enter passwd] mysql show databases; If MyDB isn't in the list either something went wrong with the xampp installation or the database for xampp got a different name. (I am no xampp expert, so

Re: catch argc-argv

2005-06-20 Thread Wolfram Kraus
mg wrote: Hello, I am writting bindings for a FEM application. In one of my function 'initModulename', called when the module is imported, I would like to get the argc and argv arguments used in the main function of Python. So, my question is: does the Python API containe fonctions like

Re: What's wrong with Zope 3 ?

2005-06-02 Thread Wolfram Kraus
Kay Schluehr wrote: Wolfram Kraus wrote: Kay Schluehr wrote: The last downloadable release is from november 2004. The Windows installer is configured for Python 2.3(!). The Zope.org main page announces Zope 2.8 beta 2. Is it stillborn? Kay What you see is not Zope 3

Re: What's wrong with Zope 3 ?

2005-06-01 Thread Wolfram Kraus
Kay Schluehr wrote: The last downloadable release is from november 2004. The Windows installer is configured for Python 2.3(!). The Zope.org main page announces Zope 2.8 beta 2. Is it stillborn? Kay What you see is not Zope 3, it is Zope X 3. To quote from the X3 information page: Zope

Re: Strings for a newbie

2005-05-27 Thread Wolfram Kraus
Malcolm Wooden wrote: I'm trying to get my head around Python but seem to be failing miserably. I use RealBasic on a Mac and find it an absolute dream! But PythonUGH! I want to put a sentence of words into an array, eg This is a sentence of words In RB it would be simple: Dim s

Re: Incrementing letters

2005-05-27 Thread Wolfram Kraus
Heiko Wundram wrote: Am Freitag, 27. Mai 2005 13:31 schrieb Michael: if(C == 'z') C='a'; else C++; if C == z: C = a else: C = chr(ord(C)+1) According to the OP's problem (with the assumption that only characters from a-z are given) he might even try a lil LC: s = shiftthis

Re: Strings for a newbie

2005-05-27 Thread Wolfram Kraus
Malcolm Wooden wrote: my actual code is: for x in range(len(l)): h = string.split(l[x]) where the sentence string is in an array of one element 'l' Error is: Traceback (most recent call last): File string, line 34, in ? File string, line 27, in SentenceText File

Re: Incrementing letters

2005-05-27 Thread Wolfram Kraus
Duncan Booth wrote: Michael wrote: Hi, I've got a string s, and i want to shift all the letters up by one, eg a-b, b-c z-a In c++ i can do this quite simply with if(C == 'z') C='a'; else C++; but i can't work out how to do this this in python?? import string upone =

Re: Writing to stdout and a log file

2005-04-20 Thread Wolfram Kraus
Mike wrote: I would like my 'print' statements to send its output to the user's screen and a log file. This is my initial attempt: class StdoutLog(file): def __init__(self, stdout, name='/tmp/stdout.log', mode='w',bufsize=-1): super(StdoutLog, self).__init__(name,mode,bufsize)

Re: display VARCHAR(mysql) and special chars in html

2005-02-23 Thread Wolfram Kraus
Jonas Meurer wrote: hello, my script selects a comment saved as VARCHAR in MySQL and displays it inside an html page. the problem is, that the comment contains several special characters, as mysterious utf-8 hyphens, german umlauts, etc. i could write a function to parse the comment and substitute

Re: python-2.4.msi installation issue

2005-02-03 Thread Wolfram Kraus
[EMAIL PROTECTED] wrote: O/S: Windows XP Home (with Service Pack 2) Downloaded python-2.4.msi from python.org (10,632KB). When I double click on the file from Windows Explorer, the installation process presents the window in which I am prompted to either install for all users (the default) or

Re: how to pass attribute name via sys.argv

2005-01-27 Thread Wolfram Kraus
Felix Hebeler wrote: Hi all, I am doing some Python scripting for a while, but I'm not too deep into it yet. So I have a problem I can't solve. I need to call an object attribute: value = object.attrName[0] the problem is, that the attribute name can only be specified at runtime. So what I have is

Re: SuSE 9.1: updating to python-2.4

2005-01-10 Thread Wolfram Kraus
Heyho! Torsten Mohr wrote: Hi, along with my distribution SuSE 9.1 came python 2.3.3. I'd like to update to 2.4 now, is this an easy thing to do or will lots of installed modules refuse to work then? I installed Python 2.4 under SuSE 9.1 and had no problems so far. If you install it via