Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-21 Thread Mark Wooding
Luis Zarrabeitia writes: > Btw, the correctness of a program (on a turing-complete language) > cannot be statically proven. Ask Turing about it. Be careful! Given a putative correctness-checking algorithm, there exist programs for which the algorithm gives the wrong answer. That doesn't necess

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-22 Thread Mark Wooding
Paul Rubin writes: > Also, the application area matters. There is a difference between > programming for one's own enjoyment or to do a personal task, and > writing programs whose reliability or lack of it can affect other > people's lives. I've never done any safe

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-22 Thread Mark Wooding
Steven D'Aprano writes: > On Thu, 22 Jan 2009 15:12:31 +0100, Bruno Desthuilliers wrote: >> Steven D'Aprano a écrit : >>> But if you have free access to attributes, then *everything* is >>> interface. >> >> Nope. > > How could anyone fail to be convinced by an argument that detailed and > carefu

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-22 Thread Mark Wooding
Bruno Desthuilliers writes: > Paul Rubin a écrit : >> I'd say that Python's FP characteristics are an important part of its >> expressiveness. > > Indeed - but they do not make Python a functional language[1]. Python is > based on objects, not on functions, I'd have a good go at defining a func

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-23 Thread Mark Wooding
Steven D'Aprano writes: > On Thu, 22 Jan 2009 19:10:05 +0000, Mark Wooding wrote: >> Well, your claim /was/ just wrong. But if you want to play dumb: the >> interface is what's documented as being the interface. > > But you miss my point. Evidently. > We&#

Re: Relax Syntax for Augmented Arithmetic?

2009-01-23 Thread Mark Wooding
[email protected] (Aahz) writes: > Actually, that is not correct. You're right, evidently. [snip] a > (1, ['foo', 'bar'], 'xyzzy') a[1] += ['spam'] > Traceback (most recent call last): > File "", line 1, in ? > TypeError: object doesn't support item assignment a > (1, ['foo

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-23 Thread Mark Wooding
"Russ P." writes: > OK, fine, you can change the code of another member of the team. Are > you going to check with him first, or just do it? The point is that > changing an interface requires agreement of the team members who use > that interface, whether on the calling or the implementation side

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-23 Thread Mark Wooding
Steven D'Aprano writes: > You've built something full of user serviceable parts. You've > insisted, publicly and loudly, that the ability to modify those parts > is absolutely essential, you've rejected every effort to lock down > those internals, and then when somebody does exactly what you > en

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-23 Thread Mark Wooding
"Russ P." writes: > Was this library module released in source form? > > If so, then why would you care that it has enforced access > restrictions? You can just take them out, then do whatever you would > have done had they not been there to start with. I don't see how that > is any more work tha

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-23 Thread Mark Wooding
Steve Holden writes: > Annotations *have* made it into 3.0, so it's possible that the might > become usable. Remember, they'll always be optional, so those who don't > want to use them won't lose anything at all. There's a problem here. An interface has two sides. Access control annotations, a

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-23 Thread Mark Wooding
Steven D'Aprano writes: > On Fri, 23 Jan 2009 13:57:52 +0100, Bruno Desthuilliers wrote: >> Why on earth couldn't I change the code of another member of my team if >> that code needs changes ? The code is the whole team's ownership. > > That's a model that works well when you have a small team of

Re: Dynamic methods and lambda functions

2009-01-23 Thread Mark Wooding
[email protected] writes: > class Person: > def __init__(self): > for prop in props: > setattr(self, "__" + prop[0], prop[1]) > setattr(Person, "Get" + prop[0], lambda self: getattr > (self, "__" + prop[0])) [...] > The attributes are right, but the getter ar

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-23 Thread Mark Wooding
Steven D'Aprano writes: > I did? Where did I make that assumption? I inferred it from the juxtaposition, apparently in error. Sorry. > What I said was that the model "The code is the whole team's ownership" > doesn't work well for large projects. *One* reason it doesn't work for > large proj

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-23 Thread Mark Wooding
array and cause buffer overflows, and random Python > code could cause core dumps (and possibly even security exploits). [...] > As I see it, you have two coherent positions. On the one hand, you could > be like Mark Wooding, and say that Yes you want to risk buffer overflows > by

Re: RegEx issues

2009-01-24 Thread Mark Tolonen
ething obvious. Either way, I thought I'd ask why this isn't working and why it seems to be changing my regex to something else. Did you try it? s='td[ct] = [[blah blah]];\r\n' re.search(reg,s).group(1) 'blah blah' -Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-25 Thread Mark Wooding
"Russ P." writes: > Calling a one-word change a "fork" is quite a stretch, I'd say. I wouldn't. I've forked a project P if I've made a different version of it which isn't going to be reflected upstream. Now I've got to maintain my fork, merging in changes from upstream as they happen, and upgr

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-25 Thread Mark Wooding
"Russ P." writes: > Imagine a person who repairs computers. He is really annoyed that he > constantly has to remove the cover to get at the guts of the computer. > So he insists that computers cases should be made without covers. Poor analogy. He gets fed up that the computers he's meant to be

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-25 Thread Mark Wooding
Steven D'Aprano writes: > On Fri, 23 Jan 2009 21:36:59 -0500, Luis Zarrabeitia wrote: >> It makes sense... if the original author is an egotist who believes he >> must control how I use that library. > > Then I guess Guido must be such an egotist, because there's plenty of > internals in Python

Re: Doc for extended call syntax; was: Re: unzip array of arrays?

2009-01-25 Thread Mark Wooding
Steve Holden writes: > No, you aren't mistaken. Looking at the "*" symbol in the 2.6 > documentation index it lists only two references. The first is the > language manual's explanation of its use in the def statement, the > second is a transitory reference to its use in function calls, but > tha

Re: Pythonic list/tuple/dict layout?

2009-01-25 Thread Mark Wooding
acking them onto multiple lines. e.g., op = XT.make_optparse \ ([('E', 'error', {'action': 'store_const', 'dest': 'type', 'const': 'error', 'help

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-25 Thread Mark Wooding
"Russ P." writes: > On Jan 25, 10:04 am, Mark Wooding wrote: > > But what if you type "mumble._seekrit" in several places, then the > library implementer decides to give in to your nagging and makes it > "public" by changing it to "mumble.see

Re: Cartesian Product of two lists (itertools)

2009-01-25 Thread Mark Wooding
Thorsten Kampe writes: > [((1, 4), 7), ((1, 4), 8), ((1, 5), 7), ((1, 5), 8), ((2, 4), 7), ((2, > 4), 8), ((2, 5), 7), ((2, 5), 8)] [...] > What's the best way to pre-process the arguments to "itertools.product" > or to post-process the result of "itertools.product" to get what I > want?! P

Re: Counting number of objects

2009-01-25 Thread Mark Wooding
Andreas Waldenburger writes: > On Sun, 25 Jan 2009 09:23:35 -0800 (PST) Kottiyath > wrote: > >> class a(object): >> counter = 0 >> def __new__(cls, *args, **kwargs): >> a.counter += 1 >> return object.__new__(cls, *args, **kwargs) Hmm. Exceptions raised during object cr

Re: ob_type in shared memory

2009-01-25 Thread Mark Wooding
Aaron Brady writes: > I am writing an extension using shared memory. I need a data type > that is able to reassign its 'ob_type' field depending on what process > is calling it. That sounds scary! > Object 'A' is of type 'Ta'. When process 'P' is looking at it, it > needs to have an 'ob_type'

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-25 Thread Mark Wooding
"Russ P." writes: [snip stuff I don't disagree with] > That makes renaming and refactoring riskier in general in Python than > in statically typed languages with enforced access restrictions. More > care and attention to detail is needed to do it right in Python. In fact, I don't disagree with

Re: Dynamic methods and lambda functions

2009-01-26 Thread Mark Wooding
Michael Torrie writes: > Basically, don't use a lambda. Create a real, local closure with a > nested def block. That way the closure is created every time the > parent function is called. Nope. I explained the real problem quite clearly, and it's to do with the difference between binding and

Re: Dynamic methods and lambda functions

2009-01-26 Thread Mark Wooding
Steve Holden writes: > Mark Wooding wrote: >> * Assignment stores a new (reference to a) value in the variable. >> >> * Binding modifies the mapping between names and variables. >> > I realise I have omitted what was doubtless intended to be explanatory >

Re: Doc for extended call syntax; was: Re: unzip array of arrays?

2009-01-27 Thread Mark Wooding
Bryan Olson writes: > Mark Wooding wrote: >> There's a full description of it in 5.4.3 in the Language Reference, but >> apparently not indexed. > > So I guess this means I can duck out of writing up a lecture on my own > understanding of Python's extended call

Re: socket.unbind or socket.unlisten? - socket.error: (48, 'Address already in use')

2009-01-27 Thread Mark Wooding
Laszlo Nagy writes: > I have a program that uses socket.bind() and socket.listen() > frequently. After that program stops, it is not able to bind() again for a > while: This is the usual TIME-WAIT problem. The TCP protocol requires one end of the connection (whichever actually started the close

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-27 Thread Mark Wooding
[No, my email address doesn't begin `m...@'. Fixed.] Michele Simionato writes: > On Jan 21, 2:11 am, Mark Wooding wrote: > >> CLOS is much more complex and dynamic than Python's object system; >> but it can be compiled very aggressively. > > I agree

Re: How many followers of comp.lang.python

2009-01-27 Thread Mark Wooding
Grant Edwards writes: > I've always found comp.lang.c to be a rather dangerous place as well. Hey, I grew up in comp.lang.c! I'd have to agree with you, though. (I try to play nice when I'm here.) In fact, comp.lang.* generally has a reputation as a place you don't want to find yourself afte

Re: Pexpect and telnet not communicating properly

2009-01-27 Thread Mark Wooding
David Anderson writes: > I am trying to automate the following session - to talk to my router: > > telnet speedtouch [...] > I am using the following code: [...] > child.expect('sername : ') > child.sendline('Administrator') I've scripted communications with my Speedtouch 510 using pexpect: I us

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-27 Thread Mark Wooding
"Russ P." writes: > If Python had a "private" keyword (or equivalent), for example, the > user would only need to delete it wherever necessary to gain the > desired access. And you obviously weren't listening when we said that having to make source code changes to upstream modules was a serious

Re: errno 22 instead of errno 2

2009-01-28 Thread Mark Hammond
x27; attributes, which more accurately reflect the source of the 2 different error numbers, where Python 2.5 would often store the windows error number in the errno field, leading to what you see. I tend to use something like "winerror = getattr(e, 'winerror', e.errno)" to

Re: How to get atexit hooks to run in the presence of execv?

2009-01-29 Thread Mark Wooding
[email protected] (R. Bernstein) writes: > Recently, I added remote debugging via TCP sockets. (Well, also FIFO's > as well but closing sockets before restarting is what's of concern.) > > I noticed that execv in Python 2.5.2 doesn't arrange exit hooks to get > called. Should it? I'd consider that

verilog like class w/ bitslicing & int/long classtype

2009-01-29 Thread mark . seagoe
ister = 0x89 Because it will get reassigned from my class value to a newly intialized memory location (int object). But can I have it read the value without the .value extension? Is this even possible? Maybe there's a way to override the = operator? (Go easy on me - I'm a hardware guy). Thx, Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Can't understand what python wants from me

2009-01-29 Thread mark . seagoe
On Jan 29, 1:50 pm, Oleksiy Khilkevich wrote: > Hello, everyone, > This may be a totally noob question, but since I am one, so here is it. For the input function, python is expecting you to input a number or a string. If you enter 'asd' without the '' then it thinks you are entering some variabl

Re: verilog like class w/ bitslicing & int/long classtype

2009-01-29 Thread mark . seagoe
Thanks. So far these solutions will return strings. So I can't really treat it like a variable, yet still perform bitslice on it, since I need a special class to do bitslice and bit selection, but as soon as I try to pass it into some other function to check a bit, I gotta then do another operati

Re: verilog like class w/ bitslicing & int/long classtype

2009-01-29 Thread mark . seagoe
On Jan 29, 3:13 pm, Stef Mientki wrote: > [email protected] wrote: > > Thanks.  So far these solutions will return strings.  So I can't > > really treat it like a variable, yet still perform bitslice on it, > > since I need a special class to do bitslice and bit selection, but as > > soon as I

Re: verilog like class w/ bitslicing & int/long classtype

2009-01-29 Thread mark . seagoe
ted text - Thanks for the tip. I checked out myhdl and it has a class called intbv which does exactly this, and much more than I need. It's GNU lesser license though, so not sure how to handle that, if I just want some concepts of the code as examples, but don't want copy it per se. Thanks, Mark -- http://mail.python.org/mailman/listinfo/python-list

Using equals operator without changing reference pointer

2009-01-29 Thread mark . seagoe
a way to lock down myInst so that it still refers to the original object, and is there some special member that will allow me to override the equals operator in this case? Or is that simply blasphemous against everything Python holds sacred? Certainly there is some keyword that I don't know a

Re: Using equals operator without changing reference pointer

2009-01-30 Thread mark . seagoe
On Jan 29, 8:03 pm, Terry Reedy wrote: > Erik Max Francis wrote: > > [email protected] wrote: > > >> Is there a way to lock down myInst so that it still refers to the > >> original object, and is there some special member that will allow me > >> to override the equals operator in this case?  O

Re: nth root

2009-01-31 Thread Mark Dickinson
uracy. Is it important to you that the integer part of the result is *exactly* right, or is it okay if (n**13)**(1./13) sometimes comes out as slightly less than n, or if (n**13-1)**(1./13) sometimes comes out as n? Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: nth root

2009-01-31 Thread Mark Dickinson
On Jan 31, 1:23 pm, Steve Holden wrote: > [Mark] > > power operation.  The integer -> float conversion is probably quite > > significant, timewise. > > I bow to your superior intuition! Here's another timing that shows the significance of the int -> float con

Re: nth root

2009-01-31 Thread Mark Dickinson
and whether gmpy makes it accessible from Python. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: nth root

2009-01-31 Thread Mark Dickinson
the following: >>> n = 12345**13 >>> n 154662214940914131102165197707101295849230845947265625L >>> int(n ** (1./13)) # should be 12345; okay 12345 >>> int((n-1) ** (1./13)) # should be 12344; oops! 12345 Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: nth root

2009-01-31 Thread Mark Dickinson
On Jan 31, 7:04 pm, ajaksu wrote: > also a great way make some innocent bystander waste his eyesight > trying to figure out the magic trick :D Oh, come on! At least I put the two lines next to each other! :-) Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Number of bits/sizeof int

2009-02-02 Thread Mark Wooding
Jon Clements writes: > "The int() type gained a bit_length method that returns the number of > bits necessary to represent its argument in binary:" > > Any tips on how to get this in 2.5.2 as that's the production version > I'm stuck with. def nbits(x): ## Special cases. if x == 0: return 0

Re: Number of bits/sizeof int

2009-02-02 Thread Mark Dickinson
On Jan 31, 7:03 am, Jon Clements wrote: > Any tips on how to get this in 2.5.2 as that's the production version > I'm stuck with. It's a bit cheeky, but: from decimal import _nbits as nbits should also work in 2.5.2 (but not in 2.5.1)! Mark -- http://mail.python.org/ma

Re: Number of bits/sizeof int

2009-02-02 Thread Mark Wooding
John Machin writes: > 3 can be represented in 2 bits and at the same time -3 can be > represented in 2 bits?? But 2 bits can support only 2 ** 2 == 4 > different possibilities, and -3 .. 3 is 7 different integers. Yeah, I made some arbitrary choices about what to do with non-positive inputs. If

Re: is python Object oriented??

2009-02-02 Thread Mark Wooding
"Russ P." writes: > I am not sure why people keep "mentioning" that "Python is not Java." > As a slogan, it is rather misleading. Python is not C++, Ada, or Scala > either. All of those languages have enforced access restriction. Why > only mention Java? Because Java is a well-known member of a

Re: Date Comparison

2009-02-03 Thread Mark Wooding
[email protected] writes: > I need to compare two dates and find the number of days between those > two dates.This can be done with datetime module in python as below, > but this is not supported in Jython. > > example > from datetime import date > a=datetime.date(2009,2,1) > b=datetime.date(2

Re: Number of bits/sizeof int

2009-02-03 Thread Mark Dickinson
On Feb 3, 1:19 am, Mark Wooding wrote: > Yeah, I made some arbitrary choices about what to do with non-positive > inputs.  If you prefer other answers, use 'em.  My ones work well with > signed-magnitude representations where the sign is stored separately. Not *that* arbitrary: th

Re: How to call python from a foreign language thread (C++)

2009-02-04 Thread Mark Hammond
Data&data) { PyGILState_STATE old = PyGILState_Acquire(); m_Function(time, data); PyGILState_Release(old); Note that Phillip is also correct; you will need to initialize threading if this is an app which embeds Python... HTH, Mark -- http://mail.python.org

Re: How to call python from a foreign language thread (C++)

2009-02-04 Thread Mark Hammond
On 4/02/2009 8:43 PM, I wrote: PyGILState_STATE old = PyGILState_Acquire(); Make that PyGILState_Ensure(); Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: sys.float_info.epsilon

2009-02-04 Thread Mark Dickinson
9e-324. In between 2**-1074 and 2**-52 there are approximately 4.4 million million million different floating-point numbers. Take your pick! If you want a specific example, how about float('6.626e-34'). Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: sys.float_info.epsilon

2009-02-04 Thread Mark Dickinson
definition...) Python's float_info.epsilon comes straight from C's DBL_EPSILON, which is defined very carefully in the C99 standard as: """the difference between 1 and the least value greater than 1 that is representable in the given floating point type""" (taki

Re: is python Object oriented??

2009-02-04 Thread Mark Wooding
"Russ P." writes: > Imagine you own a company, and you decide to lease an office building. > Would you expect the office doors to have locks on them? Oh, you > would? Why? You mean you don't "trust" your co-workers? What are locks > but enforced access restriction? Huh? The lock on the door isn

Re: is python Object oriented??

2009-02-04 Thread Mark Wooding
Steven D'Aprano writes: > Now, that's a toy example. Languages like Ada make correctness proofs, > well, perhaps not easy, but merely difficult compared to impossible for > languages like Python. Say `generally impractical' rather than `impossible' and I'll agree with you. But I'm not actuall

Re: Where & how to deallocate resources in Python C extension

2009-02-04 Thread Mark Wooding
[email protected] writes: > I've written a C extension, see code below, to provide a Python > interface to a hardware watchdog timer. As part of the initialization > it makes some calls to mmap, I am wondering should I be making > balanced calls to munmap in some kind of de-init function?

Re: structs

2009-02-04 Thread Mark Wooding
Keith Thompson writes: > "Gary Herron" writes: >> Python *is* object-oriented > > I disagree. Care to provide proof of that statement? AWOOGA! The article I'm following up to (together with at least one other) is a forgery, and the Followup-To header is set to comp.lang.c as part of an effort

Re: Using while loop and if statement to tell if a binary has an odd or even number of 1's.

2009-02-05 Thread Mark Dickinson
_set_bits(the_int) % 2 == 0 ...but anyone submitting this as a homework solution had better be prepared to explain why it works. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: sys.float_info.epsilon

2009-02-05 Thread Mark Dickinson
On Feb 4, 9:44 pm, Tim Rowe wrote: > That just leaves me puzzled as to why Mark Summerfield used it instead > of a check against zero on user input. No idea: you'd have to ask Mark Summerfield. If there's an email address published in his book, I'm sure he wouldn

Re: Flattening lists

2009-02-05 Thread Mark Dickinson
hat turns a list of lists (or iterable of iterables) into a single list; itertools.chain does this quite nicely. But I don't think I've ever encountered a need for the full recursive version. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: subprocess returncode windows

2009-02-05 Thread Mark Hammond
that cmd.exe doesn't return the exit code to *its* caller correctly. You can often work around this by avoiding the use of cmd.exe to spawn the child process, but obviously you do need it with a .bat file. I'm not aware of an easy work-around. Cheers, Mark -- http://mail.python.org/m

Re: Using multiprocessing from a Windows service

2009-02-05 Thread Mark Hammond
it... Cheers, Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Using multiprocessing from a Windows service

2009-02-05 Thread Mark Hammond
On 6/02/2009 2:50 PM, Mark Hammond wrote: On 6/02/2009 11:37 AM, Volodya wrote: Hi all, I think I've found a small bug with multiprocessing package on Windows. I'd actually argue its a bug in pythonservice.exe - it should set sys.argv[] to resemble a normal python process with arg

Re: Is c.l.py becoming less friendly?

2009-02-06 Thread Mark Dickinson
On Feb 6, 6:23 am, "Hendrik van Rooyen" wrote: > I think this thread has buggered up a perfectly ^^^ Such language. I'm appalled. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Using multiprocessing from a Windows service

2009-02-06 Thread Mark Hammond
y create executables where sys.argv[0] is the executable itself. Maybe if we consider and handle both these cases a patch to mp might be looked upon in a better light... Cheers, Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: WIn32api

2009-02-06 Thread Mark Hammond
MSCOM function CoMarshalInterThreadInterfaceInStream (exposed via the pythoncom module). The above mailing list has had a number of threads on this issue over the years... Cheers, Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Using while loop and if statement to tell if a binary has an odd or even number of 1's.

2009-02-06 Thread Mark Wooding
Duncan Booth writes: > Mark Dickinson wrote: [snip] >> while n: >> count += 1 >> n &= n-1 >> return count >> >> is_even = count_set_bits(the_int) % 2 == 0 >> >> ...but anyone submitting this as a homework >&g

Re: Python binaries with VC++ 8.0?

2009-02-09 Thread Mark Hammond
hon to free (or vice-versa) - both should be avoidable though... Mark -- http://mail.python.org/mailman/listinfo/python-list

Iterable Ctypes Struct

2009-02-10 Thread mark . seagoe
t;print n I don't want to force the end user to have preknowledge of the element names. Has anyone subclassed ctypes Structure based class to be iterable? Before a noob starts trying to do this, is it possible? How to approach it? Thx, Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Iterable Ctypes Struct

2009-02-11 Thread mark . seagoe
add another element: >>> point.z = 30 >>> print list(point) [10, 20] >>> dir(point) ['__class__', '__ctypes_from_outparam__', '__delattr__', '__ dict__', '__doc__', '__getattribute__', '__getitem__', '__ha sh__', '__init__', '__module__', '__new__', '__reduce__', '_ _reduce_ex__', '__repr__', '__setattr__', '__str__', '__weak ref__', '_b_base_', '_b_needsfree_', '_fields_', '_objects', 'x', 'y', 'z'] I don't know why the iterator (where ever it is) didn't get incremented. Thanks for any insight. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Iterable Ctypes Struct

2009-02-11 Thread mark . seagoe
. > For example, if I were to now add another element: > > >>> point.z = 30 > >>> print list(point) > [10, 20] > >>> dir(point) > > ['__class__', '__ctypes_from_outparam__', '__delattr__', '__ > dict__',

Re: Iterable Ctypes Struct

2009-02-11 Thread mark . seagoe
In last post, I mixed code w/ 'p' and 'point'. Should be: >>> point._fields_.append(('z', c_int)) >>> point.z = 30 >>> print 'List:', list(point) List: [10, 20, 30] -- http://mail.python.org/mailman/listinfo/python-list

Re: Iterable Ctypes Struct

2009-02-11 Thread mark . seagoe
this module something like "CHIP" which contains a struct. I add the "REG" struct objects as I read them in from xml file. The "REG" struct would have info about address, # of bits, type (RO, RW, etc). Thx, Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Iterable Ctypes Struct

2009-02-11 Thread mark . seagoe
ut I'd prefer the dot notation without quotes for the end user experience of script writing later. Is there something besides ctypes.Structure that would do that? Thx, Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: TTS in windows

2009-02-11 Thread Mark Hammond
c number is the value for CLSID_SpVoice, which I found by googling (for some reason, the actual definition of that CLSID doesn't appear in the SDK headers...) HTH, Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Breaking Python list into set-length list of lists

2009-02-11 Thread Mark Tolonen
nt): ... M=[] ... for i in xrange(0,len(L),count): ... M.append(L[i:i+count]) ... return M ... L=range(18) splitlist(L,3) [[0, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10, 11], [12, 13, 14], [15, 16, 17]] splitlist(L,4) [[0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11], [12, 13, 14, 15], [16,

Re: "Byte" type?

2009-02-15 Thread Mark Tolonen
32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. type(b'x') b'x'[0] 'x' As Steve said, it is just an aliased type. In 3.X it is really a bytes object: Python 3.0.1 (r301:69561, Feb 13 2009, 20:04:18) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. type(b'x') b'x'[0] 120 -Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: This application has failed to start because the application configuration is incorrect

2009-02-17 Thread Mark Hammond
ibraries via another Microsoft supplied installer. Probably the easiest workaround is to use Python 2.5 in the short term... Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: datetime.time and midnight

2009-02-22 Thread Mark Dickinson
On Feb 21, 10:44 pm, Ethan Furman wrote: > --> midnight = datetime.time(0,0,0) > --> bool(midnight) > False I'd call this a bug. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: datetime.time and midnight

2009-02-22 Thread Mark Dickinson
On Feb 22, 9:18 am, Mark Dickinson wrote: > On Feb 21, 10:44 pm, Ethan Furman wrote: > > > --> midnight = datetime.time(0,0,0) > > --> bool(midnight) > > False > > I'd call this a bug. ...although looking at the source (see the function time_nonzero in

Re: Enumerating k-segmentations of a sequence

2008-11-25 Thread Mark Dickinson
c in combinations(range(1, n), k-1): c = [0] + list(c) + [n] yield [l[c[i]:c[i+1]] for i in xrange(k)] for p in partitions(range(1, 6), 3): print p Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Enumerating k-segmentations of a sequence

2008-11-25 Thread Mark Dickinson
On Nov 25, 5:34 pm, Mark Dickinson <[EMAIL PROTECTED]> wrote: > If you have Python 2.6 available, itertools.combination might be That should be itertools.combinations, of course. The idea is that to give a partition of e.g., a 5-element list into 3 nonempty pieces, all you have to

Re: [2.5.1] ShiftJIS to Unicode?

2008-11-27 Thread Mark Tolonen
s" % title print "Found stuff" Note here that you are getting an "encode" error. When trying to print the data, Python will try to encode the Unicode data using the terminal's default encoding, which I suspect is not Shift-JIS. -Mark sql = 'INSERT INTO books (title) VALUES (?)' cursor.execute(sql,(title,)) Thank you -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list

ANN: New Book: Programming in Python 3

2008-12-04 Thread Mark Summerfield
eful (although small and basic) programs after reading chapter 1, and then go on to create larger and more sophisticated programs as they work through the chapters. -- Mark Summerfield, Qtrac Ltd, www.qtrac.eu -- http://mail.python.org/mailman/listinfo/python-list

Re: ANN: New Book: Programming in Python 3

2008-12-04 Thread Mark Summerfield
On 2008-12-04, Dotan Cohen wrote: > 2008/12/4 Mark Summerfield <[EMAIL PROTECTED]>: > > Now that Python 3 final has been released I thought it would be a good > > time to mention that there's a new book to go with it: > > > > "Programming in Python 3

ANN: Shed Skin 0.0.30, an experimental (restricted-)Python-to-C++ Compiler

2008-12-05 Thread Mark Dufour
lly like to do before that, is to improve support for the 'os' module. Please let me know if you'd like to help out here! Hopefully, with many details out of the way, I can have another good look at type inference for 0.2.. Thanks, Mark. -- "One of my most productive days wa

Re: generating a liste of characters

2008-12-05 Thread Mark Tolonen
'''Return a list of characters from startch to endch, inclusive.''' return [chr(c) for c in xrange(ord(startch),ord(endch)+1)] chars = crange('0','9') + crange('A','Z') + crange('a','z') -Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: generating a liste of characters

2008-12-05 Thread Mark Tolonen
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Mark Tolonen: Writing a helper function reduces code repetition and improves readability: def crange(startch,endch): '''Return a list of characters from startch to endch, inclusive.''' return [chr

Re: A more pythonic way of writting

2008-12-05 Thread Mark Tolonen
r( lambda m: m[0], zip(vals,'iLmsux'))) return '?'+''.join( filtered ) filtered = [c for c,v in zip('iLmsux',vals) if v] -Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: pretty strange behavior of "strip"

2008-12-05 Thread Mark Tolonen
ip('.html') 'questions' It doesn't strip the character set from the whole string, it strips it from the beginning and end of the string only. If it encounters a character that isn't in the set, it stops. Does this make it more clear? 'aabdabcdccb'.strip('cba') 'dabcd' -Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: pretty strange behavior of "strip"

2008-12-05 Thread Mark Tolonen
racters causes a split where any one (or more) of them appears. But instead the string argument is a multi-character separator. (Which is sometimes useful and I wouldn't want to lose the ability to specify a multi-character separator!) import re re.split('[,.]','blah,blah.bla

Re: Python 3.0 automatic decoding of UTF16

2008-12-06 Thread Mark Tolonen
in decode (result, consumed) = self._buffer_decode(data, self.errors, final) File "c:\dev\python30\lib\encodings\utf_16.py", line 61, in _buffer_decode codecs.utf_16_ex_decode(input, errors, 0, final) UnicodeDecodeError: 'utf16' codec can't decode byte 0x00 in position 1558: trunc ated data -Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: operators as variables

2008-12-06 Thread Mark Tolonen
for a decent Python book would be appreciated) See the operator module, and then check out pyparsing. -Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Rich Comparisons Gotcha

2008-12-07 Thread Mark Dickinson
umeric equality brings significant benefits in terms of readability of code, ease of learning, and general friendliness; it's only really troublesome in a few corner cases. Is the tradeoff worth it? So for me, this comes down to a case of 'practicality beats purity'. Mark -- http://mail.python.org/mailman/listinfo/python-list

built-in functions as class attributes

2008-12-08 Thread Mark Dickinson
bject): f = my_hex ... >>> T().f(12345) '0x3039' >>> T2().f(12345) Traceback (most recent call last): File "", line 1, in TypeError: my_hex() takes exactly 1 argument (2 given) [36412 refs] Anyone know what the precise rules that lead to this behaviou

Re: built-in functions as class attributes

2008-12-08 Thread Mark Dickinson
fore, but apparently I'd either not taken it in first time round, or entirely forgotten it. Anything written by Raymond has got to be pretty darn close to 'official'. :) Mark -- http://mail.python.org/mailman/listinfo/python-list

<    39   40   41   42   43   44   45   46   47   48   >