Re: Programming games in historical linguistics with Python

2010-11-30 Thread Vlastimil Brom
2010/11/30 Dax Bloom : > Hello, > > Following a discussion that began 3 weeks ago I would like to ask a > question regarding substitution of letters according to grammatical > rules in historical linguistics. I would like to automate the > transformation of words according to complex rules of phono

Re: ***locale.Error: unsupported locale setting***

2010-12-09 Thread Vlastimil Brom
2010/12/9 Anurag Chourasia : > Hi All, > When i try to set a locale manually, i get this error. import locale locale.setlocale(locale.LC_ALL, 'es_cl.iso88591') > Traceback (most recent call last): >   File "", line 1, in >   File "/usr/local/lib/python2.7/locale.py", line 531, in setloca

Re: Reading special Danish letters in Python

2010-12-19 Thread Vlastimil Brom
2010/12/19 Martin Hvidberg : > Dear list > > I have to read some data from an ASCII text file, filter it, and then export > it to a .dbf file. Basically a straight forward task... > My problem is that the input files contains some special national (Danish) > characters, and it appears that I have t

Re: Regular expression for "key = value" pairs

2010-12-22 Thread Vlastimil Brom
2010/12/22 Ciccio : > Hi all, > suppose I have: > > s='a=b, c=d' > > and I want to extract sub-strings a,b,c and d from s (and in general from > any longer list of such comma separated pairs). > Some failed attempts: > > In [12]: re.findall(r'(.+)=(.+)', s) > Out[12]: [('a=b, c', 'd')] > > [...] >

Re: Init a dictionary with a empty lists

2011-02-05 Thread Vlastimil Brom
2011/2/5 Lisa Fritz Barry Griffin : > Hi there, > > How can I do this in a one liner: > >        maxCountPerPhraseWordLength = {} >        for i in range(1,MAX_PHRASES_LENGTH+1): >            maxCountPerPhraseWordLength[i] = 0 > > Thanks! > -- > http://mail.python.org/mailman/listinfo/python-list >

Re: frequency of values in a field

2011-02-08 Thread Vlastimil Brom
2011/2/8, Paul Rubin : > noydb writes: >> I am looking for ways to go about capturing the frequency of unique >> values in one field in a dbf table which contains ~50k records. The >> values are numbers with atleast 5 digits to the right of the decimal, >> but I want the frequency of values to on

Re: wx.Frame hidden, and customising the close button

2011-02-11 Thread Vlastimil Brom
2011/2/11 Mark Carter : > Is there a way of testing whether a frame (suppose I have it as a > variable my_frame) is hidden in wxPython? > > Also, is there a way that I can over-ride the close button so that the > frame becomes hidden rather than destroyed, and perform supplementary > tests? > -- >

unexpected output from difflib.SequenceMatcher

2010-04-16 Thread Vlastimil Brom
Hi all, Once in a while I happen to stumble on some not expected behaviour of difflib.SequenceMatcher, in this case I hopefully managed to replicate it on an illustrative sample text. Both strings differ in a minimal way, each having one extra character in a "strategic" position, which seems to mee

Re: unexpected output from difflib.SequenceMatcher

2010-04-19 Thread Vlastimil Brom
From: Vlastimil Brom Date: 2010/4/16 Subject: unexpected output from difflib.SequenceMatcher ... Instead of just reporting the insertion and deletion of these single characters ... the output of the SequenceMatcher decides to delete a large part of the string in between the differences and to

Re: python to exe

2010-05-09 Thread Vlastimil Brom
2010/5/9 Robin : > Does anyone know of a way I can make a python script into an exe that > runs on windows7, I don't care if it is a python to c++ or python to c > translator or anything like it. The version of python I am using is > python 3.1. Thanks, > -Robin > -- > http://mail.python.org/mailma

Re: Question on Python Function

2010-05-24 Thread Vlastimil Brom
2010/5/24 joy99 : > > > Dear Group, > > I have a small question on function. > > If I write two functions like the following: > > IDLE 2.6.5 def function1(n): >        element1=5 >        element2=6 >        add=element1+element2 >        print "PRINT THE ADDITION",add > > def function2(n

modifying standard library functionality (difflib)

2010-06-23 Thread Vlastimil Brom
Hi all, I'd like to ask about the most reasonable/recommended/... way to modify the functionality of the standard library module (if it is recommended at all). I'm using difflib.SequenceMatcher for character-wise comparisons of the texts; although this might not be a usual use case, the results are

Re: modifying standard library functionality (difflib)

2010-06-24 Thread Vlastimil Brom
2010/6/24 Bruno Desthuilliers : > Vlastimil Brom a écrit : >> >> Hi all, >> I'd like to ask about the most reasonable/recommended/... way to >> modify the functionality of the standard library module (if it is >> recommended at all). > > ... >>

Re: modifying standard library functionality (difflib)

2010-06-24 Thread Vlastimil Brom
2010/6/24 Bruno Desthuilliers : > Vlastimil Brom a écrit : > > "patching source code" canonically means "physically" modifying the original > source file. Monkeypatching - which can only be done in some dynamic > languages - is what you're doing

Re: markmin 0.1

2010-07-06 Thread Vlastimil Brom
2010/7/6 Chris Rebert : > On Mon, Jul 5, 2010 at 4:56 PM, Massimo Di Pierro > wrote: >> Markmin is a wiki markup language >> implemented in less than 100 lines of code (one file, no dependencies) >> easy to read >> secure >> ... > > Okay, but where can it be downloaded from? You didn't include a l

Re: how to copy and move file with its attribute?

2010-07-19 Thread Vlastimil Brom
2010/7/19 oyster : > I mean writeonly, hidden, system and so on attributes > > I use windows, but if possible, is there any method to do so in a > crossplatfrom way? > > thanks > -- > http://mail.python.org/mailman/listinfo/python-list > You may check to see several possibilities http://timgolden.

Re: Accumulate function in python

2010-07-19 Thread Vlastimil Brom
2010/7/19 dhruvbird : > Hello, >  I have a list of integers: x = [ 0, 1, 2, 1, 1, 0, 0, 2, 3 ] >  And would like to compute the cumulative sum of all the integers > from index zero into another array. So for the array above, I should > get: [ 0, 1, 3, 4, 5, 5, 5, 7, 10 ] >  What is the best way (or

Re: how to pretty-print Python dict with unicode?

2010-08-04 Thread Vlastimil Brom
2010/8/5 kj : > > Is there a simple way to get Python to pretty-print a dict whose > values contain Unicode? (Of course, the goal here is that these > printed values are human-readable.) > > If I run the following simple script: > > from pprint import pprint > x = u'\u6c17\u304c\u9055\u3046' > pri

Re: Detect string has non-ASCII chars without checking each char?

2010-08-21 Thread Vlastimil Brom
2010/8/21 : > Python 2.6: Is there a built-in way to check if a Unicode string has > non-ASCII chars without having to check each char in the string? > > Here's my use case: I have a section of code that makes frequent calls to > hasattr. The attribute name being tested is derived from incoming da

Re: cleaning up an ASCII file?

2009-06-10 Thread Vlastimil Brom
2009/6/10 Nick Matzke : > Hi all, > > So I'm parsing an XML file returned from a database.  However, the database > entries have occasional non-ASCII characters, and this is crashing my > parsers. > > Is there some handy function out there that will schlep through a file like > this, and do somethi

Re: Need help in Python regular expression

2009-06-12 Thread Vlastimil Brom
2009/6/12 meryl : > On Jun 11, 9:41 pm, "Mark Tolonen" wrote: >> "meryl" wrote in message >> >> > I have this regular expression >... > I try adding ".*" at the end , but it ends up just matching the second > one. If there can be more matches in a line, maybe the non-greedy quantifier ".*?", a

Re: UnicodeDecodeError: problem when path contain folder start with character 'u

2009-06-22 Thread Vlastimil Brom
2009/6/22 aberry : > > 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. >>> fp = "C:\\ab\\unil" > 5. >>> un

Re: String to valid Python identifier

2009-08-08 Thread Vlastimil Brom
2009/8/8 Дамјан Георгиевски : > > >>> Is there any easy function in the stdlib to convert any random string >>> in a valid Python identifier .. possibly by replacing non-valid >>> characters with _ ? ... > > ps. > by "convert" I didn't mean a full transformation... I was more hoping > for the least

Re: Natural Language Processing in Python

2009-08-15 Thread Vlastimil Brom
2009/8/14 Prateek : > Hi, > > Can somebody please provide me link to a good online resource or e- > book for doing natural language processing programming in Python. > > Thanks, > Prateek > -- > http://mail.python.org/mailman/listinfo/python-list > Maybe you could start with NLTK http://www.nltk.o

Re: sub-list extraction, logical indexation

2009-08-17 Thread Vlastimil Brom
2009/8/17 MRAB : > Diez B. Roggisch wrote: >> >> Pierre wrote: >> >>> Hello Everyone, >>> >>> I would like to know if it is possible to extract a sub-list from a >>> list ? >>> >>> typically if : >>> >>> L =[[1, 2, 3],[4, 5, 6],[3] ] >>> >>> How to extract easily the elements 0 and 2 of L in order

Re: How to 'de-slashify' a string?

2009-08-22 Thread Vlastimil Brom
2009/8/22 AK : > Steven D'Aprano wrote: >> >> On Sat, 22 Aug 2009 04:20:23 -0400, AK wrote: >> >>> Hi, if I have a string '\\303\\266', how can I convert it to '\303\266' >>> in a general way? >> >> It's not clear what you mean. >> >> Do you mean you have a string '\\303\\266', that is: >> >> backs

Re: How to 'de-slashify' a string?

2009-08-22 Thread Vlastimil Brom
2009/8/22 AK : > Vlastimil Brom wrote: >> >> 2009/8/22 AK : >>> >>> Steven D'Aprano wrote: >>>> >>>> On Sat, 22 Aug 2009 04:20:23 -0400, AK wrote: >>>> >>>>> Hi, if I have a string '\\303\\266'

Re: break unichr instead of fix ord?

2009-08-26 Thread Vlastimil Brom
2009/8/25 : > 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'\ud800', u'\udc40') > >  # Create the same character with the uni

Re: break unichr instead of fix ord?

2009-08-26 Thread Vlastimil Brom
2009/8/27 : > On Aug 26, 2:05 am, Vlastimil Brom wrote: >>[...] >>... >> However, if I need these functions for higher unicode planes, the >> following rather hackish replacements seem to work. I presume, there >> might be smarter ways of dealing with this, b

Re: Select column from a list

2009-08-28 Thread Vlastimil Brom
2009/8/28 hoffik : > > Hello, > > I'm quite new in Python and I have one question. I have a 2D matrix of > values stored in list (3 columns, many rows). I wonder if I can select one > column without having to go through the list with 'for' command. > ... I guess, it won't be possible without an ex

Re: break unichr instead of fix ord?

2009-08-29 Thread Vlastimil Brom
2009/8/29 : > On 08/28/2009 02:12 AM, "Martin v. Löwis" wrote: > > So far, it seems not and that unichr/ord > is a poster child for "purity beats practicality". > -- > http://mail.python.org/mailman/listinfo/python-list > As Mark Tolonen pointed out earlier in this thread, in Python 3 the practic

Re: Regular Expression problem

2009-09-08 Thread Vlastimil Brom
2009/9/8 找尋自己的一片天 : > I have the following source code > > > import re > d = 'RTCB\r\nsignature:\xf1\x11 > \xde\x10\xfe\x0f\x9c\x10\xf6\xc9_\x10\xf3\xeb<\x10\xf2Zt\x10\xef\xd2\x91\x10\xe6\xe7\xfb\x10\xe5p\x99\x10\xe2\x1e\xdf\x10\xdb\x0e\x9f\x10\xd8p\x06\x10\

Re: Instatiable Pseudo-Random Number Generator

2009-09-10 Thread Vlastimil Brom
2009/9/10 Hans Georg Schaathun : > I wonder if someone knows of an API with the features I need... > random.Random and numpy.random each have only half of it... > > My application includes an object to hold a pseudo-randomly > generated matrix too large to be kept in memory.  Hence I > try to store

Re: string interpolation mystery in Python 2.6

2009-09-12 Thread Vlastimil Brom
2009/9/12 Steven D'Aprano : > On Fri, 11 Sep 2009 15:19:05 -0700, Chris Rebert wrote: > >> Sounds like IOError or one of its ancestors defines both __str__() and >> __unicode__ () special methods but has them produce different output. > > > That's what it looks like to me too, which I wouldn't call

Re: str.split() with empty separator

2009-09-15 Thread Vlastimil Brom
2009/9/15 Ulrich Eckhardt : > Hi! > > "'abc'.split('')" gives me a "ValueError: empty separator". > However, "''.join(['a', 'b', 'c'])" gives me "'abc'". > > Why this asymmetry? I was under the impression that the two would be > complementary. > > Uli > maybe it isn't quite obvious, what the behav

Re: Looking for a pure Python chart drawing module

2009-09-15 Thread Vlastimil Brom
2009/9/15 John Nagle : > I'm looking for something that can draw simple bar and pie charts > in Python.  I'm trying to find a Python package, not a wrapper for > some C library, as this has to run on both Windows and Linux > and version clashes are a problem. > > Here's the list from the Python wik

Re: Not this one the other one, from a dictionary

2009-09-18 Thread Vlastimil Brom
2009/9/18 Ross : > > Learning my way around list comprehension a bit.   I wonder if someone has a > better way to solve this issue.  I have a two element dictionary, and I know > one of the keys but not the other, and I want to look up the other one. > > So I have this dictionary: > > aDict = {'a':

Re: Set literal confusion

2009-09-22 Thread Vlastimil Brom
2009/9/22 kaoruAngel : > I recently decided to implement a small project in python after being > away from the language for a while, so, in learning the language over > again, I experimented. > > --- > Python 3.1.1 (r311:74483, Aug 17 2009, 16:45:59) [MSC v.1500

Re: Not this one the other one, from a dictionary

2009-09-22 Thread Vlastimil Brom
Thanks for the elaboration; in retrospect, given the simple requirement, that there are only two dict keys, one of which is know and the other to be determined, maybe just the direct dict methods are appropriate, e.g. d = {'a': 'bob', 'b': 'stu'} d_copy = dict(d) d_copy.pop("a") 'bob' d_copy.popit

Re: split string into multi-character "letters"

2010-08-25 Thread Vlastimil Brom
2010/8/25 Jed : > Hi, I'm seeking help with a fairly simple string processing task. > I've simplified what I'm actually doing into a hypothetical > equivalent. > Suppose I want to take a word in Spanish, and divide it into > individual letters.  The problem is that there are a few 2-character > com

Re: python path separator

2010-09-02 Thread Vlastimil Brom
2010/9/2 swapnil : > I could not find any documentation for variables os.path.sep and > os.path.altsep. Although the first is pretty straightforward can > anyone explain the purpose of the second variable? Is it even useful? > According to issue http://bugs.python.org/issue709428, os.path.altsep >

data structure suggestion (native python datatypes or sqlite; compound select)

2010-09-16 Thread Vlastimil Brom
(BTW, are these queries equivalent, as the outputs suggest, or are there some distinctions to be aware of?) Anyway, I can't really believe, this would be the expected way ... (I only marginally looked into sqlalchemy, which might simplify this a bit, is this true? - Currently I only use the standard lib, depending on the available server setup (python 2.6)). Thanks in advance for any suggestions or pointers on both the sql usage as well as the general datatype question. regards, Vlastimil Brom -- http://mail.python.org/mailman/listinfo/python-list

Re: data structure suggestion (native python datatypes or sqlite; compound select)

2010-09-16 Thread Vlastimil Brom
2010/9/17 MRAB : > On 16/09/2010 23:11, Vlastimil Brom wrote: >> >>... >> I put together some code, which works as expected, but I suspect >> somehow, that there must be better ways of doing it. >> >> Two things I am not quite clear about are using the place

Re: data structure suggestion (native python datatypes or sqlite; compound select)

2010-09-17 Thread Vlastimil Brom
2010/9/17 MRAB : > On 17/09/2010 00:56, Vlastimil Brom wrote: >> >> 2010/9/17 MRAB: >>> >>> On 16/09/2010 23:11, Vlastimil Brom wrote: >>>> >>>> ... >>>> I put together some code, which works as expected, but I suspect >>&

Re: data structure suggestion (native python datatypes or sqlite; compound select)

2010-09-18 Thread Vlastimil Brom
2010/9/18 Dennis Lee Bieber : > On Fri, 17 Sep 2010 10:44:43 +0200, Vlastimil Brom > declaimed the following in > gmane.comp.python.general: > > >> Ok, thanks for confirming my suspicion :-), >> Now I have to decide whether I shall use my custom data structure, >>

Re: data structure suggestion (native python datatypes or sqlite; compound select)

2010-09-18 Thread Vlastimil Brom
2010/9/18 Dennis Lee Bieber : > On Sat, 18 Sep 2010 10:48:44 +0200, Vlastimil Brom > declaimed the following in > gmane.comp.python.general: > >> >> http://mail.python.org/pipermail/python-list/2008-May/540773.html >> >        Ah, based on that listing you ar

Re: data structure suggestion (native python datatypes or sqlite; compound select)

2010-09-22 Thread Vlastimil Brom
2010/9/19 Dennis Lee Bieber : > On Sat, 18 Sep 2010 23:00:25 +0200, Vlastimil Brom > declaimed the following in > gmane.comp.python.general: > >> Thank you very much for detailed hints, I see, I should have mention >> the specification with my initial post... >> I

Re: Regular Expression match

2010-09-24 Thread Vlastimil Brom
2010/9/25 AON LAZIO : > Hi, >    Say I have >    p = re.compile('a|b') >    text = 'a' >    d = p.findall(text) >    #d -> ['a'] >    What is the way to find out which pattern p match (the former or latter)? > I mean without knowing the outcome of p.findall >    Thanks > > -- > Aonlazio > '

Re: Opening a webpage in the background via webbrowser.open()

2010-10-08 Thread Vlastimil Brom
2010/10/7 : > Python 2.7 (32-bit/Windows): Is there a way to use webbrowser.open() to open > a web page in the default browser, but in the background, so that the > application making the webbrowser.open() call remains the active > application? > > Thank you, > Malcolm > -- > http://mail.python.or

Re: ANN: stats 0.1a calculator statistics for Python

2010-10-18 Thread Vlastimil Brom
2010/10/17 Steven D'Aprano : > I am pleased to announce the first public release of stats for Python. > > http://pypi.python.org/pypi/stats > > stats is a pure-Python module providing basic statistics functions > similar to those found on scientific calculators. It currently includes: > > Univariat

Re: A question I have...

2010-10-23 Thread Vlastimil Brom
2010/10/22 Joe Shoulak : > I'm trying to make a sports simulation program and so far everything has > worked until I try entering: > > Score1 = (Team1Off + Team2Def)/2 > > I get the error: > > TypeError: unsupported operand type(s) for /: 'str' and 'int' > > Can someone please explain to me what th

Re: Why this result with the re module

2010-11-02 Thread Vlastimil Brom
2010/11/2 Yingjie Lan : >> From: John Bond >> Subject: Re: Why this result with the re module > ... > I suggested findall return a tuple of re.MatchObject(s), > with each MatchObject instance representing a match. > This is consistent with the re.match() function anyway. > And it will eliminate th

Re: Is there a OrderedDict which can perform an iteritems() in order?

2010-11-04 Thread Vlastimil Brom
2010/11/4 Jo Chan : > Hello all, >      I have working on a program which need a ordered dictionary that could > perform iteritems() sequentially. >      I found a package on > : http://www.voidspace.org.uk/python/odict.html#creating-an-ordered-dictionary >      but it  could only perform items() i

Re: Silly newbie question - Carrot character (^)

2010-11-05 Thread Vlastimil Brom
2010/11/5 Matty Sarro : > Hey Everyone, > Just curious - I'm working on a program which includes a calculation of a > circle, and I found myself trying to use pi*radius^2, and getting errors > that data types float and int are unsupported for "^". Now, I realized I was > making the mistake of using

Re: Using Python for a demonstration in historical linguistics

2010-11-06 Thread Vlastimil Brom
2010/11/6 Dax Bloom : > Hello, > > In the framework of a project on evolutionary linguistics I wish to > have a program to process words and simulate the effect of sound > shift, for instance following the Rask's-Grimm's rule. I look to have > python take a dictionary file or a string input and rep

regenerating unicodedata for py2.7 using py3 makeunicodedata.py?

2010-11-13 Thread Vlastimil Brom
Traceback (most recent call last): File "", line 1, in ValueError: no such name >>> unicodedata.category(u"\U0002A700") 'Lo' >>> Could please anybody confirm, whether this way of updating the unicodedata for 2.7 is generaly viable or point out possible problem this may lead to? Many thanks in advance, Vlastimil Brom -- http://mail.python.org/mailman/listinfo/python-list

Re: regenerating unicodedata for py2.7 using py3 makeunicodedata.py?

2010-11-13 Thread Vlastimil Brom
ython-list > Thanks for the confirmation Martin! Do you think, it the mentioned omission of the character names of some CJK ranges in unicodedata intended, or should it be reported to the tracker? Regards, Vlastimil Brom -- http://mail.python.org/mailman/listinfo/python-list

Re: Why datetime module is so complicated?

2010-11-14 Thread Vlastimil Brom
2010/11/14 Zeynel : > It's about a week now I've been trying to convert a datetime object to > seconds since epoch; the object is set to current time by class Rep() > in Google App Engine: > > class Rep(db.Model): >    ... >    mCOUNT = db.IntegerProperty() >    mDATE0 = db.DateTimeProperty(auto_no

Re: Does one create an event to notify parent window/GUI of something?

2017-03-12 Thread Vlastimil Brom
2017-03-12 13:14 GMT+01:00 Chris Green : ... > > This question relates to how one communicates between windows/GUIs. > > When the program starts theres a main GUI, class name abookgui. If > you want to add new entries or modify existing entries an edit GUI is > started in a separate window, class

Re: Regular expression query

2017-03-12 Thread Vlastimil Brom
2017-03-12 17:22 GMT+01:00 : > Hi All, > > I have a string which looks like > > a,b,c "4873898374", d, ee "3343,23,23,5,,5,45", f > "5546,3434,345,34,34,5,34,543,7" > > It is comma saperated string, but some of the fields have a double quoted > string as part of it (and t

<    1   2   3