doctest and exposing internals.

2006-10-20 Thread Neil Cerutti
checking if an event is queued in Glk, so I resorted to exposing the internal state main.char_request in the doc string. What are the alternatives? In addition, the last test in the docstring is only there to ensure that other tests can open a window themselves (this version of the library only allows one window to be open at a time). -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: doctest and exposing internals.

2006-10-20 Thread Neil Cerutti
On 2006-10-20, Gabriel Genellina <[EMAIL PROTECTED]> wrote: > At Friday 20/10/2006 16:29, Neil Cerutti wrote: >>The example of correct usage it what's wrong with the >>docstring. >> >>There's no interface for checking if an event is queued in Glk, >

Re: Tkinter--does anyone use it for sophisticated GUI development?

2006-10-22 Thread Neil Cerutti
i.org/ > > but none have Python support (or again maybe im wrong) PyGame for SDL, I think. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Arrays? (Or lists if you prefer)

2006-10-22 Thread Neil Cerutti
) and then fill it in afterwards. >>> b =[range(2), range(2)] >>> b [0, 1], [0, 1]] >>> b[0][1] = "OK." >>> b [0, 'OK.'], [0, 1]] A flexible way to do it instead might be to make your data attributes of objects, instead

Re: encoding of sys.argv ?

2006-10-23 Thread Neil Cerutti
rds, sys.stdin.encoding. Your only hope of accepting non-US-ASCII command line arguments in this manner is that sys.stdin.encoding is divined correctly by Python. -- Neil Cerutti Facts are stupid things. --Ronald Reagan -- http://mail.python.org/mailman/listinfo/python-list

The format of filename

2006-10-24 Thread Neil Cerutti
Where can I find documentation of what Python accepts as the filename argument to the builtin function file? As an example, I'm aware (through osmosis?) that I can use '/' as a directory separator in filenames on both Unix and Dos. But where is this documented? -- Neil C

Re: The format of filename

2006-10-24 Thread Neil Cerutti
On 2006-10-24, Leif K-Brooks <[EMAIL PROTECTED]> wrote: > Neil Cerutti wrote: >> As an example, I'm aware (through osmosis?) that I can use '/' >> as a directory separator in filenames on both Unix and Dos. >> But where is this documented? > > It&#

Re: The format of filename

2006-10-24 Thread Neil Cerutti
On 2006-10-24, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Neil Cerutti wrote: > >> Where can I find documentation of what Python accepts as the >> filename argument to the builtin function file? >> >> As an example, I'm aware (through osmosis?) that I c

Re: The format of filename

2006-10-24 Thread Neil Cerutti
On 2006-10-24, Neil Cerutti <[EMAIL PROTECTED]> wrote: > Is translation of '/' to '\\' a feature of Windows or Python? Well, *that* was easy to discover on my own. ;-) Thanks for the pointers. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: The format of filename

2006-10-24 Thread Neil Cerutti
On 2006-10-24, Neil Cerutti <[EMAIL PROTECTED]> wrote: > On 2006-10-24, Neil Cerutti <[EMAIL PROTECTED]> wrote: >> Is translation of '/' to '\\' a feature of Windows or Python? > > Well, *that* was easy to discover on my own. ;-) > > Thanks for

Re: Current stackdepth outside PyEval_EvalFrameEx

2006-10-24 Thread Neil Cerutti
alue outside of >> PyEval_EvalFrameEx. Inside of it, I'd use the STACK_LEVEL >> macro. How do I do it? > > No hints? Perhaps the inspect module will help? See 3.11.4 The Interpreter Stack. -- Neil Cerutti I make love to pressure. --Stephen Jackson -- http://mail.python.org/mailman/listinfo/python-list

Re: cleaner way to write this?

2006-10-25 Thread Neil Cerutti
pe and some of the code is intricate. Such expansion of size and complexity is a typical result of moving from prototype to production. (It's a useful book, especially for a hobbyist programmer. Though there's not much Python code in it, pretty much all the advice inside is applicab

Re: Any way of adding methods/accessors to built-in classes?

2006-10-25 Thread Neil Cerutti
#x27;t > [1,2,3].len better?) > > I think you can't add methods to Python builtin classes, I > think you can do it with Ruby. You can create derived versions of builtins with new methods (which affords the benefits of modifying builtins), but you can't change the type of a Pyt

Re: What's the best IDE?

2006-10-25 Thread Neil Cerutti
rly just Alt. Those same people often hold to the heresy that 'to fill' means 'to wrap'. They believe that modes exist for different 'languages', and moreover, that there's more than just the trinity of INSERT, EDIT and COMMAND-LINE. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: What's the best IDE?

2006-10-25 Thread Neil Cerutti
On 2006-10-26, Neil Cerutti <[EMAIL PROTECTED]> wrote: > It seems like the holy wars are pretty. We disciples of Vim and > Emacs are now content merely being holier than all he others. > > Actually, I'm not sure there's been a good Emacs VS Vim holy war > in years.

Re: The format of filename

2006-10-26 Thread Neil Cerutti
On 2006-10-26, Tim Roberts <[EMAIL PROTECTED]> wrote: > Neil Cerutti <[EMAIL PROTECTED]> wrote: >> >>Some experimentation shows that Python does seem to provide >>*some* translation. Windows lets me use '/' as a path separator, >>but not as the

Re: The format of filename

2006-10-26 Thread Neil Cerutti
On 2006-10-26, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Neil Cerutti wrote: >> Seriously, experiments show the forward slash is OK as a >> seperator, it just can't be root. > > do you think you can figure out why, even without reading the > various MSDN pages

Re: What's the best IDE?

2006-10-26 Thread Neil Cerutti
out 20 minutes with the built-in tutorial. Getting it to work seemlessly with Python code will take considerably longer. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: [OT] Win32 and forward/backslashes (was "The format of filename")

2006-10-26 Thread Neil Cerutti
globbing since the shell doesn't do it. You would think that a library would've been available to DOS programmers to unify that procedure, but apparently not. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: scared about refrences...

2006-10-30 Thread Neil Cerutti
lly simplified > example but the effects are the same... How do I specify or > create deep copies of objects that may contain other objects > that may contain other object that may contain other > objects.... See 3.18 Copy -- Shallow and deep copy operations. -- Neil Cerutti I pulled i

Style for modules with lots of constants

2006-11-01 Thread Neil Cerutti
ef_create_by_prompt('Transcript+TextMode', 'WriteAppend', 0) Parsing the combinable bitfield contants might be slowish, though. Thanks for taking the time to consider my question. -- Neil Cerutti For those of you who have children and don't know it, we have a nursery downsta

Re: Style for modules with lots of constants

2006-11-01 Thread Neil Cerutti
On 2006-11-01, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Neil Cerutti: >> scriptref = glk.fileref_create_by_prompt('Transcript+TextMode', >>'WriteAppend', 0) > > That "+" sign seems useless. A space looks enough to me. The >

Re: Style for modules with lots of constants

2006-11-01 Thread Neil Cerutti
le '.'s. > > I think this is a reasonable compromise in avoiding namespace > pollution, without inflicting unseemly text entry overhead on > your module clients. That's looks quite tempting. Thanks! It will be nice to provide a short way to import all the constants at once

Re: Style for modules with lots of constants

2006-11-02 Thread Neil Cerutti
On 2006-11-01, Paddy <[EMAIL PROTECTED]> wrote: > Neil Cerutti wrote: >> The Glk API (which I'm implementing in native Python code) >> defines 120 or so constants that users must use. The constants >> already have fairly long names, e.g., gestalt_Version, &

Re: Projecting MUD maps

2006-11-06 Thread Neil Cerutti
hat might accomplish your goal. You can write a new back-end for it to produce MUD code (so you can design your maps graphically), or you can write a new front-end to interpret MUD code (so you can make IF-Mapper draw maps for you game in progress). http://ifmapper.rubyforge.org/ -- Neil Cerutti --

Re: Simple Tkinter problem

2006-11-07 Thread Neil Cerutti
would like it to assume k=0 unless I tell it > otherwise. I've just been defining k=0 at the start of the > program but it seems there should be a better way. The best way to do it is to never use undefined names. -- Neil Cerutti If only faces could talk. --Pat Summerall -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem getting a file pathname with tkFileDialog

2006-11-09 Thread Neil Cerutti
d > openfilename() instead of openfile();-) The encoding of the filenames in the file system is available from sys.getfilesystemencoding(). That might turn out to be useful when interpreting them. -- Neil Cerutti Strangely, in slow motion replay, the ball seemed to hang in the air for even longer. -

Re: Can not download plugins for jEdit (help!!)

2006-11-09 Thread Neil Cerutti
. I haven't found it terribly useful, but in theory it's invaluable (my project is piddly in size at the moment). If you set shiftwidth to your preferred Python indent, then indenting and unindenting code blocks is as easy as the < and > commands. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Can not download plugins for jEdit (help!!)

2006-11-09 Thread Neil Cerutti
sure is needed or how it works > against the new standard python module: > >:au BufEnter *.py :set smarttab smartindent \ > cinwords="if,elif,else,for,while,def,try,rxcept,finally,class" You shouldn't need that as long as the default plugin for Python loads corre

Re: Py3K idea: why not drop the colon?

2006-11-09 Thread Neil Cerutti
tanding that the colon's justification is asthetic rather than technical (though I too had expected to see a technical excuse for it). -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: comparing Unicode and string

2006-11-10 Thread Neil Cerutti
, always make them Unicode strings by > prepending the "u". That doesn't do any good if you aren't writing them in unicode code points, though. -- Neil Cerutti To succeed in the world it is not enough to be stupid, you must also be well-mannered. --Voltaire -- http://mail.python.org/mailman/listinfo/python-list

Re: comparing Unicode and string

2006-11-10 Thread Neil Cerutti
On 2006-11-10, John Machin <[EMAIL PROTECTED]> wrote: > > Neil Cerutti wrote: >> On 2006-10-16, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: >> > Hello, >> > >> > here is something that surprises me. >> > >> > #coding: iso-885

Re: how is python not the same as java?

2006-11-10 Thread Neil Cerutti
On 2006-11-10, gavino <[EMAIL PROTECTED]> wrote: > both are interpreted oo langauges.. "..." -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Py3K idea: why not drop the colon?

2006-11-10 Thread Neil Cerutti
or, the second comma is the > to-be-continued marker Eyiyi! That's yugly. The colon's main purpose seems to be to allow one-liners: Easy to parse: if a < b: a += 1 Hard to parse if a < b a += 1 -- Neil Cerutti When you're in the public eye, it's wrong to cheat

Re: Py3K idea: why not drop the colon?

2006-11-10 Thread Neil Cerutti
s." deadflag = True Taste: print "You nibble at one of the corners. Yum!" Attack: print "What did the mushroom ever to to you?" default: print "You can't do that to a mushroom." I've often wanted a "Pythonic"

Re: Py3K idea: why not drop the colon?

2006-11-10 Thread Neil Cerutti
Peters referenced by Robert Kern > pointed out earlier in this thread, the ABC language designers > found that indentation-based block structure by itself wasn't > enough to clue new users in about the code structure. Adding > the colon at the end of the if/while/for clause helped.

Re: Py3K idea: why not drop the colon?

2006-11-10 Thread Neil Cerutti
On 2006-11-10, Bjoern Schliessmann <[EMAIL PROTECTED]> wrote: > Neil Cerutti wrote: >> On 2006-11-09, Bjoern Schliessmann > >>> if color == red or blue or green: >>> return 'primary' >>> >>>:) > >> The Inform 6* program

Re: Py3K idea: why not drop the colon?

2006-11-10 Thread Neil Cerutti
On 2006-11-10, Robert Kern <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: >> P.S. I felt I just had to tie this into the thread on >> profanity somehow. But notice that I didn't mention nazis or >> Hitler. ;-) > > You did it just now! I hate Godw

Re: comparing Unicode and string

2006-11-10 Thread Neil Cerutti
. > It then knows precisely how to decode your string literals into > Unicode. How do you write things in "Unicode code points"? for = u"f\xfcr" -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: refactoring so that multiple changes can be made with one variable?

2006-11-15 Thread Neil Cerutti
lines is to pry the details ut of the code if they might change. The above advice seems like a perfect example. -- Neil Cerutti For those of you who have children and don't know it, we have a nursery downstairs. --Church Bulletin Blooper -- http://mail.python.org/mailman/listinfo/python-list

Re: Py3K idea: why not drop the colon?

2006-11-16 Thread Neil Cerutti
? Every language has a syntax. Why not just accept > it as a given and get on with more productive activities? That's all very well if the language has a compromised and ad-hoc syntax. But since Python has a nice clean syntax, it makes me want to be associated with it by investing in i

Re: Best Editor

2006-08-24 Thread Neil Cerutti
table, industrial-strength program like Vim or emacs is something I highly recommend, but it's not necessarily a productive thing to do that at the same time you're learning Python. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Python and STL efficiency

2006-08-24 Thread Neil Cerutti
times. Those of you experiencing a temporary obsession with this topic are encouraged to study The Great Language Shootout, until the obsession goes away. ;) Your time might not be totally wasted; an opportunity to improve the Python solutions may present itself. http://shootout.alioth.debian.org

Re: Python and STL efficiency

2006-08-24 Thread Neil Cerutti
with push_back takes amortized constant time. In the example above, preallocating 4 strings saves (probably) math.log(4, 2) reallocations of the vector's storage along with the consequent copy-construction and destruction of some fixed number of strings. Most of those reallocations take place while the vector is still proportionally quite small. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Python and STL efficiency

2006-08-25 Thread Neil Cerutti
On 2006-08-25, Ben Sizer <[EMAIL PROTECTED]> wrote: > Neil Cerutti wrote: >> On 2006-08-24, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: >> > It will run a lot faster if it doesn't have to keep resizing >> > the array. >> >> I don't

Re: sum and strings

2006-08-25 Thread Neil Cerutti
called ''.join(lst) instead. But that optimization turns out to be valid only if every element of the list is a string. So there isn't, it seems, a practical way of implementing the sum(list of strings) -> ''.join(list of strings optimization. -- Neil Cerutti 8 new c

Re: Newbie programmer question: How do parsers work?(Python examples?)

2006-08-25 Thread Neil Cerutti
as you have experience in other similar languages. -- Neil Cerutti I'm tired of hearing about money, money, money, money, money. I just want to play the game, drink Pepsi, wear Reebok. --Shaquille O'Neal -- http://mail.python.org/mailman/listinfo/python-list

Re: Python editor

2006-08-29 Thread Neil Cerutti
es the Python commands (the version 6 binaries for windows did not). -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Naming conventions (was: Re: refering to base classes)

2006-08-30 Thread Neil Cerutti
first time I saw StudlyCaps I thought it was the ugliest thing I'd ever seen. Now I use it a lot. I still have trouble with GVR's preference for HTTPServer over HttpServer. The latter is, to me, easier to read and write. -- Neil Cerutti These people haven't seen the last of my face. If I go down, I'm going down standing up. --Chuck Person -- http://mail.python.org/mailman/listinfo/python-list

Re: Naming conventions

2006-08-30 Thread Neil Cerutti
On 2006-08-30, Chaz Ginger <[EMAIL PROTECTED]> wrote: > Neil Cerutti wrote: >> The first time I saw StudlyCaps I thought it was the ugliest >> thing I'd ever seen. Now I use it a lot. I still have trouble >> with GVR's preference for HTTPServer over HttpServe

Re: where or filter on list

2006-08-30 Thread Neil Cerutti
for i in xrange(1, len(seq)): if abs(n-seq[i]) < abs(n-seq[m]): m = i return seq[m] Putting my faith in Python builtins instead: def closest_to(n, seq): s = [abs(n-x) for x in seq] return seq[s.index(min(s))] -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Assignment-in-conditional

2006-08-31 Thread Neil Cerutti
; > http://pyfaq.infogami.com/why-can-t-i-use-an-assignment-in-an-expression Python saves me from ever making the assignment-as-conditional mistake, but I invented the conditional-as-assignment mistake to compensate. -- Neil Cerutti A billion here, a billion there, sooner or later i

Re: disgrating a list

2006-09-01 Thread Neil Cerutti
hon way, but I think it's cute: def flatten(x): """Flatten list x, in place.""" i = 0 while i < len(x): if isinstance(x[i], list): x[i:i+1] = x[i] i = i+1 -- Neil Cerutti In my prime I could have handled Michael

Re: disgrating a list

2006-09-01 Thread Neil Cerutti
" exceptions in this way. Is the above really a popular idiom? If so, I guess I'll get used to it. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Test for number?

2006-09-05 Thread Neil Cerutti
ValueError() > except ValueError: > Do_B > else: > Do_A > > If you want to distinguish between the two error cases (not a > number vs number not in [1,20]), handle the second one as > "Do_C" instead of raising ValueError. Is the original value of x available in Do_B and Do_A, or will it have been clobbered before getting there? -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Test for number?

2006-09-05 Thread Neil Cerutti
On 2006-09-05, George Sakkis <[EMAIL PROTECTED]> wrote: > Neil Cerutti wrote: > >> On 2006-09-04, George Sakkis <[EMAIL PROTECTED]> wrote: >> > x=raw_input('\nType a number from 1 to 20') >> > try: >> > x = int(x) >&

Re: iso creation for python backup script

2006-09-07 Thread Neil Cerutti
solution bundled with XP turned out to be incompatible with the one bundled with 95. I had to get a third-party software solution to access my old backups. You might as well start with a third-party solution to begin with. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: 3 Simple Questions About Python/IDLE

2006-09-07 Thread Neil Cerutti
ot; the > lines in memory. You could actually type a program in from last line to > first (ie, upside down) and it would run. > > NO other language that I know of uses line numbers to control > source code order. Heck, Visual BASIC doesn't use line numbers > either (I don

Re: Positive lookahead assertion

2006-09-07 Thread Neil Cerutti
27; where `something else` is enclosed by (?=...) > > The regular expression engine will surreptitiously check that > 'something else' does indeed follow, before returning any match of > 'something'. At any rate it further blurs the line between parsing and pattern-matching. ;) -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Algorithm Question

2006-09-11 Thread Neil Cerutti
me A? A = ["abb", "bbc"] B = ["a", "ab", "abb", "b", "bb", "bbc", "bc", "c"] Is that what you're after? -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: I wish I could add docstrings to vars.

2006-09-12 Thread Neil Cerutti
riting a thin wrapper around the dictionary might be beneficial, and would also furnish a place for the docstrings. Actually, the wrapper would probably prevent you from needing the docstring very often. ;) -- Neil Cerutti Eddie Robinson is about one word: winning and losing. --Eddie Robinson's a

Re: Code to add docstrings to classes

2006-09-12 Thread Neil Cerutti
On 2006-09-12, Matthew Wilson <[EMAIL PROTECTED]> wrote: > On Tue 12 Sep 2006 10:06:27 AM EDT, Neil Cerutti wrote: >> Writing a thin wrapper around the dictionary might be >> beneficial, and would also furnish a place for the docstrings. > > I wrote a function that hop

Re: [ANN] Code Golf Challenge : 1,000 Digits Of Pi

2006-09-19 Thread Neil Cerutti
rammers something to defeat. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: I need some help with a regexp please

2006-09-21 Thread Neil Cerutti
's my attempt, neither of my regexps > work quite how I want: I suggest a websearch for email address validators instead of writing of your own. Here's a hit that looks useful: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66439 -- Neil Cerutti Next Sunday Mrs. Vinson wil

Re: Replacing line in a text file

2006-09-22 Thread Neil Cerutti
getting would be helpful. That is, until such time as Guido finalizes PyESP. import PyESP e = ESP.mindread(CSUIDL, "r") # etc.. -- Neil Cerutti Life is indeed precious, and I believe the death penalty helps affirm this fact. --Edward Koch -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie RE question

2006-09-22 Thread Neil Cerutti
ython Documenation: DON'T PANIC!" >CONSULT PYTHON ABOUT RE MODULE You don't have that. >TAKE IT Taken. >CONSULT GUIDE ABOUT RE MODULE You'll have to play the game to find out how it ends. ;) -- Neil Cerutti Life is indeed precious, and I believe the death penalty helps affirm this fact. --Edward Koch -- http://mail.python.org/mailman/listinfo/python-list

Re: returning None instead of value: how to fix?

2006-09-22 Thread Neil Cerutti
the call-stack when called with value 45.0 (using the substitution model): recursive_halve(45.0) --> return recursive_halve(22.5) --> return recursive_halve(11.25) --> return recursive_halve(5.625) --> return recursive_halve(2.8125) --> return recursive_hal

Re: returning None instead of value: how to fix?

2006-09-22 Thread Neil Cerutti
us effort to solve the problem on your own. Those who take the trouble, as you did, usually get excellent free help. It's not out of the kindness of our hearts that we help. Heck, I don't know what it is. Probably I just like reading my own drivel on the internet and occassionally

Re: Ordered dicts

2006-09-26 Thread Neil Cerutti
C version of Odict (maybe fit > for the collections module). Check out http://sourceforge.net/projects/pyavl/ for a probably useful sorted mapping type, already implemented in C as an extension module. However, I haven't tried it myself. -- Neil Cerutti We're going to be excitin

Re: iterator question

2006-09-26 Thread Neil Cerutti
27;x') --> ('a','b','c'), ('d','e','f'), ('g','x','x') """ return izip(*[chain(iterable, repeat(padvalue, n-1))]*n) -- Neil Cerutti There are two ways to argue with a woman, and neither of them work. --Carlos Boozer -- http://mail.python.org/mailman/listinfo/python-list

Whither binary search?

2006-09-26 Thread Neil Cerutti
I can't find the mystic search glob that will find a binary search function in the Python documentation. Am I searching in vain, or do I need better search-fu? -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Whither binary search?

2006-09-26 Thread Neil Cerutti
On 2006-09-26, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > bisect... That doesn't tell me if an item doesn't exist in the sequence though, does it? Maybe I'm being dense. My guess nobody keeps their sequences sorted in Python. ;) -- Neil Cerutti -- http://mail.pyt

Re: Whither binary search?

2006-09-28 Thread Neil Cerutti
short function to translate my raw data into a dictionary, and that was the end of my problem. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: how do you know if open failed?

2006-09-28 Thread Neil Cerutti
#x27;rb') # Do stuff with f except IOError, inst: print 'Phooey.', inst.errno, inst.strerror -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Can string formatting be used to convert an integer to its binary form ?

2006-09-29 Thread Neil Cerutti
x / 2 >> return ''.join(out) >> >> Regards, It was surprising that >>> i = int("111010101", 2) is a one-way operation. >>> s = str(i, 2) Traceback (most recent call last): File "", line 1, in ? TypeError: str() takes at most 1 argument (2 given) -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Can string formatting be used to convert an integer to its binary form ?

2006-09-29 Thread Neil Cerutti
On 2006-09-29, Georg Brandl <[EMAIL PROTECTED]> wrote: > Neil Cerutti wrote: >> On 2006-09-29, Steve Holden <[EMAIL PROTECTED]> wrote: >>> MonkeeSage wrote: >>>> So far as unobfuscated versions go, how about the simple: >>>>

Re: remove a list from a list

2006-11-17 Thread Neil Cerutti
_exclude: > del dirs[i-1] > > I am looking for a nicer solution. I'd probably just skip over those dirs as I came them instead of troubling about mutating the list. Unless the list is needed in more than one place. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: trouble writing results to files

2006-11-29 Thread Neil Cerutti
On 2006-11-29, Roberto Bonvallet <[EMAIL PROTECTED]> wrote: > BTW, iterating over range(len(a)) is an anti-pattern in Python. Unless you're modifying elements of a, surely? -- Neil Cerutti You can't give him that cutback lane. He's so fast, and he sees it so well. He ca

Re: How to detect what type a variable is?

2006-11-29 Thread Neil Cerutti
ed to know what type it is. > >>>> x = 'asdf' >>>> type(x) > >>>> i = 0 >>>> type(i) > That makes me wonder how he manages to store Python objects in xml. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: trouble writing results to files

2006-11-29 Thread Neil Cerutti
On 2006-11-29, Roberto Bonvallet <[EMAIL PROTECTED]> wrote: > Neil Cerutti wrote: >> On 2006-11-29, Roberto Bonvallet <[EMAIL PROTECTED]> wrote: >>> BTW, iterating over range(len(a)) is an anti-pattern in Python. >> >> Unless you're modifying elem

Re: Trying to understand rfc822.Message() behaviour

2006-11-30 Thread Neil Cerutti
12.11.1 Message Objects: class Message( file[, seekable]) A Message instance is instantiated with an input object as parameter. Message relies only on the input object having a readline() method; in particular, ordinary file objects qualify. Instantiation reads headers from the i

Re: Automatic increment

2006-11-30 Thread Neil Cerutti
unter].split())) > myArray[counter, itemCounter] I was going to suggest replacing the whole loop with nothing as the best way of removing the manual counters. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there an easier way to express this list slicing?

2006-11-30 Thread Neil Cerutti
.. yield items[5:] >>> for seq in parts(range(10)): ... print seq [0] [1] [2, 3, 4] [5, 6, 7, 8, 9] -- Neil Cerutti I guess there are some operas I can tolerate and Italian isn't one of them. --Music Lit Essay -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there an easier way to express this list slicing?

2006-11-30 Thread Neil Cerutti
On 2006-11-30, Neil Cerutti <[EMAIL PROTECTED]> wrote: > On 2006-11-30, John Henry <[EMAIL PROTECTED]> wrote: >> If I have a list of say, 10 elements and I need to slice it into >> irregular size list, I would have to create a bunch of temporary >> variables and t

Re: Detecting recursion loops

2006-12-01 Thread Neil Cerutti
gt;> informative error message) in the event of bad input, rather than >> allowing that bad data to send your program into an endless loop. > > > Yet that detection is what the asked alg should do. Example: > When a HTML-(content)-relaying sends you around in a circle > thr

Re: converting dict to object

2006-12-02 Thread Neil Cerutti
;4', '16'] ai = [int(i) for i in a] Yes. But... Try: a = ['82', '4', '16', 'foo'] Ok, I go out... -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: converting dict to object

2006-12-02 Thread Neil Cerutti
On 2006-12-02, John Machin <[EMAIL PROTECTED]> wrote: > Neil Cerutti wrote: >> On 2006-12-02, Michel Claveau <[EMAIL PROTECTED]> wrote: >> > Hi! >> > >> > Yes. >> > >> > But... >> > >> > Try:d = {'a'

Re: text adventure question

2006-12-02 Thread Neil Cerutti
ing. Here's an amusing sampling: EXERCISE THREE Design and implement a full-size game. Submit it to testing, fix all resulting bugs, help marketing design a package, ship the game, and sell at lest 250,000 units. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Execution time of lines within a function

2006-12-04 Thread Neil Cerutti
bject for your bottleneck. That may help. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Execution time of lines within a function

2006-12-04 Thread Neil Cerutti
function being > called 100 times, which is correct, but the rest seems at too > low a level for me to understand which statements are causing > the slow execution. > > hw6r3.py:276(main) hw6r3.py:73(findw)(100) 26700.865 Is this the print_callees output? -- Neil

Re: Am I stupid or is 'assert' broken in Python 2.5??

2006-12-06 Thread Neil Cerutti
programmers to tell their problem to a stuffed animal first before bothering another programmer who might be in the middle of something. The stuffed animal often provided all the assistance that was needed. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Why not just show the out-of-range index?

2006-12-07 Thread Neil Cerutti
t have had time to pull the babelfish out of my ear, and so I could have avoided the nosebleed. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: merits of Lisp vs Python

2006-12-08 Thread Neil Cerutti
But either system comes naturally enough with practice. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: Snake references just as ok as Monty Python jokes/references in python community? :)

2006-12-08 Thread Neil Cerutti
ave anything to do with the name of our >> favorite language? (*Everyone* gets snake jokes! :) > > It's people like you wot cause unrest! I think the decent people of this newsgroup are sick and tired of being told that the decent people of this newsgroup are sick and tired. I'

Re: merits of Lisp vs Python

2006-12-11 Thread Neil Cerutti
pathname library. I suppose I missed whatever the point was supposed to be in the midst of the mind-boggling. I meant to get back to it but haven't yet. -- Neil Cerutti We will sell gasoline to anyone in a glass container. --sign at Santa Fe gas station -- http://mail.python.org/mailman/listinfo/python-list

Re: merits of Lisp vs Python

2006-12-12 Thread Neil Cerutti
es to matching the Python code), but whatever it is would be a better foundation for comparing brain units with the above Python. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: merits of Lisp vs Python

2006-12-12 Thread Neil Cerutti
On 2006-12-13, hit_the_lights <[EMAIL PROTECTED]> wrote: > Neil Cerutti schrieb: > >> >> a[i] = b[n] >> >> >> >> with >> >> >> >> (setf (aref a i) (aref b n)) >> >> >> >> and the attractions of Py

Re: merits of Lisp vs Python

2006-12-12 Thread Neil Cerutti
ups in > copy-paste cannot be fixed by the editor automatically, because > it cannot read the original programmer's mind, and you have to > fix it manually, and risk screwing it up. It is very easy a manual process, possibly as simple as selecting the correct s-expr and pasting i

Re: Conditional iteration

2006-12-13 Thread Neil Cerutti
't annoy me that it didn't work, but it did seem natural to me given the syntax of comprehensions. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: merits of Lisp vs Python

2006-12-14 Thread Neil Cerutti
On 2006-12-14, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Neil Cerutti wrote: >> On 2006-12-13, [EMAIL PROTECTED] >> <[EMAIL PROTECTED]> wrote: >> > Expressions keep the same meaning even if you have to start >> > breaking them across lines,

<    1   2   3   4   5   6   7   8   9   10   >