Re: [Tutor] Converting code to string

2007-08-24 Thread Bernard Lebel
Actually, regarding inspect.getsource() that raised IOErrors: Running it from imported module actually works! Thanks Bernard ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Converting code to string

2007-08-24 Thread Bernard Lebel
. Here is an example of such a plugin: # Load plugin in XSI def XSILoadPlugin( in_reg ): in_reg.Author = Bernard Lebel in_reg.Name = plugindemo in_reg.Major = 1 in_reg.Minor = 1 in_reg.RegisterProperty( propertyplugindemo ) return True # Define property

[Tutor] Converting code to string

2007-08-23 Thread Bernard Lebel
Hello, I'm looking for a way to convert Python code into a string. For example, let say I have this function: def myFunc(): print 'hello world' Now in the same module, I'd like to take this function and convert it into a string: def myFunc(): print 'hello world'\n Thanks Bernard

Re: [Tutor] Converting code to string

2007-08-23 Thread Bernard Lebel
toString() method in mind, which works beautifully. I'm looking to do the same in Python. Thanks! Bernard On 8/23/07, Kent Johnson [EMAIL PROTECTED] wrote: Bernard Lebel wrote: Hello, I'm looking for a way to convert Python code into a string. For example, let say I have this function

[Tutor] Regular expression questions

2007-05-03 Thread Bernard Lebel
Hello, Once again struggling with regular expressions. I have a string that look like something_shp1. I want to replace _shp1 by _shp. I'm never sure if it's going to be 1, if there's going to be a number after _shp. So I'm trying to use regular expression to perform this replacement. But I

Re: [Tutor] Regular expression questions

2007-05-03 Thread Bernard Lebel
Thanks a lot Kent, that indeed solves the issues altogether. Cheers Bernard On 5/3/07, Kent Johnson [EMAIL PROTECTED] wrote: Bernard Lebel wrote: Hello, Once again struggling with regular expressions. I have a string that look like something_shp1. I want to replace _shp1 by _shp

Re: [Tutor] FW: isinstance - instance

2007-02-26 Thread Bernard Lebel
Hansen Sent: Monday, February 26, 2007 2:43 PM To: 'Bernard Lebel' Subject: RE: [Tutor] isinstance - instance -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Bernard Lebel Sent: Monday, February 26, 2007 2:34 PM To: Tutor Subject

Re: [Tutor] FW: isinstance - instance

2007-02-26 Thread Bernard Lebel
Okay. right now I'm using types.InstanceType approach. To elaborate on the context of my question, I have this module whose only job is to test an object against a large array of types. The thing is that I never know in advance what is going to be the data, and it could be just about

[Tutor] Calling instance method using a string

2006-11-09 Thread Bernard Lebel
Hello, Is there a way to call an instance method using a string? Let say I have the method name in the form of a string, and I want to call this method by providing the string instead of calling the name directly. Is this possible? Say I have class A: class A: def myMethod( self ):

Re: [Tutor] Calling instance method using a string

2006-11-09 Thread Bernard Lebel
Thanks everyone for the advice. Bernard On 11/9/06, Danny Yoo [EMAIL PROTECTED] wrote: Say I have class A: class A: def myMethod( self ): print 'foo' a = A() getattr(a, 'myMethod')() The getattr() call gets the bound method, the extra parentheses at the end

[Tutor] Importing module - file system requests

2006-10-17 Thread Bernard Lebel
Hello, When I import a module in Python, I see that 6 file system operation are being made. All requests are for opening. I know very well what are the .py and and .pyc files. But I'm not so sure what are .pyd and .pyw, and why it's looking for a dll. Anyone can shed some light on this? Also, if

[Tutor] OT: Book(s) about linux

2006-10-05 Thread Bernard Lebel
Hello, Sorry to use this list for such an OT subject. But I want to get hands down with Linux, and am looking for a book or two on the subject. I'm looking for information about installation, configuration, optimisation, and management of the Linux OS. Thanks Bernard

[Tutor] Difference between popens

2006-06-09 Thread Bernard Lebel
Hi, I'd like to know what are the differences at the various os.popenX flavors. I read the documentation and I can see they return file objects. so what can you do with these file objects? I mean, why would you need a set of file objects rather than another? Sorry the difference is very not

Re: [Tutor] FileDialogBox in Tkinter

2006-06-05 Thread Bernard Lebel
Hi Phon, This is the most complete Tkinter reference I could find (although it's not exactly complete): http://www.pythonware.com/library/tkinter/introduction/ As to how to make the file dialog box to work, I found this introduction tutorial extremely helpful to get started with the Tkinter

[Tutor] how to use the image option for Button widget in Tkinter

2006-05-29 Thread Bernard Lebel
Hello everyone, I'm looking for a way to put an image on a button in a Tkinter GUI, but for the life of me I just can't find any clear directions about how to do that. No matter where I look, the only documentation I can find is this (Fred Lundz): image (image). The image to display in the

Re: [Tutor] how to use the image option for Button widget in Tkinter

2006-05-29 Thread Bernard Lebel
= oMainFrame ) # Create button oButton = tk.Button( oMainFrame, image = oOPENFOLDER ) oButton.photo = oOPENFOLDER oButton.pack( side = tk.LEFT ) # Launch GUI oMainFrame.mainloop() Cheers Bernard On 5/29/06, Bernard Lebel [EMAIL PROTECTED] wrote: Hello everyone, I'm looking for a way to put

Re: [Tutor] Changing instance attributes in different threads

2006-02-07 Thread Bernard Lebel
[EMAIL PROTECTED] wrote: Bernard Lebel wrote: Hi Kent, I have put together a little script to give a rough idea about what the program does. http://www.bernardlebel.com/scripts/nonxsi/help/bl_threadtest.py In this code, there is no guarantee that callMeWhenAttributeChanged() will see

[Tutor] Changing instance attributes in different threads

2006-02-06 Thread Bernard Lebel
Hello, I have an instance attribute (a few characters string) that two separate threads may change, potentially both at the same time. My program doesn't implement thread safety for this particular task. So far I have never run into issues with this, but I have been reading about data corruption

Re: [Tutor] Changing instance attributes in different threads

2006-02-06 Thread Bernard Lebel
hi Kent, See [Bernard] below. On 2/6/06, Kent Johnson [EMAIL PROTECTED] wrote: Bernard Lebel wrote: Hello, I have an instance attribute (a few characters string) that two separate threads may change, potentially both at the same time. My program doesn't implement thread safety

Re: [Tutor] Changing instance attributes in different threads

2006-02-06 Thread Bernard Lebel
. Thanks Bernard On 2/6/06, Kent Johnson [EMAIL PROTECTED] wrote: Bernard Lebel wrote: Example: - Class instance Bernard has attribute name, whose value is bernard. - A function in a thread tests the value of name. If name == bernard, do nothing. - A function in another thread, for some

Re: [Tutor] Exit a child thread using threading.Thread() object

2006-02-01 Thread Bernard Lebel
Thanks a lot Kent. The exit call would be made from the same thread whose fate is to terminate. Bernard On 1/31/06, Kent Johnson [EMAIL PROTECTED] wrote: Bernard Lebel wrote: A quick question. I have started a child thread using the threading.Thread class. Is there any way to cleanly

[Tutor] Exit a child thread using threading.Thread() object

2006-01-31 Thread Bernard Lebel
A quick question. I have started a child thread using the threading.Thread class. Is there any way to cleanly exit the child thread? What I mean by cleanly is for example if you use the thread.start_new() function to create a child thread, the function running in the child thread can call

Re: [Tutor] Starbucks does not use two-phase commit

2006-01-23 Thread Bernard Lebel
returns to command line input mode. Any idea why those two methods of starting threads can behave so differently? Thanks Bernard On 1/20/06, Bernard Lebel [EMAIL PROTECTED] wrote: Ultra-nice Danny, it works (ie: I have implemented your example in my code and it runs as it should). I have

Re: [Tutor] Starbucks does not use two-phase commit

2006-01-23 Thread Bernard Lebel
Hi Danny, Yes that makes sense, but.. what is a daemon? Sorry if this is super basic question. Thanks Bernard On 1/23/06, Danny Yoo [EMAIL PROTECTED] wrote: I noticed that when I do a keyboard interrupt, I get the keyboard interrupt exception messages, but after that it keeps

Re: [Tutor] Starbucks does not use two-phase commit

2006-01-23 Thread Bernard Lebel
Thanks a lot Danny. Bernard On 1/23/06, Danny Yoo [EMAIL PROTECTED] wrote: On Mon, 23 Jan 2006, Bernard Lebel wrote: Yes that makes sense, but.. what is a daemon? Sorry if this is super basic question. According to: http://docs.python.org/lib/thread-objects.html

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

2006-01-20 Thread Bernard Lebel
see, the main thread and the separateCaller function have mixed results. How can I synchronize the queues? Thanks Bernard On 1/19/06, Bernard Lebel [EMAIL PROTECTED] wrote: Thanks a lot Danny, That certainly does make sense. I'll look into implementing the Queue approach in my

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

2006-01-19 Thread Bernard Lebel
and splitted the code into separate modules. It was tricky to re-wire everything together (it took me at least 4 days), but past that, I'm glad I did it. Thanks everyone for the help, it has been a great learning experience! Bernard On 1/4/06, Bernard Lebel [EMAIL PROTECTED] wrote: Hi Danny

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

2006-01-19 Thread Bernard Lebel
Kent Bernard Lebel wrote: 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

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

Re: [Tutor] pointers

2006-01-11 Thread Bernard Lebel
Hi Burge, You can access command line argument via sys.argv: import sys print sys.argv This prints a list of the command line arguments. Since argv is a list, it means you can check its length to get the argument count: print len( sys.argv ) There is always at least one argument in this list,

[Tutor] glibc error while Python script runs

2006-01-04 Thread Bernard Lebel
Hello, I'm not sure if it's the appropriate place for this question, but since it happens because of a Python script So I have this Python script that runs on render farm nodes. All seem to work well, but at one point I get this crash: rn200.bbfxa.com Wed Jan 4 16:23:36 2006 [jobid: 9]:

Re: [Tutor] glibc error while Python script runs

2006-01-04 Thread Bernard Lebel
Hi Danny, See [Bernard] below... On 1/4/06, Danny Yoo [EMAIL PROTECTED] wrote: rn200.bbfxa.com Wed Jan 4 16:23:36 2006 [jobid: 9]: Get status of all local jobs for this job... *** glibc detected *** double free or corruption: 0x09484d58 *** Aborted Hi Bernard, Ugh. I hate memory

Re: [Tutor] glibc error while Python script runs

2006-01-04 Thread Bernard Lebel
. but not on top I'm affraid for now :-) The next project will start off better, I hope :-) Cheers Bernard On 1/4/06, Kent Johnson [EMAIL PROTECTED] wrote: Bernard Lebel wrote: Here is the script (1550 lines, I know - just wants to get to functional code before improving the design), if it can help

[Tutor] IOError: (0, 'Error')

2006-01-02 Thread Bernard Lebel
Hello, I am getting an IOError, and I have a hard time getting information about its meaning. Here is the full trace stack: Traceback (most recent call last): File X:\FARM\PYTHON\DEV\farmclient_2.0_beta03.py, line 1448, in ? client.start() File

Re: [Tutor] IOError: (0, 'Error')

2006-01-02 Thread Bernard Lebel
( os.path.join( self.nodelogs, '%s.log' % ( self.name ) ), 'a+' ) self.nodelog.write( sPrint ) self.nodelog.close() Bernard On 1/2/06, Bernard Lebel [EMAIL PROTECTED] wrote: The __nodeLog() method looks like this: On 1/2/06, Bernard Lebel [EMAIL PROTECTED] wrote: Hello

Re: [Tutor] IOError: (0, 'Error')

2006-01-02 Thread Bernard Lebel
The __nodeLog() method looks like this: On 1/2/06, Bernard Lebel [EMAIL PROTECTED] wrote: Hello, I am getting an IOError, and I have a hard time getting information about its meaning. Here is the full trace stack: Traceback (most recent call last): File X:\FARM\PYTHON\DEV

Re: [Tutor] IOError: (0, 'Error')

2006-01-02 Thread Bernard Lebel
On 1/2/06, Danny Yoo [EMAIL PROTECTED] wrote: Everytime the program has to add a line is added to the file, the file is open, appended, then closed, in order to be able to read it at any point in time. This set of operations can happen several times a second, like 1-10 or so. In this

Re: [Tutor] IOError: (0, 'Error')

2006-01-02 Thread Bernard Lebel
Hi Kent, I'm checking out the logging module atm. I'm trying the second example in Basic example: import logging logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)s %(message)s', filename='C:\\pylogger.log',

Re: [Tutor] Performance of Python loops vs multiple MySQL queries

2005-12-22 Thread Bernard Lebel
On 12/21/05, Kent Johnson [EMAIL PROTECTED] wrote: Bernard Lebel wrote: Hello, Finally, after a year and a half of learning and messing around with Python, I'm writing THE code that made learn Python in the first place: a render farm client management software. I may have several

Re: [Tutor] Performance of Python loops vs multiple MySQL queries

2005-12-22 Thread Bernard Lebel
Thanks for all the advice Kent. Bernard On 12/22/05, Kent Johnson [EMAIL PROTECTED] wrote: Bernard Lebel wrote: On 12/21/05, Kent Johnson [EMAIL PROTECTED] wrote: - Don't assume there is going to be a problem. [Bernard] Okay perhaps by problem I have not been very accurate. I

[Tutor] Performance of Python loops vs multiple MySQL queries

2005-12-21 Thread Bernard Lebel
Hello, Finally, after a year and a half of learning and messing around with Python, I'm writing THE code that made learn Python in the first place: a render farm client management software. I may have several questions regarding this, but for now I only have one. The script I'm writing is the

[Tutor] Name tables questions

2005-12-18 Thread Bernard Lebel
Hello, I have a few theoric questions regarding name tables. I wish to better understand a few things about this aspect of Python, in particular how module names and the import statements fit into the picture of name tables. - First of all, I understand each scope has its local name table,

Re: [Tutor] Using lists as table-like structure

2005-11-17 Thread Bernard Lebel
Thanks to everyone for the answers. I'll definitely check Numeric Python. Cheers Bernard On 11/16/05, Danny Yoo [EMAIL PROTECTED] wrote: On Wed, 16 Nov 2005, Bernard Lebel wrote: Let say I have a list of lists. Each individual lists have a bunch of elements. Now I would like

[Tutor] Using lists as table-like structure

2005-11-16 Thread Bernard Lebel
Hello, I am wondering if can do this: Let say I have a list of lists. Each individual lists have a bunch of elements. Now I would like to either get or set the first element of each individual list. I could do a loop and/or list comprehension, but I was wondering if it was possible with

[Tutor] Finding wich word matched in a OR re

2005-11-10 Thread Bernard Lebel
Hello, I have compiled this regular expression, with 3 strings. Basically it looks like this. r'word1|word2|word3' The point is to try to match one of these words in a string. Now let say I indeed got a match in a string. How can I find out wich one, between word1-word2-word3 has the string

Re: [Tutor] Finding wich word matched in a OR re

2005-11-10 Thread Bernard Lebel
Never mind, just came accross groups of the match object. Can't believe there is such a nice feature! Cheers Bernard On 11/10/05, Bernard Lebel [EMAIL PROTECTED] wrote: Hello, I have compiled this regular expression, with 3 strings. Basically it looks like this. r'word1|word2|word3

Re: [Tutor] RSH?

2005-11-03 Thread Bernard Lebel
I use plink http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html Basically you send a system command (os.system) to the plink executable. The actuall command will take this form: os.system( 'plink -pw %s -ssh [EMAIL PROTECTED] %s' % ( password, user, hostIP, command ) ) Now, if you

Re: [Tutor] Decompile pyc file

2005-10-20 Thread Bernard Lebel
Sorry for the late reply. Thanks a lot Kent, that was really helpful. Bernard On 10/14/05, Kent Johnson [EMAIL PROTECTED] wrote: Bernard Lebel wrote: Hello, Is there a way to decompile a pyc file? I have a big problem where the py file was lost, but the pyc file is instact. I would

[Tutor] Decompile pyc file

2005-10-14 Thread Bernard Lebel
Hello, Is there a way to decompile a pyc file? I have a big problem where the py file was lost, but the pyc file is instact. I would need to extract the source code from the pyc file. Thanks for any suggestion Beranrd ___ Tutor maillist -

Re: [Tutor] pywin32 under Win64

2005-10-02 Thread Bernard Lebel
Oh, thanks Danny! Bernard On 10/2/05, Danny Yoo [EMAIL PROTECTED] wrote: On Sun, 2 Oct 2005, Bernard Lebel wrote: I'm considering switching to Windows 64bit. However I was wondering if anyone on this list have been using the pywin32 extension (or any win32com-related package

Re: [Tutor] pywin32 under Win64

2005-10-02 Thread Bernard Lebel
Still, anyone has tried Python on Win64? Thanks Berrnard On 10/2/05, Bernard Lebel [EMAIL PROTECTED] wrote: Oh, thanks Danny! Bernard On 10/2/05, Danny Yoo [EMAIL PROTECTED] wrote: On Sun, 2 Oct 2005, Bernard Lebel wrote: I'm considering switching to Windows 64bit. However I

Re: [Tutor] Problem with BeautifulSoup

2005-09-30 Thread Bernard Lebel
', 'parameters', 'parameter', 'shader'] Not super-elegant but it works. I wrote to the author but did not get an answer. Thanks everyone! Bernard On 9/28/05, Kent Johnson [EMAIL PROTECTED] wrote: Bernard Lebel wrote: Hi Kent, Thanks a lot for that answer. I have had a look at the BS code

[Tutor] Flattening multi-dimentional list

2005-09-28 Thread Bernard Lebel
Hello, I have this list wich is made of tuples. I wish I could flatten this list, that is, to extract each element in the tuples and build a new flat list with it. Is there any shortcut to do that or do I have to go through some list comprehension-like procedure? (I have looked at sets but I

Re: [Tutor] Flattening multi-dimentional list

2005-09-28 Thread Bernard Lebel
Thanks a lot Danny. Bernard On 9/28/05, Danny Yoo [EMAIL PROTECTED] wrote: On Wed, 28 Sep 2005, Bernard Lebel wrote: I have this list wich is made of tuples. I wish I could flatten this list, that is, to extract each element in the tuples and build a new flat list

Re: [Tutor] Problem with BeautifulSoup

2005-09-28 Thread Bernard Lebel
these nesting issues. I fact I have a whole bunch of tags that I need to make nestable Thanks Bernard On 9/26/05, Kent Johnson [EMAIL PROTECTED] wrote: Bernard Lebel wrote: Hi grouchy, I seem to have found the problem. Somehow, it seems BeautifulSoup doesn't like nested tags of the same name

Re: [Tutor] Quick way to find the data type

2005-09-27 Thread Bernard Lebel
Thanks a lot Chris. Bernard On 9/27/05, Christopher Arndt [EMAIL PROTECTED] wrote: Bernard Lebel schrieb: Hello, Let say I have a string. The value of the string might be 'False', 'True', '3', '1.394', or whatever else. Is there a quick way to convert this string

Re: [Tutor] Quick way to find the data type

2005-09-27 Thread Bernard Lebel
Well I understand all the security issues but unless I'm missing something, I don't see anything wrong here. This is in order to read some XML data and transfer its content to the parameters of a 3D animation software. Since I wrote the XML writer, I always know how the XML will be formatted.

[Tutor] Problem with BeautifulSoup

2005-09-23 Thread Bernard Lebel
Hello, I have this set of XML tags: parameter scriptname=posx fullname=Model.Camera_anim.kine.local.posx type=Parameter sourceclassname=FCurve fcurve plotted=False parameters parameter scriptname=extrapolation1/parameter parameter

Re: [Tutor] Problem with BeautifulSoup

2005-09-23 Thread Bernard Lebel
parameter scriptname=lowclamp- 1.79769313486e+308 /parameter parameter scriptname=nokeyvalue7.64880829803 /parameter parameter scriptname=si3dstyleFalse /parameter parameter scriptname=type20 /parameter? On 9/23/05, Bernard Lebel [EMAIL PROTECTED] wrote: Hello, I have

Re: [Tutor] Maths: getting degrees from radians (or am I wrong?)

2005-09-21 Thread Bernard Lebel
Okay thanks a lot everyone. Bernard On 9/20/05, Kent Johnson [EMAIL PROTECTED] wrote: Bernard Lebel wrote: Hello, I have this little math problem. I have this formula from wich I get a dot product between two vectors. cos(ß) = A.B / |A|.|B| = -0.0634 So this would give me

[Tutor] Maths: getting degrees from radians (or am I wrong?)

2005-09-20 Thread Bernard Lebel
Hello, I have this little math problem. I have this formula from wich I get a dot product between two vectors. cos(ß) = A.B / |A|.|B| = -0.0634 So this would give me radians, right? Then if I use math.degrees( -0.0634 ) This gives me a value of -3.6325524211294193. However I have a book in

Re: [Tutor] ElementTree: finding a tag with specific attribute

2005-09-19 Thread Bernard Lebel
Thanks a lot everyone for this! Glad I could help debug BS! Bernard On 9/19/05, Kent Johnson [EMAIL PROTECTED] wrote: Kent Johnson wrote: I looked at this again and there is a bug in BS that causes this behaviour. It's kind of an interesting bug that is a side-effect of the way BS uses

Re: [Tutor] ElementTree: finding a tag with specific attribute

2005-09-19 Thread Bernard Lebel
Well I have just retested BS with my XML file and now it's much, much faster (I would say instantaneous). Bernard On 9/19/05, Kent Johnson [EMAIL PROTECTED] wrote: Kent Johnson wrote: I looked at this again and there is a bug in BS that causes this behaviour. It's kind of an interesting

Re: [Tutor] ElementTree: finding a tag with specific attribute

2005-09-16 Thread Bernard Lebel
Thanks Kent, I'll check your suggestion out. I have sent you the xml file. Bernard On 9/16/05, Kent Johnson [EMAIL PROTECTED] wrote: Bernard Lebel wrote: Hello, With ElementTree, can you search a tag under an Element by not only specifying the tag label, but also some tag attribute

Re: [Tutor] ElementTree: finding a tag with specific attribute

2005-09-16 Thread Bernard Lebel
Kent, sorry to send you back your request, I won't access to file until Monday, so either you send it to Danny, either Dannay waits until Monday. I'm fine with you sending the file to Danny. Guys let me know if Danny receives the file, I'll send it Monday if not. And thanks for looking into this,

Re: [Tutor] Another regular expression question

2005-09-14 Thread Bernard Lebel
Thanks Alan, I'll check BeautifulSoup asap. I'm using regex simply because I have no clue where to start to parse XML. I have read the various xml tools available in the Python library, however I'm a complete loss at what to make out of them. Many of them seem to use some programming standards,

Re: [Tutor] Another regular expression question

2005-09-14 Thread Bernard Lebel
seconds or so? Thanks Bernard On 9/14/05, Kent Johnson [EMAIL PROTECTED] wrote: Bernard Lebel wrote: Thanks Alan, I'll check BeautifulSoup asap. I'm using regex simply because I have no clue where to start to parse XML. I have read the various xml tools available in the Python

Re: [Tutor] Another regular expression question

2005-09-14 Thread Bernard Lebel
The file size is 112 Kb. Most lines look this way: parameter name=roty type=Parameter sourceclassname=nosource I'll give a try to ElementTree. Bernard On 9/14/05, Kent Johnson [EMAIL PROTECTED] wrote: Bernard Lebel wrote: Thanks for that pointer Kent, I'll check it out. Also thanks

Re: [Tutor] Another regular expression question

2005-09-14 Thread Bernard Lebel
PROTECTED] wrote: Bernard Lebel wrote: The file size is 112 Kb. Most lines look this way: parameter name=roty type=Parameter sourceclassname=nosource I'll give a try to ElementTree. To get you started: from elementtree import ElementTree doc = ElementTree.parse('myfile.xml

[Tutor] Retrieving the text of a XML tag with ElementTree

2005-09-14 Thread Bernard Lebel
Hello, Let say I have this XML chunk: ?xml version=1.0? root sceneobject name=Camera_Root fullname=Camera_Root type=CameraRoot properties property name=Visibility fullname=Camera_Root.visibility type=visibility parameters parameter scriptname=viewvis

[Tutor] Another regular expression question

2005-09-13 Thread Bernard Lebel
Hello, yet another regular expression question :-) So I have this xml file that I'm trying to find a specific tag in. For this I'm using a regular expression. Right now, the tag I'm trying to find looks like this: sceneobject name=Camera_Root_bernard type=CameraRoot So I'm using a regular

[Tutor] Partly OT: order of renaming files and directories

2005-09-12 Thread Bernard Lebel
Hello, I'm creating a script that will rename directories and files (hence the regular expression thing I asked about last week). I just wanted to ask if there is a recommended order to rename stuff, because I want to avoid any potential problem. What I mean: I traverse some areas of the file

Re: [Tutor] Partly OT: order of renaming files and directories

2005-09-12 Thread Bernard Lebel
Thanks Kent! Bernard On 9/12/05, Kent Johnson [EMAIL PROTECTED] wrote: Bernard Lebel wrote: Hello, I'm creating a script that will rename directories and files (hence the regular expression thing I asked about last week). I just wanted to ask if there is a recommended order to rename

Re: [Tutor] Substring substitution

2005-09-09 Thread Bernard Lebel
. Thanks a lot!! Bernard On 9/8/05, Kent Johnson [EMAIL PROTECTED] wrote: Bernard Lebel wrote: Ok I think I understand what is going: I'm using a 0 in the replacement argument, between the two groups. If I try with a letter or other types of characters it works fine. So how can use a digit

[Tutor] Substring substitution

2005-09-08 Thread Bernard Lebel
Hello, I have a string, and I use a regular expression to search a match in it. When I find one, I would like to break down the string, using the matched part of it, to be able to perform some formatting and to later build a brand new string with the separate parts. The regular expression part

Re: [Tutor] Substring substitution

2005-09-08 Thread Bernard Lebel
PROTECTED] wrote: Bernard Lebel wrote: Hello, I have a string, and I use a regular expression to search a match in it. When I find one, I would like to break down the string, using the matched part of it, to be able to perform some formatting and to later build a brand new string

Re: [Tutor] Substring substitution

2005-09-08 Thread Bernard Lebel
Ok I think I understand what is going: I'm using a 0 in the replacement argument, between the two groups. If I try with a letter or other types of characters it works fine. So how can use a digit here? Thanks Bernard On 9/8/05, Bernard Lebel [EMAIL PROTECTED] wrote: Hi Kent, This is nice

[Tutor] Recursive function calling

2005-08-24 Thread Bernard Lebel
Hello, Sorry in advance for the long email. I have a two-part script. The first parts creates a structure made of nested lists. Some of these lists have only strings, other have other lists. Anyway the point is to ultimately write this structure as a XML file. Here is the script that builds

[Tutor] Using join instead of string.joinfield

2005-08-23 Thread Bernard Lebel
Hello, The documentation says that the built-in join method now replaces the string.joinfield function. However how do you achieve the same operation? The join method accepts only one argument, that is, the list of strings to join. How do you then specify the separating character? Thanks

Re: [Tutor] Using join instead of string.joinfield

2005-08-23 Thread Bernard Lebel
= '-' print sep_char.join(a_list) this-is-a-list-of-words *g* -Original Message- From: Bernard Lebel [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 23, 2005 11:04 AM To: Python Tutor list Subject: [Tutor] Using join instead of string.joinfield Hello, The documentation says

Re: [Tutor] SSH commands in Python on Linux

2005-08-11 Thread Bernard Lebel
Ok thanks everyone for the recommandations, I'll check them out. Bernard On 8/11/05, Jesse Noller [EMAIL PROTECTED] wrote: On 8/10/05, Bernard Lebel [EMAIL PROTECTED] wrote: Hello, I'm trying to make a script to send a SSH command from a Linux computer to another Linux compter

[Tutor] SSH commands in Python on Linux

2005-08-10 Thread Bernard Lebel
Hello, I'm trying to make a script to send a SSH command from a Linux computer to another Linux compter. The Python syntax I'm using... import os os.system( 'ssh [EMAIL PROTECTED] ls' ) Now the problem is that I'm always asked for the password. So my question is two-fold: 1- Is there a way

[Tutor] Functional question

2005-08-05 Thread Bernard Lebel
Hello, This question is not strictly bound to Python, but rather some functional programming problem, I hope someone can help me or suggest ressources. 1 -- I have a list of lists. Each of these lists has 3 elements: a string, and two integers. Thoughout the lists, there are only two different

Re: [Tutor] Functional question

2005-08-05 Thread Bernard Lebel
it. Thanks again. Bernard On 8/5/05, Kent Johnson [EMAIL PROTECTED] wrote: Bernard Lebel wrote: Hello, This question is not strictly bound to Python, but rather some functional programming problem, I hope someone can help me or suggest ressources. 1 -- I have a list of lists. Each

[Tutor] CVS for Python

2005-08-03 Thread Bernard Lebel
Hello, Does anyone can recomment a good CVS for Python? Thanks Benrard ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] CVS for Python

2005-08-03 Thread Bernard Lebel
Okay sorry for not being clear. I meant CVS for my own Python scripts. Right now, when I make a change to an existing script, I copy it into an old directory, rename with to append the version number, and overrwrite the actual script with the new version. This works well but sometimes is a pain

Re: [Tutor] Dynamically populate Tkinter OptionMenu with list

2005-07-21 Thread Bernard Lebel
Thanks John. Bernard On 7/20/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Quoting Bernard Lebel [EMAIL PROTECTED]: I have this problem. I build a list of elements, and I never know in advance how many or what will be the elements. I then wish to populate an OptionMenu

[Tutor] Tkinter event for changing OptionMenu items

2005-07-21 Thread Bernard Lebel
Hello, I'm trying to bind an event to the changes made to an OptionMenu. Ie the user chooses a different item, the rest of the Tk window gets updated. To repopulate the window, a function would be called by the binding. Any suggestion? var1 = StringVar() var1.set( aTables[0] ) oOptionMenu =

Re: [Tutor] Tkinter event for changing OptionMenu items

2005-07-21 Thread Bernard Lebel
and repopulates it with new fields. My problem is binding this callback to the event of choosing an item. Bernard On 7/21/05, Michael Lange [EMAIL PROTECTED] wrote: On Thu, 21 Jul 2005 12:19:00 -0400 Bernard Lebel [EMAIL PROTECTED] wrote: Hello, I'm trying to bind an event to the changes made

Re: [Tutor] Tkinter: justify label

2005-07-20 Thread Bernard Lebel
Awesome, thanks a bunch! Bernard On 7/19/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Quoting Bernard Lebel [EMAIL PROTECTED]: Can you specify a justification for a label widget? I'm reading there is a justify option available on this page: http://www.pythonware.com/library/tkinter

[Tutor] Dynamically populate Tkinter OptionMenu with list

2005-07-20 Thread Bernard Lebel
Hello, I have this problem. I build a list of elements, and I never know in advance how many or what will be the elements. I then wish to populate an OptionMenu with this list of elements. How can I do that? The reason I'm asking is I'm building a little GUI to enter records in a SQL table. I

[Tutor] Tkinter: justify label

2005-07-19 Thread Bernard Lebel
Hello, Can you specify a justification for a label widget? I'm reading there is a justify option available on this page: http://www.pythonware.com/library/tkinter/introduction/x611-text-formatting.htm Although I don't know if this option works for label. If I try for sField

[Tutor] SQL headache with column

2005-07-19 Thread Bernard Lebel
Hello, Not sure if it's a Python thing, but... When sending command to the MySQL server by command line, I can use SHOW COLUMNS FROM tablename, the list of all columns with a bunch of properties is printed. However, when I run the same command from Python and I store the result, the result is

Re: [Tutor] SQL headache with column

2005-07-19 Thread Bernard Lebel
Ah yeah I to mention that I indeed tried fetchall(), but Python would raise an attribute error: def getTableColumns( sTableName ): Lists and returns the list of columns from a given table. oConnection = connect2db() oCursor = oConnection.cursor()

[Tutor] Creating MySQL table

2005-07-18 Thread Bernard Lebel
Hello, How do I create a MySQL table in Python? Here is what I'm trying: import MySQLdb as sql def connect2db(): return sql.connect( blah blah blah ) oConnection = connect2db() oCursor = oConnection.cursor() sQuery = CREATE TABLE '3DPipeline'.'TB_MT_NAME' (;\ 'ID' INTEGER UNSIGNED

Re: [Tutor] Creating MySQL table

2005-07-18 Thread Bernard Lebel
See [Bernard] On 7/18/05, Don Parris [EMAIL PROTECTED] wrote: On 7/18/05, Bernard Lebel [EMAIL PROTECTED] wrote: Hello, How do I create a MySQL table in Python? Here is what I'm trying: import MySQLdb as sql def connect2db(): return sql.connect( blah blah blah

Re: [Tutor] Catching OLE error

2005-07-15 Thread Bernard Lebel
Thanks Danny. Bernard On 7/14/05, Danny Yoo [EMAIL PROTECTED] wrote: So the errors are getting raised before Python even knows there is a problem, so it cannot catch them in an except block. From my very limited expoerience of COM programming I'd guess that there is a type

Re: [Tutor] Catching OLE error

2005-07-14 Thread Bernard Lebel
' and 'str' TypeError would be the exception so you would have: try: None + foo except: TypeError On 7/14/05, Bernard Lebel [EMAIL PROTECTED] wrote: Hello, A simple question: what is the syntax in a try/except for the OLE error? Let say you want to catch OLE error

Re: [Tutor] Catching OLE error

2005-07-14 Thread Bernard Lebel
work you could just get rid of the OLEError bit and all errors will be ignored. On 7/14/05, Bernard Lebel [EMAIL PROTECTED] wrote: Very well. #INFO : NewRenderShot importAnimation :: Import action for character ... #ERROR : 2000 - Argument 0 (Source) is invalid #ERROR : 2001

Re: [Tutor] Catching OLE error

2005-07-14 Thread Bernard Lebel
Thanks Alan, I'll check it out. Cheers Bernard On 7/14/05, Alan G [EMAIL PROTECTED] wrote: Isn't the OLEError alike the ValueError, KeyError and so on? If so shouldn't it go before the colon? The problem, as I understand it, is that OLEError is not coming from Python but from COM.

  1   2   >