[Tutor] Having a problem with markdown

2011-01-25 Thread ian douglas
Hey all, I followed a tutorial on creating a very simple wiki in Python, which worked fine until the example where the instructor wanted to render the output through markdown.markdown() Here's the view code: from agwiki.wiki.models import Page from django.shortcuts import render_to_response

Re: [Tutor] sorted question

2011-01-25 Thread Steven D'Aprano
It't me wrote: Hi all, I'm learning Python with Google's Python class Ik have a question about the following code: = def sort(var): return var[-1] #returns the last character of var Why is the function called "sort" when it doesn't sort? Why not call it "run

Re: [Tutor] ideas for a simple program

2011-01-25 Thread Steven D'Aprano
walter weston wrote: can I have some good ideas for simple programs Some more ideas... Take a built-in Python command, and try to duplicate it in pure Python. E.g.: # Untested. def my_len(obj): # Like Python's len() function, only slower. try: return obj.__len__() excep

Re: [Tutor] The trap of the year

2011-01-25 Thread Corey Richardson
On 01/25/2011 06:49 PM, Steven D'Aprano wrote: > Corey Richardson wrote: > >> To be pedantic, a method _is_ a function, just under the umbrella of a >> class, with it's parent object being passed to it. > > To be even more pedantic, a method object is a wrapper (technically, a > descriptor) aroun

Re: [Tutor] ideas for a simple program

2011-01-25 Thread Brett Ritter
On Tue, Jan 25, 2011 at 10:18 PM, Steven D'Aprano wrote: > Or a program to find anagrams. A great exercise in learning how different string operations perform is to search a text file for the largest palindrome string. I recall running one on the Constitution where a good program could do it in

Re: [Tutor] ideas for a simple program

2011-01-25 Thread Steven D'Aprano
walter weston wrote: can I have some good ideas for simple programs, What are you interested in? Find something you like to do, and write a program to help you do it. Interested in maths? Write a program to generate prime numbers, or to search for amicable numbers. Look at Project Euler, a

Re: [Tutor] class question

2011-01-25 Thread Corey Richardson
On 01/25/2011 08:50 PM, Steven D'Aprano wrote: > Corey Richardson wrote: >> On 01/25/2011 06:26 PM, Elwin Estle wrote: >>> Is it better to have one large sort of "do it all" class, or break >>> the larger class up into smaller classes? > >> If you're just learning, go ahead and make a 'do it all'

[Tutor] To learn multithreading in Python

2011-01-25 Thread Kann Vearasilp
Dear all, I want to learn about threading, multithreading, and parallel programming. I have never done this kind of programming before. Would python be a good kick-starting? Do you have any suggestions for tutorials, books? Kann ___ Tutor maillist - T

Re: [Tutor] class question

2011-01-25 Thread Steven D'Aprano
Corey Richardson wrote: On 01/25/2011 06:26 PM, Elwin Estle wrote: Is it better to have one large sort of "do it all" class, or break the larger class up into smaller classes? If you're just learning, go ahead and make a 'do it all' class. Don't do it later in your growth as a programmer tho

Re: [Tutor] class question

2011-01-25 Thread Steven D'Aprano
Elwin Estle wrote: Is it better to have one large sort of "do it all" class, or break the larger class up into smaller classes? Yes. Or no. It's impossible to answer that question definitively without knowing more about what "it all" is. But I can give some general advice: * Python isn't

Re: [Tutor] class question

2011-01-25 Thread Karim
Hello, Design Patterns is the key for code reuse and problem solving. Indeed you have to separate your objects (classes) to use it. The god class is like a script with only one function: not very flexible and easy to debug. Program towards interface that means you have to use inheritance. Try

Re: [Tutor] The trap of the year

2011-01-25 Thread Karim
Sorry Alan, When I read your tutorial I was probably blind... :-D I am going to re-read it. Regards Karim On 01/26/2011 01:30 AM, Alan Gauld wrote: "Karim" wrote If I understand a little bit what happen in: def __init__(self, parameters=[]): [...] The list argument is built before in

Re: [Tutor] The trap of the year

2011-01-25 Thread Karim
After one 2 months of python intensive development. I made this init defaults error in my db classes constructors... Shame on me :-[ Steven ! Your example shows me obvious. Regards Karim On 01/26/2011 12:33 AM, Steven D'Aprano wrote: Karim wrote: Hello All, Just to share on rageous bug

Re: [Tutor] The trap of the year

2011-01-25 Thread Karim
Thanks for the tip Steven. Regards Karim On 01/26/2011 12:39 AM, Steven D'Aprano wrote: Karim wrote: Hello Bob, I know this fact for function but in this case this is not a function but a constructor method of a class. Methods *are* functions. (Technically, they are lightweight wrappers

Re: [Tutor] sorted question

2011-01-25 Thread Emile van Sebille
On 1/25/2011 11:46 AM It't me said... Hi all, I'm learning Python with Google's Python class Ik have a question about the following code: = def sort(var): return var[-1] #returns the last character of var Nit: it'll be a character if passed in a string of ch

Re: [Tutor] ideas for a simple program

2011-01-25 Thread Steven D'Aprano
ian douglas wrote: With an Email address like "hacker0100", your best bet might be to do what we told another user just a few days ago: Ha ha, it's funny how different people interpret email addresses differently. *I* look at an email address "hacker0100" and think "wannabe". No offense Walte

Re: [Tutor] class question

2011-01-25 Thread Alan Gauld
"Elwin Estle" wrote Is it better to have one large sort of "do it all" class, or break the larger class up into smaller classes? Usually the latter. But remember that classes model objects. Objects usually have a direct relationship to some kind of "real world" entity - even if its an abstr

Re: [Tutor] extracting text from word files (.doc, .docx) and pdf

2011-01-25 Thread Alan Gauld
"Juan Jose Del Toro" wrote I am looking for a way to extract parts of a text from word (.doc,.docx) files as well as pdf; In addition to the suggestions already given you can use COM to drive Word itself if you have Word on the PC in which you are running the code. If not there are ways to

Re: [Tutor] placing widgets

2011-01-25 Thread Alan Gauld
"W S" wrote trouble with my combobox placement on the frame. is there a way to more explicitly place it other than: This method does not give a lot of control xx=apply(OptionMenu,(self,TCase)+tuple(TestCase)) xx.grid(row=1, sticky=E+W) There are basically 3 layout managers in Tk. pack()

Re: [Tutor] sorted question

2011-01-25 Thread Marc Tompkins
On Tue, Jan 25, 2011 at 11:46 AM, It't me wrote: > Hi all, > > I'm learning Python with Google's Python class > > Ik have a question about the following code: > = > def sort(var): >  return var[-1]  #returns the last character of var > > def sort_last(): >   tup = [

Re: [Tutor] The trap of the year

2011-01-25 Thread Alan Gauld
"Karim" wrote If I understand a little bit what happen in: def __init__(self, parameters=[]): [...] The list argument is built before instance creation and indeed constructor execution. So this is the same list instance of constructor parameter for all new instance creation. Yes that

Re: [Tutor] class question

2011-01-25 Thread Marc Tompkins
On Tue, Jan 25, 2011 at 3:26 PM, Elwin Estle wrote: > > Is it better to have one large sort of "do it all" class, or break the larger > class up into smaller classes?  Seems to me like the one large class would be > clearer in some ways.  I have something I am trying to do that have somewhere >

Re: [Tutor] class question

2011-01-25 Thread Corey Richardson
On 01/25/2011 06:26 PM, Elwin Estle wrote: > Is it better to have one large sort of "do it all" class, or break the larger > class up into smaller classes? Seems to me like the one large class would be > clearer in some ways. I have something I am trying to do that have somewhere > in the neig

Re: [Tutor] extracting text from word files (.doc, .docx) and pdf

2011-01-25 Thread Emile van Sebille
On 1/25/2011 1:52 PM Juan Jose Del Toro said... Dear List; I am looking for a way to extract parts of a text from word (.doc,.docx) I recently did a project extracting data from word documents and used antiword (http://www.winfield.demon.nl/) then used it like this: def setContent(self):

[Tutor] sorted question

2011-01-25 Thread It't me
Hi all, I'm learning Python with Google's Python class Ik have a question about the following code: = def sort(var): return var[-1] #returns the last character of var def sort_last(): tup = [(1, 3), (3, 2), (2, 1)] print(sorted(tup, key=sort)) sort_last() =

Re: [Tutor] The trap of the year

2011-01-25 Thread Steven D'Aprano
Corey Richardson wrote: To be pedantic, a method _is_ a function, just under the umbrella of a class, with it's parent object being passed to it. To be even more pedantic, a method object is a wrapper (technically, a descriptor) around a function object. It's also slightly different between

Re: [Tutor] The trap of the year

2011-01-25 Thread Steven D'Aprano
Karim wrote: Hello Bob, I know this fact for function but in this case this is not a function but a constructor method of a class. Methods *are* functions. (Technically, they are lightweight wrappers around functions.) They are treated exactly the same by Python. The "constructor method" _

Re: [Tutor] The trap of the year

2011-01-25 Thread Steven D'Aprano
Karim wrote: Hello All, Just to share on rageous bug I encounter where 2 lists which "should" to be different (same id) because hold by different instances of the same class are not in fact DIFFERENT, see below: I think you are confused. If the two lists have the same ID, they should be th

[Tutor] class question

2011-01-25 Thread Elwin Estle
Is it better to have one large sort of "do it all" class, or break the larger class up into smaller classes?  Seems to me like the one large class would be clearer in some ways.  I have something I am trying to do that have somewhere in the neighborhood of 20 attributes that all relate together,

Re: [Tutor] placing widgets

2011-01-25 Thread David Hutto
Note when you answer yourself, it shows initiative and responsiveness to the situation you're trying to comprehend. -- The lawyer in me says argue...even if you're wrong. The scientist in me... says shut up, listen, and then argue. But the lawyer won on appeal, so now I have to argue due to a co

Re: [Tutor] placing widgets

2011-01-25 Thread Karim
On 01/25/2011 10:31 PM, W S wrote: hi, i have written some Tk/Python code to do a few simple tasks, and am having trouble with my combobox placement on the frame. is there a way to more explicitly place it other than: This method does not give a lot of control xx=apply(OptionMenu,(self,TCase

Re: [Tutor] The trap of the year

2011-01-25 Thread Karim
Yes you're right. But the class and instance thing made me believe the context would be different. Error of judgment. Regards Karim On 01/25/2011 10:57 PM, Corey Richardson wrote: On 01/25/2011 04:28 PM, Karim wrote: Hello Bob, I know this fact for function but in this case this is not a f

Re: [Tutor] extracting text from word files (.doc, .docx) and pdf

2011-01-25 Thread Corey Richardson
On 01/25/2011 04:52 PM, Juan Jose Del Toro wrote: > Dear List; > > I am looking for a way to extract parts of a text from word (.doc,.docx) > files as well as pdf; the idea is to walk through the whole directory tree > and populate a csv file with an excerpt from each file. > For PDF I found PyPdf

Re: [Tutor] extracting text from word files (.doc, .docx) and pdf

2011-01-25 Thread Walter Prins
On 25 January 2011 21:52, Juan Jose Del Toro wrote: > Dear List; > > I am looking for a way to extract parts of a text from word (.doc,.docx) > files as well as pdf; the idea is to walk through the whole directory tree > and populate a csv file with an excerpt from each file. > For PDF I found Py

Re: [Tutor] placing widgets

2011-01-25 Thread Corey Richardson
On 01/25/2011 04:31 PM, W S wrote: > hi, i have written some Tk/Python code to do a few simple tasks, and am > having > trouble with my combobox placement on the frame. is there a way to more > explicitly place it other than: This method does not give a lot of control > xx=apply(OptionMenu,(se

Re: [Tutor] The trap of the year

2011-01-25 Thread Corey Richardson
On 01/25/2011 04:28 PM, Karim wrote: > > Hello Bob, > > I know this fact for function but in this case this is not a function > but a constructor method of a class. To be pedantic, a method _is_ a function, just under the umbrella of a class, with it's parent object being passed to it. ~Corey >

[Tutor] extracting text from word files (.doc, .docx) and pdf

2011-01-25 Thread Juan Jose Del Toro
Dear List; I am looking for a way to extract parts of a text from word (.doc,.docx) files as well as pdf; the idea is to walk through the whole directory tree and populate a csv file with an excerpt from each file. For PDF I found PyPdf ave found nothing to read doc, doc

[Tutor] placing widgets

2011-01-25 Thread W S
hi, i have written some Tk/Python code to do a few simple tasks, and am having trouble with my combobox placement on the frame. is there a way to more explicitly place it other than: This method does not give a lot of control xx=apply(OptionMenu,(self,TCase)+tuple(TestCase)) xx.grid(row=1, stic

Re: [Tutor] The trap of the year

2011-01-25 Thread Karim
On 01/25/2011 10:12 PM, Jerry Hill wrote: On Tue, Jan 25, 2011 at 3:41 PM, Karim > wrote: I am not really understanding why my init in the class made it refers to the same list object. What is the difference with 2nd example directly at the prompt? See

Re: [Tutor] The trap of the year

2011-01-25 Thread Karim
Hello Bob, I know this fact for function but in this case this is not a function but a constructor method of a class. The impact is not the same because all instance share the same argument parameter.This a kind of singleton argument :-) . I believed that the constructor will create each time

Re: [Tutor] The trap of the year

2011-01-25 Thread bob gailer
On 1/25/2011 3:41 PM, Karim wrote: Hello All, Just to share on rageous bug I encounter where 2 lists which "should" to be different (same id) because hold by different instances of the same class are not in fact DIFFERENT, see below: >>> class Device(): ... def __init__(self, parameters

Re: [Tutor] The trap of the year

2011-01-25 Thread Karim
If I understand a little bit what happen in: def __init__(self, parameters=[]): [...] The list argument is built before instance creation and indeed constructor execution. So this is the same list instance of constructor parameter for all new instance creation. For me it was a bad surpri

Re: [Tutor] The trap of the year

2011-01-25 Thread Izz ad-Din Ruhulessin
Or the internal memory id or whatever it's called. 2011/1/25 Izz ad-Din Ruhulessin > I think it has something to do with the physical id of the object > > 2011/1/25 Karim > > >> Hello All, >> >> Just to share on rageous bug I encounter where 2 lists which "should" to >> be different (same id) b

Re: [Tutor] The trap of the year

2011-01-25 Thread Jerry Hill
On Tue, Jan 25, 2011 at 3:41 PM, Karim wrote: > I am not really understanding why my init in the class made it refers to > the same list object. > What is the difference with 2nd example directly at the prompt? > See http://effbot.org/zone/default-values.htm -- Jerry __

Re: [Tutor] The trap of the year

2011-01-25 Thread Izz ad-Din Ruhulessin
I think it has something to do with the physical id of the object 2011/1/25 Karim > > Hello All, > > Just to share on rageous bug I encounter where 2 lists which "should" to be > different (same id) because hold by different instances of the same class > are not in fact DIFFERENT, see below: > >

[Tutor] The trap of the year

2011-01-25 Thread Karim
Hello All, Just to share on rageous bug I encounter where 2 lists which "should" to be different (same id) because hold by different instances of the same class are not in fact DIFFERENT, see below: >>> class Device(): ... def __init__(self, parameters=[]): ... self.parameters =

Re: [Tutor] ideas for a simple program

2011-01-25 Thread Bill Allen
For a simple programming project that probably has just enough complexity to be interesting, google for Conway's Game of Life. You'll find an algorithm to use. --Bill On Tue, Jan 25, 2011 at 11:25, walter weston wrote: > > can I have some good ideas for simple programs, I have come to rea

Re: [Tutor] ideas for a simple program

2011-01-25 Thread Brett Ritter
On Tue, Jan 25, 2011 at 12:25 PM, walter weston wrote: > can I have some good ideas for simple programs, I have come to realize the > hardest part of programming is not having a project to do and having to > think of one haha There are two ways to approach this: 1) Think of something that you'd

Re: [Tutor] ideas for a simple program

2011-01-25 Thread ian douglas
With an Email address like "hacker0100", your best bet might be to do what we told another user just a few days ago: Find an open-source project, and try to add a new feature to it, or fix a bug in it. That way you learn about the language, the project, and could get your name out there as a c

[Tutor] ideas for a simple program

2011-01-25 Thread walter weston
can I have some good ideas for simple programs, I have come to realize the hardest part of programming is not having a project to do and having to think of one haha ___ Tutor maillist - Tutor@python.org To

Re: [Tutor] Not understanding a bit of code behavior

2011-01-25 Thread Bill Allen
That's exactly right! Never heard it called that before, but that is basically what happened. I appreciate the help. --Bill On Tue, Jan 25, 2011 at 06:38, Wayne Werner wrote: > On Tue, Jan 25, 2011 at 1:42 AM, Alan Gauld wrote: > >> >> "Bill Allen" wrote >> >> Thats often the way :-) >>

Re: [Tutor] Not understanding a bit of code behavior

2011-01-25 Thread Bill Allen
Steven, Thanks! That is quite helpful to know the nuts and bolts of how that works. --Bill On Tue, Jan 25, 2011 at 07:45, Steven D'Aprano wrote: > Bill Allen wrote: > >> Ok, I have definately verified this to myself. The following works >> perfectly and is a little easier to understand.

Re: [Tutor] Not understanding a bit of code behavior

2011-01-25 Thread Steven D'Aprano
Bill Allen wrote: Ok, I have definately verified this to myself. The following works perfectly and is a little easier to understand. In this version, I am plainly modifying my parts_list iterator thus producing the effect of an iterator that is growing over the course of the operation of the c

Re: [Tutor] Not understanding a bit of code behavior

2011-01-25 Thread Wayne Werner
On Tue, Jan 25, 2011 at 1:42 AM, Alan Gauld wrote: > > "Bill Allen" wrote > > Thats often the way :-) > The act of articulating the problem forces you to think about it > differently. > Also called "Rubber Duck Debugging" http://en.wikipedia.org/wiki/Rubber_duck_debugging