Re: flexible find and replace ?

2009-02-17 Thread Gerard Flanagan
OdarR wrote: Hi guys, how would you do a clever find and replace, where the value replacing the tag is changing on each occurence ? ...TAGTAGTAG..TAG. is replaced by this : ...REPL01REPL02REPL03..REPL04...

Re: flexible find and replace ?

2009-02-17 Thread Duncan Booth
John Machin sjmac...@lexicon.net wrote: def fancyrepl(tag, replfunc, input_string): count = 0 pieces = [] pos = 0 taglen = len(tag) while 1: try: newpos = input_string.index(tag, pos) except ValueError:

Get file name from file handle

2009-02-17 Thread loial
Is there anyway, having been passed a file handle, to get the filename? I am assuming not, but thought I would ask -- http://mail.python.org/mailman/listinfo/python-list

Re: Get file name from file handle

2009-02-17 Thread Noprianto
On 2/17/09, loial jldunn2...@googlemail.com wrote: Is there anyway, having been passed a file handle, to get the filename? I am assuming not, but thought I would ask a = open('/etc/passwd') a.name '/etc/passwd' Best regards, Nop -- http://mail.python.org/mailman/listinfo/python-list

Re: memory recycling/garbage collecting problem

2009-02-17 Thread Aaron Brady
On Feb 16, 11:21 pm, Yuanxin Xi xi11w...@gmail.com wrote: I'm having some problems with the memory recycling/garbage collecting of the following testing code: a=[str(i) for i in xrange(1000)] This takes 635m/552m/2044 memory (VIRT/RES/SHR) b={} for i in xrange(1000): ...    

Re: Upgrading standard library module

2009-02-17 Thread Gabriel Genellina
En Fri, 13 Feb 2009 20:17:35 -0200, Bryan bryanv...@gmail.com escribió: On Feb 13, 1:52 pm, Jason Scheirer jason.schei...@gmail.com wrote: On Feb 13, 12:42 pm, Bryan bryanv...@gmail.com wrote: I have a Python v2.5.2 server running and I found some undesirable behavior in the xmlrpclib module

Re: memory recycling/garbage collecting problem

2009-02-17 Thread Chris Rebert
On Tue, Feb 17, 2009 at 12:33 AM, Aaron Brady castiro...@gmail.com wrote: On Feb 16, 11:21 pm, Yuanxin Xi xi11w...@gmail.com wrote: I'm having some problems with the memory recycling/garbage collecting of the following testing code: a=[str(i) for i in xrange(1000)] This takes

Re: flexible find and replace ?

2009-02-17 Thread Gerard Flanagan
Gerard Flanagan wrote: def replace(s, patt, repls): def onmatch(m): onmatch.idx += 1 return repls[onmatch.idx] onmatch.idx = -1 return patt.sub(onmatch, s) test = abcTAG TAG asdTAGxyz REPLS = [ 'REPL1', 'REPL2', 'REPL3', ] print replace(test,

Re: Get file name from file handle

2009-02-17 Thread Duncan Booth
loial jldunn2...@googlemail.com wrote: Is there anyway, having been passed a file handle, to get the filename? I am assuming not, but thought I would ask If you mean a Python file object then file.name (but it may not exist on all file objects). If you mean a system file handle, then

print string as raw string

2009-02-17 Thread Mirko Dziadzka
Hi all I'm trying to find a way to output strings in the raw-string format, e.g. print_as_raw_string(r\.) should output r\. instead of \\. Is there a better way than writing your own print function? Some magic encoding? Mirko -- http://mail.python.org/mailman/listinfo/python-list

Re: Get file name from file handle

2009-02-17 Thread bieffe62
On Feb 17, 9:21 am, loial jldunn2...@googlemail.com wrote: Is there anyway, having been passed a file handle, to get the filename? I am assuming not, but thought I would ask If by file handle you mean the object returned by 'file' and 'open' functions, it has a name attribute. If by file

Re: pythonic array subsetting

2009-02-17 Thread bearophileHUGS
Nick Matzke: I have to do this hundreds of times, so speed would be useful. Try to create a 2D array with NumPy, and then slice it. Note that slicing syntax has a stride too. Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: Will multithreading make python less popular?

2009-02-17 Thread Hendrik van Rooyen
Aahz a...@pyaft.com wrote: In article mailman.52.1234797812.11746.python-l...@python.org, Hendrik van Rooyen maorp.co.za wrote: Occam was the language that should have won the marketing prize, but didn't. It wasn't simple enough. I thought (at the time) that it was quite good

Re: Will multithreading make python less popular?

2009-02-17 Thread Hendrik van Rooyen
Ben Finney bignose+hates-s...@benfinney.id.au wrote: a...@pythoncraft.com (Aahz) writes: In article mailman.52.1234797812.11746.python-l...@python.org, Hendrik van Rooyen m...@microcorp.co.za wrote: Occam was the language that should have won the marketing prize, but didn't. It wasn't

ANN: Assembly Line 0.8.2

2009-02-17 Thread Greg Ewing
I have released an updated version of Assembly Line, my entry in PyWeek 6 and later the Pyggy Awards. http://media.pyweek.org/dl/1007/greg_pgF09/AssemblyLine-0.8.2.zip About Assembly Line --- Become a FADE! That's Factory Automation Design Engineer for Pixall Manufacturing,

Re: Need an application sends from paricular port

2009-02-17 Thread Gabriel Genellina
En Tue, 17 Feb 2009 03:44:51 -0200, Sambit Samal sambit2...@gmail.com escribió: I am new to Python world I need a python script , which binds at a user defind port sends to other enity , which waits at particular port. The other enity will respond Python script should receive that at the

Re: print string as raw string

2009-02-17 Thread Tino Wildenhain
Mirko Dziadzka wrote: Hi all I'm trying to find a way to output strings in the raw-string format, e.g. print_as_raw_string(r\.) should output r\. instead of \\. Is there a better way than writing your own print function? Some magic encoding? Thats nonsense. print r\. or in python3.0

Re: print string as raw string

2009-02-17 Thread Diez B. Roggisch
Mirko Dziadzka schrieb: Hi all I'm trying to find a way to output strings in the raw-string format, e.g. print_as_raw_string(r\.) should output r\. instead of \\. Is there a better way than writing your own print function? Some magic encoding? There is no need to do this. Rawstrings are

Re: Speedup Bitmap Parser

2009-02-17 Thread Tim Wintle
On Mon, 2009-02-16 at 16:47 -0800, bearophileh...@lycos.com wrote: Jayson Santos: Do I need use some patters or others progamming conventions ? That's a strong question... Knowing OOP well is important, and it's often a good way to program, etc. But... You may try to rewrite your code with

Re: printing bytes to stdout in Py3

2009-02-17 Thread Gabriel Genellina
En Tue, 17 Feb 2009 03:04:23 -0200, Peter Billam pe...@www.pjb.com.au escribió: Greetings. (Newbie warning as usual) In Python3, sys.stdout is a io.TextIOWrapper object; but I want to output bytes (e.g. muscript -midi t t.mid ) and they're coming out stringified :-( How can I either

Re: Will multithreading make python less popular?

2009-02-17 Thread andrew cooke
why do you think that current work is ignorant of occam? occam itself was based on hoare's communicating sequential processes which is a classic of the field. the ideas behind occam are not unknown and it hasn't been forgotten (there are many libraries based on synchronous message passing; one

Re: Will multithreading make python less popular?

2009-02-17 Thread Bruno Desthuilliers
rushen...@gmail.com a écrit : (snip) And the story begins here. As i search on the net, I have found that because of the natural characteristics of python such as GIL, we are not able to write multi threaded programs. I'm surprised no one here corrected that point yet, so here we go: yes,

Re: print string as raw string

2009-02-17 Thread Mirko Dziadzka
Diez B. Roggisch de...@nospam.web.de wrote: I'm trying to find a way to output strings in the raw-string format, e.g. print_as_raw_string(r\.) should output r\. instead of \\. Is there a better way than writing your own print function? Some magic encoding? There is no need to do this.

Re: Will multithreading make python less popular?

2009-02-17 Thread andrew cooke
Bruno Desthuilliers wrote: rushen...@gmail.com a écrit : (snip) And the story begins here. As i search on the net, I have found that because of the natural characteristics of python such as GIL, we are not able to write multi threaded programs. I'm surprised no one here corrected that

Re: print string as raw string

2009-02-17 Thread Mirko Dziadzka
Mirko Dziadzka mirko.dziad...@gmail.com wrote: Hi all I'm trying to find a way to output strings in the raw-string format, e.g. print_as_raw_string(r\.) should output r\. instead of \\. Ok, lets make a better example: re_list = {} re_list['foo'] = r'\..*' re_list['bar'] = r'.*bar.*'

Re: Pythonic way to determine if one char of many in a string

2009-02-17 Thread Steven D'Aprano
Nicolas Dandrimont wrote: I would go for something like: for char in word: if char in 'aeiouAEIUO': char_found = True break else: char_found = False (No, I did not forget to indent the else statement, see

Re: print string as raw string

2009-02-17 Thread Steven D'Aprano
Diez B. Roggisch wrote: Mirko Dziadzka schrieb: Hi all I'm trying to find a way to output strings in the raw-string format, e.g. print_as_raw_string(r\.) should output r\. instead of \\. Is there a better way than writing your own print function? Some magic encoding? There is no

Re: Pythonic way to determine if a string is a number

2009-02-17 Thread Steven D'Aprano
Roy Smith wrote: Do you really want to except SystemExit, KeyboardInterrupt, MemoryError and SyntaxError? Absolutely. Let's take my example -- you're writing software for a Mars Rover. I have no idea how you might get a MemoryError, but let's say you do. Which would you rather do,

Re: printing bytes to stdout in Py3

2009-02-17 Thread Christian Heimes
Peter Billam schrieb: Greetings. (Newbie warning as usual) In Python3, sys.stdout is a io.TextIOWrapper object; but I want to output bytes (e.g. muscript -midi t t.mid ) and they're coming out stringified :-( How can I either change the encoding on sys.stdout, or close sys.stdout and

Is there something easier than ORM?

2009-02-17 Thread 一首诗
Hi all, Recently I am studying some python ORM libraries, such as sqlalchemy. These are very powerful technologies to handle database. But I think my project are not complicated to enough to benefit from a complete ORM system. What I really want, is some easy ways to load data from database,

listing files by modification time

2009-02-17 Thread Deepak Rokade
Hi, I am using python 2.5 on sun solaris. I want to limit the number of files returned by os.listdir() to some number (say 1000), how can I do it ? Also I wan to list the files only if they are older than some x days, how can I do it? I can do this through shell script using command. find

Re: listing files by modification time

2009-02-17 Thread Chris Rebert
On Tue, Feb 17, 2009 at 4:31 AM, Deepak Rokade smartp...@gmail.com wrote: Hi, I am using python 2.5 on sun solaris. I want to limit the number of files returned by os.listdir() to some number (say 1000), how can I do it ? Also I wan to list the files only if they are older than some x

Re: Is there something easier than ORM?

2009-02-17 Thread Kottiyath
一首诗 wrote: Hi all, Recently I am studying some python ORM libraries, such as sqlalchemy. These are very powerful technologies to handle database. But I think my project are not complicated to enough to benefit from a complete ORM system. What I really want, is some easy ways to load

Re: flexible find and replace ?

2009-02-17 Thread John Machin
On Feb 17, 7:18 pm, Duncan Booth duncan.bo...@invalid.invalid wrote: John Machin sjmac...@lexicon.net wrote: def fancyrepl(tag, replfunc, input_string):     count = 0     pieces = []     pos = 0     taglen = len(tag)     while 1:         try:             newpos =

Re: Is there something easier than ORM?

2009-02-17 Thread Diez B. Roggisch
一首诗 schrieb: Hi all, Recently I am studying some python ORM libraries, such as sqlalchemy. These are very powerful technologies to handle database. But I think my project are not complicated to enough to benefit from a complete ORM system. What I really want, is some easy ways to load data

Re: Is there something easier than ORM?

2009-02-17 Thread Michele Simionato
On Feb 17, 1:27 pm, 一首诗 newpt...@gmail.com wrote: Hi all, Recently I am studying some python ORM libraries, such as sqlalchemy. These are very powerful technologies to handle database. But I think my project are not complicated to enough to benefit from a complete ORM system. What I

Re: Speedup Bitmap Parser

2009-02-17 Thread Jayson Santos
On 16 fev, 21:47, bearophileh...@lycos.com wrote: Jayson Santos: Do I need use some patters or others progamming conventions ? That's a strong question... Knowing OOP well is important, and it's often a good way to program, etc. But... You may try to rewrite your code with functions only

how to detect if an object is simple (not a pointer, unmutable ) ?

2009-02-17 Thread Stef Mientki
hello, I'm making a virtual machine, in which (small) pieces of software (called bricks) are connected, by connecting an output of a brick to the input of another brick. A connection between 2 bricks may be of any type, so it might be simple integer, or a multi-nested dictionary / list or

Re: memory recycling/garbage collecting problem

2009-02-17 Thread Tim Wintle
On Tue, 2009-02-17 at 00:40 -0800, Chris Rebert wrote: 'gc.collect()' -- I believe, but I'm not the specialist in it. If I understand correctly, that only effects objects that are part of a reference cycle and doesn't necessarily force the freed memory to be released to the OS. I

Re: listing files by modification time

2009-02-17 Thread Deepak Rokade
Yes I can do that but for that I will have to go through entire list of files and also I will have to first get the whole list of files present in directory. In case of my application this list can be huge and so want to list the files which suits my criteria. Similar to the unix find command I

Re: Is there something easier than ORM?

2009-02-17 Thread 一首诗
Thanks for your reply. With sqlalchemy, an mapped must living in a session, you have no way to disconnect it with its session. For example : #- user = session.query(User).first() session.expunge(user) print user.name #Error here

Re: how to detect if an object is simple (not a pointer, unmutable ) ?

2009-02-17 Thread Diez B. Roggisch
Stef Mientki schrieb: hello, I'm making a virtual machine, in which (small) pieces of software (called bricks) are connected, by connecting an output of a brick to the input of another brick. A connection between 2 bricks may be of any type, so it might be simple integer, or a multi-nested

Re: memory recycling/garbage collecting problem

2009-02-17 Thread Floris Bruynooghe
On Feb 17, 5:31 am, Chris Rebert c...@rebertia.com wrote: My understanding is that for efficiency purposes Python hangs on to the extra memory even after the object has been GC-ed and doesn't give it back to the OS right away. Even if Python would free() the space no more used by it's own

Re: listing files by modification time

2009-02-17 Thread Albert Hopkins
On Tue, 2009-02-17 at 19:46 +0530, Deepak Rokade wrote: Yes I can do that but for that I will have to go through entire list of files and also I will have to first get the whole list of files present in directory. In case of my application this list can be huge and so want to list the

Re: how to detect if an object is simple (not a pointer, unmutable ) ?

2009-02-17 Thread Stef Mientki
thanks Diez, Diez B. Roggisch wrote: Stef Mientki schrieb: hello, I'm making a virtual machine, in which (small) pieces of software (called bricks) are connected, by connecting an output of a brick to the input of another brick. A connection between 2 bricks may be of any type, so it might

How do I declare global vars or class vars in Python ?

2009-02-17 Thread Linuxguy123
How do I do this in Python ? # declare A,B function getA return A function getB return B function setA(value) A = value function setB(value) B = value main() getA getB dosomething setA(aValue) setB(aValue)

Re: Pythonic way to determine if a string is a number

2009-02-17 Thread Roy Smith
In article 01aaa1da$0$20629$c3e8...@news.astraweb.com, Steven D'Aprano st...@pearwood.info wrote: Okay, but that surely falls under chapter 18 of the Advanced Python Programming for the Mars Rover book rather than chapter 5 of Newbies Guide to Python. Well, sure, but this thread started out

Re: Is there something easier than ORM?

2009-02-17 Thread Mike Driscoll
On Feb 17, 8:15 am, 一首诗 newpt...@gmail.com wrote: Thanks for your reply. With sqlalchemy, an mapped must living in a session, you have no way to disconnect it with its session. For example : #- user = session.query(User).first() session.expunge(user)

Re: How do I declare global vars or class vars in Python ?

2009-02-17 Thread MRAB
Linuxguy123 wrote: How do I do this in Python ? # declare A,B function getA return A function getB return B function setA(value) A = value function setB(value) B = value main() getA getB dosomething setA(aValue) setB(aValue)

Re: can multi-core improve single funciton?

2009-02-17 Thread Cameron Laird
In article pan.2009.02.10.22.26...@remove.this.cybersource.com.au, Steven D'Aprano ste...@remove.this.cybersource.com.au wrote: . . . And now for my version (which admitedly isn't really mine, and returns slightly incorrect

Re: How do I declare global vars or class vars in Python ?

2009-02-17 Thread Paddy O'Loughlin
Use the global statement. http://docs.python.org/reference/simple_stmts.html#the-global-statement A working example based on your pseudocode would be: def getA(): global A return A def getB(): global B return B def setA(value): global A

Re: How do I declare global vars or class vars in Python ?

2009-02-17 Thread Paddy O'Loughlin
2009/2/17 MRAB goo...@mrabarnett.plus.com: It isn't possible to have an uninitialised variable. If it doesn't have a value then it doesn't exist. True, but you can use the global statement to refer to the variable within a function and read from the variable there, without it being already

Re: Pythonic way to determine if a string is a number

2009-02-17 Thread Floris Bruynooghe
On Feb 16, 12:05 am, Mel mwil...@the-wire.com wrote: Christian Heimes wrote: Roy Smith wrote: They make sense when you need to recover from any error that may occur, possibly as the last resort after catching and dealing with more specific exceptions. In an unattended embedded system

Threads vs. processes, what to consider in choosing ?

2009-02-17 Thread Barak, Ron
Hi, May I have your recommendations in choosing threads or processes for the following ? I have a wxPython application that builds an internal database from a list of files and then displays various aspects of that data, in response to user's requests. I want to add a module that finds

Re: Is there something easier than ORM?

2009-02-17 Thread J. Cliff Dyer
On Tue, 2009-02-17 at 06:15 -0800, 一首诗 wrote: Thanks for your reply. With sqlalchemy, an mapped must living in a session, you have no way to disconnect it with its session. For example : #- user = session.query(User).first() session.expunge(user)

Re: Pythonic way to determine if a string is a number

2009-02-17 Thread Floris Bruynooghe
On Feb 16, 7:09 am, Python Nutter pythonnut...@gmail.com wrote: silly me, forgot to mention build a set from digits + '.' and use that for testing. `.' is locale dependent. Some locales might use `,' instead and maybe there's even more out there that I don't know of. So developing this

Re: Pythonic way to determine if a string is a number

2009-02-17 Thread Paddy O'Loughlin
2009/2/16 Python Nutter pythonnut...@gmail.com: silly me, forgot to mention build a set from digits + '.' and use that for testing. Cheers, PN 2009/2/16 Python Nutter pythonnut...@gmail.com: Type casting seems to be the wrong way to go about this. teststring = '15719'

Re: Upgrading standard library module

2009-02-17 Thread Bryan
On Feb 17, 12:34 am, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Fri, 13 Feb 2009 20:17:35 -0200, Bryan bryanv...@gmail.com escribió: On Feb 13, 1:52 pm, Jason Scheirer jason.schei...@gmail.com wrote: On Feb 13, 12:42 pm, Bryan bryanv...@gmail.com wrote: I have a Python v2.5.2

RE: Changing the Image on a button

2009-02-17 Thread John Posner
Try this change:   from: btn.configure(image = None)     to: img1.blank() This does in fact clear the image out, however it isn't causing the text to display... Do i have have to create a new button and swap it out? I knew you were gonna ask that! :-) I haven't worked in

Re: Pythonic way to determine if a string is a number

2009-02-17 Thread python
Original poster here: Just for the record, my *original* post did include an explicit trapping of the ValueError exception. :) My point is that the coaching offered by this forum does not always fall on deaf ears. Thanks for everyone's help on this and all the other posts in this forum.

Re: Will multithreading make python less popular?

2009-02-17 Thread sturlamolden
On 16 Feb, 10:34, rushen...@gmail.com wrote: And the story begins here. As i search on the net, I have found that because of the natural characteristics of python such as GIL, we are not able to write multi threaded programs. Oooops, in a kind of time with lots of cpu cores and we are not

Re: memory recycling/garbage collecting problem

2009-02-17 Thread Christian Heimes
Yuanxin Xi wrote: Could anyone please explain why this happens? It seems some memory are not freed. I'm running into problems with this as my program is very memory cosuming and need to frequently free some object to reuse the memory. What is the best way to free the memory of b completely

Re: Will multithreading make python less popular?

2009-02-17 Thread sturlamolden
On 16 Feb, 15:18, rushen...@gmail.com wrote: As you mentioned, using multi cores makes programs more fast and more popular. But what about stackless python? Does it interpret same set of python libraries with Cpython or Does it have a special sub set? Stackless and CPython have a GIL, Jython

Re: Will multithreading make python less popular?

2009-02-17 Thread ma
Very well written response! Thanks Sturla On Tue, Feb 17, 2009 at 10:50 AM, sturlamolden sturlamol...@yahoo.nowrote: On 16 Feb, 10:34, rushen...@gmail.com wrote: And the story begins here. As i search on the net, I have found that because of the natural characteristics of python such as

Re: memory recycling/garbage collecting problem

2009-02-17 Thread Christian Heimes
Tim Wintle wrote: Basically malloc() and free() are computationally expensive, so Python tries to call them as little as possible - but it's quite clever at knowing what to do - e.g. if a list has already grown large then python assumes it might grow large again and keeps hold of a percentage

Python change a value of a variable by itself.

2009-02-17 Thread Kurda Yon
Hi, I have the following simple code: r = {} r[1] = [0.00] r_new = {} print r[1][0] r_new[1] = r[1] r_new[1][0] = r[1][0] + 0.02 print r[1][0] It outputs: 0.0 0.02 it is something strange to me since in the first and second case I output the same variable (r[1][0]) and it the two cases it

Re: Python change a value of a variable by itself.

2009-02-17 Thread Stephen Hansen
On Tue, Feb 17, 2009 at 8:19 AM, Kurda Yon kurda...@yahoo.com wrote: r_new[1] = r[1] This is the problem. r is a dictionary, a set of key/object pairs in essence. You're making the object that r[1] is pointing to a list, a mutable sequence of items. The expression r[1] will then return that

Re: How do I declare global vars or class vars in Python ?

2009-02-17 Thread Duncan Booth
Paddy O'Loughlin patrick.olough...@gmail.com wrote: True, but you can use the global statement to refer to the variable within a function and read from the variable there, without it being already initialised in the module. You don't need the global statement unless you plan to *write* the

Re: Python change a value of a variable by itself.

2009-02-17 Thread Tim Chase
I have the following simple code: r = {} r[1] = [0.00] r_new = {} print r[1][0] r_new[1] = r[1] r_new[1][0] = r[1][0] + 0.02 print r[1][0] It outputs: 0.0 0.02 it is something strange to me since in the first and second case I output the same variable (r[1][0]) and it the two cases it has

Re: printing bytes to stdout in Py3

2009-02-17 Thread Casey
On Feb 17, 7:28 am, Christian Heimes li...@cheimes.de wrote: Peter Billam schrieb: Greetings. (Newbie warning as usual) In Python3, sys.stdout is a io.TextIOWrapper object; but I want to output bytes   (e.g. muscript -midi t t.mid ) and they're coming out stringified :-(  How can I

Re: Is there something easier than ORM?

2009-02-17 Thread Philip Semanchuk
On Feb 17, 2009, at 7:27 AM, 一首诗 wrote: Hi all, Recently I am studying some python ORM libraries, such as sqlalchemy. These are very powerful technologies to handle database. But I think my project are not complicated to enough to benefit from a complete ORM system. What I really want, is

Re: Is there something easier than ORM?

2009-02-17 Thread Tim Golden
Philip Semanchuk wrote: [... snip comments on SqlAlchemy which could likewise apply to other similar offerings ...] I don't intend this as a criticism of SqlAlchemy. On the contrary I am impressed by what it does. But I often see people promoting ORM as the solution to all database access

Re: Is there something easier than ORM?

2009-02-17 Thread andrew cooke
Philip Semanchuk wrote: In short, I gather that others on this list are a lot more fond of SqlAlchemy and ORMs in general than I am. Granted, my experience is very limited. I tried to integrate SqlAlchemy in one project, struggled for a long time to express how I wanted my tables joined, and

Re: Will multithreading make python less popular?

2009-02-17 Thread Christian Heimes
rushen...@gmail.com wrote: As you mentioned, using multi cores makes programs more fast and more popular. But what about stackless python? Does it interpret same set of python libraries with Cpython or Does it have a special sub set? Your assumption is wrong. Multiple cores are able to speed

Threading and tkinter

2009-02-17 Thread gert
After reading the docs and seeing a few examples i think this should work ? Am I forgetting something here or am I doing something stupid ? Anyway I see my yellow screen, that has to count for something :) from tkinter import * from threading import Thread class Weegbrug(Thread): def

Reading from text

2009-02-17 Thread oamram
Hi All, new to python. i have a directory with about 50 text file and i need to iterate through them and get line 7 to 11 from each file and write those lines into another file(one file that will contain all lines). Cheers, Omer. -- View this message in context:

Re: Speedup Bitmap Parser

2009-02-17 Thread bearophileHUGS
Jayson Santos: After changing my code to use only functions instead classes my code is too much faster. Here cProfile statistcs: Using old code : 633608 function calls in 1.361 CPU seconds Using new code: 475487 function calls in 0.800 CPU seconds If you show a pastebin of the new version

Re: wxPython and Croatian characters

2009-02-17 Thread vedrandekovic
On 17 velj, 00:09, alejandro aleksanda...@brisiovonet.hr wrote: Provjeri da si nisi stavio ansii kada si instalirao wx.python. Mozes probat ubacit iznad svega u fajlu komentar u kojem pise da je fajl u UTF-8 i onda bi ti trebalo sljakat. Nadem sutra pa ti posaljem Pozdrav / Hello, It works

Re: Threads vs. processes, what to consider in choosing ?

2009-02-17 Thread Philip Semanchuk
On Feb 17, 2009, at 10:18 AM, Barak, Ron wrote: I have a wxPython application that builds an internal database from a list of files and then displays various aspects of that data, in response to user's requests. I want to add a module that finds events in a set of log files (LogManager).

Python-URL! - weekly Python news and links (Feb 17)

2009-02-17 Thread Gabriel Genellina
QOTW: The hardest part of design ...is keeping features out. - Donald Norman, design guru and former Apple exec https://www.technologyreview.com/business/18621/ Two short recipes: Determine whether a string is a number or not:

Re: Is there something easier than ORM?

2009-02-17 Thread Robert Kern
On 2009-02-17 10:52, andrew cooke wrote: Philip Semanchuk wrote: In short, I gather that others on this list are a lot more fond of SqlAlchemy and ORMs in general than I am. Granted, my experience is very limited. I tried to integrate SqlAlchemy in one project, struggled for a long time to

A python versioning scheme for modules, patches, softwares etc.

2009-02-17 Thread kretel
There exist a number of versioning schemes to keep track of software version. Each developer certainly have it's own style and preferred scheme. However, I am wonder if there is a specific versioning scheme for python modules. Regards, Krzysztof --

Re: Reading from text

2009-02-17 Thread JB
oamram a écrit : Hi All, new to python. i have a directory with about 50 text file and i need to iterate through them and get line 7 to 11 from each file and write those lines into another file(one file that will contain all lines). First create a function that read and parse one file Then

Re: printing bytes to stdout in Py3

2009-02-17 Thread Peter Billam
On 2009-02-17, Christian Heimes li...@cheimes.de wrote: Peter Billam schrieb: Greetings. (Newbie warning as usual) In Python3, sys.stdout is a io.TextIOWrapper object; but I want to output bytes (e.g. muscript -midi t t.mid ) and they're coming out stringified :-( How can I either change

Re: A python versioning scheme for modules, patches, softwares etc.

2009-02-17 Thread Robert Kern
On 2009-02-17 11:16, kretel wrote: There exist a number of versioning schemes to keep track of software version. Each developer certainly have it's own style and preferred scheme. However, I am wonder if there is a specific versioning scheme for python modules. A number of Python tools that

Re: printing bytes to stdout in Py3

2009-02-17 Thread Christian Heimes
Casey wrote: Is this really the 'official' way to do this? This isn't meant to be confrontational or trolling; I honestly don't know the answer and I had similar questions when I first started with the 3.0 release candidates and I have yet to find a good answer in the Python v3.0

Posting multiple files via a web site.

2009-02-17 Thread pdl5000
I would like to start write a Python script that upload multiple files to a web server. I research the methods, and I am somewhat confused between using the http urllib2 modules. I assume (and could be wrong) that the most basic method would be to use a cgi-Python script on the web server then

Re: Reading from text

2009-02-17 Thread bearophileHUGS
oamram: i have a directory with about 50 text file and i need to iterate through them and get line 7 to 11 from each file and write those lines into another file(one file that will contain all lines). Files can be iterated line-by-line, so this idiom: for line in file: ... will give you the

Re: Speedup Bitmap Parser

2009-02-17 Thread Jayson Santos
On 17 fev, 14:00, bearophileh...@lycos.com wrote: Jayson Santos: After changing my code to use only functions instead classes my code is too much faster. Here cProfile statistcs: Using old code : 633608 function calls in 1.361 CPU seconds Using new code: 475487 function calls in 0.800

Re: Threads vs. processes, what to consider in choosing ?

2009-02-17 Thread Christian Heimes
Philip Semanchuk wrote: The general rule is that it is a lot easier to share data between threads than between processes. The multiprocessing library makes the latter easier but is only part of the standard library in Python = 2.6. The design of your application matters a lot. For instance,

Re: Reading from text

2009-02-17 Thread MRAB
bearophileh...@lycos.com wrote: oamram: i have a directory with about 50 text file and i need to iterate through them and get line 7 to 11 from each file and write those lines into another file(one file that will contain all lines). Files can be iterated line-by-line, so this idiom: for line

Re: Reading from text

2009-02-17 Thread Grant Edwards
On 2009-02-17, oamram oam...@gmail.com wrote: i have a directory with about 50 text file and i need to iterate through them and get line 7 to 11 from each file and write those lines into another file(one file that will contain all lines). Assuming this is a real task and not a homework

Re: printing bytes to stdout in Py3

2009-02-17 Thread Casey
On Feb 17, 12:33 pm, Christian Heimes li...@cheimes.de wrote: Yes, it's really the official way. You can google up the discussion between me and Guido on the python-dev list if you don't trust me. ;) The docs concur with me, too. http://docs.python.org/3.0/library/sys.html#sys.stdin Note:

Re: printing bytes to stdout in Py3

2009-02-17 Thread Christian Heimes
Casey schrieb: On Feb 17, 12:33 pm, Christian Heimes li...@cheimes.de wrote: Yes, it's really the official way. You can google up the discussion between me and Guido on the python-dev list if you don't trust me. ;) The docs concur with me, too.

Re: printing bytes to stdout in Py3

2009-02-17 Thread Scott David Daniels
Casey wrote: ... Is this the 'official' way to do this?... Why wouldn't you just use: print(bytes.decode(b'abc\n'), end='') Because that code is incapable of sending bytes that cannot be interpreted as encoded in the default encoding. If you are sending a picture, for example, all possible

Re: Speedup Bitmap Parser

2009-02-17 Thread bearophileHUGS
Jayson Santos: And here is the final code:http://pastebin.com/f3e20d669 Note that if you use Psyco this lookup trick isn't useful, but if the Psyco isn't available it can improve performance a little: append = BitmapList['lines'].append I suggest to replace this code: red, green, blue

Re: Reading from text

2009-02-17 Thread Tim Chase
Assuming this is a real task and not a homework problem, then I'd do it this way: $ cd [directory containing 50 test files] $ (for file in *; do head -n11 $file | tail -n5; done) /path/to/results-file.txt I'd use sed: sed -ns 7,11p /source/path/*.txt /path/to/results.txt hard to get

RE: Kill a function while it's being executed

2009-02-17 Thread Noam Aigerman
Hi, Sorry for resurrecting an old thread, but it just bothers me that this is the best way that python has to deal with killing running functions... it's quite an ugly hack, no? Is it a feature that's needed bit missing from python, or is it left out on purpose (same way like java has deprecated

Re: Is there something easier than ORM?

2009-02-17 Thread Martin v. Löwis
So is there some libraries like that? I always use a DB-API implementation for the database I use, i.e. psycopg/psycopg2. Named tuples are really easy to provide: class NamedTuple: def __init__(self, names, values): for name, value in izip(names, values): setattr(self, name,

Re: A python versioning scheme for modules, patches, softwares etc.

2009-02-17 Thread kretel
On Feb 17, 5:31 pm, Robert Kern robert.k...@gmail.com wrote: On 2009-02-17 11:16, kretel wrote: There exist a number of versioning schemes to keep track of software version. Each developer certainly have it's own style and preferred scheme. However, I am wonder if there is a specific

  1   2   3   >