[Tutor] Multiple inheritance for mixin attributes

2010-08-16 Thread Knacktus
Hello everyone, I've got a question about class design. I want to model classes like these (examples): # class BaseItem(object): def __init__(self, ident, name, description): self.ident = ident self.name =

Re: [Tutor] Multiple inheritance for mixin attributes

2010-08-16 Thread Alan Gauld
"Knacktus" wrote I've got a question about class design. I want to model classes like these (examples): Since these only really have data and inheritance should be based on behaviour its almost impossible to make a meaningful decision on what the inheritance tree should look like. However..

[Tutor] Using Django with TortoiseSVN (overwriting files)

2010-08-16 Thread Sithembewena Lloyd Dube
Hi everyone, We have a project at work where myself and a co-developer are setting up Django. Our version control software of choice is TortoiseSVN. When doing a project update from SVN, it pulls the server version to the local project. When checking code in, it overwrites the server version of t

Re: [Tutor] Multiple inheritance for mixin attributes

2010-08-16 Thread Jan Jansen
Thanks a lot, your explanations are very helpful getting a better (right) understanding about the ideas behind inheritance. Cheers, Jan ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman

[Tutor] Schema change in ElementTree

2010-08-16 Thread justin . mailinglists
# so that ET preserves your namespaces ET._namespace_map["http://www.w3.org/2001/XMLSchema";] = 'xs' # open your file explicitly specifying the correct mode f = open('testing.xml', 'w') xml_tree.write(f, encoding='UTF-8') f.close() ___ Tutor maillist -

Re: [Tutor] Using Django with TortoiseSVN (overwriting files)

2010-08-16 Thread Evert Rol
> We have a project at work where myself and a co-developer are setting up > Django. Our version control software of choice is TortoiseSVN. > > When doing a project update from SVN, it pulls the server version to the > local project. When checking code in, it overwrites the server version of the

Re: [Tutor] Schema change in ElementTree

2010-08-16 Thread Stefan Behnel
justin.mailingli...@gmail.com, 16.08.2010 10:38: # so that ET preserves your namespaces ET._namespace_map["http://www.w3.org/2001/XMLSchema";] = 'xs' # open your file explicitly specifying the correct mode f = open('testing.xml', 'w') xml_tree.write(f, encoding='UTF-8') f.close() Note that it'

Re: [Tutor] Using Django with TortoiseSVN (overwriting files)

2010-08-16 Thread Sithembewena Lloyd Dube
Hi Evert, You are right, I actually intended the question for the Django list - it was a posting error. Thanks for the answer, we did soon figure out to exclude the settings file from any SVN checkins/ checkouts. We will simply apply this rule as it should be simple enough to observe and to make a

Re: [Tutor] Multiple inheritance for mixin attributes

2010-08-16 Thread Steven D'Aprano
On Mon, 16 Aug 2010 05:01:58 pm Knacktus wrote: > Hello everyone, > > I've got a question about class design. I want to model classes like > these (examples): > > # > class BaseItem(object): > def __init__(self, ident, name, d

Re: [Tutor] my Python learning exercise

2010-08-16 Thread Luke Paireepinart
On Sat, Aug 14, 2010 at 6:17 PM, Bill Allen wrote: > In the process of learning Python, I have given myself a programming > exercise to do.  This is a standard thing I do whenever learning a new > programming language and I have used this same exercise several times before > with other programming

[Tutor] Moving from Python 2.5.4 to 2.5.2?

2010-08-16 Thread Wayne Watson
My partner got ahead of the game last year, and installed 2.5.4, which confounds matters when the other four participants when sharing some python programs under Win XP. My guess is that if he uses control panel add/remove for py 2.5.4, he can then successfully install 2.5.2 w/o messing up any

Re: [Tutor] Moving from Python 2.5.4 to 2.5.2?

2010-08-16 Thread Luke Paireepinart
On Mon, Aug 16, 2010 at 10:39 AM, Wayne Watson wrote: > My partner got ahead of the game last year, and installed 2.5.4, which > confounds matters when the other four participants when sharing some python > programs under Win XP. My guess is that if he uses control panel add/remove > for py 2.5.4,

[Tutor] Question about Dictionaries

2010-08-16 Thread Chorn, Guillaume
Hi All, I know that I can look up the value for a particular key in a dictionary, but can I look up the key associated with a particular value? I understand that this could be problematic from the standpoint of multiple keys having the same value, but even then I feel like Python could just retur

Re: [Tutor] Question about Dictionaries

2010-08-16 Thread Emile van Sebille
On 8/16/2010 10:44 AM Chorn, Guillaume said... Hi All, I know that I can look up the value for a particular key in a dictionary, but can I look up the key associated with a particular value? Yes. But you'll need to implement it. There are likely modules out there that'll do this, but it'd t

Re: [Tutor] Moving from Python 2.5.4 to 2.5.2?

2010-08-16 Thread Wayne Watson
The question is would going back likely cause problems? I'm dealing with neophytes. He's messed up before. On 8/16/2010 8:58 AM, Luke Paireepinart wrote: On Mon, Aug 16, 2010 at 10:39 AM, Wayne Watson wrote: My partner got ahead of the game last year, and installed 2.5.4, which confounds

Re: [Tutor] Question about Dictionaries

2010-08-16 Thread Lee Harr
> I know that I can look up the value for a particular key in a > dictionary, but can I look up the key associated with a particular > value? I am using bidict in one of my projects: http://pypi.python.org/pypi/bidict/0.1.1 It's probably a bit more complex than what I need, but the parts I am u

Re: [Tutor] Moving from Python 2.5.4 to 2.5.2?

2010-08-16 Thread Luke Paireepinart
The core issue here is: are there actually issues exacerbated by the difference in Python versions? If so, which issues? There shouldn't be hardly any reason to force you all to maintain the exact same python version, especially if you're in the same sub-version (2.5) On Mon, Aug 16, 2010 at 3:5

Re: [Tutor] Lost in the control flow

2010-08-16 Thread Eduardo Vieira
On Fri, Aug 13, 2010 at 2:38 PM, Adam Bark wrote: > On 11/08/10 18:14, Eduardo Vieira wrote: > > On Tue, Aug 10, 2010 at 1:56 PM, Adam Bark wrote: > > > > The problem is you don't call make_dict unless there's a "FUEL SURCHARGE" or > multiple pins. Also you don't add the first pin to mydict["trac

Re: [Tutor] Moving from Python 2.5.4 to 2.5.2?

2010-08-16 Thread Wayne Watson
I guess it's a matter of bookkeeping. I don't need the extra hassle dealing with one of them. I'll just let it go at 2.5.x On 8/16/2010 2:41 PM, Luke Paireepinart wrote: The core issue here is: are there actually issues exacerbated by the difference in Python versions? If so, which issues?

Re: [Tutor] Moving from Python 2.5.4 to 2.5.2?

2010-08-16 Thread Emile van Sebille
On 8/16/2010 2:41 PM Luke Paireepinart said... The core issue here is: are there actually issues exacerbated by the difference in Python versions? If so, which issues? There shouldn't be hardly any reason to force you all to maintain the exact same python version, especially if you're in the sa

Re: [Tutor] Question about Dictionaries

2010-08-16 Thread Dave Angel
Chorn, Guillaume wrote: Hi All, I know that I can look up the value for a particular key in a dictionary, but can I look up the key associated with a particular value? I understand that this could be problematic from the standpoint of multiple keys having the same value, but even then I feel li

Re: [Tutor] Question about Dictionaries

2010-08-16 Thread Huy Ton That
What do you mean by subclass? On Aug 16, 2010 3:26 PM, "Emile van Sebille" wrote: On 8/16/2010 10:44 AM Chorn, Guillaume said... > > Hi All, > > I know that I can look up the value for a particular key in a > dictionary, but can... Yes. But you'll need to implement it. There are likely modul

Re: [Tutor] Question about Dictionaries

2010-08-16 Thread Alan Gauld
"Chorn, Guillaume" wrote dictionary, but can I look up the key associated with a particular value? Not directly but its not hard to do bearing in mind you will get a collection back.: d = {1:10,2:20,3:10,4:20} val = 10 ks = [k for k in d if d[k] == val] ks [1, 3] You need to trawl

Re: [Tutor] Question about Dictionaries

2010-08-16 Thread Chorn, Guillaume
Thanks Dave. Actually I figured out a relatively simple solution to my specific problem--since the dictionary I made was the result of zipping together two lists, I simply made a second dictionary with the lists switched around after the zip command and used that. It worked in my case because all

Re: [Tutor] Schema change in ElementTree

2010-08-16 Thread Alan Gauld
"Stefan Behnel" wrote Note that it's best to hit "reply" when responding to other people's postings. Or on the tutor list make that ReplyAll! :-) Alan G. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: ht

Re: [Tutor] my Python learning exercise

2010-08-16 Thread Bill Allen
On Mon, Aug 16, 2010 at 9:25 AM, Luke Paireepinart wrote: > > Anyone who finds this interesting may also want to look into > http://inventwithpython.com/ , I hear it's a good book but I haven't > personally worked through it. > > > Very interesting, looks good! Thanks, Bill __

Re: [Tutor] Moving from Python 2.5.4 to 2.5.2?

2010-08-16 Thread Steven D'Aprano
On Tue, 17 Aug 2010 06:57:37 am Wayne Watson wrote: > The question is would going back likely cause problems? I'm dealing > with neophytes. He's messed up before. There shouldn't be any differences you're likely to care about between 2.5.2 and 2.5.4, but if there is, your best approach is for you

Re: [Tutor] Question about Dictionaries

2010-08-16 Thread Steven D'Aprano
On Tue, 17 Aug 2010 03:44:33 am Chorn, Guillaume wrote: > Hi All, > > I know that I can look up the value for a particular key in a > dictionary, but can I look up the key associated with a particular > value? I understand that this could be problematic from the > standpoint of multiple keys havin

Re: [Tutor] Question about Dictionaries

2010-08-16 Thread Emile van Sebille
On 8/16/2010 4:12 PM Huy Ton That said... What do you mean by subclass? If you need repeated access such that iterating over a large dict frequently impacts performance, you could subclass dict and maintain a second index allowing instant access to the keys associated with a specific value.

Re: [Tutor] Question about Dictionaries

2010-08-16 Thread Steven D'Aprano
On Tue, 17 Aug 2010 09:12:39 am Huy Ton That wrote: > What do you mean by subclass? It's a fundamental term from object-oriented programming. If you have a class that defines certain data and behaviour, you can create a *subclass* that inherits the same data and behaviour, except for specific e

Re: [Tutor] Moving from Python 2.5.4 to 2.5.2?

2010-08-16 Thread Wayne Watson
No question about that. For the record, I'm not going to ask him to change based on the answers here. On 8/16/2010 5:14 PM, Steven D'Aprano wrote: On Tue, 17 Aug 2010 06:57:37 am Wayne Watson wrote: The question is would going back likely cause problems? I'm dealing with neophytes. He's me

Re: [Tutor] Schema change in ElementTree

2010-08-16 Thread Justin Ezequiel
> Note that it's best to hit "reply" when responding to other people's > postings. That way, mail readers can see the relation between the original > posting and the reply and sort the reply into the right thread. > > Stefan how's this? btw, I am getting daily(?) digests of the posts via E-mail an

[Tutor] box drawing characters

2010-08-16 Thread Bill Allen
I am looking for some guidance about how to best utilize box drawing characters(using unicode?) in as portable a way as possible in Python. Any good guides out there for this? Thanks, Bill ___ Tutor maillist - Tutor@python.org To unsubscribe or change

Re: [Tutor] Schema change in ElementTree

2010-08-16 Thread Stefan Behnel
> Stefan Behnel wrote: Note that it's best to hit "reply" when responding to other people's postings. That way, mail readers can see the relation between the original posting and the reply and sort the reply into the right thread. Comment to my own posting: as Alan noted already, "reply all" or