how to open a file in some application using Tkinter i am using TKINTER to create GUI application i want to know how to open a word document in open office or any other applicatio

2008-01-09 Thread brindly sujith
hi i am using TKINTER to create GUI application i want to know how to open a word document in open office or any other application please send me the tkinter coding for this -- http://mail.python.org/mailman/listinfo/python-list

Re: how to open a file in some application using Tkinter i am using TKINTER to create GUI application i want to know how to open a word document in open office or any other applicatio

2008-01-09 Thread Fredrik Lundh
brindly sujith wrote: i am using TKINTER to create GUI application i want to know how to open a word document in open office or any other application please send me the tkinter coding for this reposting the reply you received when you posted this on another mailing list: --- on

Re: Tkinter variable trace problem

2008-01-09 Thread C Martin
Thank you for your replies. I understand there are better ways to handle 'normal' UI behavior, but I was curious about the trace feature and wanted to understand how it worked. I may not actually need it in my project, but I wanted to see what my options were. Thanks again.

Pyflakes pre-commit hook in subversion

2008-01-09 Thread mobiledreamers
http://tarekziade.wordpress.com/2006/11/01/protecting-a-python-svn-code-base-with-the-pre-commit-hook/ Is it possible to check code in python before committing to svn using pyflakes, pythontidy *Pyflakes and Subversion* Pyflakes http://www.divmod.org/projects/pyflakes is a nice little utility

Re: stupid/style/list question

2008-01-09 Thread Duncan Booth
Fredrik Lundh [EMAIL PROTECTED] wrote: Giampaolo Rodola' wrote: To flush a list it is better doing del mylist[:] or mylist = []? Is there a preferred way? If yes, why? The latter creates a new list object, the former modifies an existing list in place. The latter is shorter, reads

Re: Newbie question: Classes

2008-01-09 Thread Bruno Desthuilliers
Daniel Fetchinson a écrit : nb: answering to the (unknown) OP: Basically, I have created a program using tkinter without using any class structure, simply creating widgets and functions (and finding ways around passing variables from function to function, using global variables etc). One of

Re: copy a numpy array

2008-01-09 Thread Francesco Guerrieri
On Jan 9, 2008 6:35 AM, jimgardener [EMAIL PROTECTED] wrote: thanx guys for the replies need a little clarification srcarray=array([1.2,2.3,3.4,4.5,5.6]) destarray=array(srcarray,copy=False) then srcarray[2]=99.9 will cause the change to be reflected in both src and dest. doesn't that

Re: Open a List of Files

2008-01-09 Thread Paul Hankin
On Jan 9, 2:41 am, Tim Chase [EMAIL PROTECTED] wrote: I decided that I was just trying to be too smooth by 1/2 so I fell back to messages = open(os.path.join(host_path,'messages.txt'), 'wb') deliveries = open(os.path.join(host_path,'deliveries.txt'), 'wb') actions =

Re: Collecting Rich Data Structures for students

2008-01-09 Thread Martin Marcher
Paddy wrote: On Jan 9, 2:19 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Some have offered XML repositories, which I can well understand, but in this case we're looking specifically for legal Python modules (py files), although they don't have to be Latin-1 (e.g. the sushi types file

Strange problem: MySQL and python logging using two separate cursors

2008-01-09 Thread Frank Aune
Hi, Explaining this problem is quite tricky, but please bear with me. Ive got an application which uses MySQL (InnoDB) for two things: 1. Store and retrieve application data (including viewing the application log) 2. Store the application log produced by the python logging module The

Re: Natural-language datetime parsing and display (was: user friendly datetime features)

2008-01-09 Thread tahiriman
or just calculate the difference between the moment you are and the date before and display the result in a cases (if diff is one day or 2 days or ...) -- http://mail.python.org/mailman/listinfo/python-list

Re: Open a List of Files

2008-01-09 Thread Fredrik Lundh
Paul Hankin wrote: This can be more cleanly written using locals() for fn in filenames: locals()[fn] = open(os.path.join(host_path, fname + '.txt', 'wb') from the reference manual: locals() Update and return a dictionary representing the current local symbol table.

Canonical way of deleting elements from lists

2008-01-09 Thread Robert Latest
Hello, From a list of strings I want to delete all empty ones. This works: while '' in keywords: keywords.remove('') However, to a long-term C programmer this looks like an awkward way of accomplishing a simple goal, because the list will have to be re-evaluated in each iteration. Is

Re: Canonical way of deleting elements from lists

2008-01-09 Thread Fredrik Lundh
Robert Latest wrote: From a list of strings I want to delete all empty ones. This works: while '' in keywords: keywords.remove('') However, to a long-term C programmer this looks like an awkward way of accomplishing a simple goal, because the list will have to be re-evaluated in each

Re: Open a List of Files

2008-01-09 Thread Paul Hankin
On Jan 9, 10:02 am, Fredrik Lundh [EMAIL PROTECTED] wrote: Paul Hankin wrote: This can be more cleanly written using locals() for fn in filenames: locals()[fn] = open(os.path.join(host_path, fname + '.txt', 'wb') from the reference manual: locals() Update and return a

Re: Canonical way of deleting elements from lists

2008-01-09 Thread Fredrik Lundh
Fredrik Lundh wrote: creating a new list is always almost the right way to do things like message = message.replace(always almost, almost always) -- http://mail.python.org/mailman/listinfo/python-list

alternating string replace

2008-01-09 Thread cesco
Hi, say I have a string like the following: s1 = 'hi_cat_bye_dog' and I want to replace the even '_' with ':' and the odd '_' with ',' so that I get a new string like the following: s2 = 'hi:cat,bye:dog' Is there a common recipe to accomplish that? I can't come up with any solution... Thanks in

Multi form CGI examples?

2008-01-09 Thread rodmc
Hi, I have been looking online for some examples of how to create multi form CGI scripts using Python. I have come across a few but am still a little confused - being new to CGI on Python. Can anyone provide me with some pointers to useful tutorials or advice on the best way to go about it? I

Re: Open a List of Files

2008-01-09 Thread Fredrik Lundh
Paul Hankin wrote: Thanks Fredrik! I learnt something today. I wonder if there's a reason why it doesn't raise an exception when you try to write to it? That would seem better to me than having it sometimes update variables and sometimes not. probably because it returns a standard

Re: alternating string replace

2008-01-09 Thread Fredrik Lundh
cesco wrote: and I want to replace the even '_' with ':' and the odd '_' with ',' so that I get a new string like the following: s2 = 'hi:cat,bye:dog' Is there a common recipe to accomplish that? I can't come up with any solution... how about splitting on _, joining pairs with :, and

Re: how to open a file in some application using Tkinter i am using TKINTER to create GUI application i want to know how to open a word document in open office or any other applicatio

2008-01-09 Thread Paul Boddie
On 9 Jan, 09:24, Fredrik Lundh [EMAIL PROTECTED] wrote: [Opening files in applications] on windows, you can use the os.startfile function: import os os.startfile(mydocument.doc) (this is the same as double-clicking on a document in the file explorer) on other platforms, use

Re: Canonical way of deleting elements from lists

2008-01-09 Thread Hrvoje Niksic
Robert Latest [EMAIL PROTECTED] writes: From a list of strings I want to delete all empty ones. This works: while '' in keywords: keywords.remove('') If you're looking for a quick (no quadratic behavior) and convenient way to do it, you can do it like this: keywords = [s for s in

Re: Canonical way of deleting elements from lists

2008-01-09 Thread Hrvoje Niksic
Hrvoje Niksic [EMAIL PROTECTED] writes: If you're looking for a quick (no quadratic behavior) and convenient way to do it, you can do it like this: keywords = [s for s in keywords if s != ''] It now occurred to me that a good compromise between convenience and efficiency that retains the

Re: Canonical way of deleting elements from lists

2008-01-09 Thread Robert Latest
Fredrik Lundh wrote: keywords = filter(None, keywords) # get true items only Makes seinse. BTW, where can I find all methods of the built-in types? Section 3.6 only talks about strings and mentions the list append() method only in an example. Am I too stupid to read the manual, or is this

Re: Canonical way of deleting elements from lists

2008-01-09 Thread Robert Latest
Hrvoje Niksic wrote: keywords[:] = (s for s in keywords if s) Looks good but is so far beyond my own comprehension that I don't dare include it in my code ;-) robert -- http://mail.python.org/mailman/listinfo/python-list

Re: alternating string replace

2008-01-09 Thread Peter Otten
cesco wrote: say I have a string like the following: s1 = 'hi_cat_bye_dog' and I want to replace the even '_' with ':' and the odd '_' with ',' so that I get a new string like the following: s2 = 'hi:cat,bye:dog' import re from itertools import cycle re.sub(_, lambda m, c=cycle(:,).next:

Learning Python via a little word frequency program

2008-01-09 Thread Andrew Savige
I'm learning Python by reading David Beazley's Python Essential Reference book and writing a few toy programs. To get a feel for hashes and sorting, I set myself this little problem today (not homework, BTW): Given a string containing a space-separated list of names: names = freddy fred

Re: Learning Python via a little word frequency program

2008-01-09 Thread Fredrik Lundh
Andrew Savige wrote: Here's my first attempt: names = freddy fred bill jock kevin andrew kevin kevin jock freq = {} for name in names.split(): freq[name] = 1 + freq.get(name, 0) deco = zip([-x for x in freq.values()], freq.keys()) deco.sort() for v, k in deco: print %-10s: %d

Update of Gnuplot.py

2008-01-09 Thread Tom La Bone
Can someone suggest where to get a version of Gnuplot.py (for Windows) that has been updated to use numpy? Or, is there another interface available to use GnuPlot from Python? Thanks. Tom -- View this message in context: http://www.nabble.com/Update-of-Gnuplot.py-tp14710180p14710180.html

Re: Learning Python via a little word frequency program

2008-01-09 Thread Ant
I'm interested to learn how more experienced Python folks would solve this little problem. I think I'd do the following: from collections import defaultdict names = freddy fred bill jock kevin andrew kevin kevin jock freq = defaultdict(lambda: 0) for name in names.split(): freq[name] +=

Re: How a smart editor could make Postfix type declarations PEP3117 in Python3000 more readable

2008-01-09 Thread Bruno Desthuilliers
aspineux a écrit : Hi I read the PEP 3117 about the new Postfix type declarations in Python3000. THIS PEP as been REJECTED ! Indeed - it's an april's fool joke !-) And BTW, no need to scream, we hear you pretty well. But ... The notation in the PEP is very ugly ! This make python

Re: Learning Python via a little word frequency program

2008-01-09 Thread Peter Otten
Andrew Savige wrote: I'm learning Python by reading David Beazley's Python Essential Reference book and writing a few toy programs. To get a feel for hashes and sorting, I set myself this little problem today (not homework, BTW): Given a string containing a space-separated list of names:

Re: alternating string replace

2008-01-09 Thread Duncan Booth
cesco [EMAIL PROTECTED] wrote: Hi, say I have a string like the following: s1 = 'hi_cat_bye_dog' and I want to replace the even '_' with ':' and the odd '_' with ',' so that I get a new string like the following: s2 = 'hi:cat,bye:dog' Is there a common recipe to accomplish that? I can't

Re: how to get string printed by PyErr_Print( )?

2008-01-09 Thread grbgooglefan
On Dec 19 2007, 5:55 pm, Christian Heimes [EMAIL PROTECTED] wrote: grbgooglefan wrote: PythonC API functionPyErr_Print( ) prints an error string onto stderr if PyErr_Occurred() is true. I don't want to print this to stderr because my Python+C code is running daemon mode won't have

Re: Learning Python via a little word frequency program

2008-01-09 Thread Andrew Savige
Fredrik Lundh wrote: # sort items on descending count deco = sorted(freq.items(), key=lambda x: -x[1]) Neat. Is there any way to use sorted() with multiple sort keys? ... Given that the spec calls for sorting by _two_ keys: first by frequency (descending), then by name (ascending). To

Re: Learning Python via a little word frequency program

2008-01-09 Thread Fredrik Lundh
Andrew Savige wrote: Neat. Is there any way to use sorted() with multiple sort keys? ... sure! just return the composite key as a tuple: # sort on descending count, ascending name deco = sorted(freq.items(), key=lambda x: (-x[1], x[0])) (when comparing tuples, Python first compares

Re: I'm searching for Python style guidelines

2008-01-09 Thread MartinRinehart
Matthew Woodcraft wrote: I think [the olpc guidlines are] mostly PEP 8, with some notes added. Took a good look. You are absolutely correct. PEP 8 is basically word processing text stuck between pre and /pre tags. OLPC is Wiki HTML. Good example of how the latter is a lot bigger than the

Re: Learning Python via a little word frequency program

2008-01-09 Thread Bruno Desthuilliers
Andrew Savige a écrit : I'm learning Python by reading David Beazley's Python Essential Reference book and writing a few toy programs. To get a feel for hashes and sorting, I set myself this little problem today (not homework, BTW): Given a string containing a space-separated list of

Re: Learning Python via a little word frequency program

2008-01-09 Thread Peter Otten
Andrew Savige wrote: Fredrik Lundh wrote: # sort items on descending count deco = sorted(freq.items(), key=lambda x: -x[1]) Neat. Is there any way to use sorted() with multiple sort keys? ... Given that the spec calls for sorting by _two_ keys: first by frequency (descending),

Re: Canonical way of deleting elements from lists

2008-01-09 Thread bearophileHUGS
Robert Latest: Fredrik Lundh wrote: keywords = filter(None, keywords) # get true items only Makes seinse. BTW, where can I find all methods of the built-in types? Section 3.6 only talks about strings and mentions the list append() method only in an example. Am I too stupid to read the

Re: alternating string replace

2008-01-09 Thread bearophileHUGS
My version, uses a re.sub, plus a function used as an object with a one bit state: from re import sub def repl(o): repl.n = not repl.n return : if repl.n else , repl.n = False print sub(_, repl, hi_cat_bye_dog_foo_bar_red) Bye, bearophile --

How does unicode() work?

2008-01-09 Thread Robert Latest
Here's a test snippet... import sys for k in sys.stdin: print '%s - %s' % (k, k.decode('iso-8859-1')) ...but it barfs when actually fed with iso8859-1 characters. How is this done right? robert -- http://mail.python.org/mailman/listinfo/python-list

Re: stupid/style/list question

2008-01-09 Thread bearophileHUGS
Duncan Booth: I tried to measure this with timeit, and it looks like the 'del' is actually quite a bit faster (which I find suprising). Yes, it was usually faster in my benchmarks too. Something similar is true for dicts too. I think such timings are influenced a lot by the garbage collector.

Re: How does unicode() work?

2008-01-09 Thread Fredrik Lundh
Robert Latest wrote: Here's a test snippet... import sys for k in sys.stdin: print '%s - %s' % (k, k.decode('iso-8859-1')) ...but it barfs when actually fed with iso8859-1 characters. How is this done right? it's '%s - %s' % (byte string, unicode string) that barfs. try doing

Re: How does unicode() work?

2008-01-09 Thread Robert Latest
Robert Latest wrote: ...but it barfs when actually fed with iso8859-1 characters. Specifically, it says: UnicodeDecodeError: 'ascii' codec can't decode byte 0xf6 in position 0: ordinal not in range(128) which doesn't make sense to me, because I specifically asked for the iso8859-1 decoder,

Re: Canonical way of deleting elements from lists

2008-01-09 Thread Nick Craig-Wood
Robert Latest [EMAIL PROTECTED] wrote: Hrvoje Niksic wrote: keywords[:] = (s for s in keywords if s) Looks good but is so far beyond my own comprehension that I don't dare include it in my code ;-) :-) Worth understanding thought I think - here are some hints keywords[:] = (s for

Re: Learning Python via a little word frequency program

2008-01-09 Thread Bruno Desthuilliers
Ant a écrit : I'm interested to learn how more experienced Python folks would solve this little problem. I think I'd do the following: from collections import defaultdict names = freddy fred bill jock kevin andrew kevin kevin jock freq = defaultdict(lambda: 0) for name in

Re: Collecting Rich Data Structures for students

2008-01-09 Thread bearophileHUGS
It may be better to keep the data in a simpler form: data = \ 42 40 73 45 Albany, N.Y. 35 5 106 39 Albuquerque, N.M. 35 11 101 50 Amarillo, Tex. 34 14 77 57 Wilmington, N.C. 49 54 97 7 Winnipeg, Man., Can. cities = {} for line in data.splitlines(): a1, a2, a3, a4, n = line.split( , 4)

Re: Canonical way of deleting elements from lists

2008-01-09 Thread Fredrik Lundh
Nick Craig-Wood wrote: Using keywords[:] stops the creation of another temporary list. in CPython, list[:] = iter actually creates a temporary list object on the inside, in case iter isn't already a list or a tuple. (see the implementation of PySequence_Fast() for details). /F --

Problem in the program flow...please help?

2008-01-09 Thread jatin patni
I am making a python application with a GUI using WXGlade which connects to a website and extracts some information, this takes around 5-20 seconds of time per website. I have a button(GUI) which when clicked, calls a function connect( ) which takes around 5-20 seconds to complete(As I mentioned

PIL question

2008-01-09 Thread Alex K
Hello, Would anyone know how to generate thumbnails with rounded corners using PIL? I'm also considering imagemagick if PIL turns out not to be appropriate for the task. Thank you so much, Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Collecting Rich Data Structures for students

2008-01-09 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: Some have offered XML repositories, which I can well understand, but in this case we're looking specifically for legal Python modules (py files), although they don't have to be Latin-1 (e.g. the sushi types file might not have a lot of romanji). you can of course

Re: alternating string replace

2008-01-09 Thread cokofreedom
Designed a pretty basic way that is acceptable on small strings. evenOrOdd = True s1 = hi_cat_bye_dog_foo_bar_red s2 = for i in s1: if i == '_': if evenOrOdd: s2 += ':' evenOrOdd = not evenOrOdd else: s2 += ',' evenOrOdd = not

Re: Canonical way of deleting elements from lists

2008-01-09 Thread Sion Arrowsmith
Robert Latest [EMAIL PROTECTED] wrote: BTW, where can I find all methods of the built-in types? Section 3.6 only talks about strings and mentions the list append() method only in an example. Am I too stupid to read the manual, or is this an omission? 3.6 talks about features common to all

flatten sequences in a dictionary

2008-01-09 Thread ajcppmod
Hi I wondering if someone could give me a pointer. I have a dictionary with the following structure: testDict = dict(foo=((1,2,3),(1,4,3)), bar=((3,2,1),(9,8,7,)), mumble=((1,2,3),)) I am trying to create a list of the the 3 element tuples using itertools (just for a bit of fun). I'm trying

Re: flatten sequences in a dictionary

2008-01-09 Thread Paul Hankin
On Jan 9, 1:16 pm, [EMAIL PROTECTED] wrote: Hi I wondering if someone could give me a pointer. I have a dictionary with the following structure: testDict = dict(foo=((1,2,3),(1,4,3)), bar=((3,2,1),(9,8,7,)), mumble=((1,2,3),)) I am trying to create a list of the the 3 element tuples using

Re: Newbie question: Classes

2008-01-09 Thread Sam Garson
OK i've kind of got that. The only thing left is calling the class. class Remember: def __init__(self, master): self.ent = Entry(self, ... root = Tk() app = Remember(root) I get the error Remember instance has no attribute 'tk' ...??? On Jan 8, 2008 7:36 PM, Sam Garson

Re: Python's great, in a word

2008-01-09 Thread MartinRinehart
Thanks to all for many helpful suggestions. Python, by the way, is verbose when compared to APL. (See http://catpad.net/michael/apl/ if you don't believe this.) You need to stick in an adverb (maybe gracefully concise) as standalone concise is owned by APL. Basilisk96 wrote: Did programmers

Re: PIL question

2008-01-09 Thread Fredrik Lundh
Alex K wrote: Would anyone know how to generate thumbnails with rounded corners using PIL? I'm also considering imagemagick if PIL turns out not to be appropriate for the task. create a mask image with round corners (either with your favourite image editor or using ImageDraw/aggdraw or some

Re: alternating string replace

2008-01-09 Thread Neil Cerutti
On Jan 9, 2008 5:34 AM, cesco [EMAIL PROTECTED] wrote: Hi, say I have a string like the following: s1 = 'hi_cat_bye_dog' and I want to replace the even '_' with ':' and the odd '_' with ',' so that I get a new string like the following: s2 = 'hi:cat,bye:dog' Is there a common recipe to

Re: alternating string replace

2008-01-09 Thread Neil Cerutti
On Jan 9, 2008 5:34 AM, cesco [EMAIL PROTECTED] wrote: Hi, say I have a string like the following: s1 = 'hi_cat_bye_dog' and I want to replace the even '_' with ':' and the odd '_' with ',' so that I get a new string like the following: s2 = 'hi:cat,bye:dog' Is there a common recipe to

executing newgrp from python in current shell possible?

2008-01-09 Thread Svenn Are Bjerkem
Hi, as a user on a linux system I am member of the groups users and design with users as my default group. To controll the accessibility of some parts of the file system, creation of files and directories in those parts must be done with group design. This is currently done manually with newgrp

Re: Converting a bidimensional list in a bidimensional array

2008-01-09 Thread Scott David Daniels
Santiago Romero wrote: I'm trying to change my current working source code so that it works with an array instead of using a list, but I'm not managing to do it. ... This is how I create the tilemap (and the clipboard, a copy of my tilemap): def __init__( self, bw, bh, tiles ):

Re: PIL question

2008-01-09 Thread Fredrik Lundh
Fredrik Lundh wrote: create a mask image with round corners (either with your favourite image editor or using ImageDraw/aggdraw or some such). and for people stumbling upon via a search engine some time in the future, Stani just posted a complete example over at the image-sig mailing list.

Re: Open a List of Files

2008-01-09 Thread Terry Jones
Fredrik == Fredrik Lundh [EMAIL PROTECTED] writes: Fredrik Seriously, for a limited number of files, the dictionary approach Fredrik is mostly pointless; you end up replacing Fredrik foo = open(foo) Fredrik foo.write(...) Fredrik with Fredrik somedict[foo] = open(foo) Fredrik

Re: Open a List of Files

2008-01-09 Thread Terry Jones
BJ == BJ Swope [EMAIL PROTECTED] writes: I (at least) think the code looks much nicer. BJ #Referring to files to write in various places... BJ open_files['deliveries'].write(flat_line) BJ open_files['deliveries'].write('\n') If you were doing a lot with the deliveries file at some point, you

problem building simple package with extensions in Windows, but not OS X

2008-01-09 Thread Brian Blais
Hello, I am trying to build a package of mine, and for some reason the build process with distutils is failing in Windows, but not in OS X (and I imagine also in Linux, but I haven't tested it). I am not sure if this is a Pyrex problem, a distutils problem, or me doing something stupid

How to get memory size/usage of python object

2008-01-09 Thread Santiago Romero
Is there a way to check the REAL size in memory of a python object? Something like print sizeof(mylist) or print sizeof(myclass_object) or something like that ... Thanks. -- http://mail.python.org/mailman/listinfo/python-list

packaging questions

2008-01-09 Thread Brian Blais
Hello, I am trying to package a number of python files, and I plan to use Mercurial to do the version control. In more established projects that I see, I notice that there are a number of files, like Changelog, MANIFEST, INSTALL, etc... that would seem to be generated automatically.

Re: Open a List of Files

2008-01-09 Thread Tim Chase
You don't need for fn in open_files.keys():, you can just use for fn in open_files:, but simpler than that is to just use the dictionary values: for fn in open_files.values(): fn.close() This can also work for standard variable names: for f in (messages, deliveries, actions, parts,

Re: Problem in the program flow...please help?

2008-01-09 Thread Jerry Hill
On Jan 9, 2008 7:44 AM, jatin patni [EMAIL PROTECTED] wrote: I have a button(GUI) which when clicked, calls a function connect( ) which takes around 5-20 seconds to complete(As I mentioned Earlier) The problem is, during this time the other part of the code is rendered useless, I cannot access

Re: Canonical way of deleting elements from lists

2008-01-09 Thread Nick Craig-Wood
Fredrik Lundh [EMAIL PROTECTED] wrote: Nick Craig-Wood wrote: Using keywords[:] stops the creation of another temporary list. in CPython, list[:] = iter actually creates a temporary list object on the inside, in case iter isn't already a list or a tuple. (see the implementation of

Re: How does unicode() work?

2008-01-09 Thread Fredrik Lundh
Carsten Haese wrote: If that really is the line that barfs, wouldn't it make more sense to repr() the unicode object in the second position? import sys for k in sys.stdin: print '%s - %s' % (k, repr(k.decode('iso-8859-1'))) Also, I'm not sure if the OP has told us the truth about

Re: Converting a bidimensional list in a bidimensional array

2008-01-09 Thread Santiago Romero
This is how I create the tilemap (and the clipboard, a copy of my tilemap): def __init__( self, bw, bh, tiles ): self.tilemap = [] (...) for i in range(bh): self.tilemap.append([0] * bw) def __init__( self, bw, bh, tiles ):

Re: How to get memory size/usage of python object

2008-01-09 Thread Fredrik Lundh
Santiago Romero wrote: Is there a way to check the REAL size in memory of a python object? in standard Python, without reading the interpreter source code carefully, no. to get an approximate value, create a thousand (or a million) objects and check how much the interpreter grows when you

Re: alternating string replace

2008-01-09 Thread Pablo Ziliani
cesco wrote: Hi, say I have a string like the following: s1 = 'hi_cat_bye_dog' and I want to replace the even '_' with ':' and the odd '_' with ',' so that I get a new string like the following: s2 = 'hi:cat,bye:dog' Is there a common recipe to accomplish that? I can't come up with any

RE: 'Borg' and multiple threads.

2008-01-09 Thread Reedick, Andrew
-Original Message- From: [EMAIL PROTECTED] [mailto:python- [EMAIL PROTECTED] On Behalf Of Tobiah Sent: Monday, January 07, 2008 5:24 PM To: python-list@python.org Subject: 'Borg' and multiple threads. I have a class that I call Borg that starts like this: class Borg(dict):

Re: How does unicode() work?

2008-01-09 Thread Carsten Haese
On Wed, 2008-01-09 at 13:44 +0100, Fredrik Lundh wrote: Robert Latest wrote: Here's a test snippet... import sys for k in sys.stdin: print '%s - %s' % (k, k.decode('iso-8859-1')) ...but it barfs when actually fed with iso8859-1 characters. How is this done right? it's

Re: How does unicode() work?

2008-01-09 Thread Carsten Haese
On Wed, 2008-01-09 at 15:33 +0100, Fredrik Lundh wrote: When mixing Unicode with byte strings, Python attempts to decode the byte string, not encode the Unicode string. Ah, I did not realize that. I never mix Unicode and byte strings in the first place, and now I know why. Thanks for clearing

Re: Natural-language datetime parsing and display (was: user friendly datetime features)

2008-01-09 Thread Paul McGuire
On Jan 8, 7:57 pm, Ben Finney [EMAIL PROTECTED] wrote: Daniel Fetchinson [EMAIL PROTECTED] writes: I'm guessing this feature is needed so often in so many projects that it has been implemented already by several people. Does anyone know of such a stand alone module? The 'python-dateutil'

Re(Thanks...Re: Problem in the program flow...please help?)

2008-01-09 Thread jatin patni
Thanks Jerry..For the link...I am looking into it... On Jan 9, 2008 2:36 PM, Jerry Hill [EMAIL PROTECTED] wrote: On Jan 9, 2008 7:44 AM, jatin patni [EMAIL PROTECTED] wrote: I have a button(GUI) which when clicked, calls a function connect( ) which takes around 5-20 seconds to complete(As

subprocess.Popen spawning cmd shells

2008-01-09 Thread Mrown
Hi, I'm currently writing a python program that relies on a CLI program. What I'm currently doing is using subprocess.Popen on Python 2.5.1. Here's the line that I'm currently running: child = subprocess.Popen([c:\app.exe, node, -w, str(tmpTime * 1000), '-n', str(1), '-l'],

Re: stupid/style/list question

2008-01-09 Thread Duncan Booth
[EMAIL PROTECTED] wrote: Duncan Booth: I tried to measure this with timeit, and it looks like the 'del' is actually quite a bit faster (which I find suprising). Yes, it was usually faster in my benchmarks too. Something similar is true for dicts too. I think such timings are influenced a

Re: Python's great, in a word

2008-01-09 Thread Paddy
On Jan 9, 1:02 pm, [EMAIL PROTECTED] wrote: Thanks to all for many helpful suggestions. Python, by the way, is verbose when compared to APL. (Seehttp://catpad.net/michael/apl/if you don't believe this.) You need to stick in an adverb (maybe gracefully concise) as standalone concise is owned

Re: Collecting Rich Data Structures for students

2008-01-09 Thread Paddy
On Jan 9, 6:52 am, Paddy [EMAIL PROTECTED] wrote: On Jan 9, 2:19 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Greetings Pythoneers -- Some of us over on edu-sig, one of the community actives, have been brainstorming around this Rich Data Structures idea, by which we mean Python

Re: sqlite fetchall breacking because decoding.

2008-01-09 Thread Fredrik Lundh
tyoc wrote: The database is not corrupt, I mean Im sure if I do a C program for read and print the row, it will get it and just printit and not fail like this well, the database *is* corrupt, since sqlite3 (both the engine and the Python binding) expects you to use a supported encoding for

Re: subprocess.Popen spawning cmd shells

2008-01-09 Thread Mrown
On Jan 9, 5:17 pm, Mrown [EMAIL PROTECTED] wrote: Hi,   I'm currently writing a python program that relies on a CLI program.  What I'm currently doing is using subprocess.Popen on Python 2.5.1.  Here's the line that I'm currently running:             child = subprocess.Popen([c:\app.exe,

sqlite fetchall breacking because decoding.

2008-01-09 Thread tyoc
here is the snips that can reproduce my problem in the system Im working http://tyoc.nonlogic.org/darcsrepos/snip1.zip it is 2 files a sample db with 1 row and a py with 1 function for read that row The output I get is the following: -- Traceback

Problem in importing modules using py2exe

2008-01-09 Thread jatin patni
I am trying to generate binaries on Windows platform using py2exe, but it is unable to import this module named Mechanize. The error says it could not find this module...while the module is present along with all the other modules Python/Lib/site-packages/... Any help would be

Re: sqlite fetchall breacking because decoding.

2008-01-09 Thread tyoc
well, the database *is* corrupt, since sqlite3 (both the engine and the Python binding) expects you to use a supported encoding for the data stored in the database: http://www.sqlite.org/datatype3.html http://docs.python.org/lib/node346.html Still like I said before, I have

printing dots in simple program while waiting

2008-01-09 Thread John
Ok, so this should be a really simple thing to do, but I haven't been able to get it on the first few tries and couldn't find anything after searching a bit. what i want to do is print a 'waiting' statement while a script is working-- the multithreading aspect isn't an issue, the printing on the

asynchronous timer events - how to?

2008-01-09 Thread Helmut Jarausch
Hi, I'm using a web server (Karrigell) which is based on the asyncore module. I'd like to be able to checkpoint some data (e.g. pickled dictionaries) to disk from time to time. For that I would need to setup a timer which calls a Python object/function when its time interval has expired. While

Re: printing dots in simple program while waiting

2008-01-09 Thread Tim Chase
Martin Marcher wrote: John wrote: import time s = '.' print 'working', # Note the , at the end of the line while True: print s, #Note the , at the end of this line too... time.sleep(1) see my comment in the code above... see my added comment in the code above... Though this

Re: sqlite fetchall breacking because decoding.

2008-01-09 Thread Fredrik Lundh
tyoc wrote: well, the database *is* corrupt, since sqlite3 (both the engine and the Python binding) expects you to use a supported encoding for the data stored in the database: http://www.sqlite.org/datatype3.html http://docs.python.org/lib/node346.html Still like I said

Re: printing dots in simple program while waiting

2008-01-09 Thread John
On Jan 9, 11:56 am, Martin Marcher [EMAIL PROTECTED] wrote: John wrote: import time s = '.' print 'working', # Note the , at the end of the line while True: print s time.sleep(1) see my comment in the code above... if that's what you mean /martin

centre of mass of protein

2008-01-09 Thread smriti Sebastian
hi all, Is there any script or module in python where we can find the centre of mass of protein? -- http://mail.python.org/mailman/listinfo/python-list

RE: printing dots in simple program while waiting

2008-01-09 Thread Reedick, Andrew
-Original Message- From: [EMAIL PROTECTED] [mailto:python- [EMAIL PROTECTED] On Behalf Of Martin Marcher Sent: Wednesday, January 09, 2008 11:57 AM To: python-list@python.org Subject: Re: printing dots in simple program while waiting John wrote: import time s = '.' print

Re: asynchronous timer events - how to?

2008-01-09 Thread Fredrik Lundh
Helmut Jarausch wrote: I'm using a web server (Karrigell) which is based on the asyncore module. I'd like to be able to checkpoint some data (e.g. pickled dictionaries) to disk from time to time. For that I would need to setup a timer which calls a Python object/function when its time

Re: printing dots in simple program while waiting

2008-01-09 Thread Martin Marcher
John wrote: import time s = '.' print 'working', # Note the , at the end of the line while True: print s time.sleep(1) see my comment in the code above... if that's what you mean /martin -- http://noneisyours.marcher.name http://feeds.feedburner.com/NoneIsYours You are not

Re: user friendly datetime features

2008-01-09 Thread jim-on-linux
Why not build your own module? You can use it where and when you need it. jim-on-linux http://www.inqvista.com On Tuesday 08 January 2008 20:19, Daniel Fetchinson wrote: Many times a more user friendly date format is convenient than the pure date and time. For example for a date that is

  1   2   3   >