Re: [offtopic] Re: Set of Dictionary

2005-06-26 Thread Brian van den Broek
; set theories interesting and thought that some others here > might too.) > > -- James So do I :-) Do you know of non-well-founded set theory (non-standard set theory which allows sets A, such that A is in A)? Not really on point for any of the above, but being on topic is in the rear view mirror, anyway :-) <http://cslipublications.stanford.edu/site/1575860082.html> <http://cslipublications.stanford.edu/site/0937073229.html> Best, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: Which kid's beginners programming - Python or Forth?

2005-06-27 Thread Brian van den Broek
and a bit intimidated by the prospect. It quickly got me to a place where reading "grown up" books like Learning Python was easy enough. Best, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: How to compress a folder and all of its sub directories and files into a zip file?

2005-06-28 Thread Brian van den Broek
se when writing the archive, and should be ZIP_STORED or ZIP_DEFLATED; unrecognized values will cause RuntimeError to be raised. If ZIP_DEFLATED is specified but the zlib module is not available, RuntimeError is also raised. The default is ZIP_STORED." http://docs.python.org/lib/zipfile-objects.html So, it would appear that compression requires a 3rd party module, not included in Python (and not present on my Windows box). I'm presently filing a bug suggesting this be made a touch more explicit in the zlib docs. Best to all, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: How to compress a folder and all of its sub directories and filesinto a zip file?

2005-06-28 Thread Brian van den Broek
Fredrik Lundh said unto the world upon 28/06/2005 08:04: > Brian van den Broek wrote: > > >>So, it would appear that compression requires a 3rd party module, not >>included in Python (and not present on my Windows box). > > > where did you get your Windows Pytho

Re: Newbie: Explain My Problem

2005-06-29 Thread Brian van den Broek
(raw_input("Your guess is: ")) counter = counter - 1 if guess == num: print "You guessed the number, %s in %s guesses!" %(num, 7-counter) break # else it will print success msg forever elif guess > num: print "\nThe numbe

Re: I have a question.

2005-06-30 Thread Brian van den Broek
Nathan Pinno said unto the world upon 30/06/2005 11:22: > > Hi all, > > Does Python have a random function? If so, can you show me an example > using it? > > Thanks, > Nathan Pinno > http://www.npinnowebsite.ca/ >>> import random >>> print "It took %s seconds to find the module name

Re: Programmers Contest: Fit pictures on a page

2005-07-01 Thread Brian van den Broek
on space, thus optimizing it. Unless *my* irony > processors are malfunctioning, I don't think there's anything ironic > about this. (If anything it looks like the exact opposite of irony, to me.) > > -Peter Well, I found it ironic, but only when you add that t

Re: Programmers Contest: Fit pictures on a page

2005-07-01 Thread Brian van den Broek
Robert Kern said unto the world upon 01/07/2005 17:24: > Brian van den Broek wrote: > > >>Well, I found it ironic, but only when you add that the genetic >>algorithm approach came up in the context of a "best fit" problem. >>Survival of the fittest indeed

Re: Bad Math

2005-07-01 Thread Brian van den Broek
Patrick Rutkowski said unto the world upon 01/07/2005 23:56: > I started reading a python book today, one example was: > > 4 / (2.0 + 3) > > 0.8 > > My input/output was: > > 4 (2.0 + 3) > > 0.80004 > > Something smells fishy here... whats up? > > --python 2.4.1

Re: Another newbie question from Nathan.

2005-07-01 Thread Brian van den Broek
might find the Tutor list of real help. <http://mail.python.org/mailman/listinfo/tutor>. Nothing wrong with not knowing how to do stuff like this -- few were born knowing, after all -- but the Tutor list specializes in answering in a way targeted to beginners. It's where I learned much of what I know. Best, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: Bad Math

2005-07-02 Thread Brian van den Broek
Patrick Rutkowski said unto the world upon 02/07/2005 09:25: > On 7/2/05, Brian van den Broek <[EMAIL PROTECTED]> wrote: > >>Patrick Rutkowski said unto the world upon 02/07/2005 00:12: >> >>>That's... annoying, to say the least. And my number 4/5 was a ra

precision problems in base conversion of rational numbers

2005-07-04 Thread Brian van den Broek
sion in an expression of base m in general? (I've no formal training in Comp Sci, nor in the relevant branches of mathematics.) Thanks and best, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: precision problems in base conversion of rational numbers

2005-07-05 Thread Brian van den Broek
Terry Hancock said unto the world upon 05/07/2005 11:49: > On Monday 04 July 2005 06:11 am, Brian van den Broek wrote: > >>As a self-directed learning exercise I've been working on a script to >>convert numbers to arbitrary bases. It aims to take any of whole >>nu

Re: Do a "Python beginners e-mail list" exist?

2005-07-07 Thread Brian van den Broek
> list" or a "Python beginners list" exist? Check out the Tutor list <http://mail.python.org/mailman/listinfo/tutor> Best, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: An absolute Newbie question

2005-07-10 Thread Brian van den Broek
nguage to learn, and thus far it does seem so, but > I need to get past this first;-). > > Thanks in advance, > > wpog Take a look at <http://hkn.eecs.berkeley.edu/~dyoo/python/idle_intro/>. But the quick answer: Launch IDLE. File Menu -> New Window Type away. (Be sure

Re: Replacing last comma in 'C1, C2, C3' with 'and' so that it reads 'C1, C2 and C3'

2005-07-12 Thread Brian van den Broek
regardless of the length of the string. > > Regards and sorry for the newbie question, > > Ric > Hi Ric, the rsplit method of strings should get you going: >>> data = "the first bit, then the second, finally the third" >>> chunks = data.rsplit(',',

Re: 2.4 Recent File list not working

2005-07-13 Thread Brian van den Broek
are forthcoming, you might want to try any support or user's lists for the ActiveState Python distribution. Best, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: problems with python 2.4 help

2005-07-15 Thread Brian van den Broek
ent variable to point to them. (On WinXP: Control Panel->System-Advanced->Env. Var. When I had WinME, a line in autoexec.bat) Best, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: interactive python session spool/save-log command?

2005-07-20 Thread Brian van den Broek
. > > http://ipython.scipy.org/ > If your students are more likely to feel comfortable with an interface with things right there for the clicking, IDLE allows for the interactive prompt windows to be saved. IDLE's bundled with Python, so less to install to boot. Best, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: Difference between " and '

2005-07-22 Thread Brian van den Broek
' to """double triple""" but a while back I noticed pydoc doesn't work as well with single triple quotes. When I posted here, Kent Johnson was kind enough to tease out of me what I was on about and file a bug: <http://sourceforge.net/tracker/index.php?func=detail&aid=1185124&group_id=5470&atid=105470> Best to all, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: empty classes as c structs?

2005-02-07 Thread Brian van den Broek
Alex Martelli said unto the world upon 2005-02-06 18:06: Brian van den Broek <[EMAIL PROTECTED]> wrote: ... (I'm just a hobbyist, so if this suggestion clashes with some well established use of 'Bag' in CS terminology, well, never mind.) Yep: a Bag is a more common

RESOLVED broke IDLE while defining a key-binding scheme

2005-02-07 Thread Brian van den Broek
Brian van den Broek said unto the world upon 2005-02-04 22:21: Hi all, IDLE refuses to launch, and I believe it is because I attempted to define a custom key-binding that it doesn't like. shortcuts, etc.) by clicking on it. Nothing. Ran idle.py instead > . The DOS-console this b

Re: Unable to run IDLE Under Windows

2005-02-07 Thread Brian van den Broek
t my disposal, but didn't manage to find the text you posted. (If I'd been able to find it, I'd have been able to solve my problem days ago.) Thanks and best, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: python code with indention

2005-02-07 Thread Brian van den Broek
er myself an " print "accomplished Pythoner." print print "In the face of that, " print "I know enough not to post Python 'tutorials'." Best, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: variable declaration

2005-02-07 Thread Brian van den Broek
fect the structure of the function object's bytecode, but not its behaviour when run? Or, at most, would cause a performance effect due to the bytecode being bloated by thousands of line's worth of code that would never get executed? Thanks for any confirmation of my understanding / rectification of same. Best, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: Learning Python - resources and ideas

2005-02-08 Thread Brian van den Broek
ite some time ago). The Learning Python helped a lot <http://www.oreilly.com/catalog/lpython2/>. Best, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: variable declaration

2005-02-08 Thread Brian van den Broek
Brian van den Broek said unto the world upon 2005-02-07 20:36: Steve Holden said unto the world upon 2005-02-07 17:51: The reason global is a wart can clearly be seen in the following example: >>> x = 3 >>> def f(tf, v): ... if tf: ... global x ... x = v ... &g

Re: goto, cls, wait commands

2005-02-10 Thread Brian van den Broek
repeats until guess == number. Another common idiom is while True: # do some stuff if some_condition: # some condition being True signals the break # need to break out of the loop I game to Python 10'ish years after I'd programmed some in BASIC and then not again. It took me a while to grok goto-less coding, too :-) HTH, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: Unit Testing in Python

2005-02-10 Thread Brian van den Broek
spot.com/2005/01/python-unit-testing-part-3-pytest-tool.html> <http://www.onlamp.com/lpt/a/5463> <http://www.onlamp.com/lpt/a/5584> (Your footnotes didn't come through, so these might not be new to you.) Best, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: problem with tutor mailing

2005-02-16 Thread Brian van den Broek
east, you've got to put up with long questions posted by me ;-) But, I'd encourage you to remain subscribed. I am certainly no expert (as today's Tutor traffic can attest). But, much of what I know I learned by reading other people's questions and the answers to them. B

Re: duplicate docstrings

2005-02-19 Thread Brian van den Broek
es this help: IDLE 1.1 >>> class Spam: '''I'm a very spammy docstring''' pass >>> class Ham: __doc__ = Spam.__doc__ >>> help(Ham) Help on class Ham in module __main__: class Ham | I'm a very spammy docstring >>> best, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: NOOB coding help....

2005-02-22 Thread Brian van den Broek
s you are trying to put together to see why they might not fit? For instance, look what happens when you run this, entering 42 at the prompt: ri = raw_input('Gimme!') print type(ri) print type(int(ri)) print ri == 42 print ri == '42' name_not_defined_in_this_code Does looking at the output of that help? Best, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: Selective HTML doc generation

2005-02-23 Thread Brian van den Broek
startswith('__') and name.endswith('__'): return 1 So, just change the 1 to a 0. (The `private' logic is a few lines down.) Easy :-) Hope that is at least of some help. Best, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: Selective HTML doc generation

2005-02-24 Thread Brian van den Broek
Graham Ashton said unto the world upon 2005-02-24 04:54: Thanks Brian, much appreciated. Looks quite straightforward. Graham Hi Graham, glad it helped -- I think this marks the first time I've given a useful answer to a non-trivial question on comp.lang.python. :-) G: Hi. I'm loo

Re: Need help running external program

2005-02-27 Thread Brian van den Broek
he 'r' any pointers to documentation appreciated. Thanks RiGGa <http://www.python.org/doc/current/ref/strings.html> <http://www.python.org/doc/current/lib/module-re.html> Best, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: Trees

2005-02-27 Thread Brian van den Broek
of get_descendants on a node's children, adding .all to the .descendants set (of the target node). .''' .descendants = self.children.copy() .for node in self.children: .node.get_descendants() .for n in node.descendants: . descendants.add(n)

Re: Python 2.4 removes None data type?

2005-03-07 Thread Brian van den Broek
itself -- poor thing just gave up. So, it looks like Steve has found a `commit suicide' command for an IDLE shell :-) Best to all, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: using the set command

2005-03-11 Thread Brian van den Broek
with the error message would be most handy for those who wish to help you. Python 2.4 has the set datatype as a builtin. Best, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: Tkinter WEIRDNESS or Python WEIRDNESS?

2005-03-11 Thread Brian van den Broek
bility. Still another (but one not so good for clarity or beauty) would be to put a line like: temp = currentAbility # temp a name to reference global scope name # before assignment to follow. Perhaps more expert voices will chime in and say better things. :-) HTH, Brian vd

Re: Tkinter WEIRDNESS or Python WEIRDNESS?

2005-03-12 Thread Brian van den Broek
steve said unto the world upon 2005-03-12 18:46: Brian van den Broek <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... steve said unto the world upon 2005-03-12 00:06: In a nutshell, my problem is that I am getting this runtime error, and I have no clue why. Please

Re: try / except not worknig correctly

2005-03-12 Thread Brian van den Broek
\PYTHON24\lib\string.py", line 235, in upper return s.upper() AttributeError: 'int' object has no attribute 'upper' >>> Additionally, string methods are often preferred to the string module: >>> b = 'lower' >>> b.upper() 'LOWER' >>> You might also want to test if myInput in ('A', 'B', 'C', 'etc'): .break instead of your chain of if tests. Best, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: [Python-Dev] RELEASED Python 2.4.1, release candidate 1

2005-03-13 Thread Brian van den Broek
Perhaps its not a big deal, but I'd prefer the install process to inform me if it detected a previous install and intended to remove it. Best to all, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

[OT] Re: Python becoming less Lisp-like

2005-03-16 Thread Brian van den Broek
treet fights? ;-) Best, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: newbie : modifying a string in python

2005-03-16 Thread Brian van den Broek
_chars)] + new_chars ... >>> test_string 'some text ending in GF' >>> Wrap that in a function: def replace_at_end(string, old, new): # logic here with a return of the new string as the last line and you've got something reusable :-) (There may be better ways, still; I'm no expert :-) HTH, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

replace from end of string?

2005-03-16 Thread Brian van den Broek
here oughtn't be? Thanks, and best to all, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: newbie:unique problem

2005-03-17 Thread Brian van den Broek
seen_leading_chars.add(member[:n]) output_list.append(member) return output_list test_list = ["AAA BC", "BBB KK", "CCC TD", "AAA KP", "CCC TD", "AAB KP"] print unique_up_to_n_char(test_list, 3) print unique_up_t

Re: newbie:unique problem

2005-03-17 Thread Brian van den Broek
don't know how to change the function to handle this ? I have a feeling it's not that hard though ? Thanks. Doing the same thing Brian van den Brook did with sets (also for 2.4 only): def uniqueItems(oldlist,comppos=3): rv = {} for i in reversed(oldlist): rv[i[:comp

Re: newbie:unique problem

2005-03-18 Thread Brian van den Broek
Heiko Wundram said unto the world upon 2005-03-18 01:27: On Thursday 17 March 2005 23:31, Brian van den Broek wrote: Am I not right in thinking that with the dict approach there is no guarantee that the order from the original list will be preserved? Yup, absolutely right that the original

Re: Pre-PEP: Dictionary accumulator methods

2005-03-18 Thread Brian van den Broek
dlist(self, key, sequence): try: self[key].extend(sequence) except KeyError: self[key] = list(sequence) I am, however, very open to the possibility that this says more about my level of experience than it does about which way is best :-) Best to all, Brian vdB -- http://

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Brian van den Broek
Kent Johnson said unto the world upon 2005-03-19 07:19: Brian van den Broek wrote: Raymond Hettinger said unto the world upon 2005-03-18 20:24: I would like to get everyone's thoughts on two new dictionary methods: def appendlist(self, key, *values): try:

Re: hello all

2004-12-03 Thread Brian van den Broek
ammer than the target audience, the Tutor list is very good for people just getting started with Python. <http://mail.python.org/pipermail/tutor/> The main list is also quite happy to answer newcomer help questions, but the Tutor folk specialize at it. HTH, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: window size in IDLE

2004-12-03 Thread Brian van den Broek
like a charm. HTH, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: How did you learn Python?

2004-12-03 Thread Brian van den Broek
xperience. <http://diveintopython.org/>. It is also available as a dead-tree product from APress. HTH, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: simple GUI question

2004-12-08 Thread Brian van den Broek
good place to start looking: <http://www.google.com/search?num=50&hl=en&q=Tkinter+Python+font+widget&btnG=Search&meta=> Best, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: simple GUI question

2004-12-08 Thread Brian van den Broek
Brian van den Broek said unto the world upon 2004-12-08 03:16: Hi, I don't know Tkinter past a hour of playing, so I cannot show you how. I can, however, show you a good place to start looking: <http://www.google.com/search?num=50&hl=en&q=Tkinter+Python+font+widget&btnG=

Re: uptime for Win XP?

2004-12-12 Thread Brian van den Broek
anks again! Esmail Hi Esmail, try looking for it on your box ;-) When I recently installed win32all, my Python 2.4 entry on the startmenu grew a shortcut for "Python for Windows Documentation". Best, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

lowering the case of strings in list -- WAS: (No subject)

2004-12-16 Thread Brian van den Broek
'CLASS-map Match-Any cmap2', 'MaTch AnY', 'Policy-map policy1', 'Class cmap1', 'policy-Map policy2', 'Service-PoLicy policy1', 'claSS cmap2'] .>>> lower_list_o_strings(l) ['class-map match-all cmap1', 'match ip any', 'class-map match-any cmap2', 'match any', 'policy-map policy1', 'class cmap1', 'policy-map policy2', 'service-policy policy1', 'class cmap2'] Best, Brian vdB PS "No subject" is only marginally better than "HELP!!" ;-) -- http://mail.python.org/mailman/listinfo/python-list

Re: Adding paths to sys.path permanently, and another problem...

2004-12-16 Thread Brian van den Broek
versions of Windows, but I'd imagine so.) There to, I have added a line SET PYTHONPATH=D:\List_Of_Dirs;D:\Use_a_semi_colon_to_sep_items_on_Win Which puts those dirs into sys.path (at the front, I believe). I also used the .pth file trick because they two means differ as to where in the sys.path they add their entries. Best to all, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

mailing list welcome welcome msg in wiki suggestion

2004-12-12 Thread Brian van den Broek
eems a good idea. My attempt at a draft (in wiki markup) is below. If anyone with sufficient community 'juice' thinks the idea good, please feel free to use my text to start such a page. Or, if community endorsement follows, I will happily do so myself. Best to all, Brian vdB = W

Re: NO REALLY

2004-12-15 Thread Brian van den Broek
posts. That would be so freaky... -Peter Without a doubt that is the most ignorant and small-minded thought that ever has been, and ever could be, committed to words! (My research project to build a super-cooled ultra-efficient time machine goes poorly. To save the funding, I'm driven to fudgi

Re: Boo who? (was Re: newbie question)

2004-12-20 Thread Brian van den Broek
gh I do wonder if you saw the smiley he employed above.) Then let me ask you this: does pushing that and similar points through several iterations on multiple threads really seem a very good method for making the list appear to be friendly welcoming place that I presume you want it to be? B

Re: input record sepArator (equivalent of "$|" of perl)

2004-12-21 Thread Brian van den Broek
John Machin said unto the world upon 2004-12-21 18:20: Subtle distinction: A metER is a measuring device. A MetRE is a unit of distance. Not everyone agrees <http://www.bartleby.com/61/18/M0251800.html>. I do, but then I think it ought be spelled 'colour', too. Best, B

Dubious Python WAS: Re: Lambda going out of fashion

2004-12-24 Thread Brian van den Broek
n/DubiousPython>. I hope this seems like a good idea to others, particularly those more able to extend it than I. (I'd also be grateful if others could remove any feet than I might have inadvertently put into my mouth on the wiki page.) Best to all, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: Global variables and modules

2004-12-24 Thread Brian van den Broek
ntions this idiom. However, I don't have my copy with me (seasonal travel, and all), so apologies if my memory leads me astray. For what its worth, I'm glad for the advice in Nutshell. It transforms the book from a useful thing for those who like dead-tree references into a text one can actually read (as opposed to merely consult quickly). Best to all, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Python limericks (was Re: Text-to-speech)

2005-03-20 Thread Brian van den Broek
Out of objects, command of a line There was nary a brace. In their place? Some whitespace! And cast many their Perl before swine. (I agree that the idiom played upon in the last line is obverted, but but plead poetic license :-) Best to all, Brian vdB -- http://mail.pytho

Re: Text-to-speech

2005-03-21 Thread Brian van den Broek
ess of context or language in which they are employed. A formal statement of my position shall be forthcoming from my solicitors, the illustrious firm of Dewey, Cheatem, & Howe. I am optimistic that we will be able to arrive at licencing terms both fair and equitable. I remain your most faithful servant, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: Beginner Question - Very Easy I'm Sure...

2005-03-24 Thread Brian van den Broek
gt;> rannum = str(rannum) >>> new_word = word + rannum >>> print new_word dog773 or, >>> rannum = str(random.randrange(100,999)) >>> word + rannum 'dog287' >>> HTH, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: list-comprehension and map question (simple)

2005-03-27 Thread Brian van den Broek
uld be missing some edge cases, but it seems to me that if you have list comps you don't really need map, filter, and the like. The map portion can be done by nested function applications in the list comp itself. Best, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: list-comprehension and map question (simple)

2005-03-27 Thread Brian van den Broek
Charles Hartman said unto the world upon 2005-03-27 13:35: On Mar 27, 2005, at 1:18 PM, Brian van den Broek wrote: >>> def some_arbitrary_function(y): ... return ( (y * 42) - 19 ) % 12 ... >>> [some_arbitrary_function(len(x)) for x in lines.split()] [5, 5, 11, 11, 5, 11, 5,

Re: list-comprehension and map question (simple)

2005-03-27 Thread Brian van den Broek
Brian van den Broek said unto the world upon 2005-03-27 14:12: Charles Hartman said unto the world upon 2005-03-27 13:35: On Mar 27, 2005, at 1:18 PM, Brian van den Broek wrote: >>> def some_arbitrary_function(y): ... return ( (y * 42) - 19 ) % 12 ... >>> [some_arbitrary_func

Re: String Splitter Brain Teaser

2005-03-27 Thread Brian van den Broek
turns None, this could use accumulate = result.append([result.pop()[0], char]) in place of the two lines in the if accumulate block, but I don't think that is a gain worth paying for.) HTH, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: String Splitter Brain Teaser

2005-03-27 Thread Brian van den Broek
k ... >>> group("ATT/GATA/G") [['A'], ['T'], ['T', 'G'], ['A'], ['T'], ['A', 'G']] >>> Michael Much nicer than mine. =| :-) ^ | (hats off) I've got to get iterators into my working vocabulary! Best, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: [Newbie] How do I get better at Python programming?

2005-03-28 Thread Brian van den Broek
n, I didn't get much out of reading c.l.p, but the tutor list was pitched at a level much more appropriate to the understanding I had. Other than that: Write code. Read code. Repeat. :-) Best, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: Little Q: how to print a variable's name, not its value?

2005-03-28 Thread Brian van den Broek
'myTime' : 'right now' } for item in Stewarts_data.items(): print '%s = %s' %item (There are likely even nicer ways -- for instance in Python 2.4 you can use sorted() on the dictionary -- but this gets the idea across, I hope.) Best, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: instance vs class attributes

2005-03-29 Thread Brian van den Broek
I'm a shy docstring >>> # calling a mangled method name from outside the class >>> shy = Shy() >>> shy.__mangled_method() Traceback (most recent call last): File "", line 1, in -toplevel- shy.__mangled_method() AttributeError: Shy instance has no attribute '__mangled_method' >>> shy._Shy__mangled_method() Ive been mangled! >>> Best, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

testing -- what to do for testing code with behaviour dependant upon which files exist?

2005-04-02 Thread Brian van den Broek
share with someone else, and so I'd have to know details of his file system, too. (If it matters, I am using Python 2.4.1 on windows, and I am sending the code to someone running Python 2.2 on Linux.) So, how does one handle such cases with tests? Thanks for any suggestions. Best, Brian

Re: testing -- what to do for testing code with behaviour dependant upon which files exist?

2005-04-04 Thread Brian van den Broek
"Brian van den Broek" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Hi all, I'm just starting to employ unit testing (I'm using doctest), and I am uncertain how to handle writing tests where the behaviour being tested is dependant on whether certain

Re: testing -- what to do for testing code with behaviour dependant upon which files exist?

2005-04-04 Thread Brian van den Broek
Jeremy Bowers said unto the world upon 2005-04-04 17:26: On Mon, 04 Apr 2005 17:02:20 -0400, Brian van den Broek wrote: Jeremy suggested using a directory name akin to "C:\onlyanidiotwouldhavethisdirecotrynameonadrive". That is what I had settled on before I posted. Somehow it feels u

Re: Super Newbie Question

2005-04-04 Thread Brian van den Broek
step -- just open the file in write mode when you want to write to it again, and that will over-write any extant contents. HTH, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: Change between Python 2.3 and 2.4 under WinXP

2005-04-05 Thread Brian van den Broek
one 2.4 version at a time is supported due to there being only one python24.dll. But the msi install process now informs you of this (thanks Martin :-) Best, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: Doubt regarding sorting functions

2005-04-10 Thread Brian van den Broek
sorting routine, the two dominant ways are to either use the decorate-sort-undecorate idiom or define a custom cmp function. Both are discussed in the links above. Best wishes, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: variables exist

2005-04-11 Thread Brian van den Broek
is is why I do it.) Or for some other reason? I have no partisan interests either way; I'm just trying to understand. Thanks and best, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

[OT] Re: Programming Language for Systems Administrator

2005-04-12 Thread Brian van den Broek
account of MS's plans is true, it would seem to indicate a combination of arrogance, honesty, and ignorance. (I leave it to you to decide which part, if any, of this triad, is surprising.) Best to all, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: variables exist

2005-04-12 Thread Brian van den Broek
Richard Brodie said unto the world upon 2005-04-12 04:56: "Brian van den Broek" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] I'm a hobbyist and still learning, but the claim the try/except is "lousy Python" surprise me a bit. I think it wasn't

Re: nested tuple slice

2005-04-12 Thread Brian van den Broek
_sliced_tuple = tuple([x[0:2] for x in my_tuple]) >>> my_sliced_tuple (('goat', 90), ('cat', 80), ('platypus', 60)) >>> BTW, don't use `tuple' as a name. You can, but then you hide the built-in tuple function. And, you need that :-) Best, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

pydoc preference for triple double over triple single quotes -- any reason?

2005-04-16 Thread Brian van den Broek
e PEP's have the tone of suggestions, and since the two quoting schemes are semantically equivalent . . . I do prefer the look of triple-single, but oh well. My attempts to google for an answer didn't come up with anything, so perhaps this post will help someone else, if nothing else :-) Best to all, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: pydoc preference for triple double over triple single quotes -- anyreason?

2005-04-17 Thread Brian van den Broek
Kent Johnson said unto the world upon 2005-04-16 16:41: Brian van den Broek wrote: Hi all, I'm posting partly so my problem and solution might be more easily found by google, and partly out of mere curiosity. I've just spent a frustrating bit of time figuring out why pydoc didn&#

Re: pydoc preference for triple double over triple single quotes-- anyreason?

2005-04-17 Thread Brian van den Broek
Kent Johnson said unto the world upon 2005-04-17 16:17: Brian van den Broek wrote: Kent Johnson said unto the world upon 2005-04-16 16:41: Brian van den Broek wrote: I've just spent a frustrating bit of time figuring out why pydoc didn't extract a description from my module docstr

Re: pydoc preference for triple double over triple single quotes--anyreason?

2005-04-18 Thread Brian van den Broek
acker/index.php?func=detail&aid=1185124&group_id=5470&atid=105470 Kent Thanks for sticking with this, Kent. Also, thanks for the patch and for filing the bug. (I had thought of doing so before posting, but don't yet feel quite confident enough in my judgement that I'd

Re: building a small calculator

2005-04-20 Thread Brian van den Broek
Once again, a rough first approximation.) I'd second the recommendation you received to check out the Tutor list -- both lists are friendly, but Tutor is perhaps better geared to the level of explanation that you might find most helpful in these early stages. Best, Brian vdB -- http:

Re: Private class?

2005-04-21 Thread Brian van den Broek
p://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52558> <http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/102187> <http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/286206> <http://fraca7.free.fr/blog/index.php?2005/03/23/6-design-patterns-part-iii---singleton> Best

Re: New line

2005-04-21 Thread Brian van den Broek
iles. (Be sure to save them with the .py extension, as IDLE doesn't automatically do so.) Best, brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: Dictionary question.

2005-04-21 Thread Brian van den Broek
y_dict = {} for element in sequence: frequency_dict[element] = frequency_dict.setdefault( element, 0) + 1 return frequency_dict HTH, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: time.strftime in 2.4.1 claims data out of range when not

2005-04-22 Thread Brian van den Broek
your code worked on 2.2.2; I've no idea. The docs do seem to indicate that there were a number of changes at 2.2, though. Best, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: Overiding error message when using a python program

2005-04-22 Thread Brian van den Broek
Sion Arrowsmith said unto the world upon 2005-04-22 13:00: Brian van den Broek <[EMAIL PROTECTED]> wrote: you've not included the part of your code which acts on the user's input. I think you'll find the answer to the question of where the code that acts on the user

Re: puzzled about class attribute resolution and mangling

2005-12-11 Thread Brian van den Broek
James Stroud said unto the world upon 2005-12-09 20:39: > Brian van den Broek wrote: > >>Hi all, >> >>I've the following code snippet that puzzles me: >> >>class Base(object): >>__v, u = "Base v", "Base u" >>def

Re: newbie-name mangling?

2005-12-13 Thread Brian van den Broek
m.__c AttributeError: 'Mangled' object has no attribute '__c' >>> m._Mangled__c 'very shy' >>> The __ mangling is, as I understand it, a way of saying "I don't think you, as a user of the code, should mess with this attribute unless you really know what you are doing. Proceed with caution." It isn't really private as Python lets you get to pretty much anything. It is a strong signal, though. HTH, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: newbie-one more example of difficulty in van Rossum's tutorial

2005-12-13 Thread Brian van den Broek
ll last): File "C:/Python24/foobar.py", line 13, in -toplevel- print a.evalget('__b') File "C:/Python24/foobar.py", line 8, in evalget return eval("self.%s" %arg) File "", line 0, in -toplevel- AttributeError: 'A' object has no attribute '__b' >>> In fuzzy terms, a method of a class doesn't have to mangle its __ names to access them. But, access through eval, etc. does require the mangled reference; it is as if the eval doesn't know it is being invoked in the class being accessed. HTH, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: Still Loving Python

2005-12-14 Thread Brian van den Broek
> # p.d. It seems to me that long tradition has it that "evil" in a context such as this really is not that strong a term. See <http://www.catb.org/jargon/html/E/evil.html>. If you knew that and were still objecting, sorry for the noise. Best, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: Any good Python forums?

2005-12-15 Thread Brian van den Broek
python.org/mailman/listinfo/tutor> is even more friendly to newcomers than the notably friendly list to which you posted. Best, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

<    5   6   7   8   9   10   11   12   >