Re: [Tutor] Opening .py files in firefox

2006-03-21 Thread Ed Singleton
On 20/03/06, Alan Gauld <[EMAIL PROTECTED]> wrote: > > If the browser tries to execute the script you will need to go to > > the file types setting in the browser and set .py to plain-text. > > > > This is what I need to do ... but, after looking at all the options > > (within tools->Options), I st

[Tutor] Python & MP3

2006-03-21 Thread Johanna
Hallo   This is my first post, so hallo to everyone. Im just a newbee with python so I hope my msg will make some sense. J   Is it possible to work with MP3 in python? I’m looking for a library to modify MP3s (like fade in, fade out, etc..). I know there are actually some libraries fo

[Tutor] Python Control Flow Graph

2006-03-21 Thread Brian C. Lum
Dear Python Tutors, I have been looking for a good way to convert python code into a control flow graph. I know of Python functions that will convert an expression into an abstract syntax tree (i.e. ast = parser.expr('(x+5)*5') then t = ast.totuple() then t), but I am not sure how to obtain a

Re: [Tutor] Python & MP3

2006-03-21 Thread Andre Roberge
On 3/21/06, Johanna <[EMAIL PROTECTED]> wrote: > Hallo > This is my first post, so hallo to everyone. Im just a newbee with python so > I hope my msg will make some sense. > > Is it possible to work with MP3 in python? > Pygame (http://www.pygame.org/docs/ref/music.html) apparently works with mp3

Re: [Tutor] Opening .py files in firefox

2006-03-21 Thread Andre Roberge
** Copy of a reply sent only to Alan Gauld by mistake. On 3/20/06, Alan Gauld <[EMAIL PROTECTED]> wrote: > > If the browser tries to execute the script you will need to go to > > the file types setting in the browser and set .py to plain-text. > > > > This is what I need to do ... but, after looki

[Tutor] TKinter question

2006-03-21 Thread Christian Wood
To whom this may concern, Attatched is the source code, which demonstrates a problem I am having making a GUI for my python project work. Both files need to be in the same folder. My code writes to a text file 'table.txt', and 'table.txt' is displayed in

Re: [Tutor] Python & MP3

2006-03-21 Thread Python
On Tue, 2006-03-21 at 10:50 +0100, Johanna wrote: > Hallo > > > > This is my first post, so hallo to everyone. Im just a newbee with > python so I hope my msg will make some sense. J > > > > Is it possible to work with MP3 in python? yumex lists python-eyed3 python-mad as p

[Tutor] Struggling with writing results of loop into txt file

2006-03-21 Thread Matt Dempsey
I'm using xmltramp to process some U.S. House of Rep. vote data. I can get it to print what I want but when I try to write it to a text file I had all sorts of problems. Can someone tell me what I'm doing wrong? I've done quite a bit of searching for the solution but as a novice to Python I'm at a

Re: [Tutor] Struggling with writing results of loop into txt file

2006-03-21 Thread Kent Johnson
Matt Dempsey wrote: > I'm using xmltramp to process some U.S. House of Rep. vote data. I can > get it to print what I want but when I try to write it to a text file I > had all sorts of problems. Can someone tell me what I'm doing wrong? > > for each in range(votes): >st= str(vd[each].legis

[Tutor] Pythonic? Building a full path from a "visual" file tree

2006-03-21 Thread stv
Hey all, I would like to expand the "visual" representation of a tree hierarchy, given below, where child-ness is defined by indentation, and folder-ness is highlighted with a trailing '/' Input (test.txt): dir1/ file1 file2 1-1/ file3 file4

Re: [Tutor] Python Control Flow Graph

2006-03-21 Thread Danny Yoo
On Tue, 21 Mar 2006, Brian C. Lum wrote: > I have been looking for a good way to convert python code into a control > flow graph. [text cut] Hi Brian, I think you may want to ask your question to the pypy folks, since your question is a bit specialized. Check out pypy, which is an implemenat

Re: [Tutor] Pythonic? Building a full path from a "visual" file tree

2006-03-21 Thread Kent Johnson
stv wrote: > I considered several brute-force solutions, but I persevered and came > to, what I think, is a more Pythonic solution. What do you think? Looks pretty sweet to me :-) > > import string > > def expand_tree(filetree): > indent = '\t' > stack = [] > for f in filetree: > inden

Re: [Tutor] TKinter question

2006-03-21 Thread Alan Gauld
> My code writes to a text file 'table.txt', and 'table.txt' is displayed in > the GUI. The user can generate new data at the click of a button > which re-writes 'table.txt', but I can only add the new table to the GUI > window rather than 'update' the existing one. class MoC: def __init__(sel

[Tutor] function signatures for callbacks

2006-03-21 Thread Don Taylor
I have a piece of code that wants a callback from a client: The code looks like this right now: class pawprints: def __init__(self, callback_fun = None) ... at the client calling site I have something like this: def printme(modulename, codename, lineno, line): ... paws = pa

Re: [Tutor] Pythonic? Building a full path from a "visual" file tree

2006-03-21 Thread stv
> The list comp is fine but I don't think you need it > at all, since you strip() the string before you > add it to stack. Ahh yes. I used the rstrip() in development, printing intermediary output to stdout, so I could see what my input file-to-list looked like (and it looked ugly with all those E

Re: [Tutor] function signatures for callbacks

2006-03-21 Thread Danny Yoo
> I have a piece of code that wants a callback from a client: > > The code looks like this right now: > > class pawprints: > def __init__(self, callback_fun = None) > ... > > > at the client calling site I have something like this: > > def printme(modulename, codename, lineno, line)

Re: [Tutor] function signatures for callbacks

2006-03-21 Thread Danny Yoo
> > It seems backwards to me because because if I get the function > > definition wrong in the client site then I get a traceback to the > > callback site - which is meant to be an opaque library that the client > > should not have to know about. > > Yes, what you're asking makes sense: we want to

[Tutor] unicode issue?

2006-03-21 Thread Matt Dempsey
I'm having a new problem with my House vote script. It's returning the following error: Traceback (most recent call last):  File "C:/Python24/evenmorevotes", line 20, in -toplevel-    f.write(nm+'*'+pt+'*'+vt+'*'+md['vote-result'][0]+'*'+md['vote-desc'][0]+'*'+'\n') UnicodeEncodeError: 'ascii' code

Re: [Tutor] unicode issue?

2006-03-21 Thread Danny Yoo
On Tue, 21 Mar 2006, Matt Dempsey wrote: > I'm having a new problem with my House vote script. It's returning the > following error: > > Traceback (most recent call last): > File "C:/Python24/evenmorevotes", line 20, in -toplevel- > f.write > (nm+'*'+pt+'*'+vt+'*'+md['vote-result'][0]+'*'+

Re: [Tutor] Pythonic? Building a full path from a "visual" file tree

2006-03-21 Thread stv
On 3/21/06, stv <[EMAIL PROTECTED]> wrote: > > import string > > def expand_tree(filetree): > indent = '\t' > stack = [] > for f in filetree: > indents = f.count(indent) > while len(stack) > indents: stack.pop() > stack.append(f.strip()) > yield string.join(stack,'') > if

Re: [Tutor] unicode issue? (fwd)

2006-03-21 Thread Danny Yoo
> A friend of mine showed me where the unicode is showing up but we still > can't get script to work right. We tried encoding the appropriate > variable but it still is spitting back the error. Would I just have: > u'\u201c'.encode('utf8') in my script or should it be > md['vote-desc'][0].encode('

[Tutor] how to get a line text from input file.

2006-03-21 Thread Keo Sophon
Hi all, i am new to programming language and python. I wonder how to get a line text from input file. Thanks, sophon ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] how to set a value to a block of memory

2006-03-21 Thread Keo Sophon
Hi all, How can i set a value to a bytes of block of memory. In C, i think they use memset like this. Thanks, Sophon ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Python & MP3

2006-03-21 Thread Bill Burns
Johanna wrote: > Hallo > > > > This is my first post, so hallo to everyone. Im just a newbee with > python so I hope my msg will make some sense. J > > > > Is it possible to work with MP3 in python? > > I’m looking for a library to modify MP3s (like fade in, fade out, > etc..). I know th

Re: [Tutor] how to set a value to a block of memory

2006-03-21 Thread Kent Johnson
Keo Sophon wrote: > Hi all, > > How can i set a value to a bytes of block of memory. In C, i think they use > memset like this. Python does not support direct access to memory, you will need to use another language or maybe a C extension to Python to do this. Kent

Re: [Tutor] how to get a line text from input file.

2006-03-21 Thread Kent Johnson
Keo Sophon wrote: > Hi all, > > i am new to programming language and python. I wonder how to get a line text > from input file. The simplest Python idiom to do something with each line of a file is this: for line in open('somefile.txt'): # do something with line You can find out more he

Re: [Tutor] Python & MP3

2006-03-21 Thread Gabriel S Farrell
On Tue, Mar 21, 2006 at 09:35:15PM -0500, Bill Burns wrote: > Johanna wrote: > > Is it possible to work with MP3 in python? > > > > I?m looking for a library to modify MP3s (like fade in, fade out, > > etc..). > > You may want to have a look at PyMedia: > > http://www.pymedia.org/ I agree wit

Re: [Tutor] how to get a line text from input file.

2006-03-21 Thread Danny Yoo
On Wed, 22 Mar 2006, Keo Sophon wrote: > i am new to programming language and python. I wonder how to get a line > text from input file. Hi Sophon, You may want to look at: http://wiki.python.org/moin/BeginnersGuide/NonProgrammers Many of the tutorials there talk about reading from files

Re: [Tutor] how to set a value to a block of memory

2006-03-21 Thread Danny Yoo
On Tue, 21 Mar 2006, Kent Johnson wrote: > > How can i set a value to a bytes of block of memory. In C, i think > > they use memset like this. Hi Sophon, Secondary question: why are you trying to do this? Are you trying to represent a collection or "array" of things? Some concepts in C aren

Re: [Tutor] how to set a value to a block of memory

2006-03-21 Thread Danny Yoo
> On Tue, 21 Mar 2006, Kent Johnson wrote: > > > How can i set a value to a bytes of block of memory. In C, i think > > > they use memset like this. Whoops, sorry about that Kent! I completely messed up the attribution when cutting-and-pasting.

[Tutor] Hi

2006-03-21 Thread Kaushal Shriyan
Hi I am new to python and I am going through the URL http://www.ibiblio.org/obp/thinkCSpy/index.htm, At the moment I am going through the Chapter 7 Strings, I am stuck with understanding slice which is a part of a String, I am not able to understand how it functions Awaiting your earnest reply T

Re: [Tutor] Hi

2006-03-21 Thread Danny Yoo
> I am new to python and I am going through the URL > http://www.ibiblio.org/obp/thinkCSpy/index.htm, At the moment I am going > through the Chapter 7 Strings, I am stuck with understanding slice which > is a part of a String, I am not able to understand how it functions Hello, A "slice" takes

Re: [Tutor] Hi

2006-03-21 Thread Kaushal Shriyan
On 3/22/06, Danny Yoo <[EMAIL PROTECTED]> wrote: > > > I am new to python and I am going through the URL > > http://www.ibiblio.org/obp/thinkCSpy/index.htm, At the moment I am going > > through the Chapter 7 Strings, I am stuck with understanding slice which > > is a part of a String, I am not able

Re: [Tutor] Hi

2006-03-21 Thread Noufal Ibrahim
On Wed, March 22, 2006 12:11 pm, Kaushal Shriyan wrote: > Hi > > I am new to python and I am going through the URL > http://www.ibiblio.org/obp/thinkCSpy/index.htm, At the moment > I am going through the Chapter 7 Strings, I am stuck with understanding > slice which is a part of a String, I am not