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
document is closed and reopen. 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.RegisterPr

Re: [Tutor] Converting code to string

2007-08-23 Thread Bernard Lebel
into the GUI object. Since the XSI API also supports JScript, it is my feeling that this part of the GUI toolkit was designed with JScript's toString() method in mind, which works beautifully. I'm looking to do the same in Python. Thanks! Bernard On 8/23/07, Kent Johnson <

[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 Bern

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 lo

[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. Bu

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 anything

Re: [Tutor] FW: isinstance -> instance

2007-02-26 Thread Bernard Lebel
ed all. > > > -Original Message- > > From: Mike Hansen > > Sent: Monday, February 26, 2007 2:43 PM > > To: 'Bernard Lebel' > > Subject: RE: [Tutor] isinstance -> instance > > > > > > > > > -Original Message- >

[Tutor] isinstance -> instance

2007-02-26 Thread Bernard Lebel
Hello, Following the guidelines here, at the bottom of the page: http://www.python.org/dev/peps/pep-0008/ I'm using isinstance() to test the type of some data. Now the thing is that, what is the name to use for a class instance? For example, say I run this: class A: def __init__( 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

[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 ): p

[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 __

Re: [Tutor] Difference between popens

2006-06-09 Thread Bernard Lebel
misspellings.extend(reverse_dict[value]) > close_stdout.close() # tells other program we're finished reading from > it > return misspellings > > I hope this discussion answers your questions and hasn't been too beneath > you. :) Some of it might be arcane hi

[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 c

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 wid

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

2006-05-29 Thread Bernard Lebel
ile = sOPENFOLDER, master = 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 e

[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 widge

Re: [Tutor] Changing instance attributes in different threads

2006-02-07 Thread Bernard Lebel
hnson <[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_threadte

Re: [Tutor] Changing instance attributes in different threads

2006-02-06 Thread Bernard Lebel
he value in order to control its flow. Hope I'm making sense. 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&quo

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. > &

[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] 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

[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 threa

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

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

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

2006-01-23 Thread Bernard Lebel
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 to admit that I

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

2006-01-20 Thread Bernard Lebel
1002 --Separate caller got 1002 Server does 1003 Main thread got 1003 Main thread asks b Server does b Main thread got b Main thread asks c Server does c Main thread got c As you can see, the main thread and the separateCaller function have mixed results. How can I "synchronize" the queue

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 Bernard Lebel
nd queue to return results to the main thread. Thanks I'll check these out. Bernard > > Kent > > Bernard Lebel wrote: > > Hello, > > > > For the record, in case anyone would like to know what happened with > > this issue... > > > > > >

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

2006-01-19 Thread Bernard Lebel
ram design 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 <[E

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,

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

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, > > Ug

[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] IOError: (0, 'Error')

2006-01-03 Thread Bernard Lebel
On 1/2/06, Kent Johnson <[EMAIL PROTECTED]> wrote: > Bernard Lebel wrote: > > I'm checking out the logging module atm. I'm trying the second example > > in "Basic example": > > > > import logging > > > > logging.basicConfig

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', fi

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.

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): > &

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

2006-01-02 Thread Bernard Lebel
self.nodelog = file( 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() me

[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 "X:\FARM\PYTHON\DEV\farmclient_2.0_beta0

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. > > > > > > [Be

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

[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 cli

[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, cont

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

[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 something

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 > l

[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 be

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 > >

[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 - Tutor@pyt

Re: [Tutor] Getting name scope

2005-10-05 Thread Bernard Lebel
': oMesh = oSel Application.logmessage( oMesh.name ) #Output #INFO : sphere So then the question arised if it was possible in Python to know to what scope a name belongs. I don't know any use for this, but I just wanted to know it was possible. Thanks! Bernard On 10/5/05, Kent Johnson <[EMAIL

[Tutor] Getting name scope

2005-10-05 Thread Bernard Lebel
Hello, Anyone know if it is possible to find out in what scope lies a name? For instance, let say I'm using a name in a function, but the name is actually in the global scope. I would like to know if this name was found in what scope. Is it possible at all? Thanks Bernard ___

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 Leb

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 ext

[Tutor] pywin32 under Win64

2005-10-02 Thread Bernard Lebel
Hello, 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/distribution for that matter) on Win64. Possibly the pywin*32* thing is making me cautious, but that not be nice if I find out I

Re: [Tutor] Problem with BeautifulSoup

2005-09-30 Thread Bernard Lebel
27;, 'shader'] > NESTABLE_TAGS = buildTagMap([], NESTABLE_BLOCK_TAGS) > > > Bernard Lebel wrote: > > I know I should be doing that. But somehow it doesn't work (ie I keep > > getting mangled XML tree). > > > > Bernard > > > > > > > >

Re: [Tutor] Problem with BeautifulSoup

2005-09-30 Thread Bernard Lebel
I know I should be doing that. But somehow it doesn't work (ie I keep getting mangled XML tree). Bernard On 9/30/05, Kent Johnson <[EMAIL PROTECTED]> wrote: > Bernard Lebel wrote: > > Hi Kent, > > > > Well I have decided to get this sorted once and fo

Re: [Tutor] Problem with BeautifulSoup

2005-09-30 Thread Bernard Lebel
GS = ['blockquote', 'div', 'fieldset', 'ins', 'del', 'sceneobject', 'parameters', 'parameter', 'shader'] Not super-elegant but it works. I wrote to the author but did not get an answer. Thanks everyone! Be

Re: [Tutor] Flattening multi-dimentional list

2005-09-29 Thread Bernard Lebel
Thanks for the examples and references everyone. I should clarify though that I was simply looking for a *built-in* feature rather than a function or a list-comprehension. I know these last two works and I currently use a list comprehension. # Example: >>> flatten( [ 1, 3, 4, ('allo', 'bonjour',

Re: [Tutor] Problem with BeautifulSoup

2005-09-28 Thread Bernard Lebel
, but I kept having 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

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 t

[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 ha

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

2005-09-27 Thread Bernard Lebel
Fair enough Danny, I made the changes. Thanks for the input. Still, regarding this comment. On 9/27/05, Danny Yoo <[EMAIL PROTECTED]> wrote: > The assumptions you make, about controlling the input, and being the only > source of the xml output, sound fine. But you're assuming that the > env

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. Also

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'

[Tutor] Quick way to find the data type

2005-09-27 Thread Bernard Lebel
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 into the appropriate data type other than with try/except? Thanks Bernard ___ Tutor maillist

Re: [Tutor] Problem with BeautifulSoup

2005-09-23 Thread Bernard Lebel
> > 1 > > 3 > > 1.79769313486e+308 > > False > > - 1.79769313486e+308 > > 7.64880829803 > > False > > 20 > ? > >>> > > > > > On 9/23/05, Ber

[Tutor] Problem with BeautifulSoup

2005-09-23 Thread Bernard Lebel
Hello, I have this set of XML tags: 1 3 1.79769313486e+308 False -1.79769313486e+308 7.64880829803 False 20

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. > > > >

[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 fr

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 intere

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

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] 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 > > s

[Tutor] ElementTree: finding a tag with specific attribute

2005-09-16 Thread Bernard Lebel
Hello, With ElementTree, can you search a tag under an Element by not only specifying the tag label, but also some tag attribute values? That would be in the case where I have several tags with the same label but with various attribute values. Right now I do a loop over every tag of the same labe

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

2005-09-14 Thread Bernard Lebel
Oops, false alarm. I was reading the wrong tag (the tag instead of a one). Sorry! Bernard On 9/14/05, Bernard Lebel <[EMAIL PROTECTED]> wrote: > Hello, > > Let say I have this XML chunk: > > > > > > > >type="v

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

2005-09-14 Thread Bernard Lebel
Hello, Let say I have this XML chunk: False I wish to retrieve the "False" between the opening/closing tags. I thought I could use something like: from elementtree.ElementTree import parse oTree = parse( r'C:\temp\Camera_Root.xml' ) for oXMLObject in oT

Re: [Tutor] Another regular expression question

2005-09-14 Thread Bernard Lebel
Johnson <[EMAIL PROTECTED]> wrote: > Bernard Lebel wrote: > > The file size is 112 Kb. Most lines look this way: > > > > > > > > > > I'll give a try to ElementTree. > > To get you started: > > from elementtree import Element

Re: [Tutor] Another regular expression question

2005-09-14 Thread Bernard Lebel
The file size is 112 Kb. Most lines look this way: 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 for > > letting me know I

Re: [Tutor] Another regular expression question

2005-09-14 Thread Bernard Lebel
it takes 20-30 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 p

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, w

[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: So I'm using a regular expression to find: sceneobject type="CameraRoot" My cod

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 wante

[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 ser

Re: [Tutor] Substring substitution

2005-09-09 Thread Bernard Lebel
:\temp\MT_03_04_004\mt_03_04_004_anim_v1.scn C:\temp\MT_03_05_005_anim\mt_03_05_005_anim_v1.scn C:\temp\MT_03_06_006\mt_03_06_006_anim_v1.scn This is exactly what I was after. Thanks a lot!! Bernard On 9/8/05, Kent Johnson <[EMAIL PROTECTED]> wrote: > Bernard Lebel wrote: > >

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

Re: [Tutor] Substring substitution

2005-09-08 Thread Bernard Lebel
t I have to confess that made things more confusing for me... Thanks again Bernard On 9/8/05, Kent Johnson <[EMAIL PROTECTED]> wrote: > Bernard Lebel wrote: > > Hello, > > > > I have a string, and I use a regular expression to search a match in > > it. When I fi

[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 wo

[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 the

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

2005-08-23 Thread Bernard Lebel
, 'a', 'list', 'of', 'words'] > >>> sep_char = '-' > >>> print sep_char.join(a_list) > this-is-a-list-of-words > >>> > *g* > -Original Message- > From: Bernard Lebel [mailto:[EMAIL PROTEC

[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 Bernar

[Tutor] OT: PHP-MySQL, and Python if possible

2005-08-11 Thread Bernard Lebel
Hello, Sorry for off-topic. I'm looking to buy a book about PHP, to build interface for MySQL tables. Since my current script library is in Python, something is also relevant to Python would definitely be nice. Looking for suggestions. Thanks in advance. Bernard

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

[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

Re: [Tutor] Functional question

2005-08-05 Thread Bernard Lebel
It never crossed my mind that a tuple would do 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

[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 in

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

[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

  1   2   >