[Tutor] Tutor Digest, Vol 76, Issue 57

Edward Lang edwardlang at optonline.net
Sun Jun 20 12:46:25 CEST 2010


e

tutor-request at python.org wrote:

>Send Tutor mailing list submissions to
>	tutor at python.org
>
>To subscribe or unsubscribe via the World Wide Web, visit
>	http://mail.python.org/mailman/listinfo/tutor
>or, via email, send a message with subject or body 'help' to
>	tutor-request at python.org
>
>You can reach the person managing the list at
>	tutor-owner at python.org
>
>When replying, please edit your Subject line so it is more specific
>than "Re: Contents of Tutor digest..."
>
>
>Today's Topics:
>
>   1. Re: Python glade (Lang Hurst)
>   2. Re: Question (Alan Gauld)
>   3. Re: Question (Steven D'Aprano)
>
>
>----------------------------------------------------------------------
>
>Message: 1
>Date: Fri, 18 Jun 2010 21:50:23 -0700
>From: Lang Hurst <lang at tharin.com>
>To: tutor at python.org
>Subject: Re: [Tutor] Python glade
>Message-ID: <4C1C4C8F.7080907 at tharin.com>
>Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
>Found the problem.  If you want to do this, you have to access the 
>gtkEntry like this
>
>    self.builder.get_object('student_change').set_completion(completion)
>
>
>instead of
>
>    self.student_change.set_completion(completion)
>
>
>
>
>
>Lang Hurst wrote:
>> OK, I created a UI in glade which has the following:
>>
>>     <object class="GtkEntry" id="student_change">
>>                        <property name="visible">True</property>
>>                        <property name="can_focus">True</property>
>>                        <property 
>> name="invisible_char">&#x25CF;</property>
>>                        <property name="width_chars">25</property>
>>                        <signal name="activate"
>>    handler="student_change_activate_cb"/>
>>    </object>
>>
>>
>> basically, a text box.  I'm trying to set it up to automatically 
>> complete names as I type.  My py file has the following:
>>
>>     def __init__(self):
>>          self.builder = gtk.Builder()
>>          self.builder.add_from_file('gradebook.glade')
>>          self.window = self.builder.get_object('winapp')
>>          self.builder.connect_signals(self)
>>    #      self.student_change = gtk.Entry()
>>          completion = gtk.EntryCompletion()
>>          self.names = gtk.ListStore(str)
>>          query = "SELECT * from students"
>>          db = sqlite3.connect('gradebook.db')
>>          cursor = db.cursor()
>>          cursor.execute(query)
>>          students = cursor.fetchall()
>>          for student in students:
>>              self.names.append([student[1]])
>>              print student[1]
>>          cursor.close()
>>          completion.set_model(self.names)
>>          self.student_change.set_completion(completion)
>>          completion.set_text_column(0)
>>
>>
>> When I try to run this, I get
>>
>>    AttributeError: 'appGUI' object has no attribute 'student_change'
>>
>>
>> But if I uncomment the self.student_change line from up above, it runs 
>> but doesn't do completion.
>>
>> I modeled this after
>>
>> http://www.koders.com/python/fid755022E2A82A54C79A7CF86C00438E6F825676C3.aspx?s=gtk#L4 
>>
>>
>> I'm pretty sure the problem is somewhere in the gtk.Builder part of 
>> what I'm doing, but I can't for the life of me figure this out.
>>
>
>
>-- 
>There are no stupid questions, just stupid people.
>
>
>
>------------------------------
>
>Message: 2
>Date: Sat, 19 Jun 2010 09:19:09 +0100
>From: "Alan Gauld" <alan.gauld at btinternet.com>
>To: tutor at python.org
>Subject: Re: [Tutor] Question
>Message-ID: <hvhuht$f3r$1 at dough.gmane.org>
>Content-Type: text/plain; format=flowed; charset="iso-8859-1";
>	reply-type=original
>
>"Independent Learner" <nbr1ninrsan7 at yahoo.com> wrote 
>
>> ~I was wondering if I should try to learn 2 programming languages 
>> at once, Python and C++. 
>
>No, no no! If it had been a different pair I might have said try it. 
>But C++ is one of the most difficult, complex and difficult 
>programming lamnguages out there. It is full of subtle things 
>that can trip you up and cause very weird and subtle bugs 
>that are diffficult to find. And it has similar concepts to Python 
>but implemented so entirely differently that studying the two 
>together will be an exercise in frustration.
>
>Part of the reason why C++ is so difficult is because it is 
>so powerful. You have full access to the machine through 
>the C language elements, plus a full OOP environment, 
>plus a powerful generic type system. Plus it combines 
>static and dynamic variables with a reference model all with 
>slightly different syntax and semantic behaviours.
>
>At work I hardly ever recommend that people go on language 
>training courses, C++ is the exception! You can learn C++ 
>by yourself but you will need a good book and a lot of 
>time and patience.
>
>> Obviously I am working on learning python right now, 
>> I have gotten up to Classes
>
>Stick with Python and get comfortable with that.
>
>Then move onto C++ as a separate and significant project
>if you really feel you have a need to know it.
>
>> there are still a lot of things I am not really fully 
>> comprehending, but like I said I have a pretty good idea. 
>
>Ask questions here. That's what the tutor list is for.
>
>> ~So is it better to learn 1 programming language 
>> first, then learn another. Or better to pretty much 
>> learn them at the same time? And why? 
>
>If you had asked about Python and Object Pascal 
>or Ruby or even Lisp I'd have said sure, if you enjoy 
>comparative learning. Those languages are sufficiently 
>close to makle it worthwhile. (That's why I teach 
>VBScript and JavaScript as well as Python in 
>my tutor) But C++ is awash with gotchas and has 
>an internal object model completely different to Python.
>(COBOL is another one that I'd never recommend 
>as a comparative languiage!)
>
>-- 
>Alan Gauld
>Author of the Learn to Program web site
>http://www.alan-g.me.uk/
>
>
>
>
>------------------------------
>
>Message: 3
>Date: Sat, 19 Jun 2010 18:56:34 +1000
>From: Steven D'Aprano <steve at pearwood.info>
>To: tutor at python.org
>Subject: Re: [Tutor] Question
>Message-ID: <201006191856.34526.steve at pearwood.info>
>Content-Type: text/plain;  charset="utf-8"
>
>On Sat, 19 Jun 2010 01:55:05 pm Independent Learner wrote:
>
>> ~I was wondering if I should try to learn 2 programming languages at
>> once, Python and C++.
>
>I don't know. That depends on you.
>
>How much time do you have to spend on learning the languages? If it's 
>one hour a week, you'll have trouble learning *one* language, never 
>mind two.
>
>It really depends on you, and since we don't know you, we can't answer 
>that. 
>
>Alan has said "No" because Python and C++ have radically different 
>programming models, and suggested that you should consider two 
>languages that are much more similar such as Python and Ruby. I don't 
>know about that... I think I'd much rather learn two different 
>languages, so that I could compartmentalise "these are Python rules" 
>and "these are C++ rules", rather constantly mixing up Python and Ruby 
>syntax and idioms and getting them confused. But your mileage may 
>vary -- maybe you're more like Alan than me.
>
>
>> Yea I took an intro to comp sci?class(like 2 years ago) and a
>> computer programming logic class(also like 2 years ago) both
>> using?pseudocode?
>
>Good grief! How do they teach a class in computer programming using 
>pseudocode??? That's like teaching somebody to cook by handing them 
>Playdough and a toy oven that doesn't even get warm!
>
>
>> and have since dabbled in C(I?started a programming 
>> class for school but dropped?out twice?after about 1/3 of? the
>> semester, for two consecutive semesters about?9?months ago) So here I
>> am,?a?computer engineering?major failure who had to change?my major
>> to Physics so I wouldn't have to take all those dammed comp sci
>> classes Figured I could just teach myself. I mention this because I
>> want to make clear I have the logic and critical thinking skills
>> down, and in my opinion the aptitude as well.
>
>I don't mean to be negative, but if you've dropped out of a programming 
>course *twice*, and then changed your major to avoid programming, 
>perhaps you're not cut out for programming? Obviously I don't know you, 
>maybe you have good reasons for dropping out unrelated to your ability 
>and intelligence, but speaking as a stranger, when you say "Hey guys, I 
>have a history of dropping out of a basic programming courses, but 
>don't worry, I've got the aptitude to be a programmer", it doesn't 
>really fill me with confidence. Perhaps that's something you should 
>keep more to yourself until *after* you've proven you do have the 
>chops?
>
>
>
>-- 
>Steven D'Aprano
>
>
>------------------------------
>
>_______________________________________________
>Tutor maillist  -  Tutor at python.org
>http://mail.python.org/mailman/listinfo/tutor
>
>
>End of Tutor Digest, Vol 76, Issue 57
>*************************************


More information about the Tutor mailing list