Re: [Tutor] glibc error while Python script runs - Solved

2006-01-19 Thread Bernard Lebel
Thanks a lot Danny, That certainly does make sense. I'll look into implementing the Queue approach in my program tomorrow. I remember you recommending me this module as well not long ago, although in a different discussion (where I suspected problem with file access from multiple thread, but I gue

Re: [Tutor] glibc error while Python script runs - Solved

2006-01-19 Thread Danny Yoo
On Thu, 19 Jan 2006, Kent Johnson wrote: > In your original desing were you sharing a connection between threads? > That could cause trouble. But if each connection has its own thread and > you are using transactions and isolation levels appropriately, they > shouldn't stomp on each other. Hi

Re: [Tutor] glibc error while Python script runs - Solved

2006-01-19 Thread Bernard Lebel
On 1/19/06, Kent Johnson <[EMAIL PROTECTED]> wrote: > Hi Bernard, > > I'm glad you got it working but kind of surprised at what you had to do. > You shouldn't have to have a single thread to access the database. In > your original desing were you sharing a connection between threads? That > could c

Re: [Tutor] glibc error while Python script runs - Solved

2006-01-19 Thread Kent Johnson
Hi Bernard, I'm glad you got it working but kind of surprised at what you had to do. You shouldn't have to have a single thread to access the database. In your original desing were you sharing a connection between threads? That could cause trouble. But if each connection has its own thread and

Re: [Tutor] glibc error while Python script runs - Solved

2006-01-19 Thread Bernard Lebel
Hello, For the record, in case anyone would like to know what happened with this issue... It seems that the problem was related to the way I managed MySQL connections. There was the main thread that would query every 5 seconds the database to see if a someone wanted to abort the job running on t

Re: [Tutor] getting text within an element [attribute text] using elementtree

2006-01-19 Thread Danny Yoo
On Fri, 20 Jan 2006, ps python wrote: > In my XML file some attributes have text within an element. I want to > get that text. How can I do that. Hello, The problems you have don't have to do with the calls to gettext, but to selecting namespaced nodes as with your previous questions. Let's

Re: [Tutor] getting text within an element [attribute text] using elementtree

2006-01-19 Thread ps python
Dear group, In my XML file some attributes have text within an element. I want to get that text. How can I do that. I looked into ElementTree -bits and pieces: and there is a small function. >>> def gettext(elem): ... text = elem.text or "" ... for e in elem: ... text += get

Re: [Tutor] How to get terminal settings

2006-01-19 Thread Terry Carroll
On Thu, 19 Jan 2006, Vincent Zee wrote: > Any pointers to other curses howto's? There's http://heather.cs.ucdavis.edu/~matloff/Python/PyCurses.pdf ; but it's mostly a couple of example programs, without a lot of explanation. ___ Tutor maillist - Tut

Re: [Tutor] How to get terminal settings

2006-01-19 Thread Alan Gauld
Assuming you are on a Unix style OS/terminal you can read the output of stty. Look at the rows value Here are a couple of runs of rows at different terminal sizes: $ stty -a | grep rows speed 38400 baud; rows 41; columns 80; line = 0; $ stty -a | grep rows speed 38400 baud; rows 26; columns 80;

Re: [Tutor] [Re] Fwd: Strings backwards

2006-01-19 Thread Orri Ganel
Victor Bouffier wrote: >I had to do the string-to-list-then-reverse-string-then-back-to-string >process myself before knowing about this marvelous operand. >It works on tuples (all immutable objects) too: > [SNIP] Not all immutable objects, just those that define __getslice__ (basically, those t

[Tutor] Simple MS Windows Shell Extension?

2006-01-19 Thread bernd
Hi, I have a python script that I want my users to execute with a "Right-Mouse-Click" on a file under Windows XP. (If possible without changing the default "Open with ..." behavior from Windows.) Does anybody has a simple example on how to do that? Thanks, -- Bernd __

Re: [Tutor] How to get terminal settings

2006-01-19 Thread Vincent Zee
On Thursday, 19 January 2006 at 12:37:38 -0800, Danny Yoo wrote: > > > On Thu, 19 Jan 2006, Vincent Zee wrote: > > > say you want to write a more-like program. How do you know how many > > lines the terminal window can display. > > Hi Vincent, > > It's possible that this information might alre

Re: [Tutor] How to get terminal settings

2006-01-19 Thread Danny Yoo
On Thu, 19 Jan 2006, Vincent Zee wrote: > say you want to write a more-like program. How do you know how many > lines the terminal window can display. Hi Vincent, It's possible that this information might already be in your environment. If you're using the 'bash' shell, and if the 'checkwinsiz

Re: [Tutor] References and list aliasing in Perl and Python [Was: Re: Dictionaries]

2006-01-19 Thread Victor Bouffier
On Wed, 2006-01-18 at 23:03 -0800, Danny Yoo wrote: > > > There are tradeoffs here. On the one hand, Python folks get caught > > > off guard when they first encounter list aliasing. On the other, Perl > > > folks get caught off guard when they first try to make a hash whose > > > values are thems

Re: [Tutor] How to get terminal settings

2006-01-19 Thread Vincent Zee
On Thursday, 19 January 2006 at 11:29:29 -0800, Bill Campbell wrote: > On Thu, Jan 19, 2006, Vincent Zee wrote: > >Hi, > > > >say you want to write a more-like program. > >How do you know how many lines the terminal window > >can display. > > Use the curses library, and it will take care of this f

Re: [Tutor] How to get terminal settings

2006-01-19 Thread Bill Campbell
On Thu, Jan 19, 2006, Vincent Zee wrote: >Hi, > >say you want to write a more-like program. >How do you know how many lines the terminal window >can display. Use the curses library, and it will take care of this for you. Bill -- INTERNET: [EMAIL PROTECTED] Bill Campbell; Celestial Software LLC

[Tutor] escaping spaces in a directoryname

2006-01-19 Thread Rinzwind
Hmm, a very newby question but I never had to deal with escaping spaces etc.I want to read a directory with spaces in it and it errors out (because of the space).I need to escape it with a \ I guess. I saw alot about that on some websites but they all talk about why and how you escape and not what

Re: [Tutor] Python + MySQL , my first simple program does not gives results

2006-01-19 Thread Alan Gauld
> I was trying to get the some result , eg > describe table, select * from table > but my program does not give the expected results , > nor it gives any error First of all you have only defined init() but not created an instance so it never actually gets called! But if you do call

Re: [Tutor] Links for programming using MySQL

2006-01-19 Thread Alan Gauld
>I wanted to try out python with MySQL databases What do you need to know about? Do you already know about MySql and just want to know how to connect to a database and execute a SQL statement? Or do you need to know about databases too? If the latter you can try the database topic in my

[Tutor] How to get terminal settings

2006-01-19 Thread Vincent Zee
Hi, say you want to write a more-like program. How do you know how many lines the terminal window can display. /\ Vincent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] [Re] Fwd: Strings backwards

2006-01-19 Thread Victor Bouffier
This was just posted by John Fouhy (snipped part of it): Basically, the syntax is [start:stop:step]. If step is negative, you work backwards. eg: >>> string.lowercase[20:10:-2] # letters 20, 18, 16, 14, 12 'usqom' And if you omit the sta

Re: [Tutor] Python + MySQL , my first simple program does not gives results

2006-01-19 Thread Danny Yoo
On Thu, 19 Jan 2006, John Joseph wrote: > Hi >I tried out my first Pyhton program with MySQL > I was trying to get the some result , eg > describe table, select * from table Hi John, Unlike Java, Python doesn't force you to put everything in a class. You can try the simpl

Re: [Tutor] Indexing in a series for a newbie

2006-01-19 Thread Danny Yoo
On Thu, 19 Jan 2006, Jon Moore wrote: > I need some help for a program I am writing as a newbie to Python. > > I have created a series: > > WORDS = ("python", "program", "code", "xylophone") > > and then assigned one of them randomly to the variable 'word': > > word = random.choice(WORDS) > > I

Re: [Tutor] how to do multiple searching against many lists

2006-01-19 Thread Kent Johnson
Srinivas Iyyer wrote: > Hi Group, > > my Problem: > > I have soms list for variety of animals, birds, > bacteria > > > I have another list: > search_list = > ['cat','python','parrot','donkey','e.coli'] > > animals = ['cat','tiger','donkey','zebra','lemur'] > birs = ['parrot','mina','oriole','

Re: [Tutor] how to do multiple searching against many lists

2006-01-19 Thread Pujo Aji
Yes you can.you can make:    search_list =['cat','python','parrot','donkey','e.coli']    animals = ['python','cat','tiger','donkey','zebra','lemur']    birds = ['parrot','mina','oriole','blue jay']    bacteria = [' e.coli','bacillus','staphy','acetobacter']    mydic = {}    for animal in animals :

[Tutor] how to do multiple searching against many lists

2006-01-19 Thread Srinivas Iyyer
Hi Group, my Problem: I have soms list for variety of animals, birds, bacteria I have another list: search_list = ['cat','python','parrot','donkey','e.coli'] animals = ['cat','tiger','donkey','zebra','lemur'] birs = ['parrot','mina','oriole','blue jay'] bacteria = ['e.coli','bacillus','staphy

Re: [Tutor] Indexing in a series for a newbie

2006-01-19 Thread Todd Maynard
Another approach would be to change your data structure to include the words and hints together as tuples in the same tuple. ie... WORDS=( ("python","The python hint"),("program","The program hint"), ("code","The code hint") ) then you can do... word, hint = random.choice(WORDS) >>> WORDS=(

Re: [Tutor] Indexing in a series for a newbie

2006-01-19 Thread Wolfram Kraus
Jon Moore wrote: > Hello > > I need some help for a program I am writing as a newbie to Python. > > I have created a series: > > WORDS = ("python", "program", "code", "xylophone") > > and then assigned one of them randomly to the variable 'word': > > word = random.choice(WORDS) > > I know tha

Re: [Tutor] Indexing in a series for a newbie

2006-01-19 Thread Pujo Aji
Hello Jon,Why don't use randint so you can record the index and the value Example:    WORDS = ("python", "program", "code", "xylophone")    Indword = random.randint (0,len(WORDS)-1)    word = WORDS[Indword]    print Indword    print wordCheers,pujoOn 1/19/06, Jon Moore < [EMAIL PROTECTED]> wrote:He

[Tutor] Indexing in a series for a newbie

2006-01-19 Thread Jon Moore
HelloI need some help for a program I am writing as a newbie to Python.I have created a series:WORDS = ("python", "program", "code", "xylophone") and then assigned one of them randomly to the variable 'word':word = random.choice(WORDS)I know that if I do: print wordThe randomly chosen word will be

Re: [Tutor] Python + MySQL , my first simple program does not gives results

2006-01-19 Thread Pujo Aji
You should fetch the results.   try:    result = cursor.fetchall()   print result Cheers,pujo import MySQLdbclass learnpython_db:def __init__(self): db =MySQLdb.connect(host="localhost",user ="john",password = "asdlkj", db = learnpython)cursor = db.cursor(

[Tutor] Python + MySQL , my first simple program does not gives results

2006-01-19 Thread John Joseph
Hi I tried out my first Pyhton program with MySQL I was trying to get the some result , eg describe table, select * from table but my program does not give the expected results , nor it gives any error I am adding my code in this mail P

Re: [Tutor] a class knowing its self

2006-01-19 Thread Ewald Ertl
Hi! Ben Vinger wrote: > Hello > > I've been reading about how a class has access to its > own 'self', so I tried the following, but it is not > working as I would expect: > > class Skill: >def __init__(self): > self.history = [] > >def setName(self, skill): > self.nam

Re: [Tutor] Links for programming using MySQL

2006-01-19 Thread Wolfram Kraus
John Joseph wrote: > Hi I wanted to try out python with MySQL databases , I would like > to get info about the link to sites , which gives you examples on how > to do python programming by using MySQL database Please guide > Thanks Joseph John > > Try this one: http://sourceforge.net/docman/

Re: [Tutor] Open file error

2006-01-19 Thread Kent Johnson
andy senoaji wrote: > Thanks Danny & Alan, > > your print repr(os.listdir("C:/")) has embarrased myself :(. I found out > the file name is Test.txt.txt in my c: drive. I guess I learn something > here. If you tell Windows not to hide file extensions you won't make that mistake again. On my com

[Tutor] Links for programming using MySQL

2006-01-19 Thread John Joseph
Hi I wanted to try out python with MySQL databases , I would like to get info about the link to sites , which gives you examples on how to do python programming by using MySQL database Please guide Thanks Joseph John