Re: Overlap in python
On 8/5/2009 10:56 AM, nn wrote: On Aug 5, 7:13 am, Marcus Wanner marc...@cox.net wrote: On 8/4/2009 6:09 PM, MRAB wrote: parts = [(5, 9, a), (7, 10, b), (3, 6, c), (15, 20, d), (18, 23, e)] parts.sort() parts [(3, 6, 'c'), (5, 9, 'a'), (7, 10, 'b'), (15, 20, 'd'), (18, 23, 'e')] # Merge overlapping intervals. pos = 1 while pos len(parts): # Merge the pair in parts[pos - 1 : pos + 1] if they overlap. p, q = parts[pos - 1 : pos + 1] if p[1] = q[0]: parts[pos - 1 : pos + 1] = [(p[0], max(p[1], q[1]), p[2] + . + q[2])] else: # They don't overlap, so try the next pair. pos += 1 parts [(3, 10, 'c.a.b'), (15, 23, 'd.e')] That's the best solution I've seen so far. It even has input/output formatted as close as is reasonably possible to the format specified. As we would say in googlecode, +1. Marcus How does it compare to this one? http://groups.google.com/group/comp.lang.python/browse_frm/thread/1a1d2ed9d05d11d0/56684b795fc527cc#56684b795fc527cc That is a different problem, and the solution is more complex. I am not going to try to judge which is better. Marcus -- print ''.join([chr(((ord(z)+(ord(I'M/THE[3])+sum( [ord(x)for x in 'CRYPTOR'])))%(4*ord('8')+ord( ' ' for z in ''.join(([(('\xca\x10\x03\t'+ '\x01\xff\xe6\xbe\x0c\r\x06\x12\x17\xee\xbe'+ '\x10\x03\x06\x12\r\x0c\xdf\xbe\x12\x11\x13'+ '\xe8')[13*2-y]) for y in range(int(6.5*4)+1)] ))]) -- http://mail.python.org/mailman/listinfo/python-list
Re: Using Python to automate builds
On 8/4/2009 5:52 PM, Philip Semanchuk wrote: On Aug 4, 2009, at 5:40 PM, Kosta wrote: On Aug 4, 2:34 pm, Dave Angel da...@ieee.org wrote: + I have released pyKook 0.0.2. +http://pypi.python.org/pypi/Kook/0.0.2 +http://www.kuwata-lab.com/kook/ +http://www.kuwata-lab.com/kook/pykook-users-guide.html Other possibilities: + http://pypi.python.org/pypi/vellum/ flexible small 'make' alternative + http://code.google.com/p/waf/ + http://code.google.com/p/fabricate/ DaveA- Hide quoted text - - Show quoted text - Thanks Dave. I had thought about those three options, and was honestly hoping for a foruth (I know, some people are never satisfied ;). I'll look into pyKook. Thank you for your help. Poof! Your wish is granted! =) http://www.scons.org/ Dunno if you'll find it better, worse or different than the alternatives, but there it is. have fun P I can highly recommend scons. At dolphin-emu, we use it to daily compile a project containing over 500,000 lines of c/c++ code, which is modified very frequently. It works like a charm, and is seamlessly cross- platform (in my experience). However, it might not be exactly the thing you're looking for. Marcus -- http://mail.python.org/mailman/listinfo/python-list
Re: Overlap in python
On 8/4/2009 6:09 PM, MRAB wrote: parts = [(5, 9, a), (7, 10, b), (3, 6, c), (15, 20, d), (18, 23, e)] parts.sort() parts [(3, 6, 'c'), (5, 9, 'a'), (7, 10, 'b'), (15, 20, 'd'), (18, 23, 'e')] # Merge overlapping intervals. pos = 1 while pos len(parts): # Merge the pair in parts[pos - 1 : pos + 1] if they overlap. p, q = parts[pos - 1 : pos + 1] if p[1] = q[0]: parts[pos - 1 : pos + 1] = [(p[0], max(p[1], q[1]), p[2] + . + q[2])] else: # They don't overlap, so try the next pair. pos += 1 parts [(3, 10, 'c.a.b'), (15, 23, 'd.e')] That's the best solution I've seen so far. It even has input/output formatted as close as is reasonably possible to the format specified. As we would say in googlecode, +1. Marcus -- http://mail.python.org/mailman/listinfo/python-list
Re: Overlap in python
On Aug 4, 2:15 pm, Jay Bird jay.bird0...@gmail.com wrote: Hi everyone, I've been trying to figure out a simple algorithm on how to combine a list of parts that have 1D locations that overlap into a non- overlapping list. For example, here would be my input: part name location a 5-9 b 7-10 c 3-6 d 15-20 e 18-23 And here is what I need for an output: part name location c.a.b 3-10 d.e 15-23 I've tried various methods, which all fail. Does anyone have an idea how to do this? Thank you very much! Jay Just take all the values, put them in a list, and use min() and max(). For example: import string def makelist(values): values = string.replace(values, ' ', '') listofvaluepairs = string.split(values, ',') listofvalues = [] for pair in listofvaluepairs: twovalues = string.split(pair, '-') listofvalues.append(int(twovalues[0])) listofvalues.append(int(twovalues[1])) return listofvalues values = '5-9, 7-10, 3-6' values = makelist(values) print('Values: %d-%d' %(min(values), max(values)) ) Marcus -- http://mail.python.org/mailman/listinfo/python-list
Re: Overlap in python
On 8/4/2009 2:46 PM, Ann wrote: On Aug 4, 11:31 am, Marcus Wanner marc...@cox.net wrote: On Aug 4, 2:15 pm, Jay Bird jay.bird0...@gmail.com wrote: Hi everyone, I've been trying to figure out a simple algorithm on how to combine a list of parts that have 1D locations that overlap into a non- overlapping list. For example, here would be my input: part name location a 5-9 b 7-10 c 3-6 d 15-20 e 18-23 And here is what I need for an output: part name location c.a.b3-10 d.e 15-23 I've tried various methods, which all fail. Does anyone have an idea how to do this? Thank you very much! Jay Just take all the values, put them in a list, and use min() and max(). For example: import string def makelist(values): values = string.replace(values, ' ', '') listofvaluepairs = string.split(values, ',') listofvalues = [] for pair in listofvaluepairs: twovalues = string.split(pair, '-') listofvalues.append(int(twovalues[0])) listofvalues.append(int(twovalues[1])) return listofvalues values = '5-9, 7-10, 3-6' values = makelist(values) print('Values: %d-%d' %(min(values), max(values)) ) Marcus Thank you for your help, this is a very nice program but it does not address the issue that I have values that do not overlap, for example 'c' and 'd' do not overlap in the above example and thus I would not want to output 3-20 but the individual positions instead. In addition, my inputs are not ordered from smallest to largest, thus I could have a situation where a=5-9, b=15-20, c=7-10, etc., and I would still want an output of: a.c = 5-10, b=15-20. I apologize for the complication. Thank you again! Jay That would be a bit more complicated...you might try using tuples of values in a list, or writing your own class for the data handling. Unfortunately that's not something I can just sit down and code in 5 minutes, it would take some careful thought and planning. Marcus -- http://mail.python.org/mailman/listinfo/python-list
Re: Is it possible to have the python color in the terminal ?
On 8/4/2009 2:53 PM, aurelien wrote: Hello, I am under gNewSense, i am a newbbie on Python, i look for how change the color terminal when python run. at the step all is in black and white. Is it possible to have the python color in the terminal ? Thanks for your help. aurelien You might try posting to this thread: http://groups.google.com/group/comp.lang.python/browse_thread/thread/58df7b77394e4666/f4c13766a1e09380 I don't know much about the question myself, though. Marcus -- http://mail.python.org/mailman/listinfo/python-list
Re: Is python buffer overflow proof?
On 8/3/2009 3:45 AM, Diez B. Roggisch wrote: Marcus Wanner schrieb: On 8/2/2009 10:43 AM, Christian Heimes wrote: Marcus Wanner wrote: I believe that python is buffer overflow proof. In fact, I think that even ctypes is overflow proof... No, ctypes isn't buffer overflow proof. ctypes can break and crash a Python interpreter easily. Christian I see. I thought that it said invalid array index when you try to read/write outside of an array's bounds, though... But you can cast the resulting pointer to an array of larger size, and there you are. Diez Ah, that makes sense. I had forgotten about ctypes.cast(). Marcus -- http://mail.python.org/mailman/listinfo/python-list
Re: Help understanding the decisions *behind* python?
On 8/1/2009 9:31 PM, sturlamolden wrote: - Python and C programmers use lists and arrays similarly. I'm guessing that's because of the brackets... Marcus -- http://mail.python.org/mailman/listinfo/python-list
Re: Is python buffer overflow proof?
On 8/2/2009 9:50 AM, Jizzai wrote: Is a _pure_ python program buffer overflow proof? For example in C++ you can declare a char[9] to hold user input. If the user inputs 10+ chars a buffer overflow occurs. In python, I cannot seem to find a way to define/restrict a string length. This is probably by design and raises the topic in question. Am curious to see the opinions of people who know. TIA. I believe that python is buffer overflow proof. In fact, I think that even ctypes is overflow proof... Marcus -- http://mail.python.org/mailman/listinfo/python-list
Re: Seeding the rand() Generator
On 8/2/2009 9:42 AM, Fred Atkinson wrote: How does one seed the rand() generator when retrieving random recordings in MySQL? Regards, Fred something like: import random, time random.seed(time.time()) #not actual record access code: sqlite3.recordaccessfuction(recordid = random.rand()) Marcus -- http://mail.python.org/mailman/listinfo/python-list
Re: Is python buffer overflow proof?
On 8/2/2009 10:43 AM, Christian Heimes wrote: Marcus Wanner wrote: I believe that python is buffer overflow proof. In fact, I think that even ctypes is overflow proof... No, ctypes isn't buffer overflow proof. ctypes can break and crash a Python interpreter easily. Christian I see. I thought that it said invalid array index when you try to read/write outside of an array's bounds, though... Marcus -- http://mail.python.org/mailman/listinfo/python-list
Re: How to read webpage
On 8/1/2009 11:31 AM, Jon Clements wrote: On 1 Aug, 14:52, MRAB pyt...@mrabarnett.plus.com wrote: tarun wrote: Dear All, I want to read a webpage and copy the contents of it in word file. I tried to write following code: import urllib2 urllib2.urlopen(http://www.rediff.com/;) *Error:-* urllib2.urlopen(http://www.icicibank.com/;) File C:\Python25\lib\urllib2.py, line 121, in urlopen return _opener.open(url, data) File C:\Python25\lib\urllib2.py, line 374, in open response = self._open(req, data) File C:\Python25\lib\urllib2.py, line 392, in _open '_open', req) File C:\Python25\lib\urllib2.py, line 353, in _call_chain result = func(*args) File C:\Python25\lib\urllib2.py, line 1100, in http_open return self.do_open(httplib.HTTPConnection, req) File C:\Python25\lib\urllib2.py, line 1075, in do_open raise URLError(err) urllib2.URLError: urlopen error (11001, 'getaddrinfo failed') I've just tried it. I didn't get an exception, so your problem must be elsewhere. I'm hoping this adds to MRAB's reply; it is intended however for the OP. Jeeze -- been a while since I've had to deal with Sockets (directly anyway). If memory serves correctly, it's where the system can't name resolve the required address. So best guess is it's either a temporary glitch, or an issue with your routing. Jon. Jon. 'getaddrinfo failed' means that the nameserver can't be found, or that it has no records of that address (I'm 90% sure of that). Marcus -- http://mail.python.org/mailman/listinfo/python-list
Re: threads check socket
On 7/31/2009 12:35 PM, NighterNet wrote: I been trying to find a way to check the socket is open or not. The thread are in a group and loop if the sockets are open. If they are not open delete the thread and remove the group. I need on this. Being a bit more specific would help. Are you using tcp or udp? Is it a local socket or a remote one? What is controlling the socket? Define open. Marcus -- http://mail.python.org/mailman/listinfo/python-list
Re: Regexp problem
On 7/30/2009 9:32 AM, Beldar wrote: On 30 jul, 15:07, MRAB pyt...@mrabarnett.plus.com wrote: Beldar wrote: Hi there! I have a problem and i'm not very good at regular expressions. I have a text like lalala lalala tiruri beldar-is-listening tiruri lalala I need a regexp to get the 'beldar' part, the format is 'something-is-listening', i need to get the something part, use it in my code, and then replace the whole 'something-is-listening' for another string. \w+ will match a word and enclosing it in (...) will capture what was matched: m = re.search(r(\w+)-is-listening, text) print Captured '%s' % m.group(1) print Matched from %d to %d % (m.start(), m.end()) Ok, thank you all, it was very helpful! Wow, I really need to learn more about regexp... Any tutorials you guys can recommend? Marcus -- http://mail.python.org/mailman/listinfo/python-list
Re: fast video encoding
On 7/29/2009 4:14 AM, gregorth wrote: Hi all, for a scientific application I need to save a video stream to disc for further post processing. My cam can deliver 8bit grayscale images with resolution 640x480 with a framerate up to 100Hz, this is a data rate of 30MB/s. Writing the data uncompressed to disc hits the data transfer limits of my current system and creates huge files. Therefore I would like to use video compression, preferably fast and high quality to lossless encoding. Final file size is not that important. Try googling realtime greyscale video codec... Because of the hardware I am bound to WinXP. There's always a way to run linux :p I already tried pymedia for encoding to mpeg2, however I only managed to get a framerate of about 30-40fps (on a 1.8GHz dual core). There is still room for improvements in my code, but before trying hard I want to ask for advices or other possibilities. I also found gstreamer with pygst python bindings, which seems to be more modern (and performant?) package than pymedia. I did not yet try it, especially since I didn't find a simple code example of how to use it for my use case. Can somebody give me a hint? Video encoding is not my specialty, but my recommendation here is to drop python because of its slow speed and work in c as much as possible. I also found huffyuv or lagarith which is provided as a directshow codec for Windows. Can somebody give me a hint how to use a directshow codec with python? Not me, sorry :( Never worked directly with directshow (no pun intended). I am a novice with video encoding. I found that few codecs support gray scale images. Any hints to take advantage of the fact that I only have gray scale images? Greyscale PNG or BMP compression. Thanks for any help Don't know if this counts as help, but you're welcome! Gregor Marcus -- http://mail.python.org/mailman/listinfo/python-list
Re: simple splash screen?
On 7/28/2009 11:58 PM, NighterNet wrote: I am trying to make a simple splash screen from python 3.1.Not sure where to start looking for it. Can any one help? Trying to make a splash screen for python? Or trying to do image processing in python? Marcus -- http://mail.python.org/mailman/listinfo/python-list
Re: about analyze object's stack usage
On 7/29/2009 3:51 AM, hch wrote: Is there a python script can get a list of how much stack space each function in your program uses? I don't think so. You could try raw reading of the memory from another thread using ctypes and pointers, but that would be madness. ( the program is compiled by gcc) If you're talking about a c program, almost certainly not. What you should do is just use gdb and disas each function and look at what it subtracts off of %esp at the third instruction in the function. I can explain it to you if you are not very experienced in gdb and assembly... Marcus -- http://mail.python.org/mailman/listinfo/python-list
Re: Does python have the capability for driver development ?
On 7/29/2009 7:44 PM, Martin P. Hellwig wrote: Rodrigo S Wanderley wrote: cut What about user level device drivers? Think the Python VM could communicate with the driver through the user space API. Is there a Python module for that? Sure why not? Look for example to libusb, which provides a userspace environment and pyusb which uses that and provides an interface to Python. iicr pyusb uses a c interface to libusb, not python... Marcus -- http://mail.python.org/mailman/listinfo/python-list
Re: len() should always return something
On 7/25/2009 5:34 AM, Hendrik van Rooyen wrote: On Friday 24 July 2009 22:09:15 Marcus Wanner wrote: First one to correctly decompress the value 0 into an ASCII character wins the title of the world's most capable hacker :p that is easy. the xor of 0 and 1 is 1, which is ASCII soh, if I remember right. soh is start of header. Burroughs poll select, anyone? - Hendrik nope, not soh. Marcus -- http://mail.python.org/mailman/listinfo/python-list
Re: len() should always return something
On 7/25/2009 10:08 AM, Piet van Oostrum wrote: Steven D'Aprano st...@remove-this-cybersource.com.au (SD) wrote: SD Ambiguity essentially boils down to being unable to reasonably predict SD the expectation of the coder. I say reasonably, because if you allow SD unreasonable situations, everything is ambiguous: That's for me the reason that len(42) is ambiguous. The OP apparently had 1 as expectation, whereas my first thought was the minimal number of bits to represent the number and 7.5 million came later :=). The number of bits I certainly find reasonable, and I would find the number of decimal digits equally reasonable. More so than 1, actually. 1 as the length of an int doesn't give any information. Well, for my two cents, I will say that the number of binary bits or decimal digits is certainly the most sensible return value, and that the former is the most useful, because the latter can be got with len(str(42)). However, the former can also be (/slightly/ less)easily got with len(bin(42))-2... I also think that Explicit is better than implicit. says that there should be no return value in this case, as any return value would be implicit. Marcus -- http://mail.python.org/mailman/listinfo/python-list
Re: any suggestions to synchronize typed text and speech ?
On 7/21/2009 12:13 PM, Stef Mientki wrote: hi Marcus, That sounds like a very specialized type of thing, Well from an application point of view, with the current netbooks, this looks like a perfect tool for any conversation or meeting. which only the few people with experience with wxPython, PyAudio, and Scintilla could help you with... I was afraid of that too, so I dropped the question in several places, and the writer of Scintilla himself came with the perfect answer. cheers,Stef But you might try having a dictionary with notes and associated times, or just give each note a four-digit ID number at the beginning of it when it's entered and use that in the dictionary (to keep keys shorter). Or you could just do a little hack and increase the number of bookmarks allowed (seeing as source is available) :p Marcus Glad you got a good answer from somebody. Sounds like an interesting project. About when would this be headed for a release? Could you post a link to a googlecode or sourceforge project or something so I can follow and/or help with development? For the moment it's just an idea, so no line of code yet. I first like to tackle all the problems, at least to the level I think I can handle them. So first solve the next problem, before I start coding: automatic synchronization (file uploading and deleting) between EEE-pc and desktop PC over bluetooth. And another problem, as my customers are physicians, both the text and audio need to be stored encrypted. cheers, Stef Marcus I would recommend pybluez and http://www.google.com/search?q=python+aes+encryption Marcus -- http://mail.python.org/mailman/listinfo/python-list
Re: len() should always return something
On 7/24/2009 3:04 PM, Roy Smith wrote: In article 0279f596$0$5185$c3e8...@news.astraweb.com, Steven D'Aprano st...@remove-this-cybersource.com.au wrote: On Fri, 24 Jul 2009 16:50:03 +0200, superpollo wrote: Nah. 7 contains three bits, so len(7) should *clearly* return 3. and len(7) must return 8, by the same token... but wait! len(7) 1 my python installation must me outdated ;-) No no no, you're obviously using an awesome version of Python that can compress single-character strings to a single bit! Compressing strings to a single bit is easy. It's the uncompressing that's tricky. I assume you mean ord(7)%2? First one to correctly decompress the value 0 into an ASCII character wins the title of the world's most capable hacker :p Marcus -- http://mail.python.org/mailman/listinfo/python-list
Re: len() should always return something
On 7/24/2009 4:18 PM, Mark Lawrence wrote: Marcus Wanner wrote: On 7/24/2009 3:04 PM, Roy Smith wrote: In article 0279f596$0$5185$c3e8...@news.astraweb.com, Steven D'Aprano st...@remove-this-cybersource.com.au wrote: On Fri, 24 Jul 2009 16:50:03 +0200, superpollo wrote: Nah. 7 contains three bits, so len(7) should *clearly* return 3. and len(7) must return 8, by the same token... but wait! len(7) 1 my python installation must me outdated ;-) No no no, you're obviously using an awesome version of Python that can compress single-character strings to a single bit! Compressing strings to a single bit is easy. It's the uncompressing that's tricky. I assume you mean ord(7)%2? First one to correctly decompress the value 0 into an ASCII character wins the title of the world's most capable hacker :p Marcus asciichar = chr(len(0)) if the OP's wishes come true? Nope, wasn't ?... Marcus -- http://mail.python.org/mailman/listinfo/python-list
Re: If Scheme is so good why MIT drops it?
On 7/20/2009 2:13 AM, Paul Rubin wrote: Steven D'Aprano ste...@remove.this.cybersource.com.au writes: Besides, one can legitimately disagree that 2/3 = 0 is the wrong thing to do. It's the right thing to do if you're doing integer maths. I wonder whether 2/3 = ValueError is preferable. Not for me :( -- http://mail.python.org/mailman/listinfo/python-list
Re: any suggestions to synchronize typed text and speech ?
On 7/20/2009 5:34 AM, Stef Mientki wrote: thanks Marcus, Marcus Wanner wrote: On 7/19/2009 4:15 PM, Stef Mientki wrote: hello, I'm using Scintilla as a wxPython widget with great pleasure. I now have an application where I want to make notes during a conversation, but also want to record the speech during that conversation. I'm using Scintilla as a wxPython widget for editing and PyAudio for the speech recording, until so far everything works fine. Here the problem part: I need to synchronize the typed text with the sound during playback. So if I click somewhere in the sound recording, the line of text, typed that moment should be highlighted. And vise versa, if the cursor in the text is moved and some special key is pressed, the sound starting 10 or 20seconds earlier should be playbacked. I though of adding bookmarks (because these are fixed in the text), and keep a list of bookmarks and sound pointers. This idea should work, but there are only 31 bookmarks. Any other suggestions ? thanks, Stef Mientki That sounds like a very specialized type of thing, Well from an application point of view, with the current netbooks, this looks like a perfect tool for any conversation or meeting. which only the few people with experience with wxPython, PyAudio, and Scintilla could help you with... I was afraid of that too, so I dropped the question in several places, and the writer of Scintilla himself came with the perfect answer. cheers,Stef But you might try having a dictionary with notes and associated times, or just give each note a four-digit ID number at the beginning of it when it's entered and use that in the dictionary (to keep keys shorter). Or you could just do a little hack and increase the number of bookmarks allowed (seeing as source is available) :p Marcus Glad you got a good answer from somebody. Sounds like an interesting project. About when would this be headed for a release? Could you post a link to a googlecode or sourceforge project or something so I can follow and/or help with development? Marcus -- http://mail.python.org/mailman/listinfo/python-list
Re: Design question.
On 7/20/2009 9:42 AM, Lacrima wrote: On Jul 20, 4:05 pm, Jean-Michel Pichavant jeanmic...@sequans.com wrote: Lacrima wrote: Hello! I am newbie in python and I have really simple question, but I need your advice to know how to do best. I need to store a number of dictionaries in certain place. I've decided to store them in a separate module. Like this: dicts.py --- dict1 = {} dict2 = {} dict3 = {} Then, when I need any dictionary, I can access it: import dicts dicts.dict1 Is it a good practice? Or should I store them as class attributes or anything else? Thanks in advance. With regards, Max (sorry if my English isn't very proper) Defining dict as a module attribute ic correct, but try to answer the following question: Is dict1 an attribute/property/declension of the object/entity defined by the module dicts ? If yes, then your design is correct. An correct example: fruits.py apple = {} banana = {} An incorrect one: fruit.py --- apple={} bicycle={} Basically, the rule is very straightforward, set your dict as a module attribute only if its one of its attribute (very nice paraphrase !) Most of people (including me) tend to have a module, where they put everything they have no idea about their location. This is a bad habit and result from a uncontrolled/undocumented design. Usually documenting objects in such modules is really painful. Your proposal is fine from a python syntax point of view. I can't tell of your design with names like (dicts.py and dict1,dict2) hoping you do not intend to name them that way. JM Hi, Jean-Michel! Thanks for your answer. I am not going to have names like dicts.py and dict1,dict2. That was just example. I wanted to know if it is correct to have dictionaries on a module level. Now I know that this is correct. I want to collect in one module a number of dictionaries, every of which describes a separate web service. And my function in another module will import required dictionary, depending on what web service should be used. Thanks again for the help. With regards, Max. (sorry if my English isn't very proper) Yeah, you can put just about anything in a separate module/file, but putting unrelated things in the same module is bad... For example, if you have apple and banana in a module, and had a function called slicefruit() to do something to those variables in there with them, then that would be good. But if you put bicycle and car and adjustbrakes() in the module with the fruits, or mixed the two groups in several modules, that would be bad. Marcus -- http://mail.python.org/mailman/listinfo/python-list
Re: Help understanding the decisions *behind* python?
On 7/20/2009 3:26 PM, Phillip B Oldham wrote: On Jul 20, 6:08 pm, Duncan Booth duncan.bo...@invalid.invalid wrote: The main reason why you need both lists and tuples is that because a tuple of immutable objects is itself immutable you can use it as a dictionary key. Really? That sounds interesting, although I can't think of any real- world cases where you'd use something like that. Actually, that would be very useful in the program from any suggestions to synchronize typed text and speech ?...i.e. have a dictionary key of (hour, minute, second). Marcus -- http://mail.python.org/mailman/listinfo/python-list
Re: any suggestions to synchronize typed text and speech ?
On 7/19/2009 4:15 PM, Stef Mientki wrote: hello, I'm using Scintilla as a wxPython widget with great pleasure. I now have an application where I want to make notes during a conversation, but also want to record the speech during that conversation. I'm using Scintilla as a wxPython widget for editing and PyAudio for the speech recording, until so far everything works fine. Here the problem part: I need to synchronize the typed text with the sound during playback. So if I click somewhere in the sound recording, the line of text, typed that moment should be highlighted. And vise versa, if the cursor in the text is moved and some special key is pressed, the sound starting 10 or 20seconds earlier should be playbacked. I though of adding bookmarks (because these are fixed in the text), and keep a list of bookmarks and sound pointers. This idea should work, but there are only 31 bookmarks. Any other suggestions ? thanks, Stef Mientki That sounds like a very specialized type of thing, which only the few people with experience with wxPython, PyAudio, and Scintilla could help you with... But you might try having a dictionary with notes and associated times, or just give each note a four-digit ID number at the beginning of it when it's entered and use that in the dictionary (to keep keys shorter). Or you could just do a little hack and increase the number of bookmarks allowed (seeing as source is available) :p Marcus -- http://mail.python.org/mailman/listinfo/python-list
Re: Python graphics / imaging library
On 7/18/2009 11:41 AM, Peter Chant wrote: Max Erickson wrote: More recent months contain updates to the status of 1.1.7, it is headed towards a release. Preliminary tarballs and binaries are available on effbot.org: http://effbot.org/downloads/#imaging http://effbot.org/downloads/#pil Excellent. From a very brief look it seems like it will be quite simple to use. Pete Yes, it was fun to work with (for me at least). Marcus -- http://mail.python.org/mailman/listinfo/python-list
Re: Rus Python script interactively
On 7/18/2009 12:32 PM, Gnarlodious wrote: In an interactive session (I am using iPython), what is the most elegant way to run a Python script from Terminal? Right now I am saying: import subprocess subprocess.call(python /path/to/scriptname.py, shell=True) But I am calling a shell process and I'd rather not. The script just runs, no inputs are needed. Is there a more Pythonesque method? -- Gnarlie http://Gnarlodious.com/ You could put the code of the script in a main() function and have an if __name__ == '__main__': around the internal call. That way, it will still run the code if you run it normally, and you can also run it several times from the interactive session, ie: file you want to run: {{{ def somefunction(): print 'hello world' somefunction() }}} file after modifications: {{{ def somefunction(): print 'hello world' def main(): somefunction() if __name__ == '__main__': #only true if the file is being run normally, not imported. main() }}} Both of those, if run normally, will print hello world. If the first one is imported, it will run once and not me runnable in that session again. If the second one is imported, it will not do anything until you call the main() function, and then you can call it again as many times as you want: {{{ import thefile for i in range(5): ... thefile.main() ... hello world hello world hello world hello world hello world exit() }}} Hope this helps you! Marcus -- http://mail.python.org/mailman/listinfo/python-list