Re: Least-lossy string.encode to us-ascii?

2012-09-13 Thread Mark Tolonen
On Thursday, September 13, 2012 4:53:13 PM UTC-7, Tim Chase wrote: > On 09/13/12 18:36, Terry Reedy wrote: > > > On 9/13/2012 5:26 PM, Tim Chase wrote: > > >> I've got a bunch of text in Portuguese and to transmit them, need to > > >> have them in us-ascii (7-bit). I'd like to keep as much info

Re: sys.stdout.detach() results in ValueError

2012-03-07 Thread Mark Tolonen
On Mar 7, 4:10 pm, Terry Reedy wrote: > On 3/7/2012 5:35 PM, Peter Kleiweg wrote: > > > > > > > > > > > Dave Angel schreef op de 7e dag van de lentemaand van het jaar 2012: > > >> On 03/07/2012 02:41 PM, Peter Kleiweg wrote: > >>> I want to write out some binary data to stdout in Python3. I > >>>

Re: What I do and do not know about installing Python on Win 7 with regard to IDLE.

2011-11-25 Thread Mark Tolonen
On Nov 25, 11:52 am, Sibylle Koczian wrote: > Am 25.11.2011 01:16, schrieb Steven D'Aprano: > > > As far as I can tell, nobody running the 64-bit version of Windows 7 has > > chimed in to either confirm or refute W. eWatson's claim that IDLE > > doesn't show up, so we have no way of telling whethe

Re: the stupid encoding problem to stdout

2011-06-09 Thread Mark Tolonen
"Sérgio Monteiro Basto" wrote in message news:4df137a7$0$30580$a729d...@news.telepac.pt... How I change sys.stdout.encoding always to UTF-8 ? at least have a consistent sys.stdout.encoding There is an environment variable that can force Python I/O to be a specfic encoding: PYTHONIOEN

Re: string u'hyv\xe4' to file as 'hyvä'

2010-12-26 Thread Mark Tolonen
"gintare" wrote in message news:83dc3076-9ddc-42bd-8c33-6af96b263...@l32g2000yqc.googlegroups.com... Hello, STILL do not work. WHAT to be done. import codecs item=u'hyv\xe4' F=codecs.open('/opt/finnish.txt', 'w+', 'utf8') F.writelines(item.encode('utf8')) F.close() In file i find 'hyv\xe4' i

Re: ctypes question

2010-12-14 Thread Mark Tolonen
"News Wombat" wrote in message news:413f5a8f-69a0-4351-acc2-18d7edda8...@j3g2000vbp.googlegroups.com... On Dec 11, 12:59 pm, MrJean1 wrote: > In general, for shared libraries, you need to define those first as > prototype using ctypes.CFUNCTYPE() and then instantiate each prototype > once supp

Re: ctypes question

2010-12-10 Thread Mark Tolonen
"News Wombat" wrote in message news:2abdd9b3-66ec-4125-a5f8-41315008c...@l17g2000yqe.googlegroups.com... Hi everyone, I've been experimenting with the ctypes module and think it's great. I'm hitting a few snags though with seg faults. I attached two links that holds the code. The line i'm h

Re: How to display unicode char in Windows

2010-10-15 Thread Mark Tolonen
"hiral" wrote in message news:90b62600-a0a4-47d5-bb6f-a3ae14cf6...@9g2000prn.googlegroups.com... Hi, I tried... # coding: latin-1 print "**" oo = "ö" print "char=<%s>" % oo print "

Re: utf-8 and ctypes

2010-09-29 Thread Mark Tolonen
"Brendan Miller" wrote in message news:aanlkti=2f3l++398st-16mpes8wzfblbu+qa8ztpa...@mail.gmail.com... 2010/9/29 Lawrence D'Oliveiro : In message , Brendan Miller wrote: It seems that characters not in the ascii subset of UTF-8 are discarded by c_char_p during the conversion ... Not a ch

Re: How Python works: What do you know about support for negativeindices?

2010-09-09 Thread Mark Tolonen
"Ben Finney" wrote in message news:874ody9w3v@benfinney.id.au... Raymond Hettinger writes: It doesn't seem to be common knowledge when and how a[x] gets translated to a[x+len(x)]. So, here's a short info post on how Python supports negative indices for sequences. Thanks for this. Cou

Re: Fibonacci: How to think recursively

2010-08-28 Thread Mark Tolonen
"Steven D'Aprano" wrote in message news:4c79c510$0$28655$c3e8...@news.astraweb.com... On Sat, 28 Aug 2010 16:12:36 -0700, Baba wrote: There are other techniques, but this will do to get started. Once you realize recursion for Fibonacci numbers is still fairly slow, look up generator func

Re: Proper set-up for a co-existant python 2.6 & 3.1 installation

2010-08-25 Thread Mark Tolonen
"vsoler" wrote in message news:3d85d8f5-8ce0-470f-b6ec-c86c452a3...@a36g2000yqc.googlegroups.com... On Aug 24, 1:33 am, "Martin v. Loewis" wrote: > > When I am logged-in in a session as an administrator, the BAT file on > > the Desktop, and I double-click on it, it does not work. > > This is no

Re: Trying to run Python 2.7 on Windows 7 and any suggestions onbooks/websites for "dummies guide to python" type learning

2010-08-02 Thread Mark Tolonen
"ben owen" wrote in message news:snt124-w51cdf963a687dd653cc804cc...@phx.gbl... Hi everyone, I'm new to this and was needing help with trying to learn/work with Python 2.7 on my computer. I'm running Windows 7 and trying to learn python programming from an older book from 1999 by Mark Lutz

Re: Call CFUNCTYPE, class Structure, ctype, dll and Callback function problem

2010-07-31 Thread Mark Tolonen
"legard_new" wrote in message news:70faf0b4-fead-49ac-bf18-e182fd63b...@j8g2000yqd.googlegroups.com... Hello, I have a problem with calling Callback function with Python. I have a DLL file. Below is a description in documentation. FUNCTION Callback Arguments: Callback ID integer read-only, i

Re: Ascii to Unicode.

2010-07-29 Thread Mark Tolonen
"Joe Goldthwaite" wrote in message news:5a04846ed83745a8a99a944793792...@newmbp... Hi Steven, I read through the article you referenced. I understand Unicode better now. I wasn't completely ignorant of the subject. My confusion is more about how Python is handling Unicode than Unicode its

Re: string manipulation.

2010-07-27 Thread Mark Tolonen
"gerardob" wrote in message news:29276755.p...@talk.nabble.com... I am trying to read an xml using minidom from python library xml.dom This is the xml file: - AB 100 2 -- This is the python code:

Re: Reversing backslashed escape sequences

2010-06-30 Thread Mark Tolonen
"Steven D'Aprano" wrote in message news:4c2c2cab$0$14136$c3e8...@news.astraweb.com... I have a byte-string which is an escape sequence, that is, it starts with a backslash, followed by either a single character, a hex or octal escape sequence. E.g. something like one of these in Python 2.5: '

Re: Puzzled by code pages

2010-05-15 Thread Mark Tolonen
"Adam Tauno Williams" wrote in message news:1273932760.3929.18.ca...@linux-yu4c.site... On Sat, 2010-05-15 at 20:30 +1000, Lie Ryan wrote: On 05/15/10 10:27, Adam Tauno Williams wrote: [snip] Yep. But in the interpreter both unicode() and repr() produce the same output. Nothing displays

Re: matching strings in a large set of strings

2010-04-29 Thread Mark Tolonen
"Karin Lagesen" wrote in message news:416f727c6f5b0edb932b425db9579808.squir...@webmail.uio.no... Hello. I have approx 83 million strings, all 14 characters long. I need to be able to take another string and find out whether this one is present within the 83 million strings. Now, I have trie

Re: ctypes return char array with null chars

2010-04-19 Thread Mark Tolonen
"chris cannady" wrote in message news:b103e85a-05d5-4195-a18f-bd143e9f5...@b33g2000yqc.googlegroups.com... Hi all, I am passing a ctypes struct byref to a dll. When I get the struct back, it looks like the char array in the struct was truncated at the first null char. It should be 192 bytes l

Re: Python Line Intersection

2010-04-09 Thread Mark Tolonen
"Chris Rebert" wrote in message news:y2o50697b2c1004091304u627d99bfj44ad56fa76a3c...@mail.gmail.com... On Fri, Apr 9, 2010 at 11:43 AM, John Nagle wrote: Chris Rebert wrote: On Fri, Apr 9, 2010 at 8:04 AM, Peyman Askari wrote: Hello This is partly Python related, although it might end

Re: WinXP, Python3.1.2, dir-listing to XML - problem with unicode file names

2010-04-03 Thread Mark Tolonen
"kai_nerda" wrote in message news:hp69ri+a...@egroups.com... Hi, OS = Windows XP (German language) Python = 3.1.2 I need to write a directory listing into a XML file. And after hours of trying and searching i have no clue. My main problem is that the file and folder names can have characters

Re: Python unicode and Windows cmd.exe

2010-03-14 Thread Mark Tolonen
"Terry Reedy" wrote in message news:hnjkuo$n1...@dough.gmane.org... On 3/14/2010 4:40 PM, Guillermo wrote: Adding the byte that some call a 'utf-8 bom' makes the file an invalid utf-8 file. Not true. From http://unicode.org/faq/utf_bom.html: Q: When a BOM is used, is it only in 16-bit Uni

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

2010-01-19 Thread Mark Tolonen
"Gnarlodious" wrote in message news:646ab38b-0710-4d31-b9e1-8a6ee7bfa...@21g2000yqj.googlegroups.com... Well, Python 3 is supposed to be all Unicode by default. I shouldn't even need to say # coding:UTF-8 Yes, in Python 3, an absence of a 'coding' line assumes UTF-8. And, the file is saved

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

2010-01-19 Thread Mark Tolonen
"Stephen Hansen" wrote in message news:7a9c25c21001191156j46a7fdadt58b728477b85e...@mail.gmail.com... On Tue, Jan 19, 2010 at 7:50 AM, Gnarlodious wrote: I am using Python 3, getting an error from SQLite: sqlite3.ProgrammingError: You must not use 8-bit bytestrings unless you use a text_f

Re: C Structure rebuild with ctypes

2010-01-08 Thread Mark Tolonen
"Georg" wrote in message news:7qo9avfiv...@mid.individual.net... 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 they are in/out parame

Re: Manipulating pointers in C using ctypes

2010-01-08 Thread Mark Tolonen
"Daniel Platz" wrote in message news:08bda34e-9bee-44b1-b2de-80d647151...@a15g2000yqm.googlegroups.com... Hello! I have to ask a newbie question about manipulating pointers in C using ctypes. I have a C dll with two functions. The first one creates a pointer and returns it to python. The seco

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

2010-01-06 Thread Mark Tolonen
"Daniel Platz" wrote in message news:63ac1a01-8491-4885-bae7-cb884abb5...@34g2000yqp.googlegroups.com... 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: socket programming

2009-12-30 Thread Mark Tolonen
"Zubin Mithra" wrote in message news:8e7c74320912300315r625f4c89kb8002e4b8c384...@mail.gmail.com... The code snippet i have pasted at, http://paste.pocoo.org/show/160555/ produces a traceback which also has been pasted at the above link. The snippet attempts at socket programming using OOPs

Re: dict initialization

2009-12-22 Thread Mark Tolonen
"mattia" wrote in message news:4b313b3a$0$1135$4fafb...@reader1.news.tin.it... Is there a function to initialize a dictionary? Right now I'm using: d = {x+1:[] for x in range(50)} Is there any better solution? Depending on your use case, a defaultdict might suite you: from collections impo

Re: C Structure rebuild with ctypes

2009-12-22 Thread Mark Tolonen
"Georg" wrote in message news:7pb8ubfll...@mid.individual.net... 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.POINTER(INT * numV

Re: C Structure rebuild with ctypes

2009-12-21 Thread Mark Tolonen
"Georg" wrote in message news:7padi2fsm...@mid.individual.net... 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 they being returne

Re: For...in statement and generators

2009-12-21 Thread Mark Tolonen
"Lucas Prado Melo" wrote in message news:9f4be2240912210639g58da0549jb0c81450947ef...@mail.gmail.com... Is there a way to send() information back to a generator while using the for...in statement? Thanks in advance. Yes, see "send(), (generator method)" or "yield expressions" in the help.

Re: C Structure rebuild with ctypes

2009-12-20 Thread Mark Tolonen
"Georg" wrote in message news:7p6ksnfkg...@mid.individual.net... Hi All, I need to use a library written in C. The routine "int func (int handle, int *numVars, char ***varNames, int **varTypes)" expects a complex object: " ... Variable names are structured as an array of *numVars pointer

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

2009-12-20 Thread Mark Tolonen
"Diez B. Roggisch" wrote in message news:7p7328f3r1r2...@mid.uni-berlin.de... Johannes Bauer schrieb: > Hello group, > > with this following program: > > #!/usr/bin/python3 > import gzip > x = gzip.open("testdatei", "wb") > x.write("ä") > x.close() > > I get a broken .gzip file when decompressin

Re: Regexp and multiple groups (with repeats)

2009-11-20 Thread Mark Tolonen
"mk" wrote in message news:he60ha$iv...@ger.gmane.org... Hello, >>> r=re.compile(r'(?:[a-zA-Z]:)([\\/]\w+)+') >>> r.search(r'c:/tmp/spam/eggs').groups() ('/eggs',) Obviously, I would like to capture all groups: ('/tmp', '/spam', '/eggs') But it seems that re captures only the last group. Is

Re: Calling Python functions from Excel

2009-11-17 Thread Mark Tolonen
"Chris Withers" wrote in message news:4b02d1e3.6080...@simplistix.co.uk... Mark Tolonen wrote: Please I need Calling Python functions from Excel and receive result back in Excel. Can me somebody advise simplest solution please? I am more VBA programmer than Python.

Re: Calling Python functions from Excel

2009-11-17 Thread Mark Tolonen
"Chris Withers" wrote in message news:4b028ac1.8020...@simplistix.co.uk... Cannonbiker wrote: Hi, unfortunately is my question about server COM (win32com) http://groups.google.com/group/comp.lang.python/browse_thread/thread/ee804cec7f58c6a7# without answer. Please I need Calling Python funct

Re: Run a external program.

2009-11-14 Thread Mark Tolonen
"Yasser Almeida Hernández" wrote in message news:20091114142611.sj45qput2c84s...@correo.fenhi.uh.cu... Hi all!! I'm writing a script where i call a external program which receive some arguments. One of this arguments is stored in a variable, that is passed as argument as well: import os

Re: the unicode saga continues...

2009-11-13 Thread Mark Tolonen
"Ethan Furman" wrote in message news:4afe4141.4020...@stoneleaf.us... So I've added unicode support to my dbf package, but I also have some rather large programs that aren't ready to make the switch over yet. So as a workaround I added a (rather lame) option to convert the unicode-ified dat

Re: Command parsing... best module to use?

2009-11-02 Thread Mark Tolonen
"Collin D" wrote in message news:94dbc92b-0682-4995-b358-0c615c95a...@x6g2000prc.googlegroups.com... Hey everyone. I am writing a game in python, and it includes a text console somewhat like the one in WoW and Runescape. I want to be able to include "/" commands, like IRC, and was wondering w

Re: Python 3.1.1 bytes decode with replace bug

2009-10-25 Thread Mark Tolonen
"Dave Angel" wrote in message news:4ae43150.9010...@ieee.org... Joe wrote: For the reason BK explained, the important difference is that I ran in the IDLE shell, which handles screen printing of unicode better ;-) Something still does not seem right here to me. In the example above the by

Re: Struct on on x86_64 mac os x

2009-10-21 Thread Mark Tolonen
"Tommy Grav" wrote in message news:d705ab12-0bee-495a-b1e5-c43245e40...@pha.jhu.edu... I have created a binary file that saves this struct from some C code: struct recOneData { char label[3][84]; char constName[400][6]; double timeData[3]; long int numConst;

Re: a simple unicode question

2009-10-20 Thread Mark Tolonen
;\N{DEGREE SIGN}') defined? I found http://www.unicode.org/Public/5.1.0/ucd/UnicodeData.txt Is that the place to look? George Scott David Daniels wrote: Mark Tolonen wrote: Is there a better way of getting the degrees? It seems your string is UTF-8. \xc2\xb0 is UTF-8 for DEGREE SIGN. If

Re: a simple unicode question

2009-10-19 Thread Mark Tolonen
"George Trojan" wrote in message news:hbidd7$i9...@news.nems.noaa.gov... A trivial one, this is the first time I have to deal with Unicode. I am trying to parse a string s='''48° 13' 16.80" N'''. I know the charset is "iso-8859-1". To get the degrees I did >>> encoding='iso-8859-1' >>> q=s

Re: a simple unicode question

2009-10-19 Thread Mark Tolonen
"George Trojan" wrote in message news:hbidd7$i9...@news.nems.noaa.gov... A trivial one, this is the first time I have to deal with Unicode. I am trying to parse a string s='''48° 13' 16.80" N'''. I know the charset is "iso-8859-1". To get the degrees I did >>> encoding='iso-8859-1' >>> q=s

Re: Tracking down DLL load errors in Windows ?

2009-10-18 Thread Mark Tolonen
"Fred Pacquier" wrote in message news:xns9ca8b91a1519apacmanr...@212.27.60.38... After installing the MS redistributable DLL package -- actually I had to install *three* before hitting the right one (2005SP1) -- libpyexiv2 finally loads all its dependencies. Of course I've still no idea why/

Re: print()

2009-10-17 Thread Mark Tolonen
"Terry Reedy" wrote in message news:hbdh51$g0...@ger.gmane.org... Gabriel Genellina wrote: Presumably he's using Python 3: And apparently not IDLE Python 3.1.1 (r311:74483, Aug 17 2009, 17:02:12) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for m

Re: umlauts

2009-10-17 Thread Mark Tolonen
"Diez B. Roggisch" wrote in message news:7jub5rf37div...@mid.uni-berlin.de... [snip] This is wierd. I looked at the site in FireFox - and it was displayed correctly, including umlauts. Bringing up the info-dialog claims the page is UTF-8, the XML itself says so as well (implicit, through the

Re: how to write a unicode string to a file ?

2009-10-17 Thread Mark Tolonen
"Mark Tolonen" wrote in message news:hbbo6d$6u...@ger.gmane.org... "Kee Nethery" wrote in message news:aaab63c6-6e44-4c07-b119-972d4f49e...@kagi.com... On Oct 16, 2009, at 5:49 PM, Stephen Hansen wrote: On Fri, Oct 16, 2009 at 5:07 PM, Stef Mientki wrote: snip

Re: py2exe and croatian letters

2009-10-17 Thread Mark Tolonen
"Samir aluko...@work" wrote in message news:ab6475d0-133c-478d-8f08-eafea0733...@j39g2000yqh.googlegroups.com... I am making a simple program in Croatian. In the beginning I set "# - *- coding: cp1250 -*-" code and when i run it in Python shell it comes out fine, but when i compile it with py2

Re: Tracking down DLL load errors in Windows ?

2009-10-16 Thread Mark Tolonen
"Fred P" wrote in message news:xns9ca5e52bec783pacmanr...@212.27.60.39... Hi, a bit of platform-specific advice sought here... I'm trying to diagnose one of those mysteries Windows is so fond of... Say that I have code that imports some binary Python module from site- packages (in this case,

Re: how to write a unicode string to a file ?

2009-10-16 Thread Mark Tolonen
"Kee Nethery" wrote in message news:aaab63c6-6e44-4c07-b119-972d4f49e...@kagi.com... On Oct 16, 2009, at 5:49 PM, Stephen Hansen wrote: On Fri, Oct 16, 2009 at 5:07 PM, Stef Mientki wrote: snip The thing is, I'd be VERY surprised (neigh, shocked!) if Excel can't open a file that is in

Re: unicode-to-ascii: replace with space, not "?"

2009-10-14 Thread Mark Tolonen
"Allen Fowler" wrote in message news:59796.73163...@web45608.mail.sp1.yahoo.com... Hello, I've been using "data.encode('ascii','replace')" to force an ASCII string out of Unicode data, with "?" in the place of non-ASCII letters. However, now I want to use a blank space (or maybe a dash) in

Re: Delete all list entries of length unknown

2009-10-04 Thread Mark Tolonen
"Chris Rebert" wrote in message news:50697b2c0910042047i1cf2c1a3mc388bc74bab95...@mail.gmail.com... Tuples are immutable (i.e. they cannot be modified after creation) and are created using parentheses. Slight correction: tuples are created using commas. Parentheses are only needed to disam

Re: unicode issue

2009-09-30 Thread Mark Tolonen
"Dave Angel" wrote in message news:4ac328d4.3060...@dejaviewphoto.com... gentlestone wrote: Why don't work this code on Python 2.6? Or how can I do this job? _MAP = # LATIN u'À': 'A', u'Á': 'A', u'Â': 'A', u'Ã': 'A', u'Ä': 'A', u'Å': 'A', u'Æ': 'AE', u'Ç':'C', u'È': 'E', u'É': 'E

Re: unicode text file

2009-09-27 Thread Mark Tolonen
"Junaid" wrote in message news:0267bef9-9548-4c43-bcdf-b624350c8...@p23g2000vbl.googlegroups.com... I want to do replacements in a utf-8 text file. example f=open("test.txt","r") #this file is uft-8 encoded raw = f.read() txt = raw.decode("utf-8") You can use the codecs module to open and d

Re: Format string with single quotes in it

2009-09-25 Thread Mark Tolonen
"Bahadir" wrote in message news:65b6ce03-62c7-4e56-a746-d85ce87ad...@l31g2000vbp.googlegroups.com... Hi there, My question is simple, but I've been spending some hours over the web and still struggling to get this right: How do I format a string that contains single quotes in it? I am readin

Re: Can print() be reloaded for a user defined class?

2009-09-19 Thread Mark Tolonen
"r" wrote in message news:c87c1742-e185-4377-a3ae-b32b912bc...@33g2000vbe.googlegroups.com... On Sep 19, 9:53 pm, Peng Yu wrote: (snip) > I want to understand the exact meaning of the last line ('__repr__ = > __str__'). Would you please point me to the section of the python > manual that de

Re: (A Possible Solution) Re: preferred way to set encoding for print

2009-09-16 Thread Mark Tolonen
"~flow" wrote in message news:643ca91c-b81c-483c-a8af-65c93b593...@r33g2000vbp.googlegroups.com... On Sep 16, 7:16 am, "Mark Tolonen" wrote: Setting PYTHONIOENCODING overrides the encoding used for stdin/stdout/stderr (See the Python help for details), but if your term

Re: preferred way to set encoding for print

2009-09-15 Thread Mark Tolonen
"_wolf" wrote in message news:22991c72-d00f-45cd-9bf7-0b80fc431...@k26g2000vbp.googlegroups.com... hi folks, i am doing my first steps in the wonderful world of python 3. some things are good. some things have to be relearned. some things drive me crazy. sadly, i'm working on a windows box.

Re: python 3.1 unicode question

2009-09-15 Thread Mark Tolonen
"jeffunit" wrote in message news:20090915144123964.ljka6...@cdptpa-omta01.mail.rr.com... I wrote a program that diffs files and prints out matching file names. I will be executing the output with sh, to delete select files. Most of the files names are plain ascii, but about 10% of them have un

Re: Question regarding handling of Unicode data in Devnagari

2009-09-12 Thread Mark Tolonen
"joy99" wrote in message news:fade868b-6a69-4b74-a8e8-9c28a1617...@p10g2000prm.googlegroups.com... Dear Group, As per the standard posted by the UNICODE for the Devnagari script used for Hindi and some other languages of India, we have a standard set, like from the range of 0900-097F. Where,

Re: Programming ideas?

2009-09-12 Thread Mark Tolonen
"Someone Something" wrote in message news:e196a4050909120713m76592252r9e89fb24fdaae...@mail.gmail.com... I know you've probably had this question a million and one times but here it is again. I'm intermediate at C, pretty good at Java (though I really don't want to program in this), okay at p

Re: PyWin editor modification

2009-09-12 Thread Mark Tolonen
"C or L Smith" wrote in message news:0bfe194edbb6410cb3b319cdda601...@kisc.edu.np... The PyWin editor that comes with the Windows distribution is a great little workhorse. If you have used it you perhaps notice how it intelligently works with spaces and indentation, e.g. after typing the wor

Re: Extracting patterns after matching a regex

2009-09-08 Thread Mark Tolonen
"Martin" wrote in message news:5941d8f1-27c0-47d9-8221-d21f07200...@j39g2000yqh.googlegroups.com... Hi, I need to extract a string after a matching a regular expression. For example I have the string... s = "FTPHOST: e4ftl01u.ecs.nasa.gov" and once I match "FTPHOST" I would like to extract

Re: unicode + xml

2009-09-07 Thread Mark Tolonen
"Laurent Luce" wrote in message news:255473.44957...@web54203.mail.re2.yahoo.com... Hello, I am trying to do the following: - read list of folders in a specific directory: os.listdir() - some folders have Japanese characters - post list of folders as xml to a web server: I used content-type

Re: Something confusing about non-greedy reg exp match

2009-09-06 Thread Mark Tolonen
wrote in message news:f98a6057-c35f-4843-9efb-7f36b05b6...@g19g2000yqo.googlegroups.com... If I do this: import re a=re.search(r'hello.*?money', 'hello how are you hello funny money') I would expect a.group(0) to be "hello funny money", since .*? is a non-greedy match. But instead, I get th

Re: print() a list

2009-09-04 Thread Mark Tolonen
"DarkBlue" wrote in message news:b9c0c4ac-5f8f-4133-b928-9e55ab4b2...@x5g2000prf.googlegroups.com... I am trying to get used to the new print() syntax prior to installing python 3.1: test=[["VG", "Virgin Islands, British"],["VI", "Virgin Islands, U.S."], ["WF", "Wallis and Futuna"],["EH", "We

Re: print() a list

2009-09-04 Thread Mark Tolonen
"DarkBlue" wrote in message news:b9c0c4ac-5f8f-4133-b928-9e55ab4b2...@x5g2000prf.googlegroups.com... I am trying to get used to the new print() syntax prior to installing python 3.1: test=[["VG", "Virgin Islands, British"],["VI", "Virgin Islands, U.S."], ["WF", "Wallis and Futuna"],["EH", "We

Re: break unichr instead of fix ord?

2009-08-25 Thread Mark Tolonen
wrote in message news:2ad21a79-4a6c-42a7-8923-beb304bb5...@v20g2000yqm.googlegroups.com... In Python 2.5 on Windows I could do [*1]: # Create a unicode character outside of the BMP. >>> a = u'\U00010040' # On Windows it is represented as a surogate pair. >>> len(a) 2 >>> a[0],a[1] (u'

Re: Division and right shift in python

2009-08-25 Thread Mark Tolonen
"Cevahir Demirkiran" wrote in message news:3f74e020908251648k7b391a09g78b155507b2f2...@mail.gmail.com... Hi, I would like to do a floor division by a power of 2 in python to make it faster than / (modular division in 2.x). However, it is slower. What is the reason of that? I checked them via:

Re: Converting DD MM YYYY into YYYY-MM-DD?

2009-08-19 Thread Mark Tolonen
"Gilles Ganault" wrote in message news:rtqk859vm3rkdfor0gd2u2pq5sftl8m...@4ax.com... I find it odd that the regex library can't handle European characters It can. Read the documentation about the re.LOCALE flag. -Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Read C++ enum in python

2009-08-19 Thread Mark Tolonen
"Mark Tolonen" wrote in message news:h6g9ig$vh...@ger.gmane.org... [snip] This is what 3rd party library pyparsing is great for: begin code-- from pyparsing import * # sample string with enums and other stuff sample = ''' stuff before

Re: Read C++ enum in python

2009-08-19 Thread Mark Tolonen
"MRAB" wrote in message news:4a8b3e2d.7040...@mrabarnett.plus.com... Ludo wrote: Hello, I work in a very large project where we have C++ packages and pieces of python code. I've been googleing for days but what I find seems really too complicated for what I want to do. My business is,

Re: Splitting a string into substrings of equal size

2009-08-15 Thread Mark Tolonen
"Gregor Lingl" wrote in message news:4a87036a$0$2292$91cee...@newsreader02.highway.telekom.at... Emile van Sebille schrieb: On 8/14/2009 5:22 PM candide said... ... What is the pythonic way to do this ? I like list comps... >>> jj = '1234567890123456789' >>> ",".join([jj[ii:ii+3] for i

Re: socket send

2009-07-30 Thread Mark Tolonen
"NighterNet" wrote in message news:55aba832-df6d-455f-bf34-04d37eb06...@i4g2000prm.googlegroups.com... I am trying to figure out how to send text or byte in python 3.1. I am trying to send data to flash socket to get there. I am not sure how to work it. buff= 'id=' , self.id , ':balive=False\

Re: getting rid of —

2009-07-03 Thread Mark Tolonen
"Tep" wrote in message news:46d36544-1ea2-4391-8922-11b8127a2...@o6g2000yqj.googlegroups.com... On 3 Jul., 06:40, Simon Forman wrote: > On Jul 2, 4:31 am, Tep wrote: [snip] > > > > > how can I replace '—' sign from string? Or do split at that > > > > > character? > > > > > Getting unicode

Re: os.walk and os.listdir problems python 3.0+

2009-06-24 Thread Mark Tolonen
"Amos Anderson" wrote in message news:a073a9cf0906242007k5067314dn8e9d7b1c6da62...@mail.gmail.com... I've run into a bit of an issue iterating through files in python 3.0 and 3.1rc2. When it comes to a files with '\u200b' in the file name it gives the error... Traceback (most recent call la

Re: UnicodeDecodeError: problem when path contain folder startwithcharacter 'u

2009-06-23 Thread Mark Tolonen
"aberry" wrote in message news:24164207.p...@talk.nabble.com... Mark Tolonen-3 wrote: "aberry" wrote in message news:24146775.p...@talk.nabble.com... I am facing an error on Unicode decoding of path if it contain a folder/file name starting with character 'u'

Re: UnicodeDecodeError: problem when path contain folder start withcharacter 'u

2009-06-22 Thread Mark Tolonen
"aberry" wrote in message news:24146775.p...@talk.nabble.com... I am facing an error on Unicode decoding of path if it contain a folder/file name starting with character 'u' . Here is what I did in IDLE 1. >>> fp = "C:\\ab\\anil" 2. >>> unicode(fp, "unicode_escape") 3. u'C:\x07b\x07nil' 4.

Re: Specify the sorting direction for the various columns/

2009-06-11 Thread Mark Tolonen
"Oni" wrote in message news:018f4fa2-7203-4c98-a313-da5584976...@z20g2000prh.googlegroups.com... Managed to get a dictionary to sort on multiple columns using a tuple to set the sort order (see below). However how can I control that column "date" orders descending and the column "name" orders

Re: Need help in Python regular expression

2009-06-11 Thread Mark Tolonen
"meryl" wrote in message news:2d4d8624-043b-4f5f-ae2d-bf73bca3d...@p6g2000pre.googlegroups.com... Hi, I have this regular expression blockRE = re.compile(".*RenderBlock {\w+}") it works if my source is "RenderBlock {CENTER}". But I want it to work with 1. RenderTable {TABLE} So i change the

Re: how to transfer my utf8 code saved in a file to gbk code

2009-06-07 Thread Mark Tolonen
"higer" wrote in message news:0c786326-1651-42c8-ba39-4679f3558...@r13g2000vbr.googlegroups.com... On Jun 7, 11:25 pm, John Machin wrote: On Jun 7, 10:55 pm, higer wrote: > My file contains such strings : > \xe6\x97\xa5\xe6\x9c\x9f\xef\xbc\x9a Are you sure? Does that occupy 9 bytes in

Re: import sqlite3

2009-06-04 Thread Mark Tolonen
"willgun" wrote in message news:h08c5e$au...@news.cn99.com... By the way ,what does 'best regards' means at the end of a mail? I think 恭祝 may be a good translation. -Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: unicode bit me

2009-05-09 Thread Mark Tolonen
"Piet van Oostrum" wrote in message news:m263gagjjl@cs.uu.nl... "Mark Tolonen" (MT) wrote: MT> wrote in message MT> news:994147fb-cdf3-4c55-8dc5-62d769b12...@u9g2000pre.googlegroups.com... Sorry being unclear again, hmm I am becoming an expert in

Re: unicode bit me

2009-05-09 Thread Mark Tolonen
wrote in message news:994147fb-cdf3-4c55-8dc5-62d769b12...@u9g2000pre.googlegroups.com... Sorry being unclear again, hmm I am becoming an expert in it. I pasted that code as continuation of my old code at start i.e class A(object): def __unicode__(self): return u"©au" def _

Re: Question of UTF16BE encoding / decoding

2009-05-04 Thread Mark Tolonen
"Napalmski" wrote in message news:mpg.2469d7edf8bbcd0a989...@eu.news.astraweb.com... Hello, I have an encoded string in the form "004e006100700061006c006d", if you split on every 4 characters it decodes to a single character. I have come up with this: name = '004e006100700061006c006d' name2

Re: iterate to make multiple variables?

2009-04-19 Thread Mark Tolonen
"Tairic" wrote in message news:95ea7bdf-2ae8-4e5e-a613-37169bb36...@w35g2000prg.googlegroups.com... Hi, I'm somewhat new to programming and especially to python. Today I was attempting to make a sudoku-solver, and I wanted to put numbers into sets call box1, box2, ... box9, so that I could che

Re: How to access C structures

2009-04-16 Thread Mark Tolonen
"Chris Helck" wrote in message news:6db873c2999f7547ad0d1c0e6f0c89d704285...@uspsexchs1.us.icap.com... I have a couple dozen C structures that define binary file records. I need to read the file and access the records. I need to do this very efficiantly. I am aware of the Python struct class,

Re: Regex similar to "^(?u)\w$", but without digits?

2009-04-12 Thread Mark Tolonen
"Andreas Pfrengle" wrote in message news:26d3bec3-8329-4432-a680-05c17f930...@3g2000yqk.googlegroups.com... On 12 Apr., 02:31, "Mark Tolonen" wrote: "Andreas" wrote in message news:f953c845-3660-4bb5-8ba7-00b93989c...@b1g2000vbc.googlegroups.com... > Hel

Re: regex for multiple whitespace-only lines

2009-04-12 Thread Mark Tolonen
"Phil Mayes" wrote in message news:5.2.1.1.0.20090412194731.013d0...@olivebr.com... I am trying to search for 1 or more empty or white-space-only lines. Empty lines work: >>> re.compile('(?m)(^$){1,2}') <_sre.SRE_Pattern object at 0x010F9218> One line with possible whitespace works: >>> re.co

Re: Regex similar to "^(?u)\w$", but without digits?

2009-04-11 Thread Mark Tolonen
"Andreas" wrote in message news:f953c845-3660-4bb5-8ba7-00b93989c...@b1g2000vbc.googlegroups.com... > Hello, > > I'd like to create a regex that captures any unicode character, but > not the underscore and the digits 0-9. "^(?u)\w$" captures them also. > Is there a possibility to restrict an exp

Re: Generators/iterators, Pythonicity, and primes

2009-04-04 Thread Mark Tolonen
"John Posner" wrote in message news:af9fbcc3a7624599a6f51bad2397e...@amdup... Inspired by recent threads (and recalling my first message to Python edu-sig), I did some Internet searching on producing prime numbers using Python generators. Most algorithms I found don't go for the infinite, cont

Re: meta question - how to read comp.lang.python w/o usenet feed/google interface?

2009-03-20 Thread Mark Tolonen
"Esmail" wrote in message news:03081704-17b5-4c7d-82db-8efb7ebce...@q11g2000yqh.googlegroups.com... Hi all, I've been reading/posting to usenet since the 80s with a variety of tools (vn, and most recently Thunderbird) but since my ISP (TimeWarner) no longer provides usenet feeds I'm stuck. I

Re: PyWin32 for Python 3.x

2009-03-16 Thread Mark Tolonen
"cgoldberg" wrote in message news:6047c263-c6cb-4357-ad9b-96b61ec7e...@j8g2000yql.googlegroups.com... Release 213 is out already: Tim, Mark, this is great news.. thanks for tracking 3.x so closely. I big barrier for me to eventually adopt 3.x is the ability to use pywin32. thanks! -Corey

Re: Stopping SocketServer on Python 2.5

2009-03-12 Thread Mark Tolonen
"Falcolas" wrote in message news:1b6a95a4-5680-442e-8ad0-47aa9ea08...@w1g2000prk.googlegroups.com... On Mar 11, 1:11 pm, David George wrote: Again, problem here is the issue of being unable to kill the server while it's waiting on a request. In theory, i could force it to continue by sending

Re: Stopping SocketServer on Python 2.5

2009-03-10 Thread Mark Tolonen
"David George" wrote in message news:00150e67$0$27956$c3e8...@news.astraweb.com... Hi guys, I've been developing some code for a university project using Python. We've been working on an existing codebase, cleaning it up and removing dead wood. We decided to make some changes to internal

Re: how to convert from network to host byte order

2009-03-05 Thread Mark Tolonen
"Evan" wrote in message news:79582a34-5d0b-49b2-8c1e-4139324ff...@b38g2000prf.googlegroups.com... Hello ~ I'm new with python, what my problem is, I have a binary file, I want to read first 2 bytes and convert it to host byte order, then write it to another file. There is a piece of infor

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

2009-03-01 Thread Mark Tolonen
"John O'Hagan" wrote in message news:200903011520.29405.resea...@johnohagan.com... Inspired by some recent threads here about using classes to extend the behaviour of iterators, I'm trying to replace some some top-level functions aimed at doing such things with a class. So far it's got a te

  1   2   >