#apache #archlinux #asterisk #centos #debian #gentoo #haskell #kde #kubuntu #lisp #math #mysql #perl #python #ruby-lang #rubyonrails #suse #ubuntu #vim #wikipedia 0 1 2 3 4 5 6 7 8 9 10 11
Top Prev 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 Next
#python
<pjd> in the buffer protocol, does anyone know what the point of character buffers are?
<SevenInchBread> Chousuke, Like I said... you've probably got bigger concerns in that environment.
<pjd> as apposed to read buffers
<alus> Chousuke: right. and - it should have no disadvantage
<Chousuke> except something more to learn for anyone who reads your code.
<pjd> i can't find anything any indication about how they're supposed to differ
<alus> well they have to learn .lower() or strnicmp(). neither are very hard.
<alus> and they might already know either
<SevenInchBread> heh... I'm only concerned with Solution of Least Effort (tm)
<vorsprung> case insensitive strings in unicode might be too much fun if you were implementing it yourself. It's not like the good old days when it was just an OR
<SevenInchBread> well, you would just have two different objects... one for str and one for unicode (could probably just detect which one to use based on the initial strings type)
<pjd> as far as i can tell, everything in the Python source implements them identically, except for the unicode object
<pjd> which maps "read buffer" to its UCS-2/4 buffer, and "char buffer" to a string copy encoded using Python default encoding
<pjd> Python's even
<alus> vorsprung: _mbsnicmp ?
<alus> or _wcsnicmp
<nachos> Hsss Hsss
<SpComb> no, call it iString
<tessier> hmm...how do I define a variable in the local scope when I'm not sure what I want that variables name to be? Or alternatively, how do I make it inherit values from a dictionary in the parent object if the key isn't in the dictionary I am looking at in the current object?
<tessier> I suppose I could check to see if the key is in the dictionary in the current object and if not inherit the other dictionary.
<pjd> tessier: what are you trying to do?
<tessier> Seems like a kludge though. Of course everything I am currently doing is probably a kludge.
<alus> tessier: locals().set(name, val) or locals()[name] = val
<pjd> won't a normal instance or subclass work?
<SpComb> $$foo = val; ... oh, right
<SpComb> $val, even
<tessier> pjd: Trying to make a config file which as a defaults section which is inherited if and only if the variables in that default section aren't explicitly defined in another section.
<tessier> s/as/has/
<tessier> Right now I have a class which reads the [defaults] section with config parser and populates a dictionary.
<SpComb> an ini file?
<tessier> And that class instantiates another class which looks for a particular [section] and gets its own configs from there
<pjd> tessier: you can putting the defaults in a class, and instantiate it, putting the overrides in the instance
<tessier> SpComb: Yep. ConfigParser
<pjd> "can put", even
<tessier> pjd: Yeah but then the users have to edit the class to change the defaults. Seems not as slick as having it in the config.
<tessier> I would rather the end user not have to touch the code.
<pjd> tessier: no, you can populate the class dynamically
<pjd> from the config file
<pjd> you replace the dictionary with the class, in other words
<tessier> hrm
<pjd> otherwise, the best course of action would be a dictionary subclass that implements __missing__ by looking in the other dictionary
<pjd> probably
<tessier> How do I replace the dictionary with the class?
<pjd> you just populate the class instead of the dictionary :)
<pjd> or the instance, as appropriate
<pjd> are you going to have more than one level of defaulting?
<tessier> And how do I populate the instance?
<tessier> No, just the one level
<pjd> tessier: same as the class; you just assign attributes
<tessier> But I do not necessarily know what the attribute names will be in advance.
Previous Page Next Page