Re: Comparing float and decimal

2008-09-25 Thread Mark Dickinson
ing Python 2.6): >>> n, d = 0.1.as_integer_ratio() >>> from decimal import Decimal, getcontext >>> getcontext().prec = 100 >>> Decimal(n)/Decimal(d) Decimal('0.155511151231257827021181583404541015625') which is a lot closer to Marc's answer. Looks like your float approximation to 0.1 is 6 ulps out. :-) Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Comparing float and decimal

2008-09-25 Thread Mark Dickinson
ns s | t and t | s have different sizes: >>> from decimal import Decimal >>> s = set([Decimal(2), 2.0]) >>> t = set([2]) >>> len(s | t) 2 >>> len(t | s) 1 This opens up some wonderful possibilities for hard-to-find bugs... Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: lxml question

2008-09-26 Thread Mark Thomas
xml2's "recover" mode which accommodates non-well-formed XML. parser = etree.XMLParser(recover=True) tree = etree.XML(your_xml_string, parser) You'll still need to use your wrapper root element, because recover mode will ignore everything after the first root closes (and

Python 3.0 and repr

2008-09-28 Thread Mark Tolonen
ncodeError: 'charmap' codec can't encode character '\xfe' in position 1: character maps to Why not display '\xfe' here? It seems like this inconsistency would make it difficult to write things like doctests that weren't dependent on the tester's terminal. It also makes it difficult to inspect variables without hex(ord(n)) on a character-by-character basis. Maybe repr() should always display the ASCII representation with escapes for all other characters, especially considering the "repr() should produce output suitable for eval() when possible" rule. What are others' opinions? Any insight to this design decision? -Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Music knowledge representation

2008-09-28 Thread Mark Tolonen
r the D. Check out itertools.cycle: x=itertools.cycle('ABCDEFG') x.next() 'A' x.next() 'B' x.next() 'C' x.next() 'D' x.next() 'E' x.next() 'F' x.next() 'G' x.next() 'A' x.next() 'B' -Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 3.0 and repr

2008-09-28 Thread Mark Tolonen
y usual editors (PythonWin and PyAlaMode from wxPython) don't work with Python 3, which was why I was using the Windows cmd prompt. Thanks, Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Using re to find unicode ranges

2008-09-29 Thread Mark Tolonen
or n in re.findall(ur'[\u4e00-\u9fff]+',sample): print n output: 马克 美国人 --Mark -- http://mail.python.org/mailman/listinfo/python-list

Shed Skin (restricted) Python-to-C++ compiler 0.0.29

2008-09-30 Thread Mark Dufour
ng help is also always welcome. One important feature I'd really like to have for a 0.1 release is custom class support in extension modules.. Thanks! Mark. -- "One of my most productive days was throwing away 1000 lines of code" - Ken Thompson -- http://mail.python.org/mailman/listinfo/python-list

Re: Comparing float and decimal

2008-09-30 Thread Mark Dickinson
eals to me, but I can't see how to implement it. So I guess that just leaves updating the docs. Other thoughts? Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: r""

2008-09-30 Thread Mark Thomas
about? str = "foo/bar" re = Regexp.new(str) => /foo\/bar/ -- Mark. -- http://mail.python.org/mailman/listinfo/python-list

Re: How to emit UTF-8 from console mode?

2008-09-30 Thread Mark Tolonen
ode pages to work either. There is some trick I don't know, because Chinese versions of Windows can display Chinese. I have the East Asian languages installed and Chinese IME enabled, but it doesn't help for console apps. --Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Comparing float and decimal

2008-10-01 Thread Mark Dickinson
feel it's the decimal module's responsibility to either fix or document the resulting problems. It would also be nice if it were made more obvious somewhere in the docs that transitivity of equality is important for correct set and dict behaviour. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: How to emit UTF-8 from console mode?

2008-10-01 Thread Mark Tolonen
"Ross Ridge" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] I need UTF-8 because I need to experiment with some OS function calls that give me UTF-16 and I need to emit UTF-16 or UTF-8. <[EMAIL PROTECTED]> wrote: Try setting the code page to 65001, and emit the UTF-8 explicitly

Re: How to emit UTF-8 from console mode?

2008-10-01 Thread Mark Tolonen
lly is to use ctypes, but this will only work in a Windows console: import ctypes k=ctypes.WinDLL('kernel32') x.SetConsoleOutputCP(1251) 1 print u''.join(unichr(i) for i in range(0x410,0x430)).encode('windows-1251') АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ --Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Socket Question

2008-10-01 Thread Mark Tolonen
pt of a start and end of message unless you implement something you can recognize as a complete message in the protocol. -Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Python equivalent of Perl e flag with regular expression

2008-10-02 Thread Mark Thomas
'/ee' which executes the code, then takes the output of that and executes it again. In fact, you can have an arbitrary number of e's, which is very handy for crazy people. -- Mark. -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there no end to Python?

2006-03-17 Thread Mark Warburton
the macroscopic! This way the code is readable by anyone (including you!) and you are free to dream up any algorithms you like. -- Mark Warburton Ottawa, Canada -- http://mail.python.org/mailman/listinfo/python-list

Re: Programming challenge: wildcard exclusion in cartesian products

2006-03-20 Thread Mark Tarver
[b a a] [b a b] [b a c] [b b a] [b b b] [b b c] [b c a] [b c b] [b c c] [c a a] [c a b] [c a c] [c b a] [c b b] [c b c] [c c a] [c c b] [c c c]] Remove all lists beginning with a or b. (51-) (challenge [[a | X] [b | X]] 3 [a b c]) [[c a a] [c a b] [c a c] [c b a] [c b b] [c b c] [c c a] [c c b

Re: Programming challenge: wildcard exclusion in cartesian products

2006-03-20 Thread Mark Carter
I'd like to propose a coding challenge of my own. The challenge is to reproduce the TEA (Tiny Encryption Algorith): http://www.simonshepherd.supanet.com/tea.htm in your language of choice. Here's the code, just two simple functions: void encipher(unsigned long *const v,unsigned long *const w,

Re: Programming challenge: wildcard exclusion in cartesian products

2006-03-20 Thread Mark Tarver
Interesting. But you probably need to post this as a new message, since it is a distinctly different problem from the one driving this thread. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Programming challenge: wildcard exclusion in cartesian products

2006-03-20 Thread Mark Carter
Mark Tarver wrote: > Interesting. At the risk of being labelled a troll, one thought that is occuring to me is that in Lisp it seems that sometimes it is difficult to achieve a simple thing in a simple way. To clarify ... recently, I had been trying to obtain md5 hashes of the files we had

Re: Programming challenge: wildcard exclusion in cartesian products

2006-03-22 Thread Mark Carter
Mark Carter wrote: > At the risk of being labelled a troll One thing I just discovered, and by which I mean *really* discovered ... is that Lisp is an interactive environment. I am working on trying to verify the contents of disks. I noticed that the input formats are slightly wrong,

Re: Conversion from string to integer

2006-03-22 Thread Mark Warburton
You want something like this: >>> a = '\x1dz' >>> (ord(a[0])<<8) + ord(a[1]) 7546 Each of the two characters represents one byte of a 16-bit integer. It doesn't matter if they are ascii or hex -- there are still exactly two bytes in each of your strings. The ord() function converts a character

Re: Conversion from string to integer

2006-03-22 Thread Mark Warburton
Peter Otten wrote: > To convert them you need struct.unpack() Ahh, right. Batteries included! Thanks for the enlightenment. :) -- http://mail.python.org/mailman/listinfo/python-list

Re: Conversion from string to integer

2006-03-22 Thread Mark Warburton
Grant Edwards wrote: > On 2006-03-22, Mark Warburton <[EMAIL PROTECTED]> wrote: > > Ahh, right. Batteries included! Thanks for the enlightenment. :) > > I think that's the third time _today_ that question has been > answered. Where can we put that information suc

determine file type

2006-03-26 Thread Mark Gibson
Is there an equivalent to the unix 'file' command? [mark tmp]$ file min.txt min.txt: ASCII text [mark tmp]$ file trunk trunk: directory [mark tmp]$ file compliance.tgz compliance.tgz: gzip compressed data, from Unix What I really want to do is determine if a file is 1) a directory,

Re: determine file type

2006-03-26 Thread Mark Gibson
> > > import os > def test_file(filename, maxread=1024): >if os.path.isdir(filename): > return 'directory' >afile = open(filename) # open as text >for achar in afile.read(maxread): > if ord(achar) > 127: >return 'binary' >return 'text' > > Pefect, thanks! --

Re: Characters contain themselves?

2006-04-07 Thread Mark Jackson
f/types.html > > (One item of what type, one might ask) Good point. ". . .represented by a string of length one" would be better. -- Mark Jackson - http://www.alumni.caltech.edu/~mjackson An information system based on theory isolated from reality is bound to fail. - Mitch Kabay -- http://mail.python.org/mailman/listinfo/python-list

Re: need clarification on -0

2009-11-28 Thread Mark Dickinson
's certainly the intention: there are bits of CPython's source code that are deliberately written in convoluted ways in order to avoid the assumption of two's complement. But I have a nasty suspicion that, were Python ever unlucky enough to meet a ones' complement machine, we&#

Re: need clarification on -0

2009-11-28 Thread Mark Dickinson
On Nov 28, 11:14 pm, Mark Dickinson wrote: > While that's true, I think the implementation of Python is > such that the Python objects -0 and 0 should always be > indistinguishable even on machines where the underlying > architecture represents integers using ones' compleme

Moving from Python 2 to Python 3: A 4 page "cheat sheet"

2009-12-01 Thread Mark Summerfield
I've produced a 4 page document that provides a very concise summary of Python 2<->3 differences plus the most commonly used new Python 3 features. It is aimed at existing Python 2 programmers who want to start writing Python 3 programs and want to use Python 3 idioms rather than those from Python

Re: Moving from Python 2 to Python 3: A 4 page "cheat sheet"

2009-12-01 Thread Mark Dickinson
On Dec 1, 2:03 pm, Mark Summerfield wrote: > I've produced a 4 page document that provides a very concise summary > of Python 2<->3 differences plus the most commonly used new Python 3 > features. Very nice indeed! My only quibble is with the statement on the first p

Re: Moving from Python 2 to Python 3: A 4 page "cheat sheet"

2009-12-02 Thread Mark Summerfield
On 1 Dec, 17:50, Mark Dickinson wrote: > On Dec 1, 2:03 pm, Mark Summerfield wrote: > > > I've produced a 4 page document that provides a very concise summary > > of Python 2<->3 differences plus the most commonly used new Python 3 > > features. > > Very

Re: Moving from Python 2 to Python 3: A 4 page "cheat sheet"

2009-12-02 Thread Mark Summerfield
On 1 Dec, 18:30, Lie Ryan wrote: > On 12/2/2009 1:03 AM, Mark Summerfield wrote: > > > > > I've produced a 4 page document that provides a very concise summary > > of Python 2<->3 differences plus the most commonly used new Python 3 > > features. It is a

Re: Moving from Python 2 to Python 3: A 4 page "cheat sheet"

2009-12-02 Thread Mark Summerfield
On 1 Dec, 21:55, Terry Reedy wrote: > Mark Summerfield wrote: > > I've produced a 4 page document that provides a very concise summary > > of Python 2<->3 differences plus the most commonly used new Python 3 > > features. It is aimed at existing Python 2 programme

Re: Moving from Python 2 to Python 3: A 4 page "cheat sheet"

2009-12-02 Thread Mark Summerfield
On 1 Dec, 23:52, John Bokma wrote: > Mark Summerfield writes: > > It is available as a free PDF download (no registration or anything) > > from InformIT's website. Here's the direct link: > >http://ptgmedia.pearsoncmg.com/imprint_downloads/informit/promotions/...

Re: Moving from Python 2 to Python 3: A 4 page "cheat sheet"

2009-12-02 Thread Mark Dickinson
On Dec 2, 8:01 am, Mark Summerfield wrote: > On 1 Dec, 17:50, Mark Dickinson wrote: > > My only quibble is with the statement on the first page that > > the 'String % operator is deprecated'.  I'm not sure that's > > true, for all values of '

Re: Moving from Python 2 to Python 3: A 4 page "cheat sheet"

2009-12-02 Thread Mark Summerfield
On Dec 1, 2:03 pm, Mark Summerfield wrote: > I've produced a 4 page document that provides a very concise summary > of Python 2<->3 differences plus the most commonly used new Python 3 > features. It is aimed at existing Python 2 programmers who want to > start writing Pyt

Re: Moving from Python 2 to Python 3: A 4 page "cheat sheet"

2009-12-02 Thread Mark Summerfield
On Dec 2, 8:53 am, Mark Dickinson wrote: > On Dec 2, 8:01 am, MarkSummerfield wrote: > > > On 1 Dec, 17:50, Mark Dickinson wrote: > > > My only quibble is with the statement on the first page that > > > the 'String % operator is deprecated'.  I'm

Re: Moving from Python 2 to Python 3: A 4 page "cheat sheet"

2009-12-02 Thread Mark Summerfield
On Dec 2, 11:20 am, Wolodja Wentland wrote: > On Wed, Dec 02, 2009 at 00:10 -0800, Mark Summerfield wrote: > > On 1 Dec, 18:30, Lie Ryan wrote: > > > Also, I'm not sure what this change is referring to: > > > Python 2                 Python 3 > > >

Re: Moving from Python 2 to Python 3: A 4 page "cheat sheet"

2009-12-02 Thread Mark Summerfield
On Dec 2, 11:31 am, "Martin P. Hellwig" wrote: > MarkSummerfieldwrote: > > > It is available as a free PDF download (no registration or anything) > > from InformIT's website. Here's the direct link: > >http://ptgmedia.pearsoncmg.com/imprint_downloads/informit/promotions/... > > > Very handy! Am I

Re: Moving from Python 2 to Python 3: A 4 page "cheat sheet"

2009-12-02 Thread Mark Summerfield
On Dec 2, 4:22 pm, Mark Summerfield wrote: > On Dec 2, 11:31 am, "Martin P. Hellwig" > wrote: > > > MarkSummerfieldwrote: > > > > It is available as a free PDF download (no registration or anything) > > > from InformIT's website. Here

Re: Moving from Python 2 to Python 3: A 4 page "cheat sheet"

2009-12-02 Thread Mark Dickinson
in   > another. A little less mind-bending, and every little bit helps! Or even "{:{}d}".format(456, 8), in 3.1 and 2.7 (when it appears). But you can do this with % formatting, too. In either 2.x or 3.x: >>> "%*d" % (8, 456) ' 456' -- Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Moving from Python 2 to Python 3: A 4 page "cheat sheet"

2009-12-02 Thread Mark Summerfield
On 2 Dec, 19:28, David H Wild wrote: > In article > <351fcb4c-4e88-41b0-a0aa-b3d63832d...@e23g2000yqd.googlegroups.com>, >    Mark Summerfield wrote: > > > I only just found out that I was supposed to give a different URL: > >http://www.informit.com/promotio

Beginner Q. interrogate html object OR file search?

2009-12-02 Thread Mark G
ing a string.find to look for the character patterns of the meta- tag, or should I use a DOM type library to retrieve the html element I want? Which is best practice? which occupies least code? Regards, Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Beginner Q. interrogate html object OR file search?

2009-12-02 Thread Mark G
e the html file > parsing script you say you have already, or how the date is 'modified > from' the meta-data. > > On Wed, Dec 2, 2009 at 10:24 PM, Mark G wrote: > > Hi all, > > > I am new to python and don't yet know the libraries well. What would > >

Re: Moving from Python 2 to Python 3: A 4 page "cheat sheet"

2009-12-03 Thread Mark Summerfield
On 2 Dec, 22:49, "John Posner" wrote: > On Wed, 02 Dec 2009 13:34:11 -0500, Carsten Haese   > > wrote: > > > With string interpolation, you don't need to do that, either. > >>>> '%*d' % (8,456) > > '     456' > >

Re: Moving from Python 2 to Python 3: A 4 page "cheat sheet"

2009-12-03 Thread Mark Summerfield
On 2 Dec, 20:59, MRAB wrote: > Mark Summerfield wrote: > > On 2 Dec, 19:28, David H Wild wrote: > >> In article > >> <351fcb4c-4e88-41b0-a0aa-b3d63832d...@e23g2000yqd.googlegroups.com>, > >>    Mark Summerfield wrote: > > >>> I only j

Re: Moving from Python 2 to Python 3: A 4 page "cheat sheet"

2009-12-03 Thread Mark Summerfield
On 3 Dec, 01:17, Antoine Pitrou wrote: > Le Tue, 01 Dec 2009 06:03:36 -0800, Mark Summerfield a écrit : > > > I've produced a 4 page document that provides a very concise summary of > > Python 2<->3 differences plus the most commonly used new Python 3 > > featu

Re: Moving from Python 2 to Python 3: A 4 page "cheat sheet"

2009-12-03 Thread Mark Summerfield
On 2 Dec, 21:28, David H Wild wrote: > In article > <9d290ad6-e0b8-4bfa-92c8-8209c7e93...@a21g2000yqc.googlegroups.com>, >    Mark Summerfield wrote: > > > > There is a typographical fault on page 4 of this pdf file. The letter > > > "P" is mis

Re: Moving from Python 2 to Python 3: 4 page "cheat sheet" issue#3

2009-12-04 Thread Mark Summerfield
On 3 Dec, 01:17, Antoine Pitrou wrote: > Le Tue, 01 Dec 2009 06:03:36 -0800, Mark Summerfield a écrit : > > > I've produced a 4 page document that provides a very concise summary of > > Python 2<->3 differences plus the most commonly used new Python 3 > > featu

Re: Float precision and float equality

2009-12-05 Thread Mark Dickinson
hat sort of calculations are you doing? -- Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Float precision and float equality

2009-12-05 Thread Mark Dickinson
cases where x and y are equal to within 1ulp, which presumably isn't what's wanted: >>> x, y = 0.1234565, 0.1234565004 >>> round(x, 6) == round(y, 6) False -- Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Float precision and float equality

2009-12-07 Thread Mark Dickinson
operator? That's probably not a good idea, for the reasons that Carl Banks already enumerated. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Float precision and float equality

2009-12-07 Thread Mark Dickinson
On Dec 7, 12:16 am, David Cournapeau wrote: > If you can depend on IEEE 754 semantics, one relatively robust method > is to use the number of representable floats between two numbers. The > main advantage compared to the proposed methods is that it somewhat > automatically takes into account the a

Re: which pi formula is given in the decimal module documentation?

2009-12-11 Thread Mark Dickinson
t;, "copyright", "credits" or "license" for more information. >>> from math import factorial as f >>> 3*sum(f(2*k)/f(k)/f(k)/(2*k+1)/16**k for k in range(50)) 3.141592653589794 I've no idea what its name is or where it comes from, though. I expect Raymond Hettinger would know. -- Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: which pi formula is given in the decimal module documentation?

2009-12-11 Thread Mark Dickinson
On Dec 11, 10:30 am, Mark Dickinson wrote: > > It looks like an infinite series with term `t`, where`n` = (2k-1)^2 > > and `d` = d = 4k(4k+2) for k = 1... Does it have a name? > > Interesting.  So the general term here is > 3 * (2k choose k) / (16**k * (2*k+1)),  k >= 0. &

Re: which pi formula is given in the decimal module documentation?

2009-12-11 Thread Mark Dickinson
two lines including the import) that uses Decimal to print the first 28 digits of pi: Python 2.6.4 (r264:75706, Nov 16 2009, 15:42:08) [GCC 4.0.1 (Apple Inc. build 5490)] on darwin Type "help", "copyright", "credits" or "license" for more information. >

Re: Apple Mac OS X 10.6 support & compatability with Python 3 ?

2009-12-16 Thread Mark Dickinson
rsion from the official download page, though, since Python 3.1.1 was released *before* Snow Leopard was. An easy way to get a working Python 3.1.1 on OS X 10.6 is to install MacPorts and then do a 'sudo port install python31'. I don't know anything about WConio. -- Mark -- http://mail.python.org/mailman/listinfo/python-list

Python training in Florida, January 19-21

2009-12-16 Thread Mark Lutz
lease visit the class web page: http://home.earthlink.net/~python-training/2010-public-classes.html If you are unable to attend in January, our next Sarasota class is already scheduled for April 6-8. Thanks, and we hope to see you at a Python class in sunny and warm Florida soon. --Mark Lutz at P

Re: Which version of MSVC?90.DLL's to distribute with Python 2.6 based Py2exe executables?

2009-12-17 Thread Mark Hammond
is from memory some time back though, so apologies in advance if I'm mis-remembering. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: subprocess.Popen and ordering writes to stdout and stderr

2009-12-17 Thread Mark Hammond
derr, "stderr" -- If you execute it "normally" from a command-prompt, you will see things written in the correct order. If you execute it like 'python foo.py > out 2>&1', the order will be mixed up. If you execute it like 'python -u foo.py > out

Re: Python3.1: gzip encoding with UTF-8 fails

2009-12-20 Thread Mark Tolonen
quot;ä") x.close() The result is: Traceback (most recent call last): File "C:\dev\python3\Lib\site-packages\Pythonwin\pywin\framework\scriptutils.py", line 427, in ImportFile exec(codeObj, __main__.__dict__) File "", line 1, in File "y.py", line 4, in x.write("ä") TypeError: must be bytes or buffer, not str Opening a file in binary mode should require a bytes or buffer object. -Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: C Structure rebuild with ctypes

2009-12-20 Thread Mark Tolonen
* numVars.value)) for value in varNamesArray.contents: print value for value in varTypesArray.contents: print value --- output --- 6 one two three 1 2 3 Hope this helps, -Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: For...in statement and generators

2009-12-21 Thread Mark Tolonen
expressions" in the help. -Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: C Structure rebuild with ctypes

2009-12-21 Thread Mark Tolonen
"Georg" wrote in message news:[email protected]... Hi Mark, many thanks for your help. I tried your code in my program and it worked. I would like to understand what the code is doing and I have some questions to it. Are you passing in these values, or are

Re: C Structure rebuild with ctypes

2009-12-22 Thread Mark Tolonen
"Georg" wrote in message news:[email protected]... Hi Mark, many thanks for your valuable help. # numVars contains size of returned arrays. Recast to access. varNamesArray = c.cast(varNames,c.POINTER(PCHAR * numVars.value)) varTypesArray = c.cast(varTypes,c.P

Re: dict initialization

2009-12-22 Thread Mark Tolonen
rom collections import defaultdict D=defaultdict(list) D[0] [] D[49] [] If the key doesn't exist, it will be initialized by calling the factory function provided in the constructor. -Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: force non-exponential representation for Decimal?

2009-12-23 Thread Mark Dickinson
is a production environment). Hmm. The recipe you cite is probably the easiest option, then. I can't help wondering what you're doing with numbers that small. 2.34e-19 looks an awful lot like 0 for many practical purposes... -- Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: the need for 64 bits

2009-12-28 Thread Mark Dickinson
round 137 billion, on a typical 64-bit machine. Maybe there's a configure option to change this? For Python longs, the number of limbs is stored as a signed size_t type, so on a 64-bit machine memory really is the only limitation. -- Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: socket programming

2009-12-30 Thread Mark Tolonen
using OOPs concepts. Please help. Thankx in advance Zubin Mithra If you're trying to be a server, you need to listen() before accept(), and I wouldn't call the method "connect()". If you're trying to be a client, you can skip the bind() and call connect() ins

Re: Pass multidimensional array (matrix) to c function using ctypes

2010-01-06 Thread Mark Tolonen
"Daniel Platz" wrote in message news:[email protected]... Hello, I would like to pass a two dimensional array to C function in a dll. I use ctypes to call the function. I compile the dll with visual studio 2008 express and my C source code looks

Re: Manipulating pointers in C using ctypes

2010-01-08 Thread Mark Tolonen
quot;New pointer value %f\n", *ptr); } -- OUTPUT - c_double(0.0) Pointer address 00A05DC8 Value at pointer 2.20 Value returned to python: 2.20 Pointer address 00A05DC8 Pointer value 2.20 New pointer value 2.40 Value returned to python: 2.40 - HTH, Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: C Structure rebuild with ctypes

2010-01-08 Thread Mark Tolonen
"Georg" wrote in message news:[email protected]... Hi Mark, Are you passing in these values, or are they being returned? To me the depth of the pointer references implies numVars, varNames, and varTypes are out parameters. I'll assume that for now. If

Re: C Module's '1.#INF' changes to 'inf' at Python

2010-01-09 Thread Mark Dickinson
rmance cost. There are some notes on the (intended) current behaviour at the top of the Modules/ mathmodule.c file: http://svn.python.org/view/*checkout*/python/branches/release26-maint/Modules/mathmodule.c -- Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: How to get many places of pi from Machin's Equation?

2010-01-09 Thread Mark Dickinson
e your own (e.g., based on argument reduction + Taylor series) for use with the decimal module, or you could use one of the various 3rd party arbitrary-precision arithmetic packages that do provide atan. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: How to get many places of pi from Machin's Equation?

2010-01-09 Thread Mark Dickinson
On Jan 9, 11:31 am, "Richard D. Moores" wrote: > Machin's Equation is > > 4 arctan (1/5) - arctan(1/239) = pi/4 > [...] > > Is there a way in Python 3.1 to calculate pi to greater accuracy using > Machin's Equation? Even to an arbitrary number of places? Here's some crude code (no error bounds,

Re: Python and Tkinter Programming by John Grayson

2010-01-14 Thread Mark Roseman
#x27;ttk' themed widgets. I cover these in my tutorial at http://www.tkdocs.com Mark -- http://mail.python.org/mailman/listinfo/python-list

ANN: Shed Skin 0.3

2010-01-15 Thread Mark Dufour
Hi all, I have just released Shed Skin 0.3, an experimental (restricted) Python-to-C++ compiler. Please see my blog for more details about the release: http://shed-skin.blogspot.com/ Thanks, Mark Dufour. -- "Overdesigning is a SIN. It's the archetypal example of what I call

Re: Py 3: How to switch application to Unicode strings?

2010-01-19 Thread Mark Tolonen
at does is mean that the script itself is encoded as utf8. Actually it means that the user has declared that the source file is encoded in utf-8. A common source of errors is that the source file is *not* encoded in utf-8. Make sure to save the source file in the encoding declared. -Mark

Re: Py 3: How to switch application to Unicode strings?

2010-01-19 Thread Mark Tolonen
and one of the strings in the tuple contains a character like 'ñ'. I have a version of the SQLite editor that works as expected in a browser, I don't know why. Post the simplest, complete source code that exhibits the problem. -Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Best way to convert sequence of bytes to long integer

2010-01-20 Thread Mark Dickinson
redits" or "license" for more information. >>> int.from_bytes(b"g%$f yg\n1\05", 'big') 487088900085839492165893 Until then, Peter Otten's solution is about as close as you can get, I think. -- Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Best way to convert sequence of bytes to long integer

2010-01-20 Thread Mark Dickinson
re using this functionality for? When trying to hack out the API for int.to_bytes and int.from_bytes on the mailing list and bug tracker, some of the discussion about use-cases seemed a little too much like guesswork; I'd be curious to find out about real-life use-cases. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: counting lines of code

2010-01-20 Thread Mark Hammond
google and hitting the "I feel lucky" button :) HTH, Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: decimal threading cost?

2010-01-22 Thread Mark Dickinson
of decimal, though it definitely *is* significant for decimal-in-C rewrite that's in the works: it would be interesting to do some timings against a thread-unaware version of decimal.py. -- Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Symbols as parameters?

2010-01-22 Thread Mark Dickinson
Have you considered making 'scope' a context manager? Your modifying-locals hacks could be put into the __enter__ and __exit__ methods, and you'd use the context manager with something like: with scope(): # ... # use up, down, left, right here # up, down, left, right no

Re: enumerated while loop

2010-01-23 Thread Mark Dickinson
On Jan 23, 2:44 pm, Roald de Vries wrote: > I assume a function like 'naturals' already exists, or a similar   > construction for the same purpose. But what is it called? itertools.count() -- Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Need help with a program

2010-01-28 Thread Mark Dickinson
On Jan 28, 3:07 pm, evilweasel wrote: > Hi folks, > > I am a newbie to python, and I would be grateful if someone could > point out the mistake in my program. > for j in range(0, b): >     if lister[j] == 0: At a guess, this line should be: if lister[j] == '0

Re: Got undefined symbol: _PyUnicodeUCS2_AsDefaultEncodedString on OpenSuSE 11.1

2009-09-25 Thread Mark Dickinson
F16). Most Linux distributions, however, distribute a Python that uses UCS4 (aka UTF32) instead, so it seems possible that your setuptools egg is expecting to find a UCS4 build. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Got undefined symbol: _PyUnicodeUCS2_AsDefaultEncodedString on OpenSuSE 11.1

2009-09-25 Thread Mark Dickinson
On Sep 25, 7:56 pm, Mark Dickinson wrote: > On Sep 25, 7:05 pm, Alejandro Valdez > wrote: > > Hello I sent this e-mail to the python-help list but I'm not sure if > > that list is active... so I post it again here: > > > I'm trying to build Python 2.6.2

Re: Got undefined symbol: _PyUnicodeUCS2_AsDefaultEncodedString on OpenSuSE 11.1

2009-09-27 Thread Mark Dickinson
[...] I *think* all of these warnings are benign, though the source should really be corrected if necessary to silence them (some of them, like the _struct.c one, have already been fixed in svn). I'll take a closer look at them, though. Thanks for reporting these! Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: unicode text file

2009-09-27 Thread Mark Tolonen
t codecs f = codecs.open('test.txt','r','utf-8') txt = f.read() txt = txt.replace(u'English', u'ഇംഗ്ലീഷ്') f.close() f = codecs.open('test.txt','w','utf-8') f.write(txt) f.close() -Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: variable scope

2009-09-28 Thread Mark Dickinson
'names in class scope are not accessible' gotcha, described and justified in the 'Discussion' section of PEP 227 http://www.python.org/dev/peps/pep-0227/ and somewhat more briefly in the reference manual: http://docs.python.org/reference/executionmodel.html#naming-and-binding T

Re: variable scope

2009-09-29 Thread Mark Dickinson
On Sep 29, 11:11 am, Bruno Desthuilliers wrote: > Mark Dickinson a écrit : > > On Sep 28, 9:37 am, Bruno Desthuilliers > [email protected]> wrote: > >> Looks like a bug to me. I Think you should fill a ticket... > > > I don't think it&

Re: unicode issue

2009-09-30 Thread Mark Tolonen
;Ά':'A', u'Έ':'E', u'Ί':'I', u'Ό':'O', u'Ύ':'Y', u'Ή':'H', u'Ώ':'W', u'Ϊ':'I', u'Ϋ':'Y', # TURKISH u'ş':'s', u'Ş':'S', u'ı':'i', u'İ':'I', u'ç':'c', u'Ç':'C', u'ü':'u', u'Ü':'U', u'ö':'o', u'Ö':'O', u'ğ':'g', u'Ğ':'G', # RUSSIAN u'а':'a', u'б':'b', u'в':'v', u'г':'g', u'д':'d', u'е':'e', u'ё':'yo', u'ж':'zh', u'з':'z', u'и':'i', u'й':'j', u'к':'k', u'л':'l', u'м':'m', u'н':'n', u'о':'o', u'п':'p', u'р':'r', u'с':'s', u'т':'t', u'у':'u', u'ф':'f', u'х':'h', u'ц':'c', u'ч':'ch', u'ш':'sh', u'щ':'sh', u'ъ':'', u'ы':'y', u'ь':'', u'э':'e', u'ю':'yu', u'я':'ya', u'А':'A', u'Б':'B', u'В':'V', u'Г':'G', u'Д':'D', u'Е':'E', u'Ё':'Yo', u'Ж':'Zh', u'З':'Z', u'И':'I', u'Й':'J', u'К':'K', u'Л':'L', u'М':'M', u'Н':'N', u'О':'O', u'П':'P', u'Р':'R', u'С':'S', u'Т':'T', u'У':'U', u'Ф':'F', u'Х':'H', u'Ц':'C', u'Ч':'Ch', u'Ш':'Sh', u'Щ':'Sh', u'Ъ':'', u'Ы':'Y', u'Ь':'', u'Э':'E', u'Ю':'Yu', u'Я':'Ya', # UKRAINIAN u'Є':'Ye', u'І':'I', u'Ї':'Yi', u'Ґ':'G', u'є':'ye', u'і':'i', u'ї':'yi', u'ґ':'g', # CZECH u'č':'c', u'ď':'d', u'ě':'e', u'ň':'n', u'ř':'r', u'š':'s', u'ť':'t', u'ů':'u', u'ž':'z', u'Č':'C', u'Ď':'D', u'Ě':'E', u'Ň':'N', u'Ř':'R', u'Š':'S', u'Ť':'T', u'Ů':'U', u'Ž':'Z', # POLISH u'ą':'a', u'ć':'c', u'ę':'e', u'ł':'l', u'ń':'n', u'ó':'o', u'ś':'s', u'ź':'z', u'ż':'z', u'Ą':'A', u'Ć':'C', u'Ę':'e', u'Ł':'L', u'Ń':'N', u'Ó':'o', u'Ś':'S', u'Ź':'Z', u'Ż':'Z', # LATVIAN u'ā':'a', u'č':'c', u'ē':'e', u'ģ':'g', u'ī':'i', u'ķ':'k', u'ļ':'l', u'ņ':'n', u'š':'s', u'ū':'u', u'ž':'z', u'Ā':'A', u'Č':'C', u'Ē':'E', u'Ģ':'G', u'Ī':'i', u'Ķ':'k', u'Ļ':'L', u'Ņ':'N', u'Š':'S', u'Ū':'u', u'Ž':'Z' } def downcode(name): """ >>> downcode(u"Žabovitá zmiešaná kaša") u'Zabovita zmiesana kasa' """ for key, value in _MAP.iteritems(): name =ame.replace(key, value) return name Works for me: rrr = downcode(u"Žabovitá zmiešaná kaša") print repr(rrr) print rrr prints out: u'Zabovita zmiesana kasa' Zabovita zmiesana kasa I did have to add an encoding declaration as line 2 of the file: #-*- coding: latin-1 -*- and I had to convince my editor (Komodo) to save the file in utf-8. Why decare latin-1 and save in utf-8? I'm not sure how you got that to work because those encodings aren't equivalent. I get: Traceback (most recent call last): File "", line 1, in File "testit.py", line 1 SyntaxError: encoding problem: utf-8 In fact, some of the characters in the above code don't map to latin-1. Traceback (most recent call last): File "", line 1, in UnicodeEncodeError: 'latin-1' codec can't encode character u'\u0150' in position 309: ordinal not in range(256) import unicodedata as ud ud.name(u'\u0150') -Mark -- http://mail.python.org/mailman/listinfo/python-list

New Book: Programming in Python 3 (Second Edition)

2009-10-01 Thread Mark Summerfield
Hi, A new edition of my Python 3 book will be available in the U.S. next month, and elsewhere in December or January: "Programming in Python 3 (Second Edition): A Complete Introduction to the Python Language" ISBN 0321680561 http://www.qtrac.eu/py3book.html The book is aimed at a wide audience,

Re: int rich comparisons

2009-10-02 Thread Mark Dickinson
when you do: >>> int > float True You get similar results with __call__: >>> int.__call__ >>> int.__call__(3) 3 >>> (5).__call__ Traceback (most recent call last): File "", line 1, in AttributeError: 'int' object has no attribute '__call__' Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Fast decimal arithmetic module released

2009-10-02 Thread Mark Dickinson
On Oct 2, 8:53 pm, Stefan Krah wrote: > Hi, > > today I have released the following packages for fast arbitrary precision > decimal arithmetic: > [...] Nice! I'd been wondering how you'd been finding all those decimal.py bugs. Now I know. :) -- Mark -- http:

Re: Delete all list entries of length unknown

2009-10-04 Thread Mark Tolonen
needed to disambiguate from other uses of comma: Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. a=1, a (1,) a=1,2,3 a (1, 2, 3) -Mark -- http://mail.python.org/mailman/listinfo/python-list

extract oracle-BLOBs to the file system (9.2.0.7): some docs not readable

2009-10-08 Thread Mark Dellon
.read() #this is type str f = open ("c:\\tmp\\test.pdf","wb" ) f.write(aLobData) f.close() Thank you very much for every idea. Best regards Mark -- GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT! Jetzt freischalte

<    43   44   45   46   47   48   49   50   51   52   >