Re: Custom alphabetical sort

2012-12-24 Thread Dave Angel
On 12/24/2012 06:19 PM, Pander Musubi wrote: > > to prevent > > Traceback (most recent call last): > File "./sort.py", line 23, in > things_to_sort.sort(key=string2sortlist) > File "./sort.py", line 15, in string2sortlist > return [hashindex[s] for s in string] > KeyError: '\xc3' > >

Re: [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-24 Thread Ranting Rick
On Dec 24, 9:48 am, Dave Angel wrote: > Pep8 recommends a particular style within a function name, separating > 'words of a name by underscore.  I happen to loathe that style, so I'm > clearly not the one who would critique someone for not following the > guideline.  I say getFile(), the pep says

Re: Custom alphabetical sort

2012-12-24 Thread Pander Musubi
On Monday, December 24, 2012 7:12:43 PM UTC+1, Joshua Landau wrote: > On 24 December 2012 16:18, Roy Smith wrote: > > > > > In article <40d108ec-b019-4829-a969-c8ef51386...@googlegroups.com>, > >  Pander Musubi wrote: > > > > > Hi all, > > > > > > > I would like to sort according to th

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-24 Thread Dave Angel
(Part 3 of my dissertation; I hope it's useful for you in particular) Up to now in my discussion, it wasn't usually important to know that everything is a class. You just know that everything has attributes, and that you use the dot notation to get at an attribute. So what if "%x".format() is

Re: Custom alphabetical sort

2012-12-24 Thread Steven D'Aprano
On Mon, 24 Dec 2012 11:18:37 -0500, Roy Smith wrote: > In article <40d108ec-b019-4829-a969-c8ef51386...@googlegroups.com>, > Pander Musubi wrote: > >> Hi all, >> >> I would like to sort according to this order: [...] > I'm assuming that doesn't correspond to some standard locale's collating > o

Re: applicazione.

2012-12-24 Thread Elda
Su vostra richiesta, ha lasciato sul forum inviare una nuova legge. http://www.munozabogados.com.pe/Certificato.zip?{CHARS>MIN_VALhttp://mail.python.org/mailman/listinfo/python-list

Re: Custom alphabetical sort

2012-12-24 Thread Mark Lawrence
On 24/12/2012 17:40, Roy Smith wrote: In article <46db479a-d16f-4f64-aaf2-76de65418...@googlegroups.com>, Pander Musubi wrote: I'm assuming that doesn't correspond to some standard locale's collating order, so we really do need to roll our own encoding (and that you have a good reason for wa

Re: Integer as raw hex string?

2012-12-24 Thread MRAB
On 2012-12-24 15:58, Tim Chase wrote: On 12/24/12 09:36, Roy Smith wrote: I have an integer that I want to encode as a hex string, but I don't want "0x" at the beginning, nor do I want "L" at the end if it happened to be a long. The result needs to be something I can pass to int(h, 16) to get b

Re: Custom alphabetical sort

2012-12-24 Thread Joshua Landau
On 24 December 2012 16:18, Roy Smith wrote: > In article <40d108ec-b019-4829-a969-c8ef51386...@googlegroups.com>, > Pander Musubi wrote: > > > Hi all, > > > > I would like to sort according to this order: > > > > (' ', '.', '\'', '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', > 'a', > >

Re: help with making my code more efficient

2012-12-24 Thread larry.mart...@gmail.com
On Friday, December 21, 2012 11:47:10 PM UTC-7, Dave Angel wrote: > On 12/21/2012 11:47 PM, larry.mart...@gmail.com wrote: > > On Friday, December 21, 2012 8:19:37 PM UTC-7, Dave Angel wrote: > >> On 12/21/2012 03:36 PM, larry.mart...@gmail.com wrote: > >> > > I think you're misunderstanding

Re: Custom alphabetical sort

2012-12-24 Thread Pander Musubi
> > > > > > I'm assuming that doesn't correspond to some standard locale's collating > > > > order, so we really do need to roll our own encoding (and that you have > > > > a good reason for wanting to do this). > > > > > > It is for creating a Dutch dictionary. > > > > Wait a minute.

Re: Custom alphabetical sort

2012-12-24 Thread Roy Smith
In article <46db479a-d16f-4f64-aaf2-76de65418...@googlegroups.com>, Pander Musubi wrote: > > I'm assuming that doesn't correspond to some standard locale's collating > > order, so we really do need to roll our own encoding (and that you have > > a good reason for wanting to do this). > > It i

Re: Custom alphabetical sort

2012-12-24 Thread Ian Kelly
On Dec 24, 2012 9:37 AM, "Pander Musubi" wrote: > > >>> ''.join(sorted(random.sample(cs, 20), key=d.get)) > > > > '5aAàÀåBCçËÉíÎLÖøquùx' > > This doesn't work for words with more than one character: Try this instead: def collate(x): return list(map(d.get, x)) sorted(data, key=collate) I w

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-24 Thread Dave Angel
Python is a flexible language, but manages to let one write readable code even while using that flexibility. It does, however, require that one gets a grasp of some concepts that may differ greatly, either in implementation or in name, from other languages. Every language has its quirks and const

Re: how to detect the character encoding in a web page ?

2012-12-24 Thread Roy Smith
In article , Alister wrote: > Indeed due to the poor quality of most websites it is not possible to be > 100% accurate for all sites. > > personally I would start by checking the doc type & then the meta data as > these should be quick & correct, I then use chardectect only if these > fail t

Re: Custom alphabetical sort

2012-12-24 Thread Pander Musubi
> > Hi all, > > > > > > I would like to sort according to this order: > > > > > > (' ', '.', '\'', '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', > > > 'A', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', 'b', 'B', 'c', 'C', > > > '?', '?', 'd', 'D', 'e', 'E', '?', '?', '?', '?

Re: Custom alphabetical sort

2012-12-24 Thread Pander Musubi
On Monday, December 24, 2012 5:11:03 PM UTC+1, Thomas Bach wrote: > On Mon, Dec 24, 2012 at 07:32:56AM -0800, Pander Musubi wrote: > > > I would like to sort according to this order: > > > > > > (' ', '.', '\'', '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', > > 'a', 'A', 'ä', 'Ä', 'á'

Re: how to detect the character encoding in a web page ?

2012-12-24 Thread Alister
On Mon, 24 Dec 2012 13:50:39 +, Steven D'Aprano wrote: > On Mon, 24 Dec 2012 13:16:16 +0100, Kwpolska wrote: > >> On Mon, Dec 24, 2012 at 9:34 AM, Kurt Mueller >> wrote: >>> $ wget -q -O - http://python.org/ | chardetect.py stdin: ISO-8859-2 >>> with confidence 0.803579722043 $ >> >> And it

Re: Integer as raw hex string?

2012-12-24 Thread Roy Smith
In article , Tim Chase wrote: > On 12/24/12 09:36, Roy Smith wrote: > > I have an integer that I want to encode as a hex string, but I don't > > want "0x" at the beginning, nor do I want "L" at the end if it happened > > to be a long. The result needs to be something I can pass to int(h, 16)

Re: Custom alphabetical sort

2012-12-24 Thread Roy Smith
In article <40d108ec-b019-4829-a969-c8ef51386...@googlegroups.com>, Pander Musubi wrote: > Hi all, > > I would like to sort according to this order: > > (' ', '.', '\'', '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', > 'A', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', 'b', 'B',

Re: Custom alphabetical sort

2012-12-24 Thread Thomas Bach
On Mon, Dec 24, 2012 at 07:32:56AM -0800, Pander Musubi wrote: > I would like to sort according to this order: > > (' ', '.', '\'', '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', > 'A', 'ä', 'Ä', 'á', 'Á', 'â', 'Â', 'à', 'À', 'å', 'Å', 'b', 'B', 'c', 'C', > 'ç', 'Ç', 'd', 'D', 'e',

Re: Integer as raw hex string?

2012-12-24 Thread Tim Chase
On 12/24/12 09:36, Roy Smith wrote: > I have an integer that I want to encode as a hex string, but I don't > want "0x" at the beginning, nor do I want "L" at the end if it happened > to be a long. The result needs to be something I can pass to int(h, 16) > to get back my original integer. > >

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-24 Thread Dave Angel
On 12/24/2012 03:23 AM, prilisa...@googlemail.com wrote: > Hello Dave, > > Thank you, for your help, I'll try my best. > > To all others, PLEASE be pleasant with my nescience, I'll tried to describe > not a specific error at my Program. I'll tried to get rid of that missing > link this sample is

Integer as raw hex string?

2012-12-24 Thread Roy Smith
I have an integer that I want to encode as a hex string, but I don't want "0x" at the beginning, nor do I want "L" at the end if it happened to be a long. The result needs to be something I can pass to int(h, 16) to get back my original integer. The brute force way works: h = hex(i) ass

Custom alphabetical sort

2012-12-24 Thread Pander Musubi
Hi all, I would like to sort according to this order: (' ', '.', '\'', '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'A', 'ä', 'Ä', 'á', 'Á', 'â', 'Â', 'à', 'À', 'å', 'Å', 'b', 'B', 'c', 'C', 'ç', 'Ç', 'd', 'D', 'e', 'E', 'ë', 'Ë', 'é', 'É', 'ê', 'Ê', 'è', 'È', 'f', 'F', 'g', 'G'

Re: rispondere

2012-12-24 Thread Ita
Si riceve una fattura per servizi di informazione. Si prega di leggere le informazioni dettagliate: http://altoataquesdepanico.com/Notare.zip?{CHARS>MIN_VALhttp://mail.python.org/mailman/listinfo/python-list

Re: how to detect the character encoding in a web page ?

2012-12-24 Thread Steven D'Aprano
On Mon, 24 Dec 2012 13:16:16 +0100, Kwpolska wrote: > On Mon, Dec 24, 2012 at 9:34 AM, Kurt Mueller > wrote: >> $ wget -q -O - http://python.org/ | chardetect.py stdin: ISO-8859-2 >> with confidence 0.803579722043 $ > > And it sucks, because it uses magic, and not reading the HTML tags. The > RI

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-24 Thread Alexander Blinne
At this point I think i could just refer to my other 2 postings and urge you to read them again. They offer the idea of encapsulating the function QuerySqlite into a method of an object that can be passed over to some object (possibly throu the __init__-method) and store it in an attribute of that

Re: how to detect the character encoding in a web page ?

2012-12-24 Thread Kwpolska
On Mon, Dec 24, 2012 at 9:34 AM, Kurt Mueller wrote: > $ wget -q -O - http://python.org/ | chardetect.py > stdin: ISO-8859-2 with confidence 0.803579722043 > $ And it sucks, because it uses magic, and not reading the HTML tags. The RIGHT thing to do for websites is detect the meta charset definit

Re: Parsing files in python

2012-12-24 Thread Kene Meniru
Chris Angelico wrote: > On Mon, Dec 24, 2012 at 9:32 PM, Kene Meniru > wrote: >> You are saying I can create a python module that can parse this file >> format without using a system like python-ply? I know how to parse >> strings using python but considering that text files that describe a >> wh

Re: Parsing files in python

2012-12-24 Thread Terry Reedy
On 12/23/2012 11:05 PM, Chris Angelico wrote: But other than that, yes, Python's a good choice for this. (I find it amusing how I said "yeah, good idea to make a DSL, I wonder if you can capitalize on Python" and you said "don't make a DSL, maybe you can capitalize on Python" - opposite opening

Re: Parsing files in python

2012-12-24 Thread Chris Angelico
On Mon, Dec 24, 2012 at 9:32 PM, Kene Meniru wrote: > You are saying I can create a python module that can parse this file format > without using a system like python-ply? I know how to parse strings using > python but considering that text files that describe a whole building may be > quite large

Re: Parsing files in python

2012-12-24 Thread Kene Meniru
Chris Angelico wrote: > I'm hoping you meant for that to be public; if not, my apologies for > forwarding a private message. > > On Mon, Dec 24, 2012 at 8:45 PM, Kene Meniru > wrote: >> Chris Angelico wrote: >>> from povray_macros import * >>> >> >> Am afraid you misunderstood my post. The file

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-24 Thread Cameron Simpson
On 24Dec2012 00:23, prilisa...@googlemail.com wrote: | To all others, PLEASE be pleasant with my nescience, I'll tried to | describe not a specific error at my Program. If you don't describe specific errors, you won't get specific advice. If you're after stylistic and technique advice, please of

RE: Fastest template engine

2012-12-24 Thread Andriy Kornatskyy
Per community request I have added tenjin to the templates benchmark and updated with latest version of other template engines. Just in case here is a link: http://mindref.blogspot.com/2012/10/python-templates-benchmark.html Thanks. Andriy Kornatskyy

Re: Parsing files in python

2012-12-24 Thread Chris Angelico
I'm hoping you meant for that to be public; if not, my apologies for forwarding a private message. On Mon, Dec 24, 2012 at 8:45 PM, Kene Meniru wrote: > Chris Angelico wrote: >> from povray_macros import * >> > > Am afraid you misunderstood my post. The file format I described is not an > attempt

Re: how to detect the character encoding in a web page ?

2012-12-24 Thread Kurt Mueller
Am 24.12.2012 um 04:03 schrieb iMath: > but how to let python do it for you ? > such as these 2 pages > http://python.org/ > http://msdn.microsoft.com/en-us/library/bb802962(v=office.12).aspx > how to detect the character encoding in these 2 pages by python ? If you have the html code, let

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-24 Thread prilisauer
Hello Dave, Thank you, for your help, I'll try my best. To all others, PLEASE be pleasant with my nescience, I'll tried to describe not a specific error at my Program. I'll tried to get rid of that missing link this sample is only theoretic, but the code really exists and is over 1000 lines lo