Re: What is the simplest method to get a vector result?

2014-07-24 Thread Vlastimil Brom
2014-07-24 14:53 GMT+02:00 fl : > Hi, > I have read a lot about Python, but it still has a problem now on a simple > exercise. For example, I want to generate a sine curve. First, I get a time > sequence: > > index=range(100) > > I import math module, try to calculate sine with > > math.sin(index*m

Re: Tkinter frame reset

2014-08-09 Thread Vlastimil Brom
2014-08-09 2:38 GMT+02:00 Nicholas Cannon : > Ok so I am working on a little project and I cant seem to solve something > with it. I have a label and then a clear button and I want all the numbers in > the label to clear when I push the button. This button is on a separate frame > to the buttons

Re: what's the command for (cd ..) in python

2011-09-09 Thread Vlastimil Brom
2011/9/9 kaustubh joshi : > Hello friends, > How do we carry out the command "cd .." in python? > > My problem is : > I have a set of folders say m=1,2,3,4. In each of these folders, I have > subfolders with common name say m_5,m_6,m_7,m_8. In each of these subfolder, > the

Re: How do I automate the removal of all non-ascii characters from my code?

2011-09-12 Thread Vlastimil Brom
2011/9/12 Alec Taylor : > Good evening, > > I have converted ODT to HTML using LibreOffice Writer, because I want > to convert from HTML to Creole using python-creole. Unfortunately I > get this error: "File "Convert to Creole.py", line 17 > SyntaxError: Non-ASCII character '\xe2' in file Convert t

Re: How do I automate the removal of all non-ascii characters from my code?

2011-09-13 Thread Vlastimil Brom
2011/9/13 ron : > > Depending on the load, you can do something like: > > "".join([x for x in string if ord(x) < 128]) > > It's worked great for me in cleaning input on webapps where there's a > lot of copy/paste from varied sources. > -- > http://mail.python.org/mailman/listinfo/python-list > Well

Re: How do I automate the removal of all non-ascii characters from my code?

2011-09-13 Thread Vlastimil Brom
n file Convert to Creole.py > on line 1, but no encoding declared; see > http://www.python.org/peps/pep-0263.html for details >>>> Exit Code: 1 > > Line 1: a=u'''≤'''.encode("ascii", "ignore").decode("ascii") > >

Re: how to make a nested list

2011-09-15 Thread Vlastimil Brom
2011/9/15 Stef Mientki : > hello, > > I need a nested list, like this > A= [ [None,None], [None,None], [None, None] ] A[2][0] =77 A > [[None, None], [None, None], [77, None]] > ... > > thanks, > Stef > -- > http://mail.python.org/mailman/listinfo/python-list > Besides the above suge

Re: Generating equally-spaced floats with least rounding error

2011-09-24 Thread Vlastimil Brom
2011/9/24 Chris Angelico : > On Sat, Sep 24, 2011 at 11:53 PM, Steven D'Aprano > wrote: >> #1 add multiples of the width to the starting value, 0. >> >> #2 subtract multiples of width from the ending value, 2.1. > > #3, go half and half - generate the lower half by adding to the lower > bound, and

Re: regexp compilation error

2011-09-30 Thread Vlastimil Brom
2011/9/30 Ovidiu Deac : > This is only part of a regex taken from an old perl application which > we are trying to understand/port to our new Python implementation. > > The original regex was considerably more complex and it didn't compile > in python so I removed all the parts I could in order to

Re: Question: Optional Regular Expression Grouping

2011-10-10 Thread Vlastimil Brom
2011/10/10 galyle : > HI, I've looked through this forum, but I haven't been able to find a > resolution to the problem I'm having (maybe I didn't look hard enough > -- I have to believe this has come up before).  The problem is this: > I have a file which has 0, 2, or 3 groups that I'd like to rec

Re: Regexp : repeated group identification

2011-12-14 Thread Vlastimil Brom
2011/12/14 candide : > Consider the following code > > # > import re > > z=re.match('(Spam\d)+', 'Spam4Spam2Spam7Spam8') > print z.group(0) > print z.group(1) > # > > outputting : > > > Spam4Spam2Spam7Spam8 > Spa

Re: Regexp : repeated group identification

2011-12-14 Thread Vlastimil Brom
2011/12/14 candide : ... > > Thanks for the reference and the example. I didn't know of this > reimplementation, hoping it offers the Aho-Corasick algorithm allowing > multiple keys search. > -- > http://mail.python.org/mailman/listinfo/python-list Hi, I am not sure about the underlying algorithm

Re: Correct handling of case in unicode and regexps

2013-02-23 Thread Vlastimil Brom
2013/2/23 Devin Jeanpierre : > Hi folks, > > I'm pretty unsure of myself when it comes to unicode. As I understand > it, you're generally supposed to compare things in a case insensitive > manner by case folding, right? So instead of a.lower() == b.lower() > (the ASCII way), you do a.casefold() ==

Re: Best way to convert number of minutes to hh:mm AM/PM?

2013-03-01 Thread Vlastimil Brom
2013/3/2 : > Hi, > > I need to create a list of equally spaced times (as in hh:mm AM/PM) within a > day to loop through. Having selected 30 minute intervals I figured I could: > > * Create a list from 1 to 48 > * Multiply each value by 30 > * Convert minutes to a time. datetime.timedelta seems to

Re: Encoding problem in python

2013-03-04 Thread Vlastimil Brom
2013/3/4 : > I have a problem with encoding in python 27 shell. > > when i write this in the python shell: > > w=u'العربى' > > It gives me the following error: > > Unsupported characters in input > > any help? > -- > http://mail.python.org/mailman/listinfo/python-list Hi, I guess, you are using

Re: simple GUI environment

2013-03-05 Thread Vlastimil Brom
2013/3/5 Eric Johansson : > I need a simple GUI toolkits like easygui pythoncard. The main reason I > discount both of those is that they are effectively dead as I can see. Last > updates in the 2010/2011 range. Has there been some toolkit to replace them? > And no, the existing wxpython/gtk/qt/...

Re: Recursive function

2013-03-05 Thread Vlastimil Brom
2013/3/5 Ana Dionísio : > Hello! > > I have to make a script that calculates temperature, but one of the > parameters is the temperature in the iteration before, for example: > temp = (temp_-1)+1 > > it = 0 > temp = 3 > > it = 1 > temp = 3+1 > > it = 2 > temp = 4+1 > > How can I do this in a simple

Re: A string and an integer to appear in tuple (python 2.7)

2013-03-12 Thread Vlastimil Brom
2013/3/13 Jiewei Huang : > Hi all, > > I'm currently stuck at this question on > > Writing a function len_str that takes a string as an argument and returns a > pair consisting of the length of the string and the string itself. > > Example: len_str('Meaning of life') should return the tuple (15, '

Re: Libroffice PMT equivalent in python

2013-04-25 Thread Vlastimil Brom
2013/4/25 ஆமாச்சு > Hi, > > Are there equivalent in any Python libraries that could match function > like PMT in libreoffice? > > Refer: https://help.libreoffice.org/Calc/Financial_Functions_Part_Two#PMT > > -- > > Amachu > -- > http://mail.python.org/mailman/listinfo/python-list > Hi, you may c

Re: Try/Except/Yield/Finally...I'm Lost :-}

2007-11-29 Thread Vlastimil Brom
2007/11/28, Victor Subervi <[EMAIL PROTECTED]>: > > Hi; > I am trying to find words in a document that are identical to any word in > a vocabulary list, to replace that word with special markup. Let's say the > word is "dharma". I don't want to replace the first few letters of, say > "dharmawuhirfu

format for storing textual data (for an edition) - formatting and additional info

2007-12-12 Thread Vlastimil Brom
Hi all, Firstly, I do apologize about this quite a long post without a concrete programming question - I'd like to ask about the availability of some tools or methods/concepts in python environment I am probably missing, hence I thought, I should describe my task in some detail as well as the ways

Re: WXPython - Using inline images

2008-01-01 Thread Vlastimil Brom
2007/12/31, Sick Monkey <[EMAIL PROTECTED]>: ... Is there anyway WXPython can just use the inline image without having to create a physical copy? I know this can be done in TKinter using inline gifs, but was wondering if anyone knew of a clever way to do this in WXPython? ... I think, you can use

Re: Dual look-up on keys?

2008-03-05 Thread Vlastimil Brom
2008/3/5, [EMAIL PROTECTED] <[EMAIL PROTECTED]>: > > ... > Anyway, if (a,b) is a key in dictionary d, can it guarantee that (b,a) > is also in it, and maps to the same object? > ... > Well, it's probably not the most effective way, but one can use something like: >>> d={frozenset(("a","b")):7} >>

Re: is there a shorter way to write this

2009-01-29 Thread Vlastimil Brom
2009/1/29 garywood : > I had a task in a book to pick 5 items from a list of 26 ensuring the items > are not repeated > > > import random > list = ['a','b','c','d','e','f','g','h','i','j','k','l','m', > 'n','o','p','q','r','s','t','u','v','w','x','y','z'] > word = ' ' > a = random.choice(li

Re: parsing text from a file

2009-01-29 Thread Vlastimil Brom
2009/1/29 Wes James : > If I read a windows registry file with a line like this: > ... > > with this code: > > f=open('fwrules.reg2.txt') > > for s in f: > if s.find('LANDesk') <0: >print s, > > > LANDesk is not found. > > how do I find LANDesk in a string like this. is the "\\" messing thing

Re: Empty string is False right?

2009-01-31 Thread Vlastimil Brom
2009/1/31 AJ Ostergaard : > Hi Ralf, > > Thanks for that but why: > '' and True > '' > > Surely that should be False?!? > > Regards, > AJ > > see the docs: http://docs.python.org/reference/expressions.html#boolean-operations "The expression x and y first evaluates x; if x is false, its value

Re: Why doesn't this RE match?

2009-02-06 Thread Vlastimil Brom
2009/2/7 Just Another Victim of the Ambient Morality : >    I'm confused by this behaviour: > > > import re > > regex = re.compile('foo') > match = regex.match('whatfooever') > > >    In my experience with regular expressions, regex should have found a > match.  However, in this case regex.match()

sys.exc_info() different between python 2.5.4 and 2.6.1?

2009-02-06 Thread Vlastimil Brom
Hi all, I just noticed a changed behaviour of sys.exc_info() between python 2.5.4 and 2.6.1 and wanted to ask, wheter it was intended, and how to deal with the new state. Some code triggers an error while opening a text file (windows 1250 - with non-ascii characters) wrongly as utf-8, this gets ca

Re: Replace unknow string varible in file.

2009-02-10 Thread Vlastimil Brom
2009/2/10 namire : > Hey .python first time poster here. I'm pretty good with python so > far, but I keep needed a function in my program but not knowing how to > build it. =( Here's the problem: > > Imagine a html file full of 100's of these strings all mooshed > together onto many lines; > ITEM >

Re: Using dictionary to hold regex patterns?

2008-11-23 Thread Vlastimil Brom
2008/11/23 Gilles Ganault <[EMAIL PROTECTED]> > Hello > > After downloading a web page, I need to search for several patterns, > and if found, extract information and put them into a database. > > To avoid a bunch of "if m", I figured maybe I could use a dictionary > to hold the patterns, and loop

Re: rejecting newlines with re.match

2008-11-27 Thread Vlastimil Brom
2008/11/27 r0g <[EMAIL PROTECTED]> > Hi, > > I want to use a regex to match a string "poo" but not "poo\n" or > "poo"+chr(13) or "poo"+chr(10) or "poo"+chr(10)+chr(13) > > ... > Thanks, > > > Roger. > -- > http://mail.python.org/mailman/listinfo/python-list > Hi, if I understand correctly, that

Re: newbie question: parse a variable inside an RE?

2008-12-01 Thread Vlastimil Brom
2008/12/1 <[EMAIL PROTECTED]> > Hi All, > > How do I parse a variable inside an RE? > What is the re.search() syntax when your > search string is a variable? > It's easy to parse hardcoded RE's but not > if you use a variable. > > Here is my code, input and runtime: > > $ cat test45.py > #!/usr/bi

Re: generating a liste of characters

2008-12-03 Thread Vlastimil Brom
2008/12/3 Yves Dorfsman <[EMAIL PROTECTED]>: > Is there any built in way to generate a list of characters, something > along the line of range('a'-'z') ? > > Right now I am using: > > chars = [ chr(l) for l in range(0x30, 0x3a) ] # 0 - 9 > chars += [ chr(l) for l in range(0x41, 0x5b) ] # A - Z

Re: Text parsing via regex

2008-12-08 Thread Vlastimil Brom
2008/12/8 Robocop <[EMAIL PROTECTED]>: > I'm having a little text parsing problem that i think would be really > quick to troubleshoot for someone more versed in python and Regexes. > I need to write a simple script that parses some arbitrarily long > string every 50 characters, and does not parse

Re: Python 3.0 crashes displaying Unicode at interactive prompt

2008-12-13 Thread Vlastimil Brom
2008/12/13 John Machin : > > Python 2.6.1 (r261:67517, Dec 4 2008, 16:51:00) [MSC v.1500 32 bit > (Intel)] on win32 > Type "help", "copyright", "credits" or "license" for more information. x = u'\u9876' x > u'\u9876' > > # As expected > > Python 3.0 (r30:67507, Dec 3 2008, 20:14:27) [MS

Re: wxpython for python 3.0 ?

2008-12-22 Thread Vlastimil Brom
>> The wxpython web describes compatability with python 2.4 & 2.5 . >> Does it work with 3.0 ? If not, anyone have a clue as to when ? > > This question was asked a couple of times on the wxpython-users mailing > list. It's probably going to take a while. For now, I'd stick to python 2.x. > The n

Re: Sort dictionary by value when value is a list

2008-11-14 Thread Vlastimil Brom
2008/11/14 major-john <[EMAIL PROTECTED]> > I'm having trouble sorting a dictionary based on values when the values are > all lists, and i want to sort the list by key with the largest value lists > in decreasing size. > > Currently, I have the following: > > from operator import itemgetter > > di

Re: Quick nested loop syntax?

2008-11-19 Thread Vlastimil Brom
2008/11/19 Johannes Bauer <[EMAIL PROTECTED]> > Hi group, > > if I remember correctly, wasn't there a way to quickly iterate through > nested loops? Something like > > a = { "a", "b", "c" } > b = { 4, 9, 13} > for (x, y) in someoperator(a, b): >print(x, y) > > which would print all tuples

Re: TextCtrl fully expanding at program start

2009-02-27 Thread Vlastimil Brom
2009/2/27 alex : > Hi all > I have a gridsizer consisting of two vertically stacked panels, one > with a StaticBox and the other with a TextCtrl. > I would like that the TextCtrl expands at program start fully to the > allocated panel size (lower panel of gridSizer). > Instead of like now, fully ex

Re: starting a Python 2.5 executable without the DOS window

2009-02-27 Thread Vlastimil Brom
>> 2009/2/27 Greg Miller : >> > I am working on a program that controls a piece of equipment.  The GUI/ >> > control software is written with Python2.5/wxPython.  I would like to >> > know if there is a way of starting the GUI without the DOS window >> > having to launch?  I would like only the app

Re: Perl-python regex-performance comparison

2009-03-03 Thread Vlastimil Brom
2009/3/3 MRAB wrote: >> > Python 2.7's regex will include possessive quantifiers, atomic groups, > variable-length lookbehinds, and Unicode properties (at least the common > ones), amongst other things. > -- > http://mail.python.org/mailman/listinfo/python-list > Wow, that's excellent news! Many

Re: WinCE and python

2009-03-04 Thread Vlastimil Brom
2009/3/2 ssd : > Hi, > > Has somebody tested this pyhton implementation in Windows CE 6.0? > http://sourceforge.net/projects/pythonce/ > > > I have tried in my WinCE 6.0 platform, I can run some commands in the shell, > but I can not run that commands in python script (.py), "python.exe test.py" >

cross platform accessing paths (windows, linux ...)

2009-03-12 Thread Vlastimil Brom
Hi all, I'd like to ask for some advice on how to acomplish file access in a cross platform way. My application is a kind of viewer of text and corresponding image files (stored in separate subdirectories) and I'm going to deploy it as binaries for windows and source files (again in separate direct

Re: cross platform accessing paths (windows, linux ...)

2009-03-12 Thread Vlastimil Brom
> On Thu, Mar 12, 2009 at 8:10 AM, Vlastimil Brom > wrote: >> >> Hi all, >> I'd like to ask for some advice on how to acomplish file access in a >> cross platform way. >> ... >> Any hints or comments are much appreciated; thanks in advance! >

Re: cross platform accessing paths (windows, linux ...)

2009-03-12 Thread Vlastimil Brom
2009/3/12 Christian Heimes : > Vlastimil Brom wrote: >> def path_from_pardir(path): >>     return >> os.path.realpath(os.path.normpath(os.path.join(os.path.dirname(__file__), >> os.pardir, path))) >> #  __file__ is substituted with sys.path[0] if not present &

Re: cross platform accessing paths (windows, linux ...)

2009-03-13 Thread Vlastimil Brom
2009/3/13 hendra kusuma : > you may want to use os.sep to replace manually written "/" "\" ":" for each > os > I heard that unix/linux use "/" as directory separator while windows use "\" > and mac os use ":" > Thanks for the notice about the ":" path separator on mac; windows uses "\" but normally

Re: String to sequence

2009-03-14 Thread Vlastimil Brom
2009/3/14 mattia : > How can I convert the following string: > > 'AAR','ABZ','AGA','AHO','ALC','LEI','AOC', > EGC','SXF','BZR','BIQ','BLL','BHX','BLQ' > > into this sequence: > > ['AAR','ABZ','AGA','AHO','ALC','LEI','AOC', > EGC','SXF','BZR','BIQ','BLL','BHX','BLQ'] > > Thanks a lot, > Mattia > --

Re: How to add months to a date (datetime object)?

2009-03-15 Thread Vlastimil Brom
2009/3/15 : > I have a date in the form of a datetime object and I want to add (for > example) three months to it.  At the moment I can't see any very > obvious way of doing this.  I need something like:- > >    myDate = datetime.date.today() >    inc = datetime.timedelta(months=3) >    myDate +=

Re: is there an easy way to parse a nested list ?

2009-03-16 Thread Vlastimil Brom
2009/3/16 Stef Mientki : > hello, > > I need to parse a nested list, given as a string, like this > > line = " A  [  B  [ C+2 ] + 3 ] " > ... > > thanks, > Stef > Hi, I guess, you can use e.g. pyparsing; there is a "nestedExpr" (and probably other options, I'm not aware of ...:-) Check the example

Re: is there an easy way to parse a nested list ?

2009-03-16 Thread Vlastimil Brom
2009/3/16 Vlastimil Brom : > 2009/3/16 Stef Mientki : >> hello, >> >> I need to parse a nested list, given as a string, like this >> >> line = " A  [  B  [ C+2 ] + 3 ] " >> > ... >> >> thanks, >> Stef >&g

Re: Use of HTMLparser to change language

2009-03-20 Thread Vlastimil Brom
2009/3/20 pranav : > Greetings All, > > I have huge number of HTML files, all in english. I also have their > counterpart files in Spanish. The non english files have their look > and feel a little different than their english counterpart. > > My task is to make sure that the English HTML files con

Re: unicode for beginners

2009-03-26 Thread Vlastimil Brom
2009/3/26 WallyDD : > I have something of a csv file which has somehow been converted into > something that looks like this; > " FOZ DE IGUAZ\u00da" and " R\u00cdO DE JANEIRO" > Is there a simple way to convert this into something a little bit > readable? > Is there a simple command in python to co

Re: Help with wxPython program :.: return 1?

2009-04-05 Thread Vlastimil Brom
2009/4/5 Kenny x : > Hello, I have a problem with my wxPython 2.8 Application. > The program opens and closes and on KomodoEdit it says "wxstreamredirect.py > returned 1.' >  What's wrong? > http://paste.pocoo.org/show/80/ > > P.S. I compared my source code to the source code in wxPython in Act

Re: Slicing an array in groups of eight

2009-05-21 Thread Vlastimil Brom
2009/5/21 Graham Arden : > A python novice writes. > > Hello, > > I'm trying to extract certain frames from a stack of images as part of > a project.  In order to do this I need to produce an array which > consists of a group of eight, then misses the next 8, then selects the > next eight etc.

Re: how to get the path of a module (myself) ?

2009-06-02 Thread Vlastimil Brom
2009/6/2 Stef Mientki : ... > and the files generated by Py2Exe, don't work at all. > > Through this discussion, I discovered another problem, > because __file__ isn't the current file, > I can't run 1 module(file) from another module (file) . > > -- > http://mail.python.org/mailman/listinfo/python

suggestions on code structuring? (classes; gui, data, methods...)

2008-05-14 Thread Vlastimil Brom
Hi all; I'd like to ask for suggestions regarding the appropriate structure of the code of my app. It is a gui program (wxPython; wx.aui) displaying several texts simultaneously. The user interface consists of multiple text widgets and control panels for selecting the text parts and synchronising.

Re: Need help porting Perl function

2008-06-08 Thread Vlastimil Brom
ant performance disadvantages in the two subsequent implied loops over the input list? Regards, Vlastimil Brom -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding a sense of word in a text

2008-06-12 Thread Vlastimil Brom
2008/6/11, Sengly <[EMAIL PROTECTED]>: > > Dear all, > > This might be off group but I am looking for a python library that can > help me to find a sense of a word in a text and eventually a list of > synonyms of that term. I searched the web and found one but it is > written in perl (http://www.d.

Re: regexp: match only if previous matched?

2008-06-23 Thread Vlastimil Brom
2008/6/24, cirfu <[EMAIL PROTECTED]>: > > I need to extract prices froma html-document. > > [0-9]*\$ matches 112$ 45$ etc but also just a $. why that shouldnt > really matter and it is unlikely anyway to appear a $sign with no > price attahced to it I still want to prevent it. > > How do I avoid ma

Re: How make regex that means "contains regex#1 but NOT regex#2" ??

2008-07-01 Thread Vlastimil Brom
2008/7/1, [EMAIL PROTECTED] <[EMAIL PROTECTED]>: > > I'm looking over the docs for the re module and can't find how to > "NOT" an entire regex. > > For example. > > How make regex that means "contains regex#1 but NOT regex#2" ? > > Chris > > -- > http://mail.python.org/mailman/listinfo/python-l

Re: Simple question, how do you tell how many items in a list?

2008-07-10 Thread Vlastimil Brom
2008/7/11, Alex Bryan <[EMAIL PROTECTED]>: > > I am just wondering how you get an integer value for how many items there > are in a list, preferably w/o a for loop. > > -- > http://mail.python.org/mailman/listinfo/python-list > Use len >>> len([1,2,3]) 3 >>> vbr -- http://mail.python.org/mailman/

Re: Execution speed question

2008-07-25 Thread Vlastimil Brom
2008/7/25 Suresh Pillai <[EMAIL PROTECTED]>: > ... > I naturally started coding with (2), but couldn't decide on the best data > structure for python. A set seemed ideal for speedy removal, but then I > can't iterate through them with out popping. An ordered list? Some > creative solution wi

Re: wx.Timer not working

2008-07-26 Thread Vlastimil Brom
2008/7/26 <[EMAIL PROTECTED]> > Windows XP SP3 > Python 2.5 > wx.version() = '2.8.1.1 (msw-unicode)' > -- > I have written the following *simplest* implementation of wx.timer I > can think of. No workie. I want an exception, a print statement, or > something. > > The wxpython demos all work

sqlite3 - adding tables and rows via parameters

2008-04-12 Thread Vlastimil Brom
Hi all, I would like to ask about the usage of sqlite3 in python, more specifically about a way to pass table or column names to a SQL commands using parameters. All examples I could find use the parameter substitution with "?" for values; is it possible the specify table and column names this way?

Re: sqlite3 - adding tables and rows via parameters

2008-04-12 Thread Vlastimil Brom
2008/4/12, Steve Holden <[EMAIL PROTECTED]>: > > Vlastimil Brom wrote: > > Hi all, > > I would like to ask about the usage of sqlite3 in python, more > > specifically about a way to pass table > > or column names to a SQL commands using parameters. > > &

Re: sqlite3 - adding tables and rows via parameters

2008-04-12 Thread Vlastimil Brom
2008/4/13, Steve Holden <[EMAIL PROTECTED]>: > > Vlastimil Brom wrote: > > > ... are there any (security > > ...) risks of using string interpolation for table and column names in > the SQL commands? Or > > are the values, where parametrization (with ? in

Re: list manipulation

2008-04-22 Thread Vlastimil Brom
2008/4/22, DataSmash <[EMAIL PROTECTED]>: > > Hello, > > I have a list that looks like this: > roadList = ["Motorways","Local","Arterial"] > > I want to apply some code so that the output looks like this: > "Motorways;Local;Arterial" > > ...in other words, I want each item in the list separated by

using sqlite3 - execute vs. executemany; committing ...

2008-05-03 Thread Vlastimil Brom
Hi all, I'd like to ask about some (probably elementary) things about the proper usage of sqlite3 in python (2.5.2; win). - Are there any peculiarities with using curs.executemany(...) vs. multiple curs.execute(...) ? I read a notice, sqlite3 does internally some caching, hence both should be simil

Re: using sqlite3 - execute vs. executemany; committing ...

2008-05-04 Thread Vlastimil Brom
> > > Thank you very much for your comprehensive answer and detailed informations, David; I really appreciate it! As for the number of items, there would be approx. 34 000 calls of execute() in my present code, in the final version probably more; I think executmany is more efficient here, if there

Re: using sqlite3 - execute vs. executemany; committing ...

2008-05-05 Thread Vlastimil Brom
> > > Thanks for further comments David, You are right, the choice of an appropriate data structure isn't easy; I described the requirements in an earlier post: http://mail.python.org/pipermail/python-list/2007-December/469506.html Here is a slightly modified sample of the text source I currently

Re: using sqlite3 - execute vs. executemany; committing ...

2008-05-06 Thread Vlastimil Brom
Hi David, thanks for your comments and hints, the proposed approach with a list of dicts lookup dict is indeed much faster, than my previous attempts with a database (even without psyco). I used a slightly different structure with sets of indices, since they should be unique anyway and the values a

Re: mxTexTools (Re: using sqlite3 - execute vs. executemany; committing ...)

2008-05-07 Thread Vlastimil Brom
2008/5/7, M.-A. Lemburg <[EMAIL PROTECTED]>: > > On 2008-05-07 00:07, Vlastimil Brom wrote: > > > Thanks for reminding me about > > the mxTextTools; I looked at this package very quickly several months > > ago and it seemed quite > > complex and heavy-weight,

Re: using sqlite3 - execute vs. executemany; committing ...

2008-05-07 Thread Vlastimil Brom
Hi David, thanks for your suggestions. The mentioned line of code is actually already a part of such a searching method, thus it is beeing called in a similar way you suggested, but anyhow it catched my eye ...; Thanks for the references to different markup systems, I haven't known many of them b

Re: like a "for loop" for a string

2008-08-17 Thread Vlastimil Brom
2008/8/17 Alexnb <[EMAIL PROTECTED]> > > Basically I want the code to be able to pick out how many strings there are > and then do something with each, or the number. When I say string I mean > how > many "strings" are in the string "string string string non-string string" > > Does that help? > >

Re: like a "for loop" for a string

2008-08-17 Thread Vlastimil Brom
2008/8/17 Alexnb <[EMAIL PROTECTED]> > > Uhm, "string" and "non-string" are just that, words within the string. Here > shall I dumb it down for you? > > > string = "yes text1 yes text2 yes text3 no text4 yes text5+more Text yes > text6 no text7 yes text8" > > It doesn't matter what is in the stri

Re: like a "for loop" for a string

2008-08-17 Thread Vlastimil Brom
Ok, after sending my post, I see, that the code got a bit screewed up, but morover, there should probably be a word boundary in the closing part of the regexp. A next attempt + added stripping the "yes" delimiter and the whitespace...: >>> import re >>> input_text = """yes text1 yes text2 yes text

Re: Sorting an array on the nth element in a list

2008-08-20 Thread Vlastimil Brom
2008/8/20 Ron Brennan <[EMAIL PROTECTED]> > > > Hello, > > I am trying to parse a log file. I want to sort based on the second > element the list that is in the file. > > What is the best way to do this? The sort is just on the line itself where > I want to re-organize the lines based on the sec

Re: Negative integers

2008-08-20 Thread Vlastimil Brom
2008/8/20 johnewing <[EMAIL PROTECTED]> > I am trying to figure out how to test if two numbers are of the same > sign (both positive or both negative). I have tried > > abs(x) / x == abs(y) / y > > but that fails when one of the numbers is 0. I'm sure that there is > an easy way to do this. Any

Re: Regular expressions question

2008-10-02 Thread Vlastimil Brom
2008/10/2 aditya shukla <[EMAIL PROTECTED]> > Hello folks , > > I trying to match a pattern in a string , i am new in using re .This is > what is happening > > When i do this > > p = re.compile('(\[&&NHX:)') > >>> m = p.match("[&&NHX:C=0.195.0]") > >>> print m > <_sre.SRE_Match object at 0x013FE1E

Re: Some Basic questions on the use of CTRL and ALT Keys

2009-11-28 Thread Vlastimil Brom
2009/11/28 joy99 : > On Nov 28, 2:22 pm, Lie Ryan wrote: >> On 11/28/2009 6:20 PM, joy99 wrote: >> >> > I was writing a transliteration program from Bengali to English and >> > vice versa. The program using Unicode chart is giving me perfect >> > outputs in Bengali and vice versa with Bengali inpu

Re: delete column content

2009-11-29 Thread Vlastimil Brom
2009/11/29 Francesco Pietra : > Hi: > How to replace with blank the single-character in column 21 of a pdb > file (in pdb numbering it is column 22). Attached is an incomplete > exercise with slices. I am unable to get real plain text with gmail. > > Thanks for help > > francesco pietra > > -- > ht

Re: a list/re problem

2009-12-11 Thread Vlastimil Brom
2009/12/11 Ed Keith : > I have a problem and I am trying to find a solution to it that is both > efficient and elegant. > > I have a list call it 'l': > > l = ['asc', '*nbh*', 'jlsdjfdk', 'ikjh', '*jkjsdfjasd*', 'rewr'] > > Notice that some of the items in the list start and end with an '*'. I wish

Re: How to iterate the input over a particular size?

2009-12-28 Thread Vlastimil Brom
2009/12/27 joy99 : > Dear Group, > Answers were good. But I am looking for a smarter solution like: > > for i[:2] in list: > > > etc. or by doing some looping over loop. > Do not worry I'll work out the answer. > > Wishing you a happy day ahead, > Regards, > Subhabrata. > -- > http://mail.pyt

Re: Writing a string.ishex function

2010-01-15 Thread Vlastimil Brom
2010/1/15 Duncan Booth : > MRAB wrote: > >> Duncan Booth wrote: >>> MRAB wrote: >>> I raise you one character: ishex2 = lambda s: not(set(s)-set(string.hexdigits))     # Yours ishex3 = lambda s: not set(s)-set(string.hexdigits)      # Mine I could actually go three b

Re: unicode text file

2009-09-27 Thread Vlastimil Brom
2009/9/27 Junaid : > 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") > > txt.replace{'English', ur'ഇംഗ്ലീഷ്') #replacing raw unicode string, > but not working > > f.write(txt) > f.close() >

Re: a splitting headache

2009-10-26 Thread Vlastimil Brom
2009/10/26 jhermann : > On 16 Okt., 02:18, Mensanator wrote: >> All I wanted to do is split a binary number into two lists, >> a list of blocks of consecutive ones and another list of >> blocks of consecutive zeroes. > > Back to the OP's problem, the obvious (if you know the std lib) and > easy so

Re: The ol' [[]] * 500 bug...

2009-11-14 Thread Vlastimil Brom
2009/11/14 Brian J Mingus : > > > On Sat, Nov 14, 2009 at 1:50 AM, Paul Rubin > wrote: >> >> kj writes: >> >   lol = [None] * 500 >> >   for i in xrange(len(lol)): >> >       lol[i] = [] >> >> lol = map(list, [()] * 500) > > Could someone explain what the deal is wit

Re: Converting a float to a formatted outside of print command

2009-11-23 Thread Vlastimil Brom
2009/11/23 stephen_b : > I'd like to convert a list of floats to formatted strings. The > following example raises a TypeError: > > y = 0.5 > x = '.1f' % y > -- > http://mail.python.org/mailman/listinfo/python-list Maybe '%.1f' % y ? hth vbr -- http://mail.python.org/mailman/listinfo/python-lis

Re: reposition a column

2009-11-25 Thread Vlastimil Brom
2009/11/25 Francesco Pietra : > Hi: > > In a pdb file made of lines "ATOM .." (see attachment as I was unable > to obtain plain text with gmail) I would like to reposition the second > "W" from column 19 to 17 ( (Python numbering; in pdb numbering it > would be 20 18). I started with bold slices, t

Re: Iterating over a function call

2010-02-01 Thread Vlastimil Brom
2010/2/1 Gerald Britton : > Hi -- I have many sections of code like this: > >    for value in value_iterator: >         value_function(value) > > I noticed that this does two things I don't like: >... > -- > Gerald Britton > -- > http://mail.python.org/mailman/listinfo/python-list > Hi, just to ad

Re: string to list when the contents is a list

2010-02-17 Thread Vlastimil Brom
2010/2/18 Wes James : > I have been trying to create a list form a string.  The string will be > a list (this is the contents will look like a list).  i.e. "[]" or > "['a','b']" > > The "[]" is simple since I can just check if value == "[]" then return [] > > But with "['a','b']" I have tried and g

Re: comparing two lists

2010-03-05 Thread Vlastimil Brom
2010/3/5 jimgardener : > hi > I have two lists of names.I need to find the difference between these > two lists.I tried to do it using sets.But I am wondering if there is a > better way to do it.Please tell me if there is a more elegant way. > thanks, > jim > > my code snippet follows.. > > oldlst=

negative "counts" in collections.Counter?

2010-03-07 Thread Vlastimil Brom
Hi all, I'd like to ask about the possibility of negative "counts" in collections.Counter (using Python 3.1); I believe, my usecase is rather trivial, basically I have the word frequencies of two texts and I want do compare them (e.g. to see what was added and removed between different versions of

Re: negative "counts" in collections.Counter?

2010-03-08 Thread Vlastimil Brom
2010/3/8 Raymond Hettinger : > On Mar 7, 5:46 pm, Steven D'Aprano cybersource.com.au> wrote: >> Given that Counter supports negative counts, it looks to me that the >> behaviour of __add__ and __sub__ is fundamentally flawed. You should >> raise a bug report (feature enhancement) on the bug tracke

Re: negative "counts" in collections.Counter?

2010-03-08 Thread Vlastimil Brom
2010/3/8 Raymond Hettinger : ... [snip detailed explanations] >... > In this case, we have an indication that what you really want is > a separate class supporting elementwise binary and unary operations > on vectors (where the vector fields are accessed by a dictionary > key instead of a positiona

Re: Is it possible to use re2 from Python?

2010-03-14 Thread Vlastimil Brom
2010/3/14 _wolf : >... > i would like to use re2 from Python (preferrably Python 3.1) and was > excited to see files like make_unicode_groups.py in the distro (maybe > just used during the build process?). those however were not deployed > on my machine. >... > If you would need a re engine with f

individually updating unicodedata db?

2010-03-22 Thread Vlastimil Brom
Hi all, I just tried to find some information about the unicodedata database and the possibilities of updating it to the latest version of the unicode standards (currently 5.2, while python supports 5.1 in the latest versions). An option to update this database individually might be useful as the u

Re: individually updating unicodedata db?

2010-03-23 Thread Vlastimil Brom
2010/3/23 Gabriel Genellina : > En Mon, 22 Mar 2010 21:19:04 -0300, Vlastimil Brom > escribió: > >> I guess, I am stuck here, as I use the precompiled version supplied in >> the windows installer and can't compile python from source to obtain >> the needed unicod

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

2010-11-19 Thread Vlastimil Brom
able to provide a patch, mainly because of unicodadate being C code. A while ago I considered writing some unicodedata enhancements in python, which would support the ranges and script names, full category names etc., but sofar the direct programatic lookups in the online unicode docs and with som

Re: Using Python for a demonstration in historical linguistics

2010-11-27 Thread Vlastimil Brom
2010/11/27 Dax Bloom : > On Nov 6, 6:41 am, Vlastimil Brom wrote: >> 2010/11/6 Dax Bloom : >> ... >> Rask_Grimm_re = ur"[bdgptk]ʰ?" >> Rask_Grimm_dct = {u"b":u"p", u"bʰ": u"b", u"t": u"þ", } #

<    1   2   3   >