Re: [Tutor] Trying to extract the last line of a text file

2006-10-20 Thread János Juhász
> Danny Yoo wrote: > > > > file('filename.txt').readlines()[-1] > Not to hijack the thread, but what stops you from just putting a > file.close() after your example line? > >>> Which file should file.close() close? The problem is that we don't > >>> have a handle on the particular fi

[Tutor] How to get the width of teh button widget..??

2006-10-20 Thread Asrarahmed Kadri
    Folks,   Sorry for asking you such a trivial question.!!! But i want to size up all the buttons with the same size as the largest one in the interface.. And thats why I am asking this question..   Regards, Asrarahmed -- To HIM you shall return. ___ T

Re: [Tutor] How to get the width of teh button widget..??

2006-10-20 Thread Luke Paireepinart
Asrarahmed Kadri wrote: > > > > Folks, > > Sorry for asking you such a trivial question.!!! But i want to size up > all the buttons with the same size as the largest one in the > interface.. And thats why I am asking this question.. Oops, in your hurry to send the e-mail you seem to have fo

[Tutor] I need a time object from the future

2006-10-20 Thread William O'Higgins Witteman
I've been looking into this, and I am not understanding how to get this task done. I need to be able to look at a time object and know if it si between now and a set point 120 days in the future. I can get a value for now (currently I am using datetime.datetime.now()), but I haven't found a way t

[Tutor] need some class / module help

2006-10-20 Thread shawn bright
Hey there,I am trying to create a module with one classthe module name is group.pyit looks like this so farimport DbConnectorclass Group(object):    def __init__(self, id):    self.id = id    con = DbConnector.DbConnector()    query = con.getOne("select `name`, `position` from `groups`

Re: [Tutor] I need a time object from the future

2006-10-20 Thread Carlos Hanson
On Fri, October 20, 2006 8:55 am, William O'Higgins Witteman wrote: > I've been looking into this, and I am not understanding how to get > this task done. I need to be able to look at a time object and know > if it si between now and a set point 120 days in the future. I can > get a value for n

Re: [Tutor] I need a time object from the future

2006-10-20 Thread Dave Kuhlman
On Fri, Oct 20, 2006 at 11:55:39AM -0400, William O'Higgins Witteman wrote: > I've been looking into this, and I am not understanding how to get this > task done. I need to be able to look at a time object and know if it si > between now and a set point 120 days in the future. I can get a value >

Re: [Tutor] need some class / module help

2006-10-20 Thread Bob Gailer
shawn bright wrote: Hey there, I am trying to create a module with one class the module name is group.py it looks like this so far import DbConnector class Group(object):     def __init__(self, id):     self.id = id     con = DbConnector.DbConnector()     query = con.

Re: [Tutor] need some class / module help

2006-10-20 Thread shawn bright
Hey thanks for the help, yes, the class in in another file called group. the class Group is the only class in the module. I am doing this because the script that will call it is not the only place in all our scripts where it can be used. I have been doing stuff with python for over a year now, thou

Re: [Tutor] need some class / module help

2006-10-20 Thread shawn bright
oh, one more thing.these objects are going to be created at the rate of about 20 / minute in a thread.at some point is this going to be a problem ? do they go away over time?Or do i need to write something that will kill them? thanksskOn 10/20/06, shawn bright <[EMAIL PROTECTED]> wrote: Hey thanks

Re: [Tutor] need some class / module help

2006-10-20 Thread Simon Brunning
On 10/20/06, shawn bright <[EMAIL PROTECTED]> wrote: > oh, one more thing. > these objects are going to be created at the rate of about 20 / minute in a > thread. > at some point is this going to be a problem ? do they go away over time? > Or do i need to write something that will kill them? If yo

Re: [Tutor] I need a time object from the future

2006-10-20 Thread Kent Johnson
William O'Higgins Witteman wrote: > I've been looking into this, and I am not understanding how to get this > task done. I need to be able to look at a time object and know if it si > between now and a set point 120 days in the future. I can get a value > for now (currently I am using datetime.da

Re: [Tutor] need some class / module help

2006-10-20 Thread shawn bright
if i name them, like bob = group.Group(some_id) ?what is going to happen is that each time, the variable will create a different objectlike while 1:    group = group.Group(some_id)    do some stuff with group. so since it keeps getting replaced, it should be ok without some way to destroy it ?thank

Re: [Tutor] need some class / module help

2006-10-20 Thread Python
On Fri, 2006-10-20 at 13:44 -0500, shawn bright wrote: > if i name them, like bob = group.Group(some_id) ? > > what is going to happen is that each time, the variable will create a > different object > > like > while 1: > group = group.Group(some_id) > do some stuff with group. > > so

Re: [Tutor] need some class / module help

2006-10-20 Thread shawn bright
way cool, thanks much guys.skOn 10/20/06, Python <[EMAIL PROTECTED]> wrote: On Fri, 2006-10-20 at 13:44 -0500, shawn bright wrote:> if i name them, like bob = group.Group(some_id) ?>> what is going to happen is that each time, the variable will create a> different object >> like> while 1:> grou

[Tutor] Best way to replace items in a list.

2006-10-20 Thread Chris Hengge
I'm trying to build a little piece of code that replaces an item in a list. Here is a sample of what I'd like to do.str = "This was replaced"ff item in list:   replace item with str I know I can do list.remove(item), but how do I place str back into that exact location?Is this how / best way?if ite

Re: [Tutor] Best way to replace items in a list.

2006-10-20 Thread Jason Massey
Why not:if item in list: loc = list.index(item) list[loc] = strOn 10/20/06, Chris Hengge < [EMAIL PROTECTED]> wrote:I'm trying to build a little piece of code that replaces an item in a list. Here is a sample of what I'd like to do.str = "This was replaced"ff item in list:   replace item with str

Re: [Tutor] Best way to replace items in a list.

2006-10-20 Thread Chris Hengge
Will that replace the location? or add to it? Thanks.On 10/20/06, Jason Massey <[EMAIL PROTECTED] > wrote:Why not:if item in list: loc = list.index(item)  list[loc] = strOn 10/20/06, Chris Hengge < [EMAIL PROTECTED]> wrote: I'm trying to build a little piece of code that replaces an item in a list

Re: [Tutor] Best way to replace items in a list.

2006-10-20 Thread Jason Massey
You can access and change the elements in a list by directly referencing their position in the list.Something like:>>> foo = [1,2,3]>>> foo[0]1>>> foo[0] = 'a'>>> foo ['a', 2, 3]On 10/20/06, Chris Hengge <[EMAIL PROTECTED]> wrote: Will that replace the location? or add to it? Thanks.On 10/20/06, Ja

Re: [Tutor] How to get the width of teh button widget..??

2006-10-20 Thread Michael Lange
On Fri, 20 Oct 2006 11:55:10 +0100 "Asrarahmed Kadri" <[EMAIL PROTECTED]> wrote: > Folks, > > Sorry for asking you such a trivial question.!!! But i want to size up all > the buttons with the same size as the largest one in the interface.. And > thats why I am asking this question.. > Hi Asrara

[Tutor] PyAlsaAudio with Multiple Sound Cards?

2006-10-20 Thread Rick Sterling
Hi. I am pretty new to Python, but am trying to get up to speed so I move over to Python from Perl. One progam I wrote in Perl I am trying to re-write in Python. It controls the mixer settings on my sound card. I managed to rewrite most of it by borrowing and stealing from the mixertest.py i

Re: [Tutor] Resources for Tkinter...

2006-10-20 Thread Alan Gauld
"Asrarahmed Kadri" <[EMAIL PROTECTED]> wrote > I have the Tkinter book by Grayson (Python and Tkinter > Programming).. *But > I must say, its quite boring..* It is a bit dense. And it jumps from basic to advanced pretty quickly. But it is thorough and so far I've found very few mistakes. That

Re: [Tutor] How to get the width of teh button widget..??

2006-10-20 Thread Alan Gauld
"Asrarahmed Kadri" <[EMAIL PROTECTED]> wrote > Sorry for asking you such a trivial question.!!! But i want to size > up all > the buttons with the same size as the largest one in the interface.. > And > thats why I am asking this question.. Assuming you mean in Tkinter(given yor other posts) it

Re: [Tutor] Best way to replace items in a list.

2006-10-20 Thread Alan Gauld
Chris, > Will that replace the location? or add to it? > >> if item in list: >> loc = list.index(item) >> list[loc] = str Jason already showed you the answer, but significantly he also showed you how to find out for yourself. Use the >>> prompt. Its what its there for. For some reason peopl

Re: [Tutor] Best way to replace items in a list.

2006-10-20 Thread Luke Paireepinart
Chris Hengge wrote: > I'm trying to build a little piece of code that replaces an item in a > list. > > Here is a sample of what I'd like to do. > > str = "This was replaced" > > ff item in list: >replace item with str > > I know I can do list.remove(item), but how do I place str back into >

Re: [Tutor] Best way to replace items in a list.

2006-10-20 Thread Chris Hengge
I like it because it different.. and it reads cleanly... =PAs far as the first occurance.. I'm not concerned about checking extra, because the first occurance is the only one I should ever need. On 10/20/06, Luke Paireepinart <[EMAIL PROTECTED]> wrote: Chris Hengge wrote:> I'm trying to build a li

[Tutor] My first real python project: LOLLERSKATES

2006-10-20 Thread Tracy R Reed
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 I have been a sysadmin for quite a while now and used to do a lot of perl. I haven't done much programming at all in the last couple of years but have been meaning to dump perl for python anyhow (for the usual reasons) and have finally gotten around to

Re: [Tutor] My first real python project: LOLLERSKATES

2006-10-20 Thread Chris Hengge
All I can say to this... LOLLERSKATES =DOn 10/20/06, Tracy R Reed <[EMAIL PROTECTED]> wrote: -BEGIN PGP SIGNED MESSAGE-Hash: SHA1I have been a sysadmin for quite a while now and used to do a lot of perl. I haven't done much programming at all in the last couple of yearsbut have been mea