Re: Rich Comparisons Gotcha

2008-12-09 Thread Mark Dickinson
n to use '==', without adding an 'equals' function into the mix. It would add significant extra complexity to the core language, for questionable (IMO) gain. There are certainly other languages for which this distinction would make sense; I just don't think it's approp

Re: Python 3.0 crashes displaying Unicode at interactive prompt

2008-12-13 Thread Mark Tolonen
error. I'm sure our Asian colleagues love it, but our encoding-challenged consoles now need: x='\u9876' print(ascii(x)) '\u9876' It's not very convenient, and I've found it is easier to use IDLE (or any other IDE supporting UTF-8) rather than the console when dealing with characters outside what the console supports. -Mark -- http://mail.python.org/mailman/listinfo/python-list

unsubscribe

2008-12-16 Thread Mark Jordaan
> From: [email protected]> Subject: Re: Does Python3 offer a FrozenDict?> > Date: Tue, 16 Dec 2008 09:56:57 -0800> To: [email protected]> > On 16 > Dec, 17:28, [email protected] wrote:> > Johannes Bauer:> >> > > is > there anything like a frozen dict in Python3, so I could do a> >

Re: Factoring Polynomials

2008-12-18 Thread Mark Dickinson
27;t floating-point a wonderful thing! :) Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: ANN: New Book: Programming in Python 3

2008-12-19 Thread Mark Summerfield
shows a validation technique that combines class decorators with descriptors.) On 4 Dec, 15:02, Mark Summerfield wrote: > 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

Re: ANN: New Book: Programming in Python 3

2008-12-19 Thread Mark Summerfield
On 19 Dec, 19:52, excord80 wrote: > On Dec 4, 2:42 pm, Alan G Isaac wrote: > > > Mark Summerfield wrote: > > > "Programming in Python 3: > > > A Complete Introduction to the Python Language" > > > ISBN 0137129297 > > >http://www.qtrac.eu/

Re: ANN: New Book: Programming in Python 3

2008-12-20 Thread Mark Summerfield
On 20 Dec, 00:32, "Colin J. Williams" wrote: > Thomas Heller wrote: > > Mark Summerfield schrieb: > >> Just a follow-up to say that the book has now been published in the > >> U.S. > >> It is now in stock at InformIT, and should reach other stores, e

Re: no sign() function ?

2008-12-23 Thread Mark Dickinson
where the 'default' nan is negative, in the sense that its sign bit is set: >>> nan = float('nan') >>> from math import copysign >>> copysign(5.0, nan) -5.0 >>> copysign(5.0, -nan) 5.0 >>> copysign(5.0, abs(nan)) 5.0 Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: no sign() function ?

2008-12-23 Thread Mark Dickinson
On Dec 23, 4:27 pm, ajaksu wrote: > Is "x ** 0 > 0." instead of "atan2(x, -1.) > 0." unreliable across > platforms? x**0 doesn't distinguish between x = -0.0 and x = 0.0. I suspect you're confusing -0.0**0.0 with (-0.0)**0.0. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: How to display Chinese in a list retrieved from database via python

2008-12-25 Thread Mark Tolonen
is unable to display those characters, but I get "true" from this: test alert('中文'=='\xd6\xd0\xce\xc4') -- Gabriel Genellina I did that: charset='gb2312'">, but it does not work. Alert('\xd6\xd0\xce\xc4') displays some "junks"

Re: ctypes & strings

2008-12-27 Thread Mark Tolonen
ncpy(buf,"initialized string",len-1); buf[len-1]=0; return strlen(buf); } -- PythonWin 2.6.1 (r261:67517, Dec 4 2008, 16:51:00) [MSC v.1500 32 bit (Intel)] on win32. Portions Copyright 1994-2008 Mark Hammond - see 'Help/About PythonWin' for further copyrig

Re: math module for Decimals

2008-12-28 Thread Mark Dickinson
an external addition to the decimal module, not as part of the decimal module itself). This is an itch I've often wanted scratched, as well. I might just have a go (Help in the form of code, tests, suggestions, etc. would be welcome!) Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: math module for Decimals

2008-12-28 Thread Mark Dickinson
fairly easy to emulate in Python 2.6 and above, using the as_integer_ratio float method: >>> from decimal import Decimal >>> from math import pi >>> n, d = pi.as_integer_ratio() >>> Decimal(n)/d Decimal('3.141592653589793115997963469') Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: math module for Decimals

2008-12-28 Thread Mark Dickinson
ith error of around 10**-15. As far as I know, this problem is essentially unavoidable, and it's the reason why implementing sin for inputs like 10**9 isn't feasible. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: How to display Chinese in a list retrieved from database via python

2008-12-29 Thread Mark Tolonen
the encoding used for the html file don't have to match, but the charset declared in the file and the encoding used to write the file *do* have to match. # coding: utf8 import codecs mydict = {} mydict['JUNK'] = [u'中文',u'中文',u'中文'] def conv_l

Re: Any equivalent to Ruby's 'hpricot' html/xpath/css selector package?

2008-12-29 Thread Mark Thomas
ow-standard ElementTree API. The main difference is that lxml doesn't have CSS selector syntax, but IMHO that's a gimmick when you have a full XPath 1.0 engine at your disposal. -- Mark. -- http://mail.python.org/mailman/listinfo/python-list

Re: How to display Chinese in a list retrieved from database via python

2008-12-29 Thread Mark Tolonen
"zxo102" wrote in message news:[email protected]... On 12月29日, 下午5时06分, "Mark Tolonen" wrote: "zxo102" wrote in message news:2560a6e0-c103-46d2-aa5a-8604de4d1...@b38g2000prf.googlegroups.com... [snip] T

Re: Any equivalent to Ruby's 'hpricot' html/xpath/css selector package?

2008-12-30 Thread Mark Thomas
On Dec 30, 8:20 am, Stefan Behnel wrote: > Mark Thomas wrote: > > The main difference is that lxml doesn't have CSS selector syntax > > Feel free to read the docs: > > http://codespeak.net/lxml/cssselect.html Don't know how I missed that... So lxml is pretty m

Re: idle 3.0 unicode

2009-01-01 Thread Mark Tolonen
on (but saved in utf8) : print ("ěščřžýáíé") even immediately destroyed my IDLE window without any error message. Both versions, with and without 'coding' line, destroy IDLE for me. Looks like a bug in IDLE 3.0. The print works fine from the shell, but not from a program run w

Re: greenlets and how they can be used

2009-01-03 Thread Mark Wooding
James Mills wrote: > The "greenlet" from http://codespeak.net/py/dist/greenlet.html > is a rather interesting way of handling flow of control. Ahh, yes. It's actually a rather old idea, but too rarely used. > What can "greenlet"'s be used for ? What use-cases have you guys used > them for (if

Re: math module for Decimals

2009-01-03 Thread Mark Dickinson
On Dec 31 2008, 11:02 pm, Steven D'Aprano wrote: > On Sun, 28 Dec 2008 06:38:32 -0800, Mark Dickinson wrote: > > On Dec 28, 7:28 am, Steven D'Aprano > cybersource.com.au> wrote: > >> Ah crap, I forgot that from_float() has been left out of the decimal > >&

Re: math module for Decimals

2009-01-03 Thread Mark Dickinson
On Jan 3, 9:27 pm, Mark Dickinson wrote: > Decimal.from_float() implemented by Raymond Hettinger for Python 2.7 > and Python 3.1, within 72 hours of Steven submitting the feature > request.  If only all issues could be resolved this quickly. :-) Rats. I left out the crucial line of

Re: math module for Decimals

2009-01-04 Thread Mark Dickinson
unterintuitive. (Think of the sign as analogous to the sign *bit* in an IEEE 754 floating-point number.) Mark -- http://mail.python.org/mailman/listinfo/python-list

Python training in Colorado, January 27-30

2009-01-04 Thread Mark Lutz
Python author and trainer Mark Lutz will be teaching a 4-day Python class on January 27-30, in Longmont, Colorado. This is a public training session open to individual enrollments, and covers the same topics and hands-on lab work as the onsite sessions that Mark teaches. The class provides an in

Re: math module for Decimals

2009-01-04 Thread Mark Dickinson
m_float, if it's the only thing that prevents the trunk version of decimal.py from being used with Python 2.4. On the other hand, from_float isn't going to work until 2.7 anyway, since it uses a whole bunch of new stuff: as_integer_ratio and copysign (both introduced in 2.6), and bit_length (introduced in 2.7). Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Rich Comparisons Gotcha

2009-01-05 Thread Mark Wooding
Steven D'Aprano wrote: > There is nothing to blame them for. This is the correct behaviour. NaNs > should *not* compare equal to themselves, that's mathematically > incoherent. Indeed. The problem is a paucity of equality predicates. This is hardly surprising: Common Lisp has four general-pu

Re: Rich Comparisons Gotcha

2009-01-05 Thread Mark Wooding
Steven D'Aprano wrote: > I've already mentioned NaNs. Sentinel values also sometimes need to > compare not equal with themselves. Forcing them to compare equal will > cause breakage. There's a conflict between such domain-specific considerations (NaNs, strange sentinels, SAGE's equations), and r

Re: math module for Decimals

2009-01-06 Thread Mark Dickinson
lines that look like the following (but with different modules listed). Python build finished, but the necessary bits to build these modules were not found: bsddb185 gdbm linuxaudiodev ossaudiodevspwd sunaudiodev If math is included in the modules listed, then I'd very much like to know about it. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Rich Comparisons Gotcha

2009-01-06 Thread Mark Wooding
Steven D'Aprano wrote: > Such assumptions only hold under particular domains though. You can't > assume equality is an equivalence relation once you start thinking > about arbitrary domains. >From a formal mathematical point of view, equality /is/ an equivalence relation. If you have a relation

Re: why cannot assign to function call

2009-01-06 Thread Mark Wooding
Steven D'Aprano wrote: > By all means, if Derek doesn't like the assignment model used by Python > (and Java, Ruby, C#, Perl, RealBasic, VisualBasic, Lua, and many other > languages going back to at least CLU in the mid 1970s) It goes back to Lisp in the late 1950s. [snip stuff I agree with.

Re: why cannot assign to function call

2009-01-06 Thread Mark Wooding
Steven D'Aprano wrote: > (3) Those who come from an entirely different programming model, say, > Forth or Haskell. For them, Python's assignment model is going to be the > least of their worries. Actually, Haskell's assignment model (you have to grubbing about for IORefs or STRefs to find it b

Re: why cannot assign to function call

2009-01-06 Thread Mark Wooding
Steven D'Aprano wrote: > I don't think so. Variables in algebra are quite different from variables > in programming languages. Contrast the statement: > > x = x+1 > > as a programming expression and an algebraic equation. As a programming > expression, it means "increment x by one". But as an

Re: why cannot assign to function call

2009-01-06 Thread Mark Wooding
Derek Martin wrote: > I think I have though, not that it matters, since that was never > really my point. Python's assignment model requires more explanation > than the traditional one, simply to state what it does. That alone is > evidence (but not proof). Hmm. Actually, it's not the assignm

Re: math module for Decimals

2009-01-06 Thread Mark Dickinson
7;0.0', imag='0.9272952180016123') Shouldn't the real part here be something like: 2.2204460492503132e-17 instead of 0.0? Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Rich Comparisons Gotcha

2009-01-06 Thread Mark Wooding
Steven D'Aprano wrote: > To prove my claim, all you need is two domains with a mutually > incompatible definition of equality. That's not so difficult, surely? How > about equality of integers, versus equality of integers modulo some N? No, that's not an example. The integers modulo N form a

Re: why cannot assign to function call

2009-01-06 Thread Mark Wooding
Steven D'Aprano wrote: > If I wanted a reference to a list, I'd expect to *dereference* the > reference to get to the list. That's not what Python forces you do to: > you just use the list as the list object itself. That's odd. No, you give a reference to the list to a function, and the funct

Re: why cannot assign to function call

2009-01-06 Thread Mark Wooding
Steven D'Aprano wrote: > The only tricky thing is that items 1, 2 and 3 can be inside two > different boxes at the same time. There's no obvious real world analogy > to that without the boxes being nested. This ability for objects to be in > two places at once (or even to be inside themselves!

Re: why cannot assign to function call

2009-01-06 Thread Mark Wooding
[email protected] wrote: > Is not the proper term "aliasing"? Perhaps Python "variables" should > be called "alises". No. The proper term is most definitely `binding': see SICP, for example. (Wikipedia has a link to the full text.) The topic of `aliasing' deals with a problem in compiler imple

Re: why cannot assign to function call

2009-01-07 Thread Mark Wooding
Steven D'Aprano wrote: > Only in the sense that the behaviour of *real world* objects don't > entirely match the behaviour of Python objects. If you just accept > that Python objects can be in two places at once, an unintuitive > concept I accept but hardly difficult to grasp, then you don't need

Re: Rich Comparisons Gotcha

2009-01-07 Thread Mark Wooding
Steven D'Aprano wrote: > It's only incoherent if you need equality to be an equivalence relation. > If you don't, it is perfectly reasonable to declare that i"abc" equals > "abc". Right! And if you didn't want an equivalence relation, then `==' will suit you fine. The problem is that some ap

Re: eval('07') works, eval('08') fails, why?

2009-01-08 Thread Mark Dickinson
 ^ > SyntaxError: invalid token An integer literal with a leading zero is interpreted as an octal (base 8) number, so only digits in the range 0-7 (inclusive) are permitted in such a literal. Mark > > I can't think of anything that could cause this. Similarly, eval('09

Re: why cannot assign to function call

2009-01-08 Thread Mark Wooding
[email protected] wrote: > I thought you were objecting to Python's use of the term "binding" > when you wrote: [snip] > in response to someone talking about "...all those who use the term > \"name binding\" instead of variable assignment...". Oh, that. Well, the terms are `binding' and `assign

Re: Nubie question: how to not pass "self" in call to seek() function ?

2009-01-08 Thread Mark Tolonen
?) version of Python may not be providing as helpful an error message. f=gzip.GzipFile('blah.gz','r') f.seek(-1,2) Traceback (most recent call last): File "", line 1, in File "C:\dev\python\lib\gzip.py", line 368, in seek raise ValueError('

Re: why cannot assign to function call

2009-01-08 Thread Mark Wooding
[Steven's message hasn't reached my server, so I'll reply to it here. Sorry if this is confusing.] Aaron Brady wrote: > On Jan 8, 1:45 am, Steven D'Aprano > wrote: > > On Wed, 07 Jan 2009 10:17:55 +, Mark Wooding wrote: > > > > > The `they&

Re: why cannot assign to function call

2009-01-08 Thread Mark Wooding
Erik Max Francis wrote: > Terry Reedy wrote: > > > >>> a='par'+'rot' > > >>> b='parrot' > > >>> a is b > > True > > One exactly doesn't really say much. It's implementation dependent, and > depends on the length of the string: > > >>> a = 'this is a much longer ' + 'parrot' > >>> b = 'thi

Re: Unexpected scientific notation

2009-01-09 Thread Mark Dickinson
on. >>> from decimal import Decimal >>> 0 + Decimal('3E1') Decimal('30') >>> Decimal('0.0') + Decimal('3E1') Decimal('30.0') Adding 0 also has the side-effect of turning a negative zero into a positive zero, but I suspect that this isn't going to worry you much. :) You might also want to look at the Decimal.quantize method. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: why cannot assign to function call

2009-01-09 Thread Mark Wooding
[email protected] wrote: > As a side comment (because it always bugs me when I read this, even > though I read it in very authoritative sources), ISTM that C passes > everything by value except arrays; they are passed by reference (by > passing a pointer to the array by value.) Admittedly, the clo

Re: Unexpected scientific notation

2009-01-09 Thread Mark Dickinson
tput could come out of a locale.format call. Is it possible that your user is somehow seeing a direct str() or "%s" of a Decimal instance, rather than something that's been through a format method? Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Unexpected scientific notation

2009-01-09 Thread Mark Dickinson
On Jan 9, 5:38 pm, Paul McNett wrote: > I'll clarify my LOL: Mark initially replied to me directly, to which I > responded > directly. Because he replied directly, I kept my response offline, too, not > knowing > if he had a special reason to discuss this offline instea

Re: why cannot assign to function call

2009-01-09 Thread Mark Wooding
[Sigh. I must apologize for the length of this article. I can't, alas, see a satisfactory way of trimming it. The doubly-quoted stuff later on was by me.] Steven D'Aprano wrote: > I'm pretty sure that no other pure-Python coder has manipulated > references either. They've manipulated objects

Re: why cannot assign to function call

2009-01-09 Thread Mark Wooding
references only. You may have missed this, but I explained at least twice: variables are bound to `slots' or `locations'; locations, in Python, store references to values; references are not values. But I answered this lot ages ago. I'm still dealing with the fallout because of my a

Re: why cannot assign to function call

2009-01-09 Thread Mark Wooding
Steven D'Aprano wrote: > Python doesn't do the same thing as C. It actually passes the same value > to the function, without copying it. > > Why oh why do you keep insisting that Python is no different from C? I'm beginning to think that you're not bothing to read what I'm writing, but I'll as

Re: why cannot assign to function call

2009-01-09 Thread Mark Wooding
[email protected] wrote: > If one accepts that there are a "lot" of people who post in here that > clearly are surprised by Python's assignment semantics, But one should not accept that. One might accept that there are many who post who claim that they are surprised by Python's assignment semant

Re: how to get the thighest bit position in big integers?

2008-10-06 Thread Mark Dickinson
> machine, so the first correction is sometimes needed.  I do not know if > the second is or not. See also http://bugs.python.org/issue3439 where there's a proposal to expose the _PyLong_NumBits method. This would give an O(1) solution. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: how to get the thighest bit position in big integers?

2008-10-08 Thread Mark Dickinson
On Oct 7, 5:19 pm, [EMAIL PROTECTED] wrote: > but I want to make clear that I think that (0).numbits()==-1 > is the natural solution. At least for all square-and-multiply-like > algorithms needed in [...] Can you clarify this? Why is -1 the natural solution? I can see a case for 0, for -infinity

Re: unicode .replace not working - why?

2008-10-12 Thread Mark Tolonen
s the modified string, so you have to reassign it. -Mark "Kurt Peters" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Thanks, clearly though, my "For loop" shows a character using ord(167), and using print repr(textu), it shows the character \xa7 (as do

Re: Unicode File Names

2008-10-18 Thread Mark Tolonen
Since the behavior is now identical it seems os.getcwdu() should be dropped. -Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Unicode File Names

2008-10-18 Thread Mark Tolonen
formation. import os [s for s in dir(os) if 'cwd' in s] ['getcwd', 'getcwdu'] -Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: urllib2.HTTPError: HTTP Error 204: NoContent

2008-10-19 Thread Mark Sapiro
eaders['User-Agent'] = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; >>> rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3' >>> ro = urllib2.Request(url, None, headers) >>> op = urllib2.urlopen(ro) >>> page = op.read() >>> page (lots of H

Python 2.5: wrong number of arguments given in TypeError for function argument aggregation (dictionary input vs the norm)

2008-10-30 Thread mark floyd
rts the incorrect number of arguments given (I would expect to see '2 given') We've tested this locally using Python 2.5, Debian Etch 32-bit installation Thanks, - Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: how to call this dll in python

2008-11-03 Thread Mark Tolonen
"Shark" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] I have a windows dll1.dll with a export function: int f1(char filename,char **buf,int *bufLen) { int len; //got the length of file anyway,such as 100 len = 100;//len = getLen(filename); *buf = (char*)calloc(100); *bufLen = len

Using subprocess.Popen() in a Windows service

2008-11-05 Thread Mark Shewfelt
hes. I am using Python 2.5 on a Windows XP Professional machine. Any help would be greatly appreciated. Best Regards, Mark Shewfelt -- http://mail.python.org/mailman/listinfo/python-list

2009 Python class schedule

2008-11-06 Thread Mark Lutz
provide in-depth and hands-on introductions to Python and its common applications, and are based upon the instructor's popular Python books. Thanks for your interest, --Mark Lutz at Python Training -- http://mail.python.org/mailman/listinfo/python-list

Re: Very simple - please help

2008-11-07 Thread Mark Tolonen
guess, I'd suspect Blah and commands are in different modules and you didn't import Blah into commands' module, hence why Python can't find it. But we'd need some more details to be able to determine that. Cheers, Chris Also, you don't need a lambda for this example: class Blah(list): pass ... d={1:Blah} d[1]() [] -Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Where to locate existing standard encodings in python

2008-11-09 Thread Mark Tolonen
/lib/node127.html Now my question: Can I find the same info in the standard python doc or query python with a certain command to print out all existing codings? The first hit from googling "site:python.org encodings": http://www.python.org/doc/2.5.2/lib/standard-encodings.html -Mar

Re: SocketServer.ThreadingTCPServer accepts clients outside server_forever

2008-11-09 Thread Mark Tolonen
ept connections while server_forever is running. Kind regards, Okko serve_forever() only calls accept() in a loop. clients will be able to connect up to the backlog of the listen() call. -Mark -- http://mail.python.org/mailman/listinfo/python-list

First post, recursive references with pickle.

2008-11-10 Thread mark starnes
that if so, the recursive component will be immediately visible, easing the bug hunt. Any help would be appreciated. BR, Mark. -- http://mail.python.org/mailman/listinfo/python-list

Re: IBM integer and double formats

2008-11-10 Thread Mark Dickinson
iding how to handle NaNs and infinities when encoding to IBM format, and how to handle out-of-range floats coming back (if I recall correctly, the IBM format allows a wider range of exponents than IEEE). Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: IBM integer and double formats

2008-11-10 Thread Mark Dickinson
On Nov 10, 8:16 pm, Mark Dickinson <[EMAIL PROTECTED]> wrote: > and how to handle out-of-range floats coming back (if I recall > correctly, the IBM format allows a wider range of exponents > than IEEE). > Whoops---wrong way around. It looks like it's IEEE that has th

Re: IBM integer and double formats

2008-11-10 Thread Mark Dickinson
e isnan and isinf functions that are in Python 2.6; if you don't have Python 2.6 or don't care about IEEE specials then just delete the relevant lines. Mark def IBMtoIEEE(x): """Convert a Python float (assumed stored as an IEEE 754 double) to IBM hexadecimal float form

Re: IBM integer and double formats

2008-11-11 Thread Mark Dickinson
wercase with no leading > zeroes ... variable length and lowercase doesn't seem very IBM to me. True. Replace "%x" with "%016X" for fixed-length uppercase. Or as you say, bytes output is probably more natural. I was guessing that the OP wants to write the converted float o

Re: IBM integer and double formats

2008-11-11 Thread Mark Dickinson
On Nov 11, 12:07 pm, Mark Dickinson <[EMAIL PROTECTED]> wrote: > "All character data are stored in ASCII, regardless of the > operating system." But character data is not the same thing as numeric data. Okay--- you win again, John. > Sheesh. [...] Apologies for ann

Re: IBM integer and double formats

2008-11-11 Thread Mark Dickinson
> XPORT format. Which is stored in ASCII, no? From the link you gave earlier, 3rd line of the introduction: "All character data are stored in ASCII, regardless of the operating system." Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Identifying unicode punctuation characters with Python regex

2008-11-14 Thread Mark Tolonen
.0rc2): import unicodedata Po=''.join(chr(x) for x in range(65536) if unicodedata.category(chr(x)) == 'Po') import re r=re.compile('['+Po+']') x='我是美國人。' x '我是美國人。' r.findall(x) ['。'] -Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Identifying unicode punctuation characters with Python regex

2008-11-14 Thread Mark Tolonen
"Mark Tolonen" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] "Shiao" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Hello, I'm trying to build a regex in python to identify punctuation characters in all the languages. Some rege

Re: Avoiding local variable declarations?

2008-11-14 Thread Mark Wooding
Chris Mellon <[EMAIL PROTECTED]> wrote: > Any time you port between languages, it's rarely a good idea to just > convert code verbatim. For example: > > import random, string > def random_char(): > return random.choice(string.ascii_letters + string.digits) Note that this code doesn't preserve

Re: Clustering the keys of a dict according to its values

2008-11-14 Thread Mark Wooding
Florian Brucker <[EMAIL PROTECTED]> wrote: > That is, generate a new dict which holds for each value of the old > dict a list of the keys of the old dict that have that very value. > Another requirement is that it should also work on lists, in that case > with indices instead of keys. We may assum

Re: Windows PE and Python 2.6 (Side-by-Side error)

2008-11-14 Thread Mark Tolonen
r to do this is buried in Microsoft Visual Studio 2008. The are installed to the C:\Windows\WinSxS subdirectory. Take a look at this directory and see if Microsoft really has solved "DLL Hell". -Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: ElementTree XML Namspace

2008-11-14 Thread Mark Tolonen
ext("{http://tempuri.org/invoice_batch_generic.xsd}invoice_batch/{http://tempuri.org/invoice_batch_generic.xsd}batch_id/";) -Mark [1]http://effbot.org/zone/element.htm#xml-namespaces -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie code review of parsing program Please

2008-11-16 Thread Mark Tolonen
;_len = ' + str(rec_len) output.write(lenrec) output.close() *** RESULTING OUTPUT *** salesmen = [ ('salesmen_no', 3, 'Xint', 0), ('salesmen_name', 30, 'Xstr', 0), ('salesmen_territory', 30, 'Xstr', 0), ('salesmen_quota', 4, 'Pdec', 0), ('salesmen_1st_bonus', 4, 'Pdec', 2), ('salesmen_2nd_bonus', 4, 'Pdec', 2), ('salesmen_3rd_bonus', 4, 'Pdec', 2), ('salesmen_4th_bonus', 4, 'Pdec', 2) ] salesmen_len = 83 If you find this code useful please feel free to use any or all of it at your own risk. Thanks Len S You might want to check out the pyparsing library. -Mark -- http://mail.python.org/mailman/listinfo/python-list

RE: [Py2exe-users] py2exe 0.6.9 released

2008-11-16 Thread Mark Hammond
msvcp90.dll and msvcr90.dll from the Python directory into your app's directory. Your installer will need to arrange for these to be installed with your app (assuming you have the rights to redistribute them) or you can download the installer from MS which installs them globally. Hope thi

Re: Newbie code review of parsing program Please

2008-11-17 Thread Mark Tolonen
"Steve Holden" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Mark Tolonen wrote: "len" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] [...] You might want to check out the pyparsing library. And you might want to trim your mess

Re: Sieve of Zakiya

2008-11-18 Thread Mark Dickinson
gainst Bernstein's primegen package? http://cr.yp.to/primegen.html Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Sieve of Zakiya

2008-11-18 Thread Mark Dickinson
le back. On my machine, the function wheelSieve comes out around 60% faster than your 'SoZP11', for inputs of around 10**6 or so. Mark from math import sqrt from bisect import bisect_left def basicSieve(n): """Given a positive integer n, generate the primes < n.&qu

Re: Sieve of Zakiya

2008-11-19 Thread Mark Dickinson
ticians will become > interested in some of the features and characteristics I've found in > the method's elements, and do a better and more thorough analysis of > what's going on than I'm able to do presently. This is getting off-topic for comp.lang.python. I suggest you take

Re: Avoiding local variable declarations?

2008-11-19 Thread Mark Wooding
greg <[EMAIL PROTECTED]> wrote: > I've only ever seen "identity element" in English mathematics. > "Neutral element" sounds like something my car's gearbox > might have... I've encountered both. I think `neutral element' is more common when dealing with the possibility that it might not be uniqu

Re: Inheriting frozenset gives bug if i overwrite __repr__ method

2008-11-19 Thread Mark Dickinson
>>> c = a+b >>> c 8 >>> type(c) >>> class fs(frozenset): pass ... >>> a = fs([1, 2, 3]) >>> b = fs([3, 4, 5]) >>> c = a - b >>> c fs([1, 2]) >>> type(c) >>> Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Inheriting frozenset gives bug if i overwrite __repr__ method

2008-11-19 Thread Mark Dickinson
issue1721812 It's fixed in 3.0; backporting the fix to 2.x was deemed too risky. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Quick nested loop syntax?

2008-11-19 Thread Mark Dickinson
duct If you don't have Python 2.6 available, then the documentation above also contains (almost) equivalent Python code that might work for you. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: A little comments of ctypes and construct.

2008-11-21 Thread Mark Tolonen
;L',data)] ['0x1020304', '0x11121314', '0x21222324', '0x31323334', '0x41424344'] -Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: matching exactly a 4 digit number in python

2008-11-21 Thread Mark Tolonen
"harijay" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] I want to parse a number of strings and extract only those that contain a 4 digit number anywhere inside a string Try: p = re.compile(r'\b\d{4}\b') -Mark -- http://mail.python.org/mailman/listinfo/python-list

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

2009-02-23 Thread Mark Dufour
Hi all, I have recently released version 0.1 of Shed Skin, an experimental (restricted-)Python-to-C++ compiler. Please see my blog for more info about the release: http://shed-skin.blogspot.com Thanks, Mark Dufour. -- "One of my most productive days was throwing away 1000 lines of

Re: How does one get from "ImportError: DLL load failed:..." to a culprit .dll and symbol?

2009-02-23 Thread Mark Hammond
- if you follow his instructions that should all become quite obvious. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: getting at individual bits inside byte field: struct module : bitwise operator

2009-02-23 Thread Mark Tolonen
actual code we can't figure out what you are doing wrong. This works as expected: import struct format = struct.Struct(" 0x6161 print element1 & 0x1f 1 -Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem in accessing files with unicode fonts.

2009-02-23 Thread Mark Tolonen
27;wt',encoding='utf-8') for path,dirs,files in os.walk(u'.'): for fname in files: output.write(os.path.join(path,fname)+'\n') output.close() -Mark "venu madhav" wrote in message news:daf1e02e0902232315j7e66593ewecfdd739972ad...@ma

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

2009-02-25 Thread Mark Hammond
On 26/02/2009 4:51 AM, Lorenzo wrote: PS: Mark, this could be added to a kind of "Deployment" entry in py2exe wiki, it would be useful. IIRC, I've never edited the py2exe wiki (despite appearances to the contrary sometimes, I don't formally maintain that package!).

Re: why cannot assign to function call

2009-02-28 Thread Mark Wooding
Ethan Furman writes: > Mark Wooding wrote: >> Here's what I think is the defining property of pass-by-value [...]: >> >> The callee's parameters are /new variables/, initialized /as if by >> assignment/ from the values of caller's argument expressio

Re: Iterator class to allow self-restarting generator expressions?

2009-03-01 Thread Mark Tolonen
then uses the list to generate successive iterations. -Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: siple for in expression

2009-03-03 Thread Mark Wooding
"Matko" writes: > Can someone help me to understand the following code: > > uv_face_mapping = [[0,0,0,0] for f in faces] It constructs a fresh list, with the same number of elements as are in the iterable object referred to by `faces', and where each element is a distinct list of four zero-value

Re: how to convert from network to host byte order

2009-03-05 Thread Mark Tolonen
',data)) # default is host-order, could be big or little. e.close() If the original binary file is big-endian, change the 3rd line: data = struct.unpack('>H',f.read(2))[0] -Mark -- http://mail.python.org/mailman/listinfo/python-list

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