Re: GUI apps in Windows with native widgets?

2007-06-19 Thread vbr

> 
> From: Gilles Ganault <[EMAIL PROTECTED]>
> Subj: GUI apps in Windows with native widgets?
> Date: 19.6.2007 04:15:55
> 
> Hello
> 
>   I'd like to write a GUI app in Python exclusively for Windows.
> Apparently, development of PythonWin has stopped a long time ago.
> 
> Is there another thin wrapper to write apps in Windows? I'd rather not
> have to ship eg. WxWidgets, GTK+, or QT.
> 
> Thank you.
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 
> 
> 

Hello,
I haven't tried it myself in a real application (while using wxpython), but 
Venster seems to be much more lightweight than some other more popular GUI 
toolkits; it also supports only Windows. You may check it here:

http://venster.sourceforge.net/htdocs/index.html

The most important thing would be to determine, if it suits your needs (e.g. 
the supported widgets, methods etc.) 


Greetings,
Vlastimil Brom
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Reversing a string

2007-06-27 Thread vbr

>  Původní zpráva 
> Od: Will Maier <[EMAIL PROTECTED]>
> Předmět: Re: Reversing a string
> Datum: 27.6.2007 19:08:40
> 
> On Wed, Jun 27, 2007 at 12:53:36PM -0400, Scott wrote:
> > So how on earth would be the best way to: Write a function that
> > takes a string as an argument and outputs the letters backward,
> > one per line.
> 
> >>> def rev(forward):
> ... backward = list(forward)
> ... backward.reverse()
> ... return ''.join(backward)
> >>> rev("spam")
> 'maps'
> 
> list.reverse() changes the list in-place. Instead of iterating over
> the items in the string sequence, you can just convert the input
> string outright.
> 
> -- 
> 
> [Will [EMAIL PROTECTED]|http://www.lfod.us/]
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 
> 
> 

Or using string slice with negative step?

>>> "spam"[::-1]
'maps'

or one letter per line:

>>> print "\n".join("spam"[::-1])
m
a
p
s


Greetings,

Vlastimil Brom
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: unicode data - accessing codepoints > FFFF on narrow python builts

2007-04-18 Thread vbr
Hi, thanks for the answer,

> From: Gabriel Genellina <[EMAIL PROTECTED]>
> Subj: Re: unicode data - accessing codepoints >  on narrow python builts
> Datum: 18.4.2007 21:33:11
> 
> 
> py> x=u"\N{GOTHIC LETTER AHSA}"
> py> ord(x)
> Traceback (most recent call last):
>File "", line 1, in 
> TypeError: ord() expected a character, but string of length 2 found
> py> unicodedata.name(x)
> Traceback (most recent call last):
>File "", line 1, in 
> TypeError: need a single Unicode character as parameter
> py> len(x)
> 2
> py> list(x)
> [u'\ud800', u'\udf30']

> 
> That looks like UTF-16 (?) but seen as two characters instead of one.
> Probably in a 32bits build Python should refuse to use such character (and  
> limit Unicode support to the basic plane?) (or not?) (if not, what's the  
> point of sys.maxunicode?) (enough parenthesis for now).
> 

> -- 
> Gabriel Genellina
> 


Yes, this is a UTF-16 surrogate pair, which is, as far as I know the usual way 
the characters outside the basic plane are handled on narrow python builds. 
There are some problems with it, but most things (I need) with non-basic plane 
characters can be done this way (GUI display, utf-8 text saving) - thus I 
wouldn't be happy, if this support were removed.
The problem is the access to unicodedata, which requires "a string of length 
1"; I thought, it could also accept the codepoint number, but it doesn't seem 
to be possible.
Thanks again.


vbr - Vlastimil Brom
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: unicode data - accessing codepoints > FFFF on narrow python builts

2007-04-18 Thread vbr
Hi, thanks for your answer,
I'll try to check the source of unicodedata;
Using the wide Unicode build seems to be a kind of overkill for now, as for the 
vast majority of my uses, the BMP is enough. I was rather looking for some 
"lower-cost" alternatives for those rare cases, when I need higher multilingual 
planes.

Thanks again,

Vlastimil Brom
 - vbr

> From: "Martin v. Löwis" <[EMAIL PROTECTED]>
> Subj.: Re: unicode data - accessing codepoints >  on narrow python builts
> Datum: 18.4.2007 21:37:39
> 
> > Is it a bug in unicodedata, or is this the expected behaviour on a
> > narrow build?
> 
> It's a bug. It should either raise an exception, or return the correct
> result. If you know feel like submitting a bug report: please try to
> come up with a patch instead.
> 
> > Another problem I have is to access the "characters" and their
> > properties by the respective codepoints: under  it is possible,
> > to use unichr(), which isn't valid for higher valules on a narrow
> > build It is possible to derive the codepoint from the surrogate pair,
> > which would be usable also for wider codepoints.
> 
> See PEP 261. This is by design.
> 
> > Currently, I'm using a kind of parallel database for some unicode
> > ranges above , but I don't think, this is the most effective way.
> 
> Just use a wide Unicode build instead.
> 
> Regards,
> Martin
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 
> 
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: multiline regular expression (replace)

2007-05-29 Thread vbr

> Od: Zdenek Maxa <[EMAIL PROTECTED]>
> Předmět: Re: multiline regular expression (replace)
> Datum: 29.5.2007 13:46:32
> 
> [EMAIL PROTECTED] wrote:
> > On May 29, 2:03 am, Zdenek Maxa <[EMAIL PROTECTED]> wrote:
> >   
> >> Hi all,
> >>
> >> I would like to perform regular expression replace (e.g. removing
> >> everything from within tags in a XML file) with multiple-line pattern.
> >> How can I do this?
> >>
> >> where = open("filename").read()
> >> multilinePattern = "^  <\/tag>$"
> >> re.search(multilinePattern, where, re.MULTILINE)
> >>
> >> Thanks greatly,
> >> Zdenek
> >> 
> >
> > Why not use an xml package for working with xml files?  I'm sure
> > they'll handle your multiline tags.
> >
> > http://effbot.org/zone/element-index.htm
> > http://codespeak.net/lxml/
> >
> > ~Sean
> >
> >   
> 
> Hi,
> 
> that was merely an example of what I would like to achieve. However, in 
> general, is there a way for handling multiline regular expressions in 
> Python, using presumably only modules from distribution like re?
> 
> Thanks,
> Zdenek
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 
> 
> 
There shouldn't be any problems matching multiline strings using re (even 
without flags), there might be some problem with the search pattern, however, 
especially the "..." part :-) if you are in fact using dots - which don't 
include newlines in this pattern.

the flag re.M only changes the behaviour of ^ and $ metacharacters, cf. the 
docs:
re.M
MULTILINE
When specified, the pattern character "^" matches at the beginning of the 
string and at the beginning of each line (immediately following each newline); 
and the pattern character "$" matches at the end of the string and at the end 
of each line (immediately preceding each newline). By default, "^" matches only 
at the beginning of the string, and "$" only at the end of the string and 
immediately before the newline (if any) at the end of the string. 

you may also check the S flag:
re.S
DOTALL
Make the "." special character match any character at all, including a newline; 
without this flag, "." will match anything except a newline.


see 
http://docs.python.org/lib/node46.html
http://docs.python.org/lib/re-syntax.html

Vlasta

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Use variable in regular expression

2007-08-02 Thread vbr
...
> Yesterday's date is 20070731, and assigned to the variable
> "yesterday_date". I want to loop thru a directory and find all of the
> yesterday's data ONLY IF the feature class has the date at the
> BEGINNING of the filename.
...
> I can't figure out the
> syntax of inserting the "^" into the regex. 
> 
...
e.g.

yesterdayRE = re.compile("^"+yesterday_date)
...
should work (assuming yesterday_date is a string), but for that simple tests 
you may also try e.g.

filename.startswith(yesterday_date)

(with both filename and yesterday_date being strings).

Greetings,
   Vlasta

-- 
http://mail.python.org/mailman/listinfo/python-list


unicode data - accessing codepoints > FFFF on narrow python builts

2007-04-18 Thread vbr
Hi all,
I'd like to ask about the usage of unicode data on a narrow python build.
Unicode string literals \N{name} work even without the (explicit) import of 
unicodedata and it correctly handles also the  "wider" unicodes planes - over 


>>>  u"\N{LATIN SMALL LETTER E}"
u'e'
>>>  u"\N{GOTHIC LETTER AHSA}"
u'\U00010330'

The unicode data functions works analogous in the basic plane, but behave 
differently otherwise:

>>>  unicodedata.lookup("LATIN SMALL LETTER E")
u'e'
>>> unicodedata.lookup("GOTHIC LETTER AHSA")
u'\u0330'

(0001 gets trimmed)

Is it a bug in unicodedata, or is this the expected behaviour on a narrow build?

Another problem I have is to access the "characters" and their properties by 
the respective codepoints:
under  it is possible, to use unichr(), which isn't valid for higher 
valules on a narrow build
It is possible to derive the codepoint from the surrogate pair, which would be 
usable also for wider codepoints.

Currently, I'm using a kind of parallel database for some unicode ranges above 
, but I don't think, this is the most effective way.
I actually found something similar at http: / / 
inamidst.com/phenny/modules/codepoint.py  using directly the UnicodeData.txt;

but I was wondering, If there is a simpler way for doing that; it seems 
obvious, that the data are present, if it could be used for constucting unicode 
literals.

Any hints are welcome,   thanks.

vbr
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Combinate 2 lists to a dict ?

2007-04-18 Thread vbr

> Hi all.
> 
>  I have 2 lists,
>  a = [1,2,3]
>  b = ["ooo","aaa","ppp"]
> 
>  What is the fastest way to make a dict like {1:"ooo",2:"aaa",
> 3:"ppp"} ?
> 
> Thanx

>>> dict(zip(a,b))
{1: 'ooo', 2: 'aaa', 3: 'ppp'}

works for me, but not sure, if it is the fastest way; a, b have to be of the 
same length, otherwise the shorter is used.

vbr
-- 
http://mail.python.org/mailman/listinfo/python-list