[Tutor] move forward in arbitrary direction

2006-10-27 Thread Michael Shulman
Hello, I have what should be a basic math question, but I keep messing it up. How do I code an equation so that when I have an object facing an arbitrary vector, pressing a key will make it move forwards in that direction? (I understand all the key-based setup, it's just the equation for moving

Re: [Tutor] basic question ...

2006-10-27 Thread Ravi Kondamuru
Thanks a lot for all that info. I am going to start with the doc/lib index for an overview and dir looks like a good runtime help command.Ravi.On 10/27/06, Danny Yoo <[EMAIL PROTECTED]> wrote: On Fri, 27 Oct 2006, Ravi Kondamuru wrote:> How does one figure all the builtin libraries/ classes that p

Re: [Tutor] problem importing class

2006-10-27 Thread Danny Yoo
>> It looks like people have identified the problem, that your site.py >> module isn't being found because it conflicts with something from >> Python's Standard Library. >> >> This isn't the first time this kind of problem has hit people. This >> problem is well known and is the subject of a Pyt

Re: [Tutor] basic question ...

2006-10-27 Thread Danny Yoo
On Fri, 27 Oct 2006, Ravi Kondamuru wrote: > How does one figure all the builtin libraries/ classes that python > supports? > > For example if I want to sort a list of names, I would normally think of > implementing the sorting routine in C. I am just beginning to learn > python. It looks lik

Re: [Tutor] basic question ...

2006-10-27 Thread Glenn T Norton
Ravi Kondamuru wrote: > Hi, > > How does one figure all the builtin libraries/ classes that python > supports? > > For example if I want to sort a list of names, I would normally think > of implementing the sorting routine in C. I am just beginning to learn > python. It looks like there is a ri

[Tutor] basic question ...

2006-10-27 Thread Ravi Kondamuru
Hi,How does one figure all the builtin libraries/ classes that python supports?For example if I want to sort a list of names, I would normally think of implementing the sorting routine in C. I am just beginning to learn python. It looks like there is a rich set available builtin libraries. So, is t

Re: [Tutor] database question

2006-10-27 Thread Alan Gauld
> For example > with "SELECT * FROM a", I use this code > > ... to know how many columns are in the result, As a general rule its better to avoid "Select * From" in production SQL. If the table definition changes the data returned can change in unexpected ways and break your application. In addi

Re: [Tutor] recommendations for database module based on my needs

2006-10-27 Thread Alan Gauld
"Pine Marten" <[EMAIL PROTECTED]> wrote > it is just a small dataset. But how small is small? A potentially big topic. But heres my purely arbitrary guidelines: Less than 1000 records use a text file (or maybe XML) 1,000 - 100,000 records consider an in memory database or something like g

Re: [Tutor] Getting the type of a variable

2006-10-27 Thread Alan Gauld
"Etrade Griffiths" <[EMAIL PROTECTED]> wrote > > I want to check the type of a variable so that I know which format > to use > for printing eg That's sometimes necessary but you may find that just using %s will suffice. print "%s\n" % 42 print "%s\n" % "42" print "%s\n" % 42.0 You usually only

[Tutor] recommendations for database module based on my needs

2006-10-27 Thread Pine Marten
I'm hoping to create an app which takes user data via a GUI with checkboxes, textcontrols, spinner controls, etc. The data would be some text, some numbers, some checkboxes checked or not, etc. I've been making a little progress on that via wxPython and Boa Constructor. Now I want to save th

[Tutor] (OT) Non-Python discussions (Was: I am terribly confused about "generators" ...)

2006-10-27 Thread Carroll, Barry
Greetings: I agree completely with David. There are plenty of places to discuss controvercial topics. Let's not do it here, where it will only disrupt, and possibly ruin, an exceptionally useful teaching and learning channel. Regards, Barry [EMAIL PROTECTED] 541-302-1107 ___

Re: [Tutor] XML parsing in Python.. resources needed

2006-10-27 Thread Gabriel Farrell
On Fri, Oct 27, 2006 at 11:24:00AM +0100, Asrarahmed Kadri wrote: > Hi Folks, > > ANy comments about ELementTree module... > > I have heard that it is more 'Pythonic'... > > I need some basic examples to start learning the stuff.. If anyone has got > the information, please pass it along.. > E

Re: [Tutor] Why is this only catching one occurance?

2006-10-27 Thread Carroll, Barry
Chris: See below. > -Original Message- > Message: 7 > Date: Fri, 27 Oct 2006 12:20:51 -0700 > From: "Chris Hengge" <[EMAIL PROTECTED]> > Subject: Re: [Tutor] Why is this only catching one occurance? > To: "Bob Gailer" <[EMAIL PROTECTED]> > Cc: Tutor > Message-ID: > <[EMAIL PROTE

Re: [Tutor] Why is this only catching one occurance?

2006-10-27 Thread Chris Hengge
That was supposed to say "Thanks for this" but I was in a hurry.Anyways, here is my solution:# Remove any copies of .hex that aren't BMC    for foundItem in directoryList:    try:     if ".hex" in foundItem.lower():    if "bmc" in foundItem.lower():  

Re: [Tutor] line number when reading files using csv module CORRECTION

2006-10-27 Thread Bob Gailer
Bob Gailer wrote: > Duncan Gibson wrote: > >> [snip] >> > > >> but I would like to record the line number in the file. >> >> > How about using enumerate(): > >> for line_num, data in enumerate(reader): >> # print reader.line_num, data # SHOULD BE: >> print

Re: [Tutor] Why is this only catching one occurance?

2006-10-27 Thread Chris Hengge
I've tried to use your example:for unWantedItem in directoryList[,,-1]:but I get an error:for unWantedItem in directoryList[,,-1]:                     ^SyntaxError: invalid syntax I understand what you are saying to do, and it makes sense, but I'm not sure how to implime

Re: [Tutor] Why is this only catching one occurance?

2006-10-27 Thread Chris Hengge
Thats for this very humorous reply =DOn 10/26/06, Luke Paireepinart <[EMAIL PROTECTED]> wrote: Chris Hengge wrote:> Here is my code:> for unWantedItem in directoryList:> try: > if "hex" in unWantedItem.lower():> if not "bmc" in unWantedItem.lower():> 

Re: [Tutor] line number when reading files using csv module

2006-10-27 Thread Bob Gailer
Duncan Gibson wrote: > [snip] > but I would like to record the line number in the file. > How about using enumerate(): > > for line_num, data in enumerate(reader): > print reader.line_num, data > > -- Bob Gailer 510-978-4454 ___ Tu

Re: [Tutor] I am terribly confused about "generators" and "iterators".. Help me

2006-10-27 Thread wesley chun
> What are generators and iterators...??And why are they are needed..?? > > I can do my stuff with a 'for' or a 'while' loop.. so why do I need an > ITERATOR..? > > And what is a generator ..? I did try to read about these two things on the > web, but still I AM CONFUSED. here are some more place

Re: [Tutor] Getting the type of a variable

2006-10-27 Thread wesley chun
> > I want to check the type of a variable so that I know which format to use > > for printing eg > > > Alternatively, you could just cast it as a string. what joshua is saying is that for just displaying something, that it's just as easy to convert it to a string, or, if you're using print, to no

Re: [Tutor] Getting the type of a variable

2006-10-27 Thread Joshua Simpson
  On 10/27/06, Etrade Griffiths <[EMAIL PROTECTED]> wrote: Hi I want to check the type of a variable so that I know which format to use for printing egAlternatively, you could just cast it as a string.  ___ Tutor maillist - Tutor@python.org http

Re: [Tutor] I am terribly confused about "generators" and "iterators".. Help me

2006-10-27 Thread David Heiser
May I invite EVERYONE to NOT introduce political or religious elements into these discussions. It has no place here and can destroy this excellent discussion group. I've seen it happen. PLEASE take it elsewhere. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Beh

Re: [Tutor] I am terribly confused about "generators" and "iterators".. Help me

2006-10-27 Thread Kent Johnson
Bob Gailer wrote: > Asrarahmed Kadri wrote: >> >> What are generators and iterators...??And why are they are needed..?? >> >> I can do my stuff with a 'for' or a 'while' loop.. so why do I need an >> ITERATOR..? > iterators & generators do not replace while or for loops! No, actually iterato

Re: [Tutor] line number when reading files using csv module

2006-10-27 Thread Bob Gailer
Duncan Gibson wrote: > If I have the following data file, data.csv: > 1 2 3 > 2 3 4 5 > > then I can read it in Python 2.4 on linux using: > > import csv > f = file('data.csv', 'rb') > reader = csv.reader(f) > for data in reader: > print data > > OK, that's all well

Re: [Tutor] I am terribly confused about "generators" and "iterators".. Help me

2006-10-27 Thread Bob Gailer
Asrarahmed Kadri wrote: > > > Hi Folks, > > What are generators and iterators...??And why are they are needed..?? > > I can do my stuff with a 'for' or a 'while' loop.. so why do I need an > ITERATOR..? iterators & generators do not replace while or for loops! > > And what is a generato

Re: [Tutor] Why is this only catching one occurance?

2006-10-27 Thread Bob Gailer
Chris Hengge wrote: > Here is my code: > for unWantedItem in directoryList: > try: > if "hex" in unWantedItem.lower(): > if not "bmc" in unWantedItem.lower(): >print unWantedItem + " removed!" >directory

Re: [Tutor] Getting the type of a variable

2006-10-27 Thread Etrade Griffiths
Thanks, guys - like so many things, easy when you know how! Alun Griffiths At 14:27 27/10/2006, you wrote: Use this:   if type(a) == type(1):     print "a is int %d" elif type(a) == type(1.1):   ...   HTH.. Regards, Asrarahmed Kadri   On 10/27/06, Etrade Griffiths <[EMAIL PROTECTED]> wrote:

Re: [Tutor] Getting the type of a variable

2006-10-27 Thread Asrarahmed Kadri
Use this:   if type(a) == type(1):     print "a is int %d" elif type(a) == type(1.1):   ...   HTH.. Regards, Asrarahmed Kadri   On 10/27/06, Etrade Griffiths <[EMAIL PROTECTED]> wrote: HiI want to check the type of a variable so that I know which format to usefor printing eg def print_correct_f

Re: [Tutor] Getting the type of a variable

2006-10-27 Thread Kent Johnson
Etrade Griffiths wrote: > Hi > > I want to check the type of a variable so that I know which format to use > for printing eg > > def print_correct_format(a): > > if type(a) == 'int': > print "a is an integer, value %i" % (a) > elif type(a) == 'float': > p

Re: [Tutor] Getting the type of a variable

2006-10-27 Thread Glenn T Norton
Etrade Griffiths wrote: >Hi > >I want to check the type of a variable so that I know which format to use >for printing eg > >def print_correct_format(a): > > if type(a) == 'int': > print "a is an integer, value %i" % (a) > elif type(a) == 'float': > print "

[Tutor] Getting the type of a variable

2006-10-27 Thread Etrade Griffiths
Hi I want to check the type of a variable so that I know which format to use for printing eg def print_correct_format(a): if type(a) == 'int': print "a is an integer, value %i" % (a) elif type(a) == 'float': print "a is a float, value %f" % (a)

Re: [Tutor] [pygtk] ListStore question

2006-10-27 Thread shawn bright
this is cool, ill give it a shotskOn 10/27/06, euoar <[EMAIL PROTECTED]> wrote: euoar escribió:> mc collilieux escribió:>> euoar wrote:>> I'm learning the use of liststores and treeviews. I have wrotten this litle class as exercice: # name is the name of the new column to add, valu

Re: [Tutor] line number when reading files using csv module

2006-10-27 Thread Kent Johnson
Duncan Gibson wrote: > > Kent Johnson wrote: >> The line_num attribute is new in Python 2.5. This is a doc bug, >> it should be noted in the description of line_num. > > Is there some way to create a wrapper around a 2.4 csv.reader to > give me pseudo line number handling? I've been experimenting

Re: [Tutor] line number when reading files using csv module

2006-10-27 Thread Duncan Gibson
Kent Johnson wrote: > The line_num attribute is new in Python 2.5. This is a doc bug, > it should be noted in the description of line_num. Is there some way to create a wrapper around a 2.4 csv.reader to give me pseudo line number handling? I've been experimenting with: import csv clas

Re: [Tutor] [pygtk] ListStore question

2006-10-27 Thread euoar
euoar escribió: > mc collilieux escribió: >> euoar wrote: >> I'm learning the use of liststores and treeviews. I have wrotten this litle class as exercice: >> >> # name is the name of the new column to add, values is a tuple with the values to add def add_result (self, name, va

[Tutor] I am terribly confused about "generators" and "iterators".. Help me

2006-10-27 Thread Asrarahmed Kadri
    Hi Folks,   What are generators and iterators...??And why are they are needed..??   I can do my stuff with a 'for' or a 'while' loop.. so why do I need an ITERATOR..?   And what is a generator ..? I did try to read about these two things on the web, but still I AM CONFUSED.   To be honest, I am

Re: [Tutor] XML parsing in Python.. resources needed

2006-10-27 Thread Kent Johnson
Asrarahmed Kadri wrote: > > > Hi Folks, > > ANy comments about ELementTree module... > > I have heard that it is more 'Pythonic'... > > I need some basic examples to start learning the stuff.. If anyone has > got the information, please pass it along.. http://effbot.org/zone/element.htm

[Tutor] XML parsing in Python.. resources needed

2006-10-27 Thread Asrarahmed Kadri
    Hi Folks,   ANy comments about ELementTree module...   I have heard that it is more 'Pythonic'...   I need some basic examples to start learning the stuff.. If anyone has got the information, please pass it along..   Thanks.   Regards, Asrarahmed Kadri-- To HIM you shall return. _

Re: [Tutor] line number when reading files using csv module

2006-10-27 Thread Kent Johnson
Duncan Gibson wrote: > If I have the following data file, data.csv: > 1 2 3 > 2 3 4 5 > > then I can read it in Python 2.4 on linux using: > > import csv > f = file('data.csv', 'rb') > reader = csv.reader(f) > for data in reader: > print data > > OK, that's all we

Re: [Tutor] Why is this only catching one occurance?

2006-10-27 Thread Kent Johnson
Chris Hengge wrote: > Here is my code: > for unWantedItem in directoryList: > try: > if "hex" in unWantedItem.lower(): > if not "bmc" in unWantedItem.lower(): >print unWantedItem + " removed!" >directory

Re: [Tutor] line number when reading files using csv module

2006-10-27 Thread Duncan Gibson
On Fri, 27 Oct 2006 11:35:40 +0200 Duncan Gibson <[EMAIL PROTECTED]> wrote: > > If I have the following data file, data.csv: > 1 2 3 > 2 3 4 5 > > then I can read it in Python 2.4 on linux using: > > import csv > f = file('data.csv', 'rb') > reader = csv.reader(f) > for

Re: [Tutor] Witch gui to choose for this script?

2006-10-27 Thread Kent Johnson
rolando wrote: > Well, I don't know if I can ask this question here, but never mind that :) Yes, it's fine. > > It´s like this, I created this python script that translates "human > language" to Al-bhed language (it's a language from the game Final > Fantasy 10, it's basicly a change in the let

[Tutor] database question

2006-10-27 Thread euoar
I'm learning to use python with the database mysql. I'm writing a widget in pygtk that should show the results of a sql query. For example with "SELECT * FROM a", I use this code count = 0 a = db.cursor.description for tuple in a: print tuple[0][0] count = count + 1

Re: [Tutor] Witch gui to choose for this script?

2006-10-27 Thread rolando
If you're just going for a simple two-textbox, one button, 'type here, hit the button, and the translated text appears in the other box' Yeah, its something like that :D Nothing to much fancy, it just that it can get kind of boring always going to the linux console to run the script. I'm go

[Tutor] line number when reading files using csv module

2006-10-27 Thread Duncan Gibson
If I have the following data file, data.csv: 1 2 3 2 3 4 5 then I can read it in Python 2.4 on linux using: import csv f = file('data.csv', 'rb') reader = csv.reader(f) for data in reader: print data OK, that's all well and good, but I would like to record the li

Re: [Tutor] Witch gui to choose for this script?

2006-10-27 Thread Luke Paireepinart
rolando wrote: > Well, I don't know if I can ask this question here, but never mind > that :) > > It´s like this, I created this python script that translates "human > language" to Al-bhed language (it's a language from the game Final > Fantasy 10, it's basicly a change in the letters for exampl

Re: [Tutor] Python and config files?

2006-10-27 Thread Basil Shubin
Kent Johnson пишет: > Basil Shubin wrote: >> Hi, friends! >> >> Is there exist a module for working with config file? Simple enough, >> just read/write config file (like for most unix app), determine where >> row is contain config words with it's parameters (like >> 'config_word=parameter') or i

[Tutor] Witch gui to choose for this script?

2006-10-27 Thread rolando
Well, I don't know if I can ask this question here, but never mind that :) It´s like this, I created this python script that translates "human language" to Al-bhed language (it's a language from the game Final Fantasy 10, it's basicly a change in the letters for example A becomes W or B become

Re: [Tutor] Mailing list question

2006-10-27 Thread rolando
Oh, ok :D Luke Paireepinart escreveu: > rolando wrote: >> I just use the reply button in my Thunderbird, and then change the >> email I want to send to tutor@python.org > It's better to use reply-all, in my opinion, because then, if > someone's involved in an e-mail thread, they'll get an insta