Re: [Tutor] subprocess Popen

2009-04-03 Thread Tiago Saboga
On Fri, Apr 03, 2009 at 03:12:08PM -0700, Weidner, Ronald wrote: > I have a long running py script that I'm trying to kick off from > another long running py script as a separate process... If either > script fails or terminates, I don't want the other script to be > effected as a result. In other

[Tutor] re module / separator

2009-06-24 Thread Tiago Saboga
?)+", text) Out[36]: ['a2345b. ', 'a435643b. '] What's the difference between search and findall in [33-34]? And why I cannot generalize [33] to [35]? Out[35] would make sense to me if I had put a non-greedy +, but why do re gets only one word? Thanks, Tiago Saboga. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] re module / separator

2009-06-24 Thread Tiago Saboga
Serdar Tumgoren writes: > Hey Tiago, > >> text = "a2345b. f325. a45453b. a325643b. a435643b. g234324b." >> >> Of this line of text, I want to take out strings where all words start >> with a, end with "b.". But I don't want a list of words. I want that: >> >> ["a2345b.", "a45453b. a325643b. a4356

Re: [Tutor] re module / separator

2009-06-25 Thread Tiago Saboga
Thanks Kent! Once more you go straight to the point! Kent Johnson writes: > On Wed, Jun 24, 2009 at 2:24 PM, Tiago Saboga wrote: >> In [33]: re.search("(a[^.]*?b\.\s?){2}", text).group(0) >> Out[33]: 'a45453b. a325643b. ' > > group(0) is the entire match

Re: [Tutor] updating Unix config file

2009-10-20 Thread Tiago Saboga
andler = subprocess.Popen(['cat'], stdout=subprocess.PIPE, stdin=subprocess.PIPE) Or you can import just the names you will use in the global namespace: from subprocess import Popen, PIPE handler = Popen(['cat'], stdout=PIPE, stdin=PIPE) HTH, Tiago Saboga. __

Re: [Tutor] detecing palindromic strings

2007-09-28 Thread Tiago Saboga
On Fri, Sep 28, 2007 at 04:59:26PM -0700, Christopher Spears wrote: > How do I get around this? Is there a better way to > write this script? I can't figure out how to loop > through a string starting from the last character. A string is a sequence of chars, and you can use slices with it [1].

Re: [Tutor] linux terminal coloring in python

2007-09-29 Thread Tiago Saboga
On Sat, Sep 29, 2007 at 08:32:37AM -0700, Robert Jackson wrote: > I'm trying to get some pretty colored output for a Linux console / terminal window. Google searches only reveal the curses module to colorize output. > Is there a simpler way? Curses seems to be FAR too powerful for what it is I

Re: [Tutor] using python to execute from Dir A in Dir B

2007-10-04 Thread Tiago Saboga
On Thu, Oct 04, 2007 at 03:15:41PM -0400, Andre Walker-Loud wrote: > what I need to do is have my python script run another executable, > but it must do it from a directory different from the one I am in, it > needs to run in the /scratch/ directory (again not my choice) > > Is this possible,

[Tutor] PyQt segfault

2007-11-30 Thread Tiago Saboga
Hi! I am making a front-end to ffmpeg with pyqt and I am stuck in a segmentation fault I can't understand. I have written a little dialogbox just to show the problem. I have already found a workaround, commented out in the code, but I would like to know where is the problem. I am sending the pyui

Re: [Tutor] PyQt segfault

2007-11-30 Thread Tiago Saboga
07 at 01:13:39PM -, Alan Gauld wrote: > "Tiago Saboga" <[EMAIL PROTECTED]> wrote > > I am making a front-end to ffmpeg with pyqt and I am stuck in a > > segmentation fault I can't understand. I have written a little > > > def main(args): > >

Re: [Tutor] lstrip removes '/' unexpectedly

2007-11-30 Thread Tiago Saboga
Read this: In [50]: print str.lstrip.__doc__ S.lstrip([chars]) -> string or unicode Return a copy of the string S with leading whitespace removed. If chars is given and not None, remove characters in chars instead. If chars is unicode, S will be converted to unicode before stripping --- The

Re: [Tutor] PyQt segfault

2007-12-01 Thread Tiago Saboga
On Sat, Dec 01, 2007 at 01:04:04AM +0100, David Boddie wrote: > Something like that, yes. The internal character data becomes invalid, but > there's still a reference to the QString object. > > Here's the original code posted by Tiago: > > > class Combobox(QtGui.QDialog): > > def __init__(sel

Re: [Tutor] Questions about wxEvents

2007-12-06 Thread Tiago Saboga
On Thu, Dec 06, 2007 at 09:12:59AM -0800, Marc Tompkins wrote: > I have a specific question - how can I generalize a > FileBrowseButtonWithHistory - and I realized, as I was trying to word my > question, that my real question is a bit more generic. > > First, the specific question: The FileBrowse

[Tutor] thread and os.pipe (was: logic for a tree like structure)

2007-12-08 Thread Tiago Saboga
I started a message, changed my mind, wrote about some other thing and forgot to change the subject. Sorry for the noise. Tiago. On Sat, Dec 08, 2007 at 07:25:16AM -0200, Tiago Saboga wrote: > Hi, > > I need an additional thread in my app, and I am trying to understand > how it

[Tutor] logic for a tree like structure

2007-12-08 Thread Tiago Saboga
by a os.pipe, but it seems like I can only read the pipe when everything was done. I was hoping to see the output of writer.py come out in real time, but it is coming out all together when writer.py returns. Why? Thanks, Tiago Saboga. =writer.py=== #!/usr/bin/python2.5 import tim

Re: [Tutor] thread and os.pipe

2007-12-08 Thread Tiago Saboga
On Sat, Dec 08, 2007 at 11:54:07AM -, Alan Gauld wrote: > "Tiago Saboga" <[EMAIL PROTECTED]> wrote > > > what's happening in this simple example. I want to establish a > > connection between my two threads by a os.pipe, > > While its possible

Re: [Tutor] logic for a tree like structure

2007-12-09 Thread Tiago Saboga
On Sat, Dec 08, 2007 at 04:13:19PM -0800, Jeff Younker wrote: > Pipes and IO channels are buffered. The buffers are much larger than > the amount of information you are writing to them, so they're never getting > flushed while the program is running. The child program completes, the > IO channe

Re: [Tutor] thread and os.pipe

2007-12-13 Thread Tiago Saboga
On Sun, Dec 09, 2007 at 12:25:59AM -, Alan Gauld wrote: > > updated to show the output from the commands. What I want to do > > is make the doit() method of the Converter class return a pipe, > > through which it will then send the output of the programs. > > I'm still not convinced that a pip

[Tutor] ipython / readline problem

2007-12-13 Thread Tiago Saboga
Hi, I am facing what seems like a bug, and the docs are not enough to tell me where the bug lies. In ipython, I can't type a multiline unicode string. The bug is reported here [1], and the output is like that (except that the commented out lines are modifications I have done): ===

Re: [Tutor] ipython / readline problem

2007-12-13 Thread Tiago Saboga
On Thu, Dec 13, 2007 at 07:41:08AM -0500, Kent Johnson wrote: > Tiago Saboga wrote: >> : 'ascii' codec can't encode >> character u'\xe7' in position 2: ordinal not in range(128) >> >> === >> >>

Re: [Tutor] Learning about callbaks

2007-12-30 Thread Tiago Saboga
On Sun, Dec 30, 2007 at 09:17:42AM -, Alan Gauld wrote: > Yes, the Python tutor list is one of the best features of Python. This expresses exactly the way I feel about python. Everytime I have to work in another language, I keep asking myself: but where is the tutor mailing list for this langu

Re: [Tutor] Choice of GUI builders

2008-01-03 Thread Tiago Saboga
It's why I finally started using Qt. In fact I do not really like WYSIWYG designers - I always remember html produced by Dreamweaver and co. - but qtdesigner + pyuic (see pyqt) always gave me readable code. Tiago Saboga. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] designing POOP

2008-02-05 Thread Tiago Saboga
aviour. Could you please elaborate on this last sentence? I don't understand what you mean, and I feel I may be on this track. Thanks, Tiago Saboga. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] designing POOP

2008-02-06 Thread Tiago Saboga
On Wed, Feb 06, 2008 at 08:58:09AM -, Alan Gauld wrote: > Thus always base inheriotance on common mbehaviour not on > common data. > > I hope that makes it clearer. Thanks Alan, it's clear now. And now I know that this is not one of the mistakes I am making

Re: [Tutor] if ... else shorthand form ?

2008-02-09 Thread Tiago Saboga
On Sat, Feb 09, 2008 at 09:21:41AM +, dave selby wrote: > Hi all, > > Returning to python after a brief affair with C++, I have the following code > ... > > if (items.has_keys('snapshot_interval')): > self.snap_init[i] = items['snapshot_interval'] >

Re: [Tutor] problems with the shebang line and linux

2006-02-16 Thread Tiago Saboga
ck which package it is, if you want): $ fromdos -b testerlybar.py Of course, reading the manual page for fromdos is a good thing. tiago saboga. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] unable to insert data into database

2006-02-18 Thread Tiago Saboga
avior observed by Servando: if you create different sorts of tables on windows, mac and linux, you'll have different behaviors... I hope you'll understand my poor english... Tiago Saboga. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] MySQLdb: at a complete loss

2006-02-18 Thread Tiago Saboga
Em Sáb 18 Fev 2006 17:51, Danny Yoo escreveu: > > db=MySQLdb.connect(host='localhost',user='root',passwd='081300',db='tut') > > cursor=db.cursor() > > name = raw_input("Please enter a Name: ") > > color =raw_input("Please enter a Color: ") > > cursor.execute("""INSERT INTO horses(na

[Tutor] mysql store directory information

2006-04-06 Thread Tiago Saboga
Hi! As a first part of a project, I need to store a directory tree in a mysql db. I'm wondering if there is a canonical way of doing that. I don't know if it's an appropriate question for this list, but I think it's not only a choice of db design, but also a choice of appropriate python tools.

Re: [Tutor] mysql store directory information

2006-04-06 Thread Tiago Saboga
Em Qui 06 Abr 2006 15:41, Danny Yoo escreveu: > On Thu, 6 Apr 2006, Tiago Saboga wrote: > > As a first part of a project, I need to store a directory tree in a > > mysql db. I'm wondering if there is a canonical way of doing that. I > > don't know if it's a

Re: [Tutor] mysql store directory information

2006-04-06 Thread Tiago Saboga
Em Qui 06 Abr 2006 23:10, R. Alan Monroe escreveu: > > Em Qui 06 Abr 2006 15:41, Danny Yoo escreveu: > > > > model for that. But I want also to able to find these files, which are on > > removable media (cds and dvds). As I'll have to store where's the file, I > > thought I could as well store some

[Tutor] sqlobject behavior

2006-04-13 Thread Tiago Saboga
Hi! I don't understand why sqlobject's ForeignKey attribute has to have the same name of the linked class. The following example doesn't work (the traceback is just after) unless I rename the 'p' attribute of 'Address' class as 'person'. Thanks, Tiago. class Person(SQLObject): name = Str

[Tutor] string formatting (%s)

2006-04-15 Thread Tiago Saboga
Can I use string formatting in my own functions, or is it stuck with builtins? It doesn't make much sense for me, but I don't understand the following error: In [1]: var = 456 In [2]: def printd(arg): ...: print('>>> %s') % arg ...: In [3]: printd(var) >>> 456 In [4]: printd('Variab

[Tutor] python file browser with urwid

2006-07-17 Thread Tiago Saboga
I'm trying to write a file browser with urwid. In the future, I want to make a light front-end for cds burning, but for now I'm doing it as an exercise. The problem is I'm a little stuck now. I'm sending my actual working code, with some working functionality, but I would like to know if I shoul

Re: [Tutor] python file browser with urwid

2006-07-18 Thread Tiago Saboga
Thank you Kent, I've done the modifications you suggested, and the code follows. I splitted the __init__ method in four methods (__init__, header, footer, dir_browser) and took the get_file_names out of pyrun class. Now I have two more general questions, if you don't mind. 1) (first a philosoph

Re: [Tutor] about copy.copy

2006-07-20 Thread Tiago Saboga
Em Quinta 20 Julho 2006 04:51, linda.s escreveu: > But in the following example, a change in a spread to both b and c: > >>> a=[[1,2,3], [4,5,6]] > >>> b=a > >>> c=copy.copy(a) > >>> a[0][0]='a' > >>> a > > [['a', 2, 3], [4, 5, 6]] > > >>> b > > [['a', 2, 3], [4, 5, 6]] > > >>> c > > [['a', 2, 3],

[Tutor] man pages parser

2006-08-18 Thread Tiago Saboga
for html. It's why I'm asking here first if there is a better solution or other advices... Thanks. Tiago Saboga. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] re syntax

2006-08-28 Thread Tiago Saboga
A couple of weeks ago I asked about a way to parse man pages, and Danny and Alan answered me with some tips (thanks). I've tryed doclifter, which I already knew, but could not yet master it; in fact, it just doesn't work with many of the man-pages I tried in my debian system. Anyway, I'm refresh

Re: [Tutor] re syntax

2006-08-28 Thread Tiago Saboga
Em Segunda 28 Agosto 2006 11:12, Kent Johnson escreveu: > Ahem. Which part of "Whitespace within the pattern is ignored" do you > not understand? :-) It's easy ;-) It's the "whitespace" part. I read it as the space character, not as any blank character. I should have noted that new lines are igno

Re: [Tutor] re syntax

2006-08-29 Thread Tiago Saboga
Em Segunda 28 Agosto 2006 15:54, Kent Johnson escreveu: > A 'space character' is the single character \x20. A 'whitespace > character' is any character in a some set of non-printing (white) > characters. I guess it is a subtle distinction but it's common usage, > not just Python; it even has a Wiki

[Tutor] man pages parsing (still)

2006-09-11 Thread Tiago Saboga
I'm still there, trying to parse man pages (I want to gather a list of all options with their help strings). I've tried to use regex on both the formatted output of man and the source troff files and I discovered what is already said in the doclifter man page: you have to do a number of hints, a

Re: [Tutor] man pages parsing (still)

2006-09-11 Thread Tiago Saboga
Em Segunda 11 Setembro 2006 11:15, Kent Johnson escreveu: > Tiago Saboga wrote: > > I'm still there, trying to parse man pages (I want to gather a list of > > all options with their help strings). I've tried to use regex on both the > > formatted output of man a

Re: [Tutor] man pages parsing (still)

2006-09-11 Thread Tiago Saboga
Em Segunda 11 Setembro 2006 12:24, Kent Johnson escreveu: > Tiago Saboga wrote: > > Em Segunda 11 Setembro 2006 11:15, Kent Johnson escreveu: > >> Tiago Saboga wrote: > >> How big is the XML? 25 seconds is a long time...I would look at > >> cElementTree (implem

Re: [Tutor] man pages parsing (still)

2006-09-11 Thread Tiago Saboga
Em Segunda 11 Setembro 2006 12:59, Kent Johnson escreveu: > Tiago Saboga wrote: > > Em Segunda 11 Setembro 2006 12:24, Kent Johnson escreveu: > >> Tiago Saboga wrote: > >>> Em Segunda 11 Setembro 2006 11:15, Kent Johnson escreveu: > >>>> Tiago Saboga wr

Re: [Tutor] man pages parsing (still)

2006-09-12 Thread Tiago Saboga
Em Segunda 11 Setembro 2006 19:45, Kent Johnson escreveu: > Tiago Saboga wrote: > > Ok, the guilty line (279) has a "©" that was probably defined in the > > dtd, but as it doesn't know what is the right dtd... But wait... How does > > python read the dtd? It

Re: [Tutor] Input mask for console?

2006-09-14 Thread Tiago Saboga
Em Quarta 13 Setembro 2006 21:55, Chris Hengge escreveu: > nevermind.. figured it out.. Thanks. Hi Chris, It's not just for you, but I'd like to make a comment. When you write to this list, remember that other people read your questions too, and may be interested in the answers. By the way, I'v

[Tutor] importing module with non-standard name

2006-09-27 Thread Tiago Saboga
Hi! I'm still playing with man pages parsing, and following advices here, I'm using doclifter. But I want to use the installed version on my debian system, and not make it a part of my package. The problem is it isn't installed as a python module, but rather as an executable file lying in /usr/

Re: [Tutor] importing module with non-standard name

2006-09-28 Thread Tiago Saboga
Em Quarta 27 Setembro 2006 14:51, Kent Johnson escreveu: > Tiago Saboga wrote: > > Hi! > > > > I'm still playing with man pages parsing, and following advices here, I'm > > using doclifter. But I want to use the installed version on my debian > > system

[Tutor] re-reading file-like objects

2006-10-09 Thread Tiago Saboga
Hi! I have a problem with file-like objects for months now, and I hoped I could cope with it, but I keep using what seems to me like a newbie workaround... The question is: how can I read a file (more precisely, a file-like object) more than one single time? In the following example, I want t

Re: [Tutor] re-reading file-like objects (SOLVED?)

2006-10-09 Thread Tiago Saboga
I keep the original question: Em Segunda 09 Outubro 2006 09:21, Tiago Saboga escreveu: > Hi! > > I have a problem with file-like objects for months now, and I hoped I could > cope with it, but I keep using what seems to me like a newbie workaround... > > The question is: how

Re: [Tutor] re-reading file-like objects

2006-10-09 Thread Tiago Saboga
Em Segunda 09 Outubro 2006 10:41, Kent Johnson escreveu: > Tiago Saboga wrote: > > Hi! > > > > I have a problem with file-like objects for months now, and I hoped I > > could cope with it, but I keep using what seems to me like a newbie > > workaround... > >

Re: [Tutor] Variable help

2006-10-09 Thread Tiago Saboga
Hi! I think your problem was solved, and that the list of lists is the better approach indeed. But I'd like to add an answer to a direct question you asked: Em Domingo 08 Outubro 2006 07:47, Tom R. escreveu: > Basically I want to be able to integrate the value of one variable into > another var

Re: [Tutor] Please comment on this code...WORD FREQUENCY COUNTER

2006-10-23 Thread Tiago Saboga
Em Segunda 23 Outubro 2006 18:03, Asrarahmed Kadri escreveu: > Folks, > > I have written a program which calculates teh frequency of each word that > appears in a file. I would like to have your feedback. Sorry, I couldn't resist. Others talked about your code, but here's what I use (no, it's not

Re: [Tutor] for loop

2008-06-10 Thread Tiago Saboga
count += 1 > print i > continue > > it prints absolutely nothing. The count var is never updated. What about: for i in someArray[1:]: print i Tiago Saboga. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Replace sequence in list - looking for direction

2008-06-16 Thread Tiago Saboga
he value from dict b. At the end I would like to have list a represented > as: > > a = ['super', 'a4', 'a5', 'a6'] The following works for your example. I assume the values in the a list are unique. for key in b: keylist = key.split(',

Re: [Tutor] Checking the desktop environment

2008-06-20 Thread Tiago Saboga
t thing, launching gksu, kdesu or simply su in a new xterm. Tiago Saboga. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] how to run a process forever

2008-12-10 Thread Tiago Saboga
s PID to a file. The cron > script can check that file and see if that process is still alive before > deciding to start another. If you are in a debian-based system, see start-stop-daemon (possibly available in other distros too). Tiago Saboga. _