Re: RUN ALL TEST

2013-10-30 Thread Ben Finney
Chandru Rajendran  writes:

> Hi all,

Welcome!

Please remove the mass of legalese nonsense (this is a public discussion
forum, your message is clearly not confidential), or use a mail system
which does not add that when discussing here.

> I am building my script. I want to run all the test scripts.

What version of Python are you using?

Test discovery is now a part of the standard library ‘unittest’ module
http://docs.python.org/3/library/unittest.html#unittest-test-discovery>.

If you are using Python earlier than version 2.7, you can use a
third-party module for adding test discovery to the standard test runner
https://pypi.python.org/pypi/unittest2>.

> Currently I am running the code "python setup.py test"

That invokes whatever the ‘setup.py’ defines as the test suite and
runner. You'll need to change that in order to get it to run the tests
differently.

-- 
 \“I used to work in a fire hydrant factory. You couldn't park |
  `\  anywhere near the place.” —Steven Wright |
_o__)  |
Ben Finney

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


Re: personal library

2013-10-30 Thread Paul Rudin
Chris Angelico  writes:

> On Wed, Oct 30, 2013 at 1:00 PM, Dave Angel  wrote:
>> First, I haven't seen any mention of a source control system.  Get one,
>> learn it, and use it.  That should always hold your master copy.  And
>> the actual repository should be on a system you can access from any of
>> the others.
>>
>> Then, once you can get to such a repository, you use it to sync your
>> various local copies on your individual machines.  You could have the
>> synch happen automatically once a day, or whatever.  You could also
>> build an auto-synch utility which pushed the synch from the server
>> whenever the server was updated.
>>
>> If you're always going to be using these machines with real-time access
>> to the central server, you could use Windows shares to avoid needing any
>> updates.  Just create a share on the server, and mount it on each of the
>> clients.  Add it to your system.path and you're done.
>
> I don't know about Mercurial, but with git it's pretty easy to set up
> a post-push hook that gets run whenever new changes hit the server.
>>From there, you could have some registered replicas that get
> immediately told to pull, which will give fairly immediate
> replication. It's not actually real-time, but you have a guarantee
> that they're up-to-date - if any change gets missed, it'll be caught
> in the next update. It'd take a little work to set up, but you could
> have something almost as convenient as shared folders but without the
> messes and risks.
>
> *Definitely* use source control.
>

Indeed. Also note that there's nothing per se wrong with putting your
repositories on Dropbox or similar - especially in a single user
situation. I do this so as to keep things synced across different
machines. You don't always want to check stuff in as you move from
e.g. laptop to desktop, but you do want to be able to pick up where you
left off on the other machine.


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


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread Tim Roberts
[email protected] wrote:
>
>Why did Python not implement end... The end is really not necessary for
>the programming language it can be excluded, but it is a courtesy to
>the programmer and could easily be transformed to indents automaticly,
>that is removed before the compiliation/interpretation of code.  

You only say that because your brain has been poisoned by languages that
require some kind of "end".  It's not necessary, and it's extra typing. 99%
of programmers do the indentation anyway, to make the program easy to read,
so why not just make it part of the syntax?  That way, you don't
accidentally have the indentation not match the syntax.
-- 
Tim Roberts, [email protected]
Providenza & Boekelheide, Inc.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Using "with open(filename, 'ab'):" and calling code only if the file is new?

2013-10-30 Thread Antoon Pardon
Op 30-10-13 02:02, Victor Hooi schreef:
> Hi,
> 
> I have a CSV file that I will repeatedly appending to.
> 
> I'm using the following to open the file:
> 
> with open(self.full_path, 'r') as input, open(self.output_csv, 'ab') as 
> output:
> fieldnames = (...)
> csv_writer = DictWriter(output, filednames)
> # Call csv_writer.writeheader() if file is new.
> csv_writer.writerows(my_dict)
> 
> I'm wondering what's the best way of calling writeheader() only if the file 
> is new?

If you are using 3.3 you could use something like this:

with open(self.full_path, 'r') as input:
try:
output = open(self.output_csv, 'abx')
new_file = True
except FileExistsError:
output = open(self.output_csv, 'ab')
new_file = False
fieldnames = (...)
csv_writer = DictWriter(output, filednames)
if new_file:
csv_writer.writeheader()
csv_writer.writerows(my_dict)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: trying to strip out non ascii.. or rather convert non ascii

2013-10-30 Thread wxjmfauth
Le mercredi 30 octobre 2013 03:17:21 UTC+1, Chris Angelico a écrit :
> On Wed, Oct 30, 2013 at 2:56 AM, Mark Lawrence  
> wrote:
> 
> > You've stated above that logically unicode is badly handled by the fsr.  You
> 
> > then provide a trivial timing example.  WTF???
> 
> 
> 
> His idea of bad handling is "oh how terrible, ASCII and BMP have
> 
> optimizations". He hates the idea that it could be better in some
> 
> areas instead of even timings all along. But the FSR actually has some
> 
> distinct benefits even in the areas he's citing - watch this:
> 
> 
> 
> >>> import timeit
> 
> >>> timeit.timeit("a = 'hundred'; 'x' in a")
> 
> 0.3625614428649451
> 
> >>> timeit.timeit("a = 'hundreij'; 'x' in a")
> 
> 0.6753936603674484
> 
> >>> timeit.timeit("a = 'hundred'; 'ģ' in a")
> 
> 0.25663261671525106
> 
> >>> timeit.timeit("a = 'hundreij'; 'ģ' in a")
> 
> 0.3582399439035271
> 
> 
> 
> The first two examples are his examples done on my computer, so you
> 
> can see how all four figures compare. Note how testing for the
> 
> presence of a non-Latin1 character in an 8-bit string is very fast.
> 
> Same goes for testing for non-BMP character in a 16-bit string. The
> 
> difference gets even larger if the string is longer:
> 
> 
> 
> >>> timeit.timeit("a = 'hundred'*1000; 'x' in a")
> 
> 10.083378194714726
> 
> >>> timeit.timeit("a = 'hundreij'*1000; 'x' in a")
> 
> 18.656413035735
> 
> >>> timeit.timeit("a = 'hundreij'*1000; 'ģ' in a")
> 
> 18.436268855399135
> 
> >>> timeit.timeit("a = 'hundred'*1000; 'ģ' in a")
> 
> 2.8308718007456264
> 
> 
> 
> Wow! The FSR speeds up searches immensely! It's obviously the best
> 
> thing since sliced bread!
> 
> 
> 
> ChrisA

-


It is not obvious to make comparaisons with all these
methods and characters (lookup depending on the position
in the table, ...). The only think that can be done and
observed is the tendency between the subsets the FSR
artificially creates.
One can use the best algotithms to adjust bytes, it is
very hard to escape from the fact that if one manipulates
two strings with different internal representations, it
is necessary to find a way to have a "common internal
coding " prior manipulations.
It seems to me that this FSR, with its "negative logic"
is always attempting to "optimize" with the worst
case instead of "optimizing" with the best case.
This kind of effect is shining on the memory side.
Compare utf-8, which has a memory optimization on
a per code point basis with the FSR which has an
optimization based on subsets (One of its purpose).

>>> # FSR
>>> sys.getsizeof( ('a'*1000) + 'z')
1026
>>> sys.getsizeof( ('a'*1000) + '€')
2040
>>> # utf-8
>>> sys.getsizeof( (('a'*1000) + 'z').encode('utf-8'))
1018
>>> sys.getsizeof( (('a'*1000) + '€').encode('utf-8'))
1020

jmf

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


Re: trying to strip out non ascii.. or rather convert non ascii

2013-10-30 Thread wxjmfauth
Le mardi 29 octobre 2013 06:24:50 UTC+1, Steven D'Aprano a écrit :
> On Mon, 28 Oct 2013 09:23:41 -0500, Tim Chase wrote:
> 
> 
> 
> > On 2013-10-28 07:01, [email protected] wrote:
> 
> >>> Simply ignoring diactrics won't get you very far.
> 
> >> 
> 
> >> Right. As an example, these four French words : cote, côte, coté, côté
> 
> >> .
> 
> > 
> 
> > Distinct words with distinct meanings, sure.
> 
> > 
> 
> > But when a naïve (naive? ☺) person or one without the easy ability to
> 
> > enter characters with diacritics searches for "cote", I want to return
> 
> > possible matches containing any of your 4 examples.  It's slightly
> 
> > fuzzier if they search for "coté", in which case they may mean "coté" or
> 
> > they might mean be unable to figure out how to add a hat and want to
> 
> > type "côté". Though I'd rather get more results, even if it has some
> 
> > that only match fuzzily.
> 
> 
> 
> The right solution to that is to treat it no differently from other fuzzy 
> 
> searches. A good search engine should be tolerant of spelling errors and 
> 
> alternative spellings for any letter, not just those with diacritics. 
> 
> Ideally, a good search engine would successfully match all three of 
> 
> "naïve", "naive" and "niave", and it shouldn't rely on special handling 
> 
> of diacritics.
> 
> 
> 
--

This is a non sense. The purpose of a diacritical mark is to
make a letter a different letter. If a tool is supposed to
match an ô, there is absolutely no reason to match something
else.

jmf

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


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread jonas . thornvall
Den onsdagen den 30:e oktober 2013 kl. 08:07:31 UTC+1 skrev Tim Roberts:
> [email protected] wrote:
> 
> >
> 
> >Why did Python not implement end... The end is really not necessary for
> 
> >the programming language it can be excluded, but it is a courtesy to
> 
> >the programmer and could easily be transformed to indents automaticly,
> 
> >that is removed before the compiliation/interpretation of code.  
> 
> 
> 
> You only say that because your brain has been poisoned by languages that
> 
> require some kind of "end".  It's not necessary, and it's extra typing. 99%
> 
> of programmers do the indentation anyway, to make the program easy to read,
> 
> so why not just make it part of the syntax?  That way, you don't
> 
> accidentally have the indentation not match the syntax.
> 
> -- 
> 
> Tim Roberts, [email protected]
> 
> Providenza & Boekelheide, Inc.

It maybe common practice in program languages, but to me it is slightly 
confusing to have the while/for loop on the same indent level, as the regular 
statements.
Because when the while loop ends there is no other identification then that the 
indent stopped, and to me it is easy to interpret that terms that actually 
straight under the loop belongs to it.

But of course it is a matter of adjust the way i look at the code.
Thanks for help guys.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: trying to strip out non ascii.. or rather convert non ascii

2013-10-30 Thread Mark Lawrence

On 30/10/2013 01:33, Piet van Oostrum wrote:

Mark Lawrence  writes:


Please provide hard evidence to support your claims or stop posting this
ridiculous nonsense.  Give us real world problems that can be reported
on the bug tracker, investigated and resolved.


I think it is much better just to ignore this nonsense instead of asking for 
evidence you know you will never get.



A good point, but note he doesn't have the courage to reply to me but 
always to others.  I guess he spends a lot of time clucking, not because 
he's run out of supplies, but because he's simply a chicken.


--
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

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


Re: Organising packages/modules - importing functions from a common.py in a separate directory?

2013-10-30 Thread Peter Otten
Victor Hooi wrote:

> Wait - err, subpackage != module, right? Do you think you could explain
> what a sub-package is please? I tried Googling, and couldn't seem to find
> the term in this context.

In analogy to subdirectory I em_load and pg_load -- and common if you add an 
__init__.py would be sub-packages, provided only the parent of foo_loading 
is in sys.path and you import them with

import foo_loading.pg_load

etc.

> Also, so you're saying to put the actual script that I want to invoke
> *outside* the Python package.
> 
> Do you mean something like this:
> 
>> sync_em.py
>> sync_pg.py
>> foo_loading/
>> __init__.py
>> common/
   __init__.py
>> common_foo.py
>> em_load/
>> __init__.py
>> config.yaml
>> em.py
>> pg_load/
>> __init__.py
>> config.yaml
>> pg.py
> 
> and the sync_em.py and sync_pg.py would just be thin wrappers pulling in
> things from em.py and pg.py? Is that a recommended approach to organise
> the code?

I don't know. I prefer it that way.
 
> Would it make any difference if I actually packaged it up so you could
> install it in site-packages? Could I then call modules from other modules
> within the package?

If you mean "import", yes, installing is one way to get it into sys.path.


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


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread jonas . thornvall
Den onsdagen den 30:e oktober 2013 kl. 09:52:16 UTC+1 skrev 
[email protected]:
> Den onsdagen den 30:e oktober 2013 kl. 08:07:31 UTC+1 skrev Tim Roberts:
> 
> > [email protected] wrote:
> 
> > 
> 
> > >
> 
> > 
> 
> > >Why did Python not implement end... The end is really not necessary for
> 
> > 
> 
> > >the programming language it can be excluded, but it is a courtesy to
> 
> > 
> 
> > >the programmer and could easily be transformed to indents automaticly,
> 
> > 
> 
> > >that is removed before the compiliation/interpretation of code.  
> 
> > 
> 
> > 
> 
> > 
> 
> > You only say that because your brain has been poisoned by languages that
> 
> > 
> 
> > require some kind of "end".  It's not necessary, and it's extra typing. 99%
> 
> > 
> 
> > of programmers do the indentation anyway, to make the program easy to read,
> 
> > 
> 
> > so why not just make it part of the syntax?  That way, you don't
> 
> > 
> 
> > accidentally have the indentation not match the syntax.
> 
> > 
> 
> > -- 
> 
> > 
> 
> > Tim Roberts, [email protected]
> 
> > 
> 
> > Providenza & Boekelheide, Inc.
> 
> 
> 
> It maybe common practice in program languages, but to me it is slightly 
> confusing to have the while/for loop on the same indent level, as the regular 
> statements.
> 
> Because when the while loop ends there is no other identification then that 
> the indent stopped, and to me it is easy to interpret that terms that 
> actually straight under the loop belongs to it.
> 
> 
> 
> But of course it is a matter of adjust the way i look at the code.
> 
> Thanks for help guys.

To show you guys that i am not totally uneducable i actually followed your 
sugestions ;D. 
(Is there any support similar javascript canvas for drawing, and HTML for 
interactivity, textbox, buttons in python?). 

I have been programming some PHP long time ago, basicly only remember you had 
to have a server running to interact via HTML. 

#!/usr/bin/python
import math
# Function definition is here
def sq(number):
   
  square=1
  factor=2
  multip=exponent*exponent
  print(x,"= ", end="")
  while number>=multip:
 while square<=number:
factor+=1
square=factor*factor
 factor-=1  
 print(factor,"^2+",sep="",end="")
 square=factor*factor
 number=number-(factor*factor)
 square=1
 factor=1
  print(number)

#Set exponent here  
exponent=3
print("Exp=x^",exponent,sep="")
#Set range of numbers x
for x in range (1,100):
  sq(x);
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread jonas . thornvall
Den onsdagen den 30:e oktober 2013 kl. 10:48:36 UTC+1 skrev 
[email protected]:
> Den onsdagen den 30:e oktober 2013 kl. 09:52:16 UTC+1 skrev 
> [email protected]:
> 
> > Den onsdagen den 30:e oktober 2013 kl. 08:07:31 UTC+1 skrev Tim Roberts:
> 
> > 
> 
> > > [email protected] wrote:
> 
> > 
> 
> > > 
> 
> > 
> 
> > > >
> 
> > 
> 
> > > 
> 
> > 
> 
> > > >Why did Python not implement end... The end is really not necessary for
> 
> > 
> 
> > > 
> 
> > 
> 
> > > >the programming language it can be excluded, but it is a courtesy to
> 
> > 
> 
> > > 
> 
> > 
> 
> > > >the programmer and could easily be transformed to indents automaticly,
> 
> > 
> 
> > > 
> 
> > 
> 
> > > >that is removed before the compiliation/interpretation of code.  
> 
> > 
> 
> > > 
> 
> > 
> 
> > > 
> 
> > 
> 
> > > 
> 
> > 
> 
> > > You only say that because your brain has been poisoned by languages that
> 
> > 
> 
> > > 
> 
> > 
> 
> > > require some kind of "end".  It's not necessary, and it's extra typing. 
> > > 99%
> 
> > 
> 
> > > 
> 
> > 
> 
> > > of programmers do the indentation anyway, to make the program easy to 
> > > read,
> 
> > 
> 
> > > 
> 
> > 
> 
> > > so why not just make it part of the syntax?  That way, you don't
> 
> > 
> 
> > > 
> 
> > 
> 
> > > accidentally have the indentation not match the syntax.
> 
> > 
> 
> > > 
> 
> > 
> 
> > > -- 
> 
> > 
> 
> > > 
> 
> > 
> 
> > > Tim Roberts, [email protected]
> 
> > 
> 
> > > 
> 
> > 
> 
> > > Providenza & Boekelheide, Inc.
> 
> > 
> 
> > 
> 
> > 
> 
> > It maybe common practice in program languages, but to me it is slightly 
> > confusing to have the while/for loop on the same indent level, as the 
> > regular statements.
> 
> > 
> 
> > Because when the while loop ends there is no other identification then that 
> > the indent stopped, and to me it is easy to interpret that terms that 
> > actually straight under the loop belongs to it.
> 
> > 
> 
> > 
> 
> > 
> 
> > But of course it is a matter of adjust the way i look at the code.
> 
> > 
> 
> > Thanks for help guys.
> 
> 
> 
> To show you guys that i am not totally uneducable i actually followed your 
> sugestions ;D. 
> 
> (Is there any support similar javascript canvas for drawing, and HTML for 
> interactivity, textbox, buttons in python?). 
> 
> 
> 
> I have been programming some PHP long time ago, basicly only remember you had 
> to have a server running to interact via HTML. 
> 
> 
> 
> #!/usr/bin/python
> 
> import math
> 
> # Function definition is here
> 
> def sq(number):
> 
>
> 
>   square=1
> 
>   factor=2
> 
>   multip=exponent*exponent
> 
>   print(x,"= ", end="")
> 
>   while number>=multip:
> 
>  while square<=number:
> 
> factor+=1
> 
> square=factor*factor
> 
>  factor-=1
> 
>  print(factor,"^2+",sep="",end="")
> 
>  square=factor*factor
> 
>  number=number-(factor*factor)
> 
>  square=1
> 
>  factor=1
> 
>   print(number)
> 
> 
> 
> #Set exponent here  
> 
> exponent=3
> 
> print("Exp=x^",exponent,sep="")
> 
> #Set range of numbers x
> 
> for x in range (1,100):
> 
>   sq(x);

Forgot change the static square that was written out, i am a bit undecuable 
afterall...

#!/usr/bin/python
import math
# Function definition is here
def sq(number):
   
  square=1
  factor=2
  multip=exponent*exponent
  print(x,"= ", end="")
  while number>=multip:
 while square<=number:
factor+=1
square=factor*factor
 factor-=1  
 print(factor,"^",exponent,"+",sep="",end="")
 square=factor*factor
 number=number-(factor*factor)
 square=1
 factor=1
  print(number)

#Set exponent here  
exponent=3
print("Exp=x^",exponent,sep="")
#Set range of numbers x
for x in range (1,100):
  sq(x);
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread Mark Lawrence

On 30/10/2013 09:52, [email protected] wrote:

Please stop sending us double spaced crap.

--
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

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


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread jonas . thornvall
Den onsdagen den 30:e oktober 2013 kl. 08:07:31 UTC+1 skrev Tim Roberts:
> [email protected] wrote:
> 
> >
> 
> >Why did Python not implement end... The end is really not necessary for
> 
> >the programming language it can be excluded, but it is a courtesy to
> 
> >the programmer and could easily be transformed to indents automaticly,
> 
> >that is removed before the compiliation/interpretation of code.  
> 
> 
> 
> You only say that because your brain has been poisoned by languages that
> 
> require some kind of "end".  It's not necessary, and it's extra typing. 99%
> 
> of programmers do the indentation anyway, to make the program easy to read,
> 
> so why not just make it part of the syntax?  That way, you don't
> 
> accidentally have the indentation not match the syntax.
> 
> -- 
> 
> Tim Roberts, [email protected]
> 
> Providenza & Boekelheide, Inc.

Well Tim ***one could argue*** why not do a (i think it is called parser) that 
react to "loop", "end" and "function". And lazy like me do not have to think 
about "what is not part of program".

I certainly do not like the old bracket style it was a catastrophe, but in 
honesty the gui editor of python should have what i propose, a parser that 
indent automaticly at loops, functions and end. I promise you it will save 
millions of hours of bug searching all over world in a month.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread jonas . thornvall
Den onsdagen den 30:e oktober 2013 kl. 11:08:11 UTC+1 skrev 
[email protected]:
> Den onsdagen den 30:e oktober 2013 kl. 08:07:31 UTC+1 skrev Tim Roberts:
> 
> > [email protected] wrote:
> 
> > 
> 
> > >
> 
> > 
> 
> > >Why did Python not implement end... The end is really not necessary for
> 
> > 
> 
> > >the programming language it can be excluded, but it is a courtesy to
> 
> > 
> 
> > >the programmer and could easily be transformed to indents automaticly,
> 
> > 
> 
> > >that is removed before the compiliation/interpretation of code.  
> 
> > 
> 
> > 
> 
> > 
> 
> > You only say that because your brain has been poisoned by languages that
> 
> > 
> 
> > require some kind of "end".  It's not necessary, and it's extra typing. 99%
> 
> > 
> 
> > of programmers do the indentation anyway, to make the program easy to read,
> 
> > 
> 
> > so why not just make it part of the syntax?  That way, you don't
> 
> > 
> 
> > accidentally have the indentation not match the syntax.
> 
> > 
> 
> > -- 
> 
> > 
> 
> > Tim Roberts, [email protected]
> 
> > 
> 
> > Providenza & Boekelheide, Inc.
> 
> 
> 
> Well Tim ***one could argue*** why not do a (i think it is called parser) 
> that react to "loop", "end" and "function". And lazy like me do not have to 
> think about "what is not part of program".
> 
> 
> 
> I certainly do not like the old bracket style it was a catastrophe, but in 
> honesty the gui editor of python should have what i propose, a parser that 
> indent automaticly at loops, functions and end. I promise you it will save 
> millions of hours of bug searching all over world in a month.

Instead of having going over indent manually, you just drop in an end it is so 
simple, no marking no meny indent unindent it is automaticly done. And that was 
the purpose of python to remove idiocies, like brackets and indents.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread jonas . thornvall
Den onsdagen den 30:e oktober 2013 kl. 11:00:30 UTC+1 skrev Mark Lawrence:
> On 30/10/2013 09:52, [email protected] wrote:
> 
> 
> 
> Please stop sending us double spaced crap.
> 
> 
> 
> -- 
> 
> Python is the second best programming language in the world.
> 
> But the best has yet to be invented.  Christian Tismer
> 
> 
> 
> Mark Lawrence
I am not sure what you want.
You want me to remove the empty line in function? I do it for it is easier to 
read for me.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread jonas . thornvall
Den onsdagen den 30:e oktober 2013 kl. 11:11:17 UTC+1 skrev 
[email protected]:
> Den onsdagen den 30:e oktober 2013 kl. 11:08:11 UTC+1 skrev 
> [email protected]:
> 
> > Den onsdagen den 30:e oktober 2013 kl. 08:07:31 UTC+1 skrev Tim Roberts:
> 
> > 
> 
> > > [email protected] wrote:
> 
> > 
> 
> > > 
> 
> > 
> 
> > > >
> 
> > 
> 
> > > 
> 
> > 
> 
> > > >Why did Python not implement end... The end is really not necessary for
> 
> > 
> 
> > > 
> 
> > 
> 
> > > >the programming language it can be excluded, but it is a courtesy to
> 
> > 
> 
> > > 
> 
> > 
> 
> > > >the programmer and could easily be transformed to indents automaticly,
> 
> > 
> 
> > > 
> 
> > 
> 
> > > >that is removed before the compiliation/interpretation of code.  
> 
> > 
> 
> > > 
> 
> > 
> 
> > > 
> 
> > 
> 
> > > 
> 
> > 
> 
> > > You only say that because your brain has been poisoned by languages that
> 
> > 
> 
> > > 
> 
> > 
> 
> > > require some kind of "end".  It's not necessary, and it's extra typing. 
> > > 99%
> 
> > 
> 
> > > 
> 
> > 
> 
> > > of programmers do the indentation anyway, to make the program easy to 
> > > read,
> 
> > 
> 
> > > 
> 
> > 
> 
> > > so why not just make it part of the syntax?  That way, you don't
> 
> > 
> 
> > > 
> 
> > 
> 
> > > accidentally have the indentation not match the syntax.
> 
> > 
> 
> > > 
> 
> > 
> 
> > > -- 
> 
> > 
> 
> > > 
> 
> > 
> 
> > > Tim Roberts, [email protected]
> 
> > 
> 
> > > 
> 
> > 
> 
> > > Providenza & Boekelheide, Inc.
> 
> > 
> 
> > 
> 
> > 
> 
> > Well Tim ***one could argue*** why not do a (i think it is called parser) 
> > that react to "loop", "end" and "function". And lazy like me do not have to 
> > think about "what is not part of program".
> 
> > 
> 
> > 
> 
> > 
> 
> > I certainly do not like the old bracket style it was a catastrophe, but in 
> > honesty the gui editor of python should have what i propose, a parser that 
> > indent automaticly at loops, functions and end. I promise you it will save 
> > millions of hours of bug searching all over world in a month.
> 
> 
> 
> Instead of having going over indent manually, you just drop in an end it is 
> so simple, no marking no meny indent unindent it is automaticly done. And 
> that was the purpose of python to remove idiocies, like brackets and indents.

You could have it in the menu indent parser on off. If on you write out ends, 
and the text is automaticly indented, by using end or a reserved sign. It is 
quite simple i could program it in a day...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Organising packages/modules - importing functions from a common.py in a separate directory?

2013-10-30 Thread Peter Otten
Victor Hooi wrote:

> Wait - err, subpackage != module, right? Do you think you could explain
> what a sub-package is please? I tried Googling, and couldn't seem to find
> the term in this context.

[second attempt]

In analogy to the term "subdirectory" em_load and pg_load -- and common if 
you add an __init__.py -- would be sub-packages, provided only the parent of 
foo_loading is in sys.path and you import them with

import foo_loading.pg_load

etc.


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


Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea.

2013-10-30 Thread Steven D'Aprano
On Tue, 29 Oct 2013 13:00:07 -0700, rurpy wrote:

> On Tuesday, October 29, 2013 8:08:16 AM UTC-6, Steven D'Aprano wrote:
>> On Tue, 29 Oct 2013 12:37:36 +0100, Skybuck Flying wrote:
>>[...]
>> Skybuck, please excuse my question, but have you ever done any
>> programming at all? You don't seem to have any experience with actual
>> programming languages.
>>[...]
>> Wait until you actually start programming before deciding what makes
>> sense or doesn't.
> 
> Couldn't you have simply made your points without the above comments?
> Those points stand perfectly fine on their own without the ad hominem
> attack.

Not every observation about a person is "ad hominem", let alone an 
attack, even if they are uncomplimentary. You are mistaken to identify 
such observations as both.

"Ad hominem" is the standard term for a logical fallacy, whereby a claim 
is rejected solely because of *irrelevant personal characteristics* of 
the person making the claim, rather than allowing it to stand on its own 
merits. It is not an ad hominem to call somebody a pillock. It is, 
however, an ad hominem to imply that *merely because they are a pillock* 
their arguments must therefore be wrong.

Ad hominems:

"Henry's argument cannot be believed, as he is known to hang 
 around loose women, thieves and tax collectors."

"Of course George would oppose the war, he's a homosexual."

"Clearly Julie is mistaken, she's just a girl, what would 
 she know about programming?"


Not ad hominems:

"Susan's argument in favour of the proposal is influenced by
 the fact that she will make a lot of money if it goes ahead."

"David has no experience with Oracle databases, and his advice
 about Oracle technology should be taken with caution."

"Barry is a plonker. His post is good evidence of this, and
 here are the reasons why..."


Skybuck's experience at programming *is relevant* to the question of 
whether or not he understands what he is talking about.

If you consider that merely suggesting that somebody is not experienced 
at programming counts as an attack, well, words fail me.

If you want to accuse me of anything underhanded, "poisoning the well" 
would be more appropriate. At least that is in the ball-park. A cynical, 
nasty-minded person [this is an example of poisoning the well] might 
consider that by merely pointing out that Skybuck appears to have no 
actual experience in programming, I'm trying to influence others to 
reject his claims out of hand. If that's how you want to see it, I can't 
stop you. On the other hand, an alternative interpretation is that by 
gently reminding Skybuck that he doesn't have any real experience in the 
topic he's discussing (or so it seems), he'll be encouraged to actually 
learn something.

I think it is quite unfair of you to misrepresent my post as an attack, 
particularly since my reply gave an example of a type of loop that 
supports Skybuck's position.


 
-- 
Steven
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Maintaining a backported module

2013-10-30 Thread Metallicow
On Thursday, October 24, 2013 12:46:51 AM UTC-5, Metallicow wrote:
> +1 for stdev Steven. Thanks for the extra legs.
> Hope all goes well with introductions... I'm sure it will.
> :) Good Job.

Well, what I am trying to get at is whether it is better as...

stddev or stdev...? 6(3standard abc) vs 5(2nonstandard abc)
How many people are going to have to change their code...

Is alphabetsoup ABC better than oppsImissedAspoonfull(AC)?

As far as readability and standard naming conventions are concerned?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread Chris Angelico
On Wed, Oct 30, 2013 at 9:08 PM,   wrote:
> Well Tim ***one could argue*** why not do a (i think it is called parser) 
> that react to "loop", "end" and "function". And lazy like me do not have to 
> think about "what is not part of program".

Python actually does have a symbol for what you're thinking of - but
it's not a keyword. Check this out:

print("Hello, world!")
for i in range(5):
#{
print("Line #%d"%i)
#}

if i>3:
#{
print("After the loop, i is huge!")
#}
else:
#{
print("After the loop, something is seriously screwy.")
raise RuntimeError
#}

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread jonas . thornvall
Den onsdagen den 30:e oktober 2013 kl. 11:00:30 UTC+1 skrev Mark Lawrence:
> On 30/10/2013 09:52, [email protected] wrote:
> 
> 
> 
> Please stop sending us double spaced crap.
> 
> 
> 
> -- 
> 
> Python is the second best programming language in the world.
> 
> But the best has yet to be invented.  Christian Tismer
> 
> 
> 
> Mark Lawrence

I think it is not me it is probably google groups, well maybe they should 
consider changing linebreak sign as stored in database.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread Antoon Pardon
Op 30-10-13 08:07, Tim Roberts schreef:
> [email protected] wrote:
>>
>> Why did Python not implement end... The end is really not necessary for
>> the programming language it can be excluded, but it is a courtesy to
>> the programmer and could easily be transformed to indents automaticly,
>> that is removed before the compiliation/interpretation of code.  
> 
> You only say that because your brain has been poisoned by languages that
> require some kind of "end".  It's not necessary, and it's extra typing. 99%
> of programmers do the indentation anyway, to make the program easy to read,
> so why not just make it part of the syntax?  That way, you don't
> accidentally have the indentation not match the syntax.

Because it is a pain in the ass. Now suddenly my program doesn't work
because I somehow inserted a tab instead of spaces.

The end would also gives extra protection against faulty manipulations.
I have at one time accidently copied a function partly further below.
Because python doesn't need an end, the compilor was unable to detect
this was only part of a function which caused a bug which was harder to
find.

Python made it's choice and I can live with that, but telling people
who prefer it had made an other choice that their brain is poisoned,
only shows you are unable to see the disadvantages.

-- 
Antoon Pardon
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread rusi
On Wednesday, October 30, 2013 3:43:03 PM UTC+5:30, [email protected] wrote:
> Den onsdagen den 30:e oktober 2013 kl. 11:00:30 UTC+1 skrev Mark Lawrence:

* * Please stop sending us double spaced crap.
* * Mark Lawrence
* I am not sure what you want.

And then again 

* You want me to remove the empty line in function? I do it for it is easier to 
* read for me.

* I think it is not me it is probably google groups, well maybe they should 
* consider changing linebreak sign as stored in database.

1. Go to the python archive for this month
https://mail.python.org/pipermail/python-list/2013-October/author.html#start
2. Search for your posts by control-f jonas
3. Open 4 or 4 at random and try to read them

Now do you see that google-groups (stupidly) inserts extra lines that causes a 
lot of irritation to a lot of people?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread Chris Angelico
On Wed, Oct 30, 2013 at 11:01 PM, Antoon Pardon
 wrote:
> Because it is a pain in the ass. Now suddenly my program doesn't work
> because I somehow inserted a tab instead of spaces.

I broadly agree with your post (I'm of the school of thought that
braces are better than indentation for delimiting blocks), but I don't
think this argument holds water. All you need to do is be consistent
about tabs OR spaces (and I'd recommend tabs, since they're simpler
and safer), and you'll never have this trouble. Also, the parser
should tell you if you mix tabs and spaces, so that won't trip
anything either.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread Antoon Pardon
Op 30-10-13 13:17, Chris Angelico schreef:
> On Wed, Oct 30, 2013 at 11:01 PM, Antoon Pardon
>  wrote:
>> Because it is a pain in the ass. Now suddenly my program doesn't work
>> because I somehow inserted a tab instead of spaces.
> 
> I broadly agree with your post (I'm of the school of thought that
> braces are better than indentation for delimiting blocks), but I don't
> think this argument holds water. All you need to do is be consistent
> about tabs OR spaces (and I'd recommend tabs, since they're simpler
> and safer), and you'll never have this trouble.

Easier said than done. First of all I can be as consistent as possible,
I can't just take code from someone else and insert it because that
other person may be consistenly doing it different from me.

Then if you are working on different machines, the settings of your
editor may not always be the same so that you have tabs on one machine
and spaces on an other, which causes problem when you move the code.

Also when you have an xterm, selecting a tab and pasting it into
another it will turn the tab into spaces.

All these things usually can be ignored, they typically only show
up when you print something and things aren't aligned as you expect
but with python you are forced to correct those things immediatly,
forcing you to focus on white space layout issues instead of on
the logic of the code.

> Also, the parser
> should tell you if you mix tabs and spaces, so that won't trip
> anything either.

Maybe you mean something differen than I understand but a program
throwing a syntax error because there is a tab instead of a number
of spaces or vice versa, is something I would understand as tripping.

-- 
Antoon Pardon



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


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread Ned Batchelder


On 10/30/13 6:13 AM, [email protected] wrote:

Den onsdagen den 30:e oktober 2013 kl. 11:00:30 UTC+1 skrev Mark Lawrence:

On 30/10/2013 09:52, [email protected] wrote:



Please stop sending us double spaced crap.



--

Python is the second best programming language in the world.

But the best has yet to be invented.  Christian Tismer



Mark Lawrence

I am not sure what you want.
You want me to remove the empty line in function? I do it for it is easier to 
read for me.


Jonas, he's talking about the quoted content that Google Groups includes 
in your messages.  Some people find this extremely aggravating.


As for your code, you should actually give it much more space:

#!/usr/bin/env python
import math

# Function definition is here
def sq(number):
  square = 1
  factor = 2
  multip = exponent * exponent # not sure why exponent is accessed 
globally..
  print(x, "= ", end="")

  while number >= multip:
 while square <= number:
factor += 1
square = factor * factor
 factor -= 1
 print(factor, "^", exponent, "+", sep="", end="")
 number -= factor*factor
 square = 1
 factor = 1

  print(number)

# Set exponent here
exponent = 3
print("Exp=x^", exponent, sep="")

# Set range of numbers x
for x in range (1, 100):
  sq(x)


--Ned.


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


Re: trying to strip out non ascii.. or rather convert non ascii

2013-10-30 Thread Ned Batchelder


On 10/30/13 4:49 AM, [email protected] wrote:

Le mardi 29 octobre 2013 06:24:50 UTC+1, Steven D'Aprano a écrit :

On Mon, 28 Oct 2013 09:23:41 -0500, Tim Chase wrote:




On 2013-10-28 07:01, [email protected] wrote:

Simply ignoring diactrics won't get you very far.

Right. As an example, these four French words : cote, côte, coté, côté
.

Distinct words with distinct meanings, sure.
But when a naïve (naive? ☺) person or one without the easy ability to
enter characters with diacritics searches for "cote", I want to return
possible matches containing any of your 4 examples.  It's slightly
fuzzier if they search for "coté", in which case they may mean "coté" or
they might mean be unable to figure out how to add a hat and want to
type "côté". Though I'd rather get more results, even if it has some
that only match fuzzily.



The right solution to that is to treat it no differently from other fuzzy

searches. A good search engine should be tolerant of spelling errors and

alternative spellings for any letter, not just those with diacritics.

Ideally, a good search engine would successfully match all three of

"naïve", "naive" and "niave", and it shouldn't rely on special handling

of diacritics.




--

This is a non sense. The purpose of a diacritical mark is to
make a letter a different letter. If a tool is supposed to
match an ô, there is absolutely no reason to match something
else.

jmf



jmf, Tim Chase described his use case, and it seems reasonable to me.  
I'm not sure why you would describe it as nonsense.


--Ned.
--
https://mail.python.org/mailman/listinfo/python-list


Re: Looking for UNICODE to ASCII Conversioni Example Code

2013-10-30 Thread Roy Smith
On 20/10/2013 03:13, I wrote:
> Heck, I can't even really move off 2.6 because we use Amazon's EMR
> service, which is stuck on 2.6.


On Sunday, October 20, 2013 5:11:32 AM UTC-4, Mark Lawrence wrote:
> Dear Amazon,
> 
> Please upgrade to Python 3.3 or similar so that users can have better 
> unicode support amongst other things.
> 
> Love and kisses. 
> 
> Mark.

It seems to have semi-worked.  At least they've finally moved past 2.6!

http://docs.aws.amazon.com/ElasticMapReduce/latest/DeveloperGuide/emr-plan-ami.html#ami-versions-supported

3.0.0   
This new major Amazon EMR AMI version provides the following features:
[…] Python 2.6.8, Python 2.7.5





--
Roy Smith
[email protected]



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


Small emacs fix for Google group users

2013-10-30 Thread Rustom Mody
For the double spacing rubbish produced by GG, I hacked up a bit of
emacs lisp code
-
(defun clean-gg ()
  (interactive)
  (replace-regexp "^> +\n> +\n> +$" "-=\=-" nil 0 (point-max))
  (flush-lines "> +$" 0 (point-max))
  (replace-regexp "-=\=-" "" nil 0 (point-max)))

(global-set-key (kbd "") 'clean-gg)
--
To try
1. Eval the following in emacs*
2. Cut-paste the quoted text from GG into emacs
3. Call with F9
4. Cut-paste back into GG

* Yeah emacs usage will seem weird to non emacs users
Im just hoping some more habitual emacs users can try this, maybe a
few tweaks here and there and then less habituated emacs users can try
it.

For now if you put the elisp above in a file gg.el and start emacs with
$ emacs -l gg.el
(thats an el not a one) it should do the eval above.


Rusi
-- 
http://www.the-magus.in
http://blog.languager.org
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Small emacs fix for Google group users

2013-10-30 Thread rusi
On Wednesday, October 30, 2013 6:43:33 PM UTC+5:30, rusi wrote:
> For the double spacing rubbish produced by GG, I hacked up a bit of
> emacs lisp code

> --
> To try
> 1. Eval the following in emacs*

Tsk! It should be eval the preceding elisp!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Using "with open(filename, 'ab'):" and calling code only if the file is new?

2013-10-30 Thread Neil Cerutti
On 2013-10-30, Victor Hooi  wrote:
> Hi,
>
> I have a CSV file that I will repeatedly appending to.
>
> I'm using the following to open the file:
>
> with open(self.full_path, 'r') as input, open(self.output_csv, 'ab') as 
> output:
> fieldnames = (...)
> csv_writer = DictWriter(output, filednames)
> # Call csv_writer.writeheader() if file is new.
> csv_writer.writerows(my_dict)
>
> I'm wondering what's the best way of calling writeheader() only
> if the file is new?
>
> My understanding is that I don't want to use os.path.exist(),
> since that opens me up to race conditions.
>
> I'm guessing I can't use try-except with IOError, since the
> open(..., 'ab') will work whether the file exists or not.
>
> Is there another way I can execute code only if the file is new?

A heavy-duty approach involves prepending the old contents to a
temporary file.

fieldnames = (...)

with tempfile.TempDirectory() as temp:
tempname = os.path.join(temp, 'output.csv')
with open(tempname, 'wb') as output:
writer = csv.DictWriter(output, fieldnames=fieldnames)
writer.writeheader()
try:
with open(self.output_csv, 'b') old_data:
reader = csv.DictReader(old_data)
for rec in reader:
writer.writerow(rec)
except IOError:
pass
with open(self.full_path, 'b') as infile:
# etc...
shutil.copy(tempname, self.output_csv)

This avoids clobbering output_csv unless new data is succesfully
written. I believe TempDirectory isn't available in Python 2, so
some other way of creating that path will be needed, and I'm too
lazy to look up how. ;)

-- 
Neil Cerutti
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how to avoid checking the same condition repeatedly ?

2013-10-30 Thread Mariano Anaya
On Monday, October 28, 2013 6:50:19 AM UTC-3, Wolfgang Maier wrote:
> Dear all,
> 
> this is a recurring programming problem that I'm just not sure how to solve
> 
> optimally, so I thought I'd ask for your advice:
> 
> imagine you have a flag set somewhere earlier in your code, e.g.,
> 
> 
> 
> needs_processing = True
> 
> 
> 
> then in a for loop you're processing the elements of an iterable, but the
> 
> kind of processing depends on the flag, e.g.,:
> 
> 
> 
> for elem in iterable:
> 
> if needs_processing:
> 
> pre_process(elem)  # reformat elem in place
> 
> print(elem)
> 
> 
> 
> this checks the condition every time through the for loop, even though there
> 
> is no chance for needs_processing to change inside the loop, which does not
> 
> look very efficient. Of course, you could rewrite the above as:
> 
> 
> 
> if needs_processing:
> 
> for elem in iterable:
> 
> pre_process(elem)  # reformat elem in place
> 
> print(elem)
> 
> else:
> 
> for elem in iterable:
> 
> print(elem)
> 
> 
> 
> but this means unnecessary code-duplication.
> 
> 
> 
> You could also define functions (or class methods):
> 
> def pre_process_and_print (item):
> 
> pre_process(item)
> 
> print(item)
> 
> 
> 
> def raw_print (item):
> 
> print(item)
> 
> 
> 
> then:
> 
> process = pre_process_and_print if needs_processing else raw_print
> 
> for elem in iterable:
> 
> process(elem)
> 
> 
> 
> but while this works for the simple example here, it becomes complicated if
> 
> pre_process requires more information to do its job because then you will
> 
> have to start passing around (potentially lots of) arguments.
> 
> 
> 
> So my question is: is there an agreed-upon generally best way of dealing
> 
> with this?
> 
> 
> 
> Thanks for your help,
> 
> Wolfgang

Hi All, 
Trying to help you out, I wonder if something like the following code will help 
on what you need.

for elem in (needs_processing and iterable or []):
pre_process(elem)  # reformat elem in place
print(elem) 

It avoids code duplication and only process and iterates if the condition is 
True.
I hope it helps, otherwise, we could keep thinking alternatives.

Regards.
Mariano.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread Alister
On Wed, 30 Oct 2013 03:08:11 -0700, jonas.thornvall wrote:

> Den onsdagen den 30:e oktober 2013 kl. 08:07:31 UTC+1 skrev Tim Roberts:
>> [email protected] wrote:
>> 
> 
> I certainly do not like the old bracket style it was a catastrophe, but
> in honesty the gui editor of python should have what i propose, a parser
> that indent automaticly at loops, functions and end. I promise you it
> will save millions of hours of bug searching all over world in a month.

What editor are you using?
I suggest you replace it with one that knows python.

I use Geany but may others operate the same way.
when i press return after a line that starts a loop it automatically 
indents the next line the require amount.
it retains the current indent level on subsequent lines until i press 
backspace to return to the previous level

it really does not get any simpler than that.





-- 
If you don't care where you are, then you ain't lost.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread Alister
On Wed, 30 Oct 2013 13:42:37 +0100, Antoon Pardon wrote:

> Op 30-10-13 13:17, Chris Angelico schreef:
>> On Wed, Oct 30, 2013 at 11:01 PM, Antoon Pardon
>>  wrote:
>> I broadly agree with your post (I'm of the school of thought that
>> braces are better than indentation for delimiting blocks), but I don't
>> think this argument holds water. All you need to do is be consistent
>> about tabs OR spaces (and I'd recommend tabs, since they're simpler and
>> safer), and you'll never have this trouble.
> 
> Easier said than done. First of all I can be as consistent as possible,
> I can't just take code from someone else and insert it because that
> other person may be consistenly doing it different from me.

I disagree it is very easy.

1) make sure you editor is set to inset 4 spaces rather than tab when 
pressing the tab key. consistency in your own code is now not an issue.

2) when importing code from someone else a simple search & replace of tab 
with 4 spaces will instantly correct the formatting on code using tab 
without breaking code that doesn't.


> 
> Then if you are working on different machines, the settings of your
> editor may not always be the same so that you have tabs on one machine
> and spaces on an other, which causes problem when you move the code.
> 
that is fixed by setting your environment consistantly but step 2 above 
will fix it if you forget.

> Also when you have an xterm, selecting a tab and pasting it into another
> it will turn the tab into spaces.

Read pep 11 & always use 4 spaces for indentation not tab.

> 
> All these things usually can be ignored, they typically only show up
> when you print something and things aren't aligned as you expect but
> with python you are forced to correct those things immediately, forcing
> you to focus on white space layout issues instead of on the logic of the
> code.
> 
>> Also, the parser should tell you if you mix tabs and spaces, so that
>> won't trip anything either.
> 
> Maybe you mean something different than I understand but a program
> throwing a syntax error because there is a tab instead of a number of
> spaces or vice versa, is something I would understand as tripping.

no more than failing to close a brace in a C like language
indentation is the syntax of python you will grow to love it, like most 
people I found it distracting at first even though i tended to indent 
other code (inconsistently)to make it readable.




-- 
I am what you will be; I was what you are.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread jonas . thornvall
Den onsdagen den 30:e oktober 2013 kl. 11:11:17 UTC+1 skrev 
[email protected]:
> Den onsdagen den 30:e oktober 2013 kl. 11:08:11 UTC+1 skrev 
> [email protected]:
> 
> > Den onsdagen den 30:e oktober 2013 kl. 08:07:31 UTC+1 skrev Tim Roberts:
> 
> > 
> 
> > > [email protected] wrote:
> 
> > 
I suddenly realised i mixed code from a plain square system with the generic 
exponential modulus system.

Here is the code, what it does is encode numbers in an exponential modulus 
base. So it is basicly a numbersystem of my own you do not need to write out + 
^ and exponent because the numbersystem create unique values for every natural 
number.

Well without the + ^ it is hard to read but so are binary, ternary and 
hexadecimal. I think the requirment for a numbersystem is that it have a 
working arithmetic, and mine have.

So here is the working code, to write out exponential modulus number for and 
exponent.

#!/usr/bin/python
import math
# Function definition is here
def sq(number):
   
  exp=1
  factor=2
  multip=math.pow(2,exponent)
  print(x,"= ", end="")
  while number>=multip:
 while exp<=number:
factor+=1
exp=math.pow(factor,exponent)
 factor-=1  
 print(factor,"^",exponent,"+",sep="",end="")
 exp=math.pow(factor,exponent)
 number=number-exp
 exp=1
 factor=1
  print(number)

#Set exponent here  
exponent=2
print("Exp=x^",exponent,sep="")
#Set range of numbers x
for x in range (1,100):
  sq(x) 

> 
> > > 
> 
> > 
> 
> > > >
> 
> > 
> 
> > > 
> 
> > 
> 
> > > >Why did Python not implement end... The end is really not necessary for
> 
> > 
> 
> > > 
> 
> > 
> 
> > > >the programming language it can be excluded, but it is a courtesy to
> 
> > 
> 
> > > 
> 
> > 
> 
> > > >the programmer and could easily be transformed to indents automaticly,
> 
> > 
> 
> > > 
> 
> > 
> 
> > > >that is removed before the compiliation/interpretation of code.  
> 
> > 
> 
> > > 
> 
> > 
> 
> > > 
> 
> > 
> 
> > > 
> 
> > 
> 
> > > You only say that because your brain has been poisoned by languages that
> 
> > 
> 
> > > 
> 
> > 
> 
> > > require some kind of "end".  It's not necessary, and it's extra typing. 
> > > 99%
> 
> > 
> 
> > > 
> 
> > 
> 
> > > of programmers do the indentation anyway, to make the program easy to 
> > > read,
> 
> > 
> 
> > > 
> 
> > 
> 
> > > so why not just make it part of the syntax?  That way, you don't
> 
> > 
> 
> > > 
> 
> > 
> 
> > > accidentally have the indentation not match the syntax.
> 
> > 
> 
> > > 
> 
> > 
> 
> > > -- 
> 
> > 
> 
> > > 
> 
> > 
> 
> > > Tim Roberts, [email protected]
> 
> > 
> 
> > > 
> 
> > 
> 
> > > Providenza & Boekelheide, Inc.
> 
> > 
> 
> > 
> 
> > 
> 
> > Well Tim ***one could argue*** why not do a (i think it is called parser) 
> > that react to "loop", "end" and "function". And lazy like me do not have to 
> > think about "what is not part of program".
> 
> > 
> 
> > 
> 
> > 
> 
> > I certainly do not like the old bracket style it was a catastrophe, but in 
> > honesty the gui editor of python should have what i propose, a parser that 
> > indent automaticly at loops, functions and end. I promise you it will save 
> > millions of hours of bug searching all over world in a month.
> 
> 
> 
> Instead of having going over indent manually, you just drop in an end it is 
> so simple, no marking no meny indent unindent it is automaticly done. And 
> that was the purpose of python to remove idiocies, like brackets and indents.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread jonas . thornvall
Den onsdagen den 30:e oktober 2013 kl. 15:22:50 UTC+1 skrev Alister:
> On Wed, 30 Oct 2013 13:42:37 +0100, Antoon Pardon wrote:
> 
> 
> 
> > Op 30-10-13 13:17, Chris Angelico schreef:
> 
> >> On Wed, Oct 30, 2013 at 11:01 PM, Antoon Pardon
> 
> >>  wrote:
> 
> >> I broadly agree with your post (I'm of the school of thought that
> 
> >> braces are better than indentation for delimiting blocks), but I don't
> 
> >> think this argument holds water. All you need to do is be consistent
> 
> >> about tabs OR spaces (and I'd recommend tabs, since they're simpler and
> 
> >> safer), and you'll never have this trouble.
> 
> > 
> 
> > Easier said than done. First of all I can be as consistent as possible,
> 
> > I can't just take code from someone else and insert it because that
> 
> > other person may be consistenly doing it different from me.
> 
> 
> 
> I disagree it is very easy.
> 
> 
> 
> 1) make sure you editor is set to inset 4 spaces rather than tab when 
> 
> pressing the tab key. consistency in your own code is now not an issue.
> 
> 
> 
> 2) when importing code from someone else a simple search & replace of tab 
> 
> with 4 spaces will instantly correct the formatting on code using tab 
> 
> without breaking code that doesn't.
> 
> 
> 
> 
> 
> > 
> 
> > Then if you are working on different machines, the settings of your
> 
> > editor may not always be the same so that you have tabs on one machine
> 
> > and spaces on an other, which causes problem when you move the code.
> 
> > 
> 
> that is fixed by setting your environment consistantly but step 2 above 
> 
> will fix it if you forget.
> 
> 
> 
> > Also when you have an xterm, selecting a tab and pasting it into another
> 
> > it will turn the tab into spaces.
> 
> 
> 
> Read pep 11 & always use 4 spaces for indentation not tab.
> 
> 
> 
> > 
> 
> > All these things usually can be ignored, they typically only show up
> 
> > when you print something and things aren't aligned as you expect but
> 
> > with python you are forced to correct those things immediately, forcing
> 
> > you to focus on white space layout issues instead of on the logic of the
> 
> > code.
> 
> > 
> 
> >> Also, the parser should tell you if you mix tabs and spaces, so that
> 
> >> won't trip anything either.
> 
> > 
> 
> > Maybe you mean something different than I understand but a program
> 
> > throwing a syntax error because there is a tab instead of a number of
> 
> > spaces or vice versa, is something I would understand as tripping.
> 
> 
> 
> no more than failing to close a brace in a C like language
> 
> indentation is the syntax of python you will grow to love it, like most 
> 
> people I found it distracting at first even though i tended to indent 
> 
> other code (inconsistently)to make it readable.
> 
> 
> 
> 
> 
> 
> 
> 
> 
> -- 
> 
> I am what you will be; I was what you are.

Alister i do not ask for changing the actual implementation with indents that 
the compiler/interpretator work with. What i ask for is some courtesy relative 
the programmers using IDLE, to incorporate a simple automatic parser that let 
them who like to write slopy formatted with end instead to do so. And the 
parser in editor automaticly go in and autoindent *function, loops, if and 
allow end that the editor autoindent to end of loop. It can not be that hard i 
have implemented my own python using this...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread Antoon Pardon
Op 30-10-13 15:22, Alister schreef:
> On Wed, 30 Oct 2013 13:42:37 +0100, Antoon Pardon wrote:
> 
>> Op 30-10-13 13:17, Chris Angelico schreef:
>>> On Wed, Oct 30, 2013 at 11:01 PM, Antoon Pardon
>>>  wrote:
>>> I broadly agree with your post (I'm of the school of thought that
>>> braces are better than indentation for delimiting blocks), but I don't
>>> think this argument holds water. All you need to do is be consistent
>>> about tabs OR spaces (and I'd recommend tabs, since they're simpler and
>>> safer), and you'll never have this trouble.
>>
>> Easier said than done. First of all I can be as consistent as possible,
>> I can't just take code from someone else and insert it because that
>> other person may be consistenly doing it different from me.
> 
> I disagree it is very easy.

You can disagree, as much as you want. You don't get to define my
experience. Maybe all those things you enumerate are all easy, all
taken together they can makes it cumbersome at times.

> 1) make sure you editor is set to inset 4 spaces rather than tab when 
> pressing the tab key. consistency in your own code is now not an issue.
> 
> 2) when importing code from someone else a simple search & replace of tab 
> with 4 spaces will instantly correct the formatting on code using tab 
> without breaking code that doesn't.

But why should I have to do all that. When I write other code I just
don't have to bother and it is all indented as desired too.

>> Then if you are working on different machines, the settings of your
>> editor may not always be the same so that you have tabs on one machine
>> and spaces on an other, which causes problem when you move the code.
>>
> that is fixed by setting your environment consistantly but step 2 above 
> will fix it if you forget.

Again why should I have to bother. Why does python force me to go
through all this trouble when other languages allow themselves to
be happily edited without all this.

>> Also when you have an xterm, selecting a tab and pasting it into another
>> it will turn the tab into spaces.
> 
> Read pep 11 & always use 4 spaces for indentation not tab.

I'll decide how to layout my code.

>> All these things usually can be ignored, they typically only show up
>> when you print something and things aren't aligned as you expect but
>> with python you are forced to correct those things immediately, forcing
>> you to focus on white space layout issues instead of on the logic of the
>> code.
>>
>>> Also, the parser should tell you if you mix tabs and spaces, so that
>>> won't trip anything either.
>>
>> Maybe you mean something different than I understand but a program
>> throwing a syntax error because there is a tab instead of a number of
>> spaces or vice versa, is something I would understand as tripping.
> 
> no more than failing to close a brace in a C like language
> indentation is the syntax of python you will grow to love it, like most 
> people I found it distracting at first even though i tended to indent 
> other code (inconsistently)to make it readable.

I didn't like it at first, accustomed to it a bit and then disliked it
again. So no I don't think I will grow to love it. Python is a tool,
not a religion, so I can live with it if the tool I use has some
featurese I dislike about it. As long as I evaluate the usefulness of
the tool as positive I can live with the peeves.

What is more annoying are the people with some kind of need to reason
your peeves away, as if it is sacriledge daring to dislike something
about the language.

-- 
Antoon Pardon
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread Mark Lawrence

On 30/10/2013 14:31, [email protected] wrote:

Would you please be kind enough to read, digest and action this 
https://wiki.python.org/moin/GoogleGroupsPython


TIA.

--
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

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


Re: How do I update a virtualenv?

2013-10-30 Thread Skip Montanaro
> I believe you may have misread the instructions slightly. You should have a
> project structure like this:
>
> my_project/
> /venv
> .gitignore
>
> The instructions mention adding 'venv' to your .gitignore, so it will be
> excluded from version control. If you have .git & .gitignore files inside
> your venv folder, then you've changed directory into it when you should be
> calling it from the project root instead.

I have .git and .gitignore at the top level, and venv is in
.gitignore. I did, indeed, misunderstand things though. That's the
problem with monkey-see-monkey-do. I completely glossed over the part
where venv was excluded from my git repo. That being the case then, to
update my virtualenv, I need to first create a new one in a fresh
directory (using my existing requirements.txt file). I should be able
to simply swap out the old venv directory for the new one.

Skip
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: RELEASED: Python 2.6.9 final

2013-10-30 Thread Skip Montanaro
> Thanks Barry for all the hard work.

Ditto. Wish I still had my Guido van Rossum World Tour t-shirt!

Skip
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread Alister
On Wed, 30 Oct 2013 07:31:04 -0700, jonas.thornvall wrote:

> Den onsdagen den 30:e oktober 2013 kl. 15:22:50 UTC+1 skrev Alister:
>> On Wed, 30 Oct 2013 13:42:37 +0100, Antoon Pardon wrote:
>> 
>> 
>> 
>> > Op 30-10-13 13:17, Chris Angelico schreef:
>> 
>> >> On Wed, Oct 30, 2013 at 11:01 PM, Antoon Pardon
>> 
>> >>  wrote:
>> 
>> >> I broadly agree with your post (I'm of the school of thought that
>> 
>> >> braces are better than indentation for delimiting blocks), but I
>> >> don't
>> 
>> >> think this argument holds water. All you need to do is be consistent
>> 
>> >> about tabs OR spaces (and I'd recommend tabs, since they're simpler
>> >> and
>> 
>> >> safer), and you'll never have this trouble.
>> 
>> 
>> > 
>> > Easier said than done. First of all I can be as consistent as
>> > possible,
>> 
>> > I can't just take code from someone else and insert it because that
>> 
>> > other person may be consistenly doing it different from me.
>> 
>> 
>> 
>> I disagree it is very easy.
>> 
>> 
>> 
>> 1) make sure you editor is set to inset 4 spaces rather than tab when
>> 
>> pressing the tab key. consistency in your own code is now not an issue.
>> 
>> 
>> 
>> 2) when importing code from someone else a simple search & replace of
>> tab
>> 
>> with 4 spaces will instantly correct the formatting on code using tab
>> 
>> without breaking code that doesn't.
>> 
>> 
>> 
>> 
>> 
>> 
>> > 
>> > Then if you are working on different machines, the settings of your
>> 
>> > editor may not always be the same so that you have tabs on one
>> > machine
>> 
>> > and spaces on an other, which causes problem when you move the code.
>> 
>> 
>> > 
>> that is fixed by setting your environment consistantly but step 2 above
>> 
>> will fix it if you forget.
>> 
>> 
>> 
>> > Also when you have an xterm, selecting a tab and pasting it into
>> > another
>> 
>> > it will turn the tab into spaces.
>> 
>> 
>> 
>> Read pep 11 & always use 4 spaces for indentation not tab.
>> 
>> 
>> 
>> 
>> > 
>> > All these things usually can be ignored, they typically only show up
>> 
>> > when you print something and things aren't aligned as you expect but
>> 
>> > with python you are forced to correct those things immediately,
>> > forcing
>> 
>> > you to focus on white space layout issues instead of on the logic of
>> > the
>> 
>> > code.
>> 
>> 
>> > 
>> >> Also, the parser should tell you if you mix tabs and spaces, so that
>> 
>> >> won't trip anything either.
>> 
>> 
>> > 
>> > Maybe you mean something different than I understand but a program
>> 
>> > throwing a syntax error because there is a tab instead of a number of
>> 
>> > spaces or vice versa, is something I would understand as tripping.
>> 
>> 
>> 
>> no more than failing to close a brace in a C like language
>> 
>> indentation is the syntax of python you will grow to love it, like most
>> 
>> people I found it distracting at first even though i tended to indent
>> 
>> other code (inconsistently)to make it readable.
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> --
>> 
>> I am what you will be; I was what you are.
> 
> Alister i do not ask for changing the actual implementation with indents
> that the compiler/interpretator work with. What i ask for is some
> courtesy relative the programmers using IDLE, to incorporate a simple
> automatic parser that let them who like to write slopy formatted with
> end instead to do so. And the parser in editor automaticly go in and
> autoindent *function, loops, if and allow end that the editor autoindent
> to end of loop. It can not be that hard i have implemented my own python
> using this...

In that case I think you have found yourself a project ;-)

I believe Idle is itself written in python so adding a clean-up function 
that meets your requirements should be feasible. you may even find others 
who find it useful.

Personally I would recommend finding a better environment than Idle




-- 
Your love life will be... interesting.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: trying to strip out non ascii.. or rather convert non ascii

2013-10-30 Thread Mark Lawrence

On 30/10/2013 08:13, [email protected] wrote:

Le mercredi 30 octobre 2013 03:17:21 UTC+1, Chris Angelico a écrit :

On Wed, Oct 30, 2013 at 2:56 AM, Mark Lawrence  wrote:


You've stated above that logically unicode is badly handled by the fsr.  You



then provide a trivial timing example.  WTF???




His idea of bad handling is "oh how terrible, ASCII and BMP have

optimizations". He hates the idea that it could be better in some

areas instead of even timings all along. But the FSR actually has some

distinct benefits even in the areas he's citing - watch this:




import timeit



timeit.timeit("a = 'hundred'; 'x' in a")


0.3625614428649451


timeit.timeit("a = 'hundreij'; 'x' in a")


0.6753936603674484


timeit.timeit("a = 'hundred'; 'ģ' in a")


0.25663261671525106


timeit.timeit("a = 'hundreij'; 'ģ' in a")


0.3582399439035271



The first two examples are his examples done on my computer, so you

can see how all four figures compare. Note how testing for the

presence of a non-Latin1 character in an 8-bit string is very fast.

Same goes for testing for non-BMP character in a 16-bit string. The

difference gets even larger if the string is longer:




timeit.timeit("a = 'hundred'*1000; 'x' in a")


10.083378194714726


timeit.timeit("a = 'hundreij'*1000; 'x' in a")


18.656413035735


timeit.timeit("a = 'hundreij'*1000; 'ģ' in a")


18.436268855399135


timeit.timeit("a = 'hundred'*1000; 'ģ' in a")


2.8308718007456264



Wow! The FSR speeds up searches immensely! It's obviously the best

thing since sliced bread!



ChrisA


-


It is not obvious to make comparaisons with all these
methods and characters (lookup depending on the position
in the table, ...). The only think that can be done and
observed is the tendency between the subsets the FSR
artificially creates.
One can use the best algotithms to adjust bytes, it is
very hard to escape from the fact that if one manipulates
two strings with different internal representations, it
is necessary to find a way to have a "common internal
coding " prior manipulations.
It seems to me that this FSR, with its "negative logic"
is always attempting to "optimize" with the worst
case instead of "optimizing" with the best case.
This kind of effect is shining on the memory side.
Compare utf-8, which has a memory optimization on
a per code point basis with the FSR which has an
optimization based on subsets (One of its purpose).


# FSR
sys.getsizeof( ('a'*1000) + 'z')

1026

sys.getsizeof( ('a'*1000) + '€')

2040

# utf-8
sys.getsizeof( (('a'*1000) + 'z').encode('utf-8'))

1018

sys.getsizeof( (('a'*1000) + '€').encode('utf-8'))

1020

jmf



How do theses figures compare to the ones quoted here 
https://mail.python.org/pipermail/python-dev/2011-September/113714.html ?


--
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

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


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread jonas . thornvall
Den onsdagen den 30:e oktober 2013 kl. 16:09:25 UTC+1 skrev Mark Lawrence:
> On 30/10/2013 14:31, [email protected] wrote:
> 
> 
> 
> Would you please be kind enough to read, digest and action this 
> 
> https://wiki.python.org/moin/GoogleGroupsPython
> 
> 
> 
> TIA.
> 
> 
> 
> -- 
> 
> Python is the second best programming language in the world.
> 
> But the best has yet to be invented.  Christian Tismer
> 
> 
> 
> Mark Lawrence

I am all for automatiation to be honest i rather go in change the code for 
google than do it manual. Maybe those who complain should adress Google? There 
must be a simple solution or?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread Mark Lawrence

On 30/10/2013 15:35, [email protected] wrote:

Den onsdagen den 30:e oktober 2013 kl. 16:09:25 UTC+1 skrev Mark Lawrence:

On 30/10/2013 14:31, [email protected] wrote:



Would you please be kind enough to read, digest and action this

https://wiki.python.org/moin/GoogleGroupsPython



TIA.



--

Python is the second best programming language in the world.

But the best has yet to be invented.  Christian Tismer



Mark Lawrence


I am all for automatiation to be honest i rather go in change the code for 
google than do it manual. Maybe those who complain should adress Google? There 
must be a simple solution or?



The simplest solution is that you stop posting, as you've been spewing 
this double spaced crap all day and show no inclination to do anything 
about it.  I assume that google won't fix their problem as there's not 
enough profit in it.


--
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

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


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread Grant Edwards
On 2013-10-30, Antoon Pardon  wrote:
> Op 30-10-13 08:07, Tim Roberts schreef:
>> [email protected] wrote:
>>>
>>> Why did Python not implement end... The end is really not necessary for
>>> the programming language it can be excluded, but it is a courtesy to
>>> the programmer and could easily be transformed to indents automaticly,
>>> that is removed before the compiliation/interpretation of code.  
>> 
>> You only say that because your brain has been poisoned by languages that
>> require some kind of "end".  It's not necessary, and it's extra typing. 99%
>> of programmers do the indentation anyway, to make the program easy to read,
>> so why not just make it part of the syntax?  That way, you don't
>> accidentally have the indentation not match the syntax.
>
> Because it is a pain in the ass. Now suddenly my program doesn't work
> because I somehow inserted a tab instead of spaces.

Then don't do that.

I'm only half-kidding.  Inserting incorrect tokens into program source
breaks programs in all languages.  The tricky bit is that in many
editors spaces and tabs look the same.  You can pick an editor that
provides a visual difference, or you can pick an editor that always
does the right thing, or you can stick with it until your fingers
learn to do the right thing.

> The end would also gives extra protection against faulty
> manipulations. I have at one time accidently copied a function partly
> further below. Because python doesn't need an end, the compilor was
> unable to detect this was only part of a function which caused a bug
> which was harder to find.
>
> Python made it's choice and I can live with that, but telling people
> who prefer it had made an other choice that their brain is poisoned,
> only shows you are unable to see the disadvantages.

Those of us who've been using Python for more than a few days think it
is you who are unable to see the advantages. ;)

Whether allowing indentation via either tabs or spaces was a
fundamental design flaw has long been debated.  Personally, I think
tabs should be outlawed in all source code...

-- 
Grant Edwards   grant.b.edwardsYow! Uh-oh!!  I'm having
  at   TOO MUCH FUN!!
  gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread jonas . thornvall
Den onsdagen den 30:e oktober 2013 kl. 16:35:29 UTC+1 skrev 
[email protected]:
> Den onsdagen den 30:e oktober 2013 kl. 16:09:25 UTC+1 skrev Mark Lawrence:
> 
> > On 30/10/2013 14:31, [email protected] wrote:
> 
> > 
> 
> > 
> 
> > 
> 
> > Would you please be kind enough to read, digest and action this 
> 
> > 
> 
> > https://wiki.python.org/moin/GoogleGroupsPython
> 
> > 
> 
> > 
> 
> > 
> 
> > TIA.
> 
> > 
> 
> > 
> 
> > 
> 
> > -- 
> 
> > 
> 
> > Python is the second best programming language in the world.
> 
> > 
> 
> > But the best has yet to be invented.  Christian Tismer
> 
> > 
> 
> > 
> 
> > 
> 
> > Mark Lawrence
> 
> 
> 
> I am all for automatiation to be honest i rather go in change the code for 
> google than do it manual. Maybe those who complain should adress Google? 
> There must be a simple solution or?

Another solution would of course be use a newsreader that can do it for you?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread rusi
On Wednesday, October 30, 2013 9:05:29 PM UTC+5:30, Jonas Thornval wrote:
> Den onsdagen den 30:e oktober 2013 kl. 16:09:25 UTC+1 skrev Mark Lawrence:
> > On 30/10/2013 14:31, Jonas Thornval wrote:
> > Would you please be kind enough to read, digest and action this 
> > https://wiki.python.org/moin/GoogleGroupsPython
> > TIA.
> > -- 
> > Python is the second best programming language in the world.
> > But the best has yet to be invented.  Christian Tismer
> > Mark Lawrence

> I am all for automatiation to be honest i rather go in change the code for 
> google than do it manual. Maybe those who complain should adress Google?
> There must be a simple solution or?

A fully automatic solution would be for google to stop screwing up :-)
One step less is to have some kind of javascript (greasemonkey??) plugin for 
firefox to cleanup GG's mess

Since I dont pretend to know JS/greasemonkey, I have made a small emacs script.
It involves
1. cut-pasting from browser to emacs
2. pressing a key
3. Cut pasting back

More details 
https://groups.google.com/forum/#!topic/comp.lang.python/Imo2m4GrS_I

So...
4 choices:

1. Do it by hand
2. Do it by emacs
3. Ignore and get unpopular
4. Dont use Google Groups
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread Alister
On Wed, 30 Oct 2013 08:35:29 -0700, jonas.thornvall wrote:

> Den onsdagen den 30:e oktober 2013 kl. 16:09:25 UTC+1 skrev Mark
> Lawrence:
>> On 30/10/2013 14:31, [email protected] wrote:
>> 
>> 
>> 
>> Would you please be kind enough to read, digest and action this
>> 
>> https://wiki.python.org/moin/GoogleGroupsPython
>> 
>> 
>> 
>> TIA.
>> 
>> 
>> 
>> --
>> 
>> Python is the second best programming language in the world.
>> 
>> But the best has yet to be invented.  Christian Tismer
>> 
>> 
>> 
>> Mark Lawrence
> 
> I am all for automatiation to be honest i rather go in change the code
> for google than do it manual. Maybe those who complain should adress
> Google? There must be a simple solution or?

Google are unlikely to change any time soon, if you do not compensate for 
there bad behaviour many people here will start to ignore your posts.

I agree it is a pain, & it is not your fault but these are the basic 
facts.



-- 
A rolling stone gathers no moss.
-- Publilius Syrus
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread jonas . thornvall
Den onsdagen den 30:e oktober 2013 kl. 16:54:19 UTC+1 skrev Mark Lawrence:
> On 30/10/2013 15:35, [email protected] wrote:
> 
> > Den onsdagen den 30:e oktober 2013 kl. 16:09:25 UTC+1 skrev Mark Lawrence:
> 
> >> On 30/10/2013 14:31, [email protected] wrote:
> 
> >>
> 
> >>
> 
> >>
> 
> >> Would you please be kind enough to read, digest and action this
> 
> >>
> 
> >> https://wiki.python.org/moin/GoogleGroupsPython
> 
> >>
> 
> >>
> 
> >>
> 
> >> TIA.
> 
> >>
> 
> >>
> 
> >>
> 
> >> --
> 
> >>
> 
> >> Python is the second best programming language in the world.
> 
> >>
> 
> >> But the best has yet to be invented.  Christian Tismer
> 
> >>
> 
> >>
> 
> >>
> 
> >> Mark Lawrence
> 
> >
> 
> > I am all for automatiation to be honest i rather go in change the code for 
> > google than do it manual. Maybe those who complain should adress Google? 
> > There must be a simple solution or?
> 
> >
> 
> 
> 
> The simplest solution is that you stop posting, as you've been spewing 
> 
> this double spaced crap all day and show no inclination to do anything 
> 
> about it.  I assume that google won't fix their problem as there's not 
> 
> enough profit in it.
> 
> 
> 
> -- 
> 
> Python is the second best programming language in the world.
> 
> But the best has yet to be invented.  Christian Tismer
> 
> 
> 
> Mark Lawrence

Bug of anal monkey either solve your own problems, or implement your own 
newsreader.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread jonas . thornvall
Den onsdagen den 30:e oktober 2013 kl. 16:50:43 UTC+1 skrev Grant Edwards:
> On 2013-10-30, Antoon Pardon  wrote:
> 
> > Op 30-10-13 08:07, Tim Roberts schreef:
> 
> >> [email protected] wrote:
> 
> >>>
> 
> >>> Why did Python not implement end... The end is really not necessary for
> 
> >>> the programming language it can be excluded, but it is a courtesy to
> 
> >>> the programmer and could easily be transformed to indents automaticly,
> 
> >>> that is removed before the compiliation/interpretation of code.  
> 
> >> 
> 
> >> You only say that because your brain has been poisoned by languages that
> 
> >> require some kind of "end".  It's not necessary, and it's extra typing. 99%
> 
> >> of programmers do the indentation anyway, to make the program easy to read,
> 
> >> so why not just make it part of the syntax?  That way, you don't
> 
> >> accidentally have the indentation not match the syntax.
> 
> >
> 
> > Because it is a pain in the ass. Now suddenly my program doesn't work
> 
> > because I somehow inserted a tab instead of spaces.
> 
> 
> 
> Then don't do that.
> 
> 
> 
> I'm only half-kidding.  Inserting incorrect tokens into program source
> 
> breaks programs in all languages.  The tricky bit is that in many
> 
> editors spaces and tabs look the same.  You can pick an editor that
> 
> provides a visual difference, or you can pick an editor that always
> 
> does the right thing, or you can stick with it until your fingers
> 
> learn to do the right thing.
> 
> 
> 
> > The end would also gives extra protection against faulty
> 
> > manipulations. I have at one time accidently copied a function partly
> 
> > further below. Because python doesn't need an end, the compilor was
> 
> > unable to detect this was only part of a function which caused a bug
> 
> > which was harder to find.
> 
> >
> 
> > Python made it's choice and I can live with that, but telling people
> 
> > who prefer it had made an other choice that their brain is poisoned,
> 
> > only shows you are unable to see the disadvantages.
> 
> 
> 
> Those of us who've been using Python for more than a few days think it
> 
> is you who are unable to see the advantages. ;)
> 
> 
> 
> Whether allowing indentation via either tabs or spaces was a
> 
> fundamental design flaw has long been debated.  Personally, I think
> 
> tabs should be outlawed in all source code...
> 
> 
> 
> -- 
> 
> Grant Edwards   grant.b.edwardsYow! Uh-oh!!  I'm having
> 
>   at   TOO MUCH FUN!!
> 
>   gmail.com

I think the idea with tab indentation would been it is an easy road for 
automation. I think it is easily that project goes anal when let over to code 
monkeys, maybe that is the case.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread Alister
On Wed, 30 Oct 2013 15:56:32 +0100, Antoon Pardon wrote:

> Op 30-10-13 15:22, Alister schreef:
>> On Wed, 30 Oct 2013 13:42:37 +0100, Antoon Pardon wrote:
>> 
>>> Op 30-10-13 13:17, Chris Angelico schreef:
 On Wed, Oct 30, 2013 at 11:01 PM, Antoon Pardon
  wrote:
 I broadly agree with your post (I'm of the school of thought that
 braces are better than indentation for delimiting blocks), but I
 don't think this argument holds water. All you need to do is be
 consistent about tabs OR spaces (and I'd recommend tabs, since
 they're simpler and safer), and you'll never have this trouble.
>>>
>>> Easier said than done. First of all I can be as consistent as
>>> possible, I can't just take code from someone else and insert it
>>> because that other person may be consistenly doing it different from
>>> me.
>> 
>> I disagree it is very easy.
> 
> You can disagree, as much as you want. You don't get to define my
> experience. Maybe all those things you enumerate are all easy, all taken
> together they can makes it cumbersome at times.
> 
>> 1) make sure you editor is set to inset 4 spaces rather than tab when
>> pressing the tab key. consistency in your own code is now not an issue.
>> 
>> 2) when importing code from someone else a simple search & replace of
>> tab with 4 spaces will instantly correct the formatting on code using
>> tab without breaking code that doesn't.
> 
> But why should I have to do all that. When I write other code I just
> don't have to bother and it is all indented as desired too.
> 
>>> Then if you are working on different machines, the settings of your
>>> editor may not always be the same so that you have tabs on one machine
>>> and spaces on an other, which causes problem when you move the code.
>>>
>> that is fixed by setting your environment consistantly but step 2 above
>> will fix it if you forget.
> 
> Again why should I have to bother. Why does python force me to go
> through all this trouble when other languages allow themselves to be
> happily edited without all this.
> 
>>> Also when you have an xterm, selecting a tab and pasting it into
>>> another it will turn the tab into spaces.
>> 
>> Read pep 11 & always use 4 spaces for indentation not tab.
> 
> I'll decide how to layout my code.
> 
>>> All these things usually can be ignored, they typically only show up
>>> when you print something and things aren't aligned as you expect but
>>> with python you are forced to correct those things immediately,
>>> forcing you to focus on white space layout issues instead of on the
>>> logic of the code.
>>>
 Also, the parser should tell you if you mix tabs and spaces, so that
 won't trip anything either.
>>>
>>> Maybe you mean something different than I understand but a program
>>> throwing a syntax error because there is a tab instead of a number of
>>> spaces or vice versa, is something I would understand as tripping.
>> 
>> no more than failing to close a brace in a C like language indentation
>> is the syntax of python you will grow to love it, like most people I
>> found it distracting at first even though i tended to indent other code
>> (inconsistently)to make it readable.
> 
> I didn't like it at first, accustomed to it a bit and then disliked it
> again. So no I don't think I will grow to love it. Python is a tool, not
> a religion, so I can live with it if the tool I use has some featurese I
> dislike about it. As long as I evaluate the usefulness of the tool as
> positive I can live with the peeves.
> 
> What is more annoying are the people with some kind of need to reason
> your peeves away, as if it is sacriledge daring to dislike something
> about the language.

I guess your experience & mine differ, that is personal taste
I am certainly not trying to "reason your peeves away" just presenting an 
alternate view.

Just for fun I knocked up a quick function to parse a poorly writen 
program as described by the OP (with end as a block terminator) and came 
up with the following

def fixfile(i,o):
infile=open(i,'r')
outfile=open(o,'w')
indent=0
for line in infile:
text=line.strip()
if text[-3:]=='end':
indent=indent -1
continue
outfile.write("%s%s\r\n"%(" "*(indent*4),text))
if text[-1]==":":
indent=indent+1

obviously this is just proof of concept with no error checking vbut it 
did convert this:-

def function():
print "this should be indented but isnt"
print "indented with tab"
   print "too many spaces"
for x in range(10):
print "this should be indented twice!"
end
print "should be indented once"
end
print "this should not be indented at all!"


into this:-

def function():
print "this should be indented but isnt"
print "indented with tab"
print "too many spaces"
for x in range(10):
print "this should be indented twice!"
print "should be indented once"
print "this should not be indented at all!"


-- 

Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread Alister
On Wed, 30 Oct 2013 08:57:08 -0700, jonas.thornvall wrote:

> Den onsdagen den 30:e oktober 2013 kl. 16:54:19 UTC+1 skrev Mark
> Lawrence:
>> On 30/10/2013 15:35, [email protected] wrote:
>> 
>> > Den onsdagen den 30:e oktober 2013 kl. 16:09:25 UTC+1 skrev Mark
>> > Lawrence:
>> 
>> >> On 30/10/2013 14:31, [email protected] wrote:
>> 
>> 
>> >>
>> 
>> >>
>> 
>> >>
>> >> Would you please be kind enough to read, digest and action this
>> 
>> 
>> >>
>> >> https://wiki.python.org/moin/GoogleGroupsPython
>> 
>> 
>> >>
>> 
>> >>
>> 
>> >>
>> >> TIA.
>> 
>> 
>> >>
>> 
>> >>
>> 
>> >>
>> >> --
>> 
>> 
>> >>
>> >> Python is the second best programming language in the world.
>> 
>> 
>> >>
>> >> But the best has yet to be invented.  Christian Tismer
>> 
>> 
>> >>
>> 
>> >>
>> 
>> >>
>> >> Mark Lawrence
>> 
>> 
>> >
>> > I am all for automatiation to be honest i rather go in change the
>> > code for google than do it manual. Maybe those who complain should
>> > adress Google? There must be a simple solution or?
>> 
>> 
>> >
>> 
>> 
>> The simplest solution is that you stop posting, as you've been spewing
>> 
>> this double spaced crap all day and show no inclination to do anything
>> 
>> about it.  I assume that google won't fix their problem as there's not
>> 
>> enough profit in it.
>> 
>> 
>> 
>> --
>> 
>> Python is the second best programming language in the world.
>> 
>> But the best has yet to be invented.  Christian Tismer
>> 
>> 
>> 
>> Mark Lawrence
> 
> Bug of anal monkey either solve your own problems, or implement your own
> newsreader.

That was totally unnecessary, your rudeness levels are now approaching 
that of another poster I wont mention.
I expect the level of assistance you receive will fall of dramatically 
now which is a shame as newcomers to the language should be helped & 
encouraged wherever possible.




-- 
I always turn to the sports pages first, which record people's 
accomplishments.
The front page has nothing but man's failures.
-- Chief Justice Earl Warren
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread jonas . thornvall
Den onsdagen den 30:e oktober 2013 kl. 16:51:58 UTC+1 skrev Alister:
> On Wed, 30 Oct 2013 08:35:29 -0700, jonas.thornvall wrote:
> 
> 
> 
> > Den onsdagen den 30:e oktober 2013 kl. 16:09:25 UTC+1 skrev Mark
> 
> > Lawrence:
> 
> >> On 30/10/2013 14:31, [email protected] wrote:
> 
> >> 
> 
> >> 
> 
> >> 
> 
> >> Would you please be kind enough to read, digest and action this
> 
> >> 
> 
> >> https://wiki.python.org/moin/GoogleGroupsPython
> 
> >> 
> 
> >> 
> 
> >> 
> 
> >> TIA.
> 
> >> 
> 
> >> 
> 
> >> 
> 
> >> --
> 
> >> 
> 
> >> Python is the second best programming language in the world.
> 
> >> 
> 
> >> But the best has yet to be invented.  Christian Tismer
> 
> >> 
> 
> >> 
> 
> >> 
> 
> >> Mark Lawrence
> 
> > 
> 
> > I am all for automatiation to be honest i rather go in change the code
> 
> > for google than do it manual. Maybe those who complain should adress
> 
> > Google? There must be a simple solution or?
> 
> 
> 
> Google are unlikely to change any time soon, if you do not compensate for 
> 
> there bad behaviour many people here will start to ignore your posts.
> 
> 
> 
> I agree it is a pain, & it is not your fault but these are the basic 
> 
> facts.
> 
> 
> 
> 
> 
> 
> 
> -- 
> 
> A rolling stone gathers no moss.
> 
>   -- Publilius Syrus

Well i ain't going to change so i promise unless the spaceout rows fill some 
purpose it is Google who is going to change. 

Google groups work good for me and i certainly have no intention to change 
newsreader, but i agree Google should have done something about this years ago 
*if the empty lines fill no purpose*. And they did a mayor change a couple of 
years ago, it is a mystery they could not fix this if it serve no purpose?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread rusi
On Wednesday, October 30, 2013 9:27:08 PM UTC+5:30, [email protected] wrote:
> Den onsdagen den 30:e oktober 2013 kl. 16:54:19 UTC+1 skrev Mark Lawrence:
> > The simplest solution is that you stop posting, as you've been spewing 
> > this double spaced crap all day and show no inclination to do anything 
> > about it.  I assume that google won't fix their problem as there's not 
> > enough profit in it.

> Bug of anal monkey either solve your own problems, or implement your own 
> newsreader.

Yes I guess if Mark speaks in that way he will get that kind of response. (Sigh)

However Jonas, please remember that this list is read by thousands.
And by posting 5 times more lines than is relevant to the discussion you are 
making a nuisance of yourself to all those readers.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread Alister
On Wed, 30 Oct 2013 16:07:47 +, Alister wrote:

> On Wed, 30 Oct 2013 15:56:32 +0100, Antoon Pardon wrote:
> 
>> Op 30-10-13 15:22, Alister schreef:
>>> On Wed, 30 Oct 2013 13:42:37 +0100, Antoon Pardon wrote:
>>> 
 Op 30-10-13 13:17, Chris Angelico schreef:
> On Wed, Oct 30, 2013 at 11:01 PM, Antoon Pardon
>  wrote:
> I broadly agree with your post (I'm of the school of thought that
> braces are better than indentation for delimiting blocks), but I
> don't think this argument holds water. All you need to do is be
> consistent about tabs OR spaces (and I'd recommend tabs, since
> they're simpler and safer), and you'll never have this trouble.

 Easier said than done. First of all I can be as consistent as
 possible, I can't just take code from someone else and insert it
 because that other person may be consistenly doing it different from
 me.
>>> 
>>> I disagree it is very easy.
>> 
>> You can disagree, as much as you want. You don't get to define my
>> experience. Maybe all those things you enumerate are all easy, all
>> taken together they can makes it cumbersome at times.
>> 
>>> 1) make sure you editor is set to inset 4 spaces rather than tab when
>>> pressing the tab key. consistency in your own code is now not an
>>> issue.
>>> 
>>> 2) when importing code from someone else a simple search & replace of
>>> tab with 4 spaces will instantly correct the formatting on code using
>>> tab without breaking code that doesn't.
>> 
>> But why should I have to do all that. When I write other code I just
>> don't have to bother and it is all indented as desired too.
>> 
 Then if you are working on different machines, the settings of your
 editor may not always be the same so that you have tabs on one
 machine and spaces on an other, which causes problem when you move
 the code.

>>> that is fixed by setting your environment consistantly but step 2
>>> above will fix it if you forget.
>> 
>> Again why should I have to bother. Why does python force me to go
>> through all this trouble when other languages allow themselves to be
>> happily edited without all this.
>> 
 Also when you have an xterm, selecting a tab and pasting it into
 another it will turn the tab into spaces.
>>> 
>>> Read pep 11 & always use 4 spaces for indentation not tab.
>> 
>> I'll decide how to layout my code.
>> 
 All these things usually can be ignored, they typically only show up
 when you print something and things aren't aligned as you expect but
 with python you are forced to correct those things immediately,
 forcing you to focus on white space layout issues instead of on the
 logic of the code.

> Also, the parser should tell you if you mix tabs and spaces, so that
> won't trip anything either.

 Maybe you mean something different than I understand but a program
 throwing a syntax error because there is a tab instead of a number of
 spaces or vice versa, is something I would understand as tripping.
>>> 
>>> no more than failing to close a brace in a C like language indentation
>>> is the syntax of python you will grow to love it, like most people I
>>> found it distracting at first even though i tended to indent other
>>> code (inconsistently)to make it readable.
>> 
>> I didn't like it at first, accustomed to it a bit and then disliked it
>> again. So no I don't think I will grow to love it. Python is a tool,
>> not a religion, so I can live with it if the tool I use has some
>> featurese I dislike about it. As long as I evaluate the usefulness of
>> the tool as positive I can live with the peeves.
>> 
>> What is more annoying are the people with some kind of need to reason
>> your peeves away, as if it is sacriledge daring to dislike something
>> about the language.
> 
> I guess your experience & mine differ, that is personal taste I am
> certainly not trying to "reason your peeves away" just presenting an
> alternate view.
> 
> Just for fun I knocked up a quick function to parse a poorly writen
> program as described by the OP (with end as a block terminator) and came
> up with the following
> 
> def fixfile(i,o):
> infile=open(i,'r')
> outfile=open(o,'w')
> indent=0 for line in infile:
> text=line.strip()
> if text[-3:]=='end':
> indent=indent -1 continue
> outfile.write("%s%s\r\n"%(" "*(indent*4),text))
> if text[-1]==":":
> indent=indent+1
> 
> obviously this is just proof of concept with no error checking vbut it
> did convert this:-
> 
> def function():
> print "this should be indented but isnt"
>   print "indented with tab"
>print "too many spaces"
> for x in range(10):
> print "this should be indented twice!"
> end print "should be indented once"
> end
> print "this should not be indented at all!"
> 
> 
> into this:-
> 
> def function():
> print "this should be indented but isnt"
> print "indented

Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread jonas . thornvall
Den onsdagen den 30:e oktober 2013 kl. 16:54:19 UTC+1 skrev Mark Lawrence:
> On 30/10/2013 15:35, [email protected] wrote:
> 
> > Den onsdagen den 30:e oktober 2013 kl. 16:09:25 UTC+1 skrev Mark Lawrence:
> 
> >> On 30/10/2013 14:31, [email protected] wrote:
> 
> >>
> 
> >>
> 
> >>
> 
> >> Would you please be kind enough to read, digest and action this
> 
> >>
> 
> >> https://wiki.python.org/moin/GoogleGroupsPython
> 
> >>
> 
> >>
> 
> >>
> 
> >> TIA.
> 
> >>
> 
> >>
> 
> >>
> 
> >> --
> 
> >>
> 
> >> Python is the second best programming language in the world.
> 
> >>
> 
> >> But the best has yet to be invented.  Christian Tismer
> 
> >>
> 
> >>
> 
> >>
> 
> >> Mark Lawrence
> 
> >
> 
> > I am all for automatiation to be honest i rather go in change the code for 
> > google than do it manual. Maybe those who complain should adress Google? 
> > There must be a simple solution or?
> 
> >
> 
> 
> 
> The simplest solution is that you stop posting, as you've been spewing 
> 
> this double spaced crap all day and show no inclination to do anything 
> 
> about it.  I assume that google won't fix their problem as there's not 
> 
> enough profit in it.
> 
> 
> 
> -- 
> 
> Python is the second best programming language in the world.
> 
> But the best has yet to be invented.  Christian Tismer
> 
> 
> 
> Mark Lawrence

For what *they* actually have done is replacing the curl paragraph slavery with 
indentation slavery. And looking at the other features of python i easily can 
tell that was not the intention of the creator, it was to remove the anal code 
monkey stuff and replace it with simplicity and automation.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: trying to strip out non ascii.. or rather convert non ascii

2013-10-30 Thread wxjmfauth
Le mercredi 30 octobre 2013 13:44:47 UTC+1, Ned Batchelder a écrit :
> On 10/30/13 4:49 AM, [email protected] wrote:
> 
> > Le mardi 29 octobre 2013 06:24:50 UTC+1, Steven D'Aprano a écrit :
> 
> >> On Mon, 28 Oct 2013 09:23:41 -0500, Tim Chase wrote:
> 
> >>
> 
> >>
> 
> >>
> 
> >>> On 2013-10-28 07:01, [email protected] wrote:
> 
> > Simply ignoring diactrics won't get you very far.
> 
>  Right. As an example, these four French words : cote, côte, coté, côté
> 
>  .
> 
> >>> Distinct words with distinct meanings, sure.
> 
> >>> But when a naïve (naive? ☺) person or one without the easy ability to
> 
> >>> enter characters with diacritics searches for "cote", I want to return
> 
> >>> possible matches containing any of your 4 examples.  It's slightly
> 
> >>> fuzzier if they search for "coté", in which case they may mean "coté" or
> 
> >>> they might mean be unable to figure out how to add a hat and want to
> 
> >>> type "côté". Though I'd rather get more results, even if it has some
> 
> >>> that only match fuzzily.
> 
> >>
> 
> >>
> 
> >> The right solution to that is to treat it no differently from other fuzzy
> 
> >>
> 
> >> searches. A good search engine should be tolerant of spelling errors and
> 
> >>
> 
> >> alternative spellings for any letter, not just those with diacritics.
> 
> >>
> 
> >> Ideally, a good search engine would successfully match all three of
> 
> >>
> 
> >> "naïve", "naive" and "niave", and it shouldn't rely on special handling
> 
> >>
> 
> >> of diacritics.
> 
> >>
> 
> >>
> 
> >>
> 
> > --
> 
> >
> 
> > This is a non sense. The purpose of a diacritical mark is to
> 
> > make a letter a different letter. If a tool is supposed to
> 
> > match an ô, there is absolutely no reason to match something
> 
> > else.
> 
> >
> 
> > jmf
> 
> >
> 
> 
> 
> jmf, Tim Chase described his use case, and it seems reasonable to me.  
> 
> I'm not sure why you would describe it as nonsense.
> 
> 
> 
> --Ned.



My comment had nothing to do with Python, it was a
general comment. A diacritical mark just makes a letter
a different letter; a "ï " and a "i" are "as
diferent" as a "a" from a "z". A diacritical mark
is more than a simple ornementation.

From a unicode perspective.
Unicode.org "knows", these chars a very important, that's
the reason why they exist in two forms, precomposed and
composed forms.

From a software perspective.
Luckily for the end users, all the serious software
are considering all these chars in an equal way. They
are all belonging to the BMP plane. An "Ą" is treated
as an "ê", same memory consumption, same performance,
==> very smooth software.

jmf

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


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread Mark Lawrence

On 30/10/2013 15:57, [email protected] wrote:

Den onsdagen den 30:e oktober 2013 kl. 16:54:19 UTC+1 skrev Mark Lawrence:

On 30/10/2013 15:35, [email protected] wrote:


Den onsdagen den 30:e oktober 2013 kl. 16:09:25 UTC+1 skrev Mark Lawrence:



On 30/10/2013 14:31, [email protected] wrote:















Would you please be kind enough to read, digest and action this







https://wiki.python.org/moin/GoogleGroupsPython















TIA.















--







Python is the second best programming language in the world.







But the best has yet to be invented.  Christian Tismer















Mark Lawrence







I am all for automatiation to be honest i rather go in change the code for 
google than do it manual. Maybe those who complain should adress Google? There 
must be a simple solution or?








The simplest solution is that you stop posting, as you've been spewing

this double spaced crap all day and show no inclination to do anything

about it.  I assume that google won't fix their problem as there's not

enough profit in it.



--

Python is the second best programming language in the world.

But the best has yet to be invented.  Christian Tismer



Mark Lawrence


Bug of anal monkey either solve your own problems, or implement your own 
newsreader.



I have no need to implement a newsreader as I can quite happily send and 
receive data using Thunderbird.  There are several other similar email 
options available.  An alternative is for you to show others some 
courtesy and follow the instructions that would show just a few lines up 
from here, except that your insistence on using bug ridden technology 
means it's actually light years away.


--
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

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


Re: trying to strip out non ascii.. or rather convert non ascii

2013-10-30 Thread Mark Lawrence

On 30/10/2013 16:08, [email protected] wrote:

Would you please read, digest and action this 
https://wiki.python.org/moin/GoogleGroupsPython


TIA.

--
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

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


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread Kushal Kumaran
rusi  writes:

> On Wednesday, October 30, 2013 9:05:29 PM UTC+5:30, Jonas Thornval wrote:
>> Den onsdagen den 30:e oktober 2013 kl. 16:09:25 UTC+1 skrev Mark Lawrence:
>> > On 30/10/2013 14:31, Jonas Thornval wrote:
>> > Would you please be kind enough to read, digest and action this 
>> > https://wiki.python.org/moin/GoogleGroupsPython
>> > TIA.
>> > -- 
>> > Python is the second best programming language in the world.
>> > But the best has yet to be invented.  Christian Tismer
>> > Mark Lawrence
>
>> I am all for automatiation to be honest i rather go in change the code for 
>> google than do it manual. Maybe those who complain should adress Google?
>> There must be a simple solution or?
>
> A fully automatic solution would be for google to stop screwing up :-)
> One step less is to have some kind of javascript (greasemonkey??) plugin for 
> firefox to cleanup GG's mess
>
> Since I dont pretend to know JS/greasemonkey, I have made a small emacs 
> script.
> It involves
> 1. cut-pasting from browser to emacs
> 2. pressing a key
> 3. Cut pasting back
>

Getting off topic here, but if you use Firefox, there is an extension
that can do steps 1 and 3 for you:
https://github.com/docwhat/itsalltext/

> More details 
> https://groups.google.com/forum/#!topic/comp.lang.python/Imo2m4GrS_I
>
> So...
> 4 choices:
>
> 1. Do it by hand
> 2. Do it by emacs
> 3. Ignore and get unpopular
> 4. Dont use Google Groups

-- 
regards,
kushal


pgpSyPDCozr8d.pgp
Description: PGP signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread jonas . thornvall
Den onsdagen den 30:e oktober 2013 kl. 17:22:23 UTC+1 skrev Mark Lawrence:
> On 30/10/2013 15:57, [email protected] wrote:
> 
> > Den onsdagen den 30:e oktober 2013 kl. 16:54:19 UTC+1 skrev Mark Lawrence:
> 
> >> On 30/10/2013 15:35, [email protected] wrote:
> 
> >>
> 
> >>> Den onsdagen den 30:e oktober 2013 kl. 16:09:25 UTC+1 skrev Mark Lawrence:
> 
> >>
> 
>  On 30/10/2013 14:31, [email protected] wrote:
> 
> >>
> 
> 
> 
> >>
> 
> 
> 
> >>
> 
> 
> 
> >>
> 
>  Would you please be kind enough to read, digest and action this
> 
> >>
> 
> 
> 
> >>
> 
>  https://wiki.python.org/moin/GoogleGroupsPython
> 
> >>
> 
> 
> 
> >>
> 
> 
> 
> >>
> 
> 
> 
> >>
> 
>  TIA.
> 
> >>
> 
> 
> 
> >>
> 
> 
> 
> >>
> 
> 
> 
> >>
> 
>  --
> 
> >>
> 
> 
> 
> >>
> 
>  Python is the second best programming language in the world.
> 
> >>
> 
> 
> 
> >>
> 
>  But the best has yet to be invented.  Christian Tismer
> 
> >>
> 
> 
> 
> >>
> 
> 
> 
> >>
> 
> 
> 
> >>
> 
>  Mark Lawrence
> 
> >>
> 
> >>>
> 
> >>
> 
> >>> I am all for automatiation to be honest i rather go in change the code 
> >>> for google than do it manual. Maybe those who complain should adress 
> >>> Google? There must be a simple solution or?
> 
> >>
> 
> >>>
> 
> >>
> 
> >>
> 
> >>
> 
> >> The simplest solution is that you stop posting, as you've been spewing
> 
> >>
> 
> >> this double spaced crap all day and show no inclination to do anything
> 
> >>
> 
> >> about it.  I assume that google won't fix their problem as there's not
> 
> >>
> 
> >> enough profit in it.
> 
> >>
> 
> >>
> 
> >>
> 
> >> --
> 
> >>
> 
> >> Python is the second best programming language in the world.
> 
> >>
> 
> >> But the best has yet to be invented.  Christian Tismer
> 
> >>
> 
> >>
> 
> >>
> 
> >> Mark Lawrence
> 
> >
> 
> > Bug of anal monkey either solve your own problems, or implement your own 
> > newsreader.
> 
> >
> 
> 
> 
> I have no need to implement a newsreader as I can quite happily send and 
> 
> receive data using Thunderbird.  There are several other similar email 
> 
> options available.  An alternative is for you to show others some 
> 
> courtesy and follow the instructions that would show just a few lines up 
> 
> from here, except that your insistence on using bug ridden technology 
> 
> means it's actually light years away.
> 
> 
> 
> -- 
> 
> Python is the second best programming language in the world.
> 
> But the best has yet to be invented.  Christian Tismer
> 
> 
> 
> Mark Lawrence

No that is not my problem, apparently so it is that the newsreader constructors 
do not like the competition of Google groups otherwise they would had written 
the five lines of codes necessary to remove the empty linebreaks.
I like web based features, and i will use them until "they get it right, 
understood?"
End of story
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread Mark Lawrence

On 30/10/2013 16:16, rusi wrote:

On Wednesday, October 30, 2013 9:27:08 PM UTC+5:30, [email protected] wrote:

Den onsdagen den 30:e oktober 2013 kl. 16:54:19 UTC+1 skrev Mark Lawrence:

The simplest solution is that you stop posting, as you've been spewing
this double spaced crap all day and show no inclination to do anything
about it.  I assume that google won't fix their problem as there's not
enough profit in it.



Bug of anal monkey either solve your own problems, or implement your own 
newsreader.


Yes I guess if Mark speaks in that way he will get that kind of response. (Sigh)

However Jonas, please remember that this list is read by thousands.
And by posting 5 times more lines than is relevant to the discussion you are 
making a nuisance of yourself to all those readers.



I count 21 emails from the OP within the last 24 hours.  That means 20 
are double spaced.  So, how many times do you have to ask before the 
culprit does something about the problem?  In this case infinity as the 
OP has stated that they will not change, thanks a bunch for that.


--
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

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


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread rusi
Super Kushal!
Below is the result of that
First the original 
Then emacs' cleaned up version!



-Original --

On Wednesday, October 30, 2013 10:00:47 PM UTC+5:30, Kushal Kumaran wrote:
> rusi  writes:
> 
> 
> 
> > On Wednesday, October 30, 2013 9:05:29 PM UTC+5:30, Jonas Thornval wrote:
> 
> >> Den onsdagen den 30:e oktober 2013 kl. 16:09:25 UTC+1 skrev Mark Lawrence:
> 
> >> > On 30/10/2013 14:31, Jonas Thornval wrote:
> 
> >> > Would you please be kind enough to read, digest and action this 
> 
> >> > https://wiki.python.org/moin/GoogleGroupsPython
> 
> >> > TIA.
> 
> >> > -- 
> 
> >> > Python is the second best programming language in the world.
> 
> >> > But the best has yet to be invented.  Christian Tismer
> 
> >> > Mark Lawrence
> 
> >
> 
> >> I am all for automatiation to be honest i rather go in change the code for 
> 
> >> google than do it manual. Maybe those who complain should adress Google?
> 
> >> There must be a simple solution or?
> 
> >
> 
> > A fully automatic solution would be for google to stop screwing up :-)
> 
> > One step less is to have some kind of javascript (greasemonkey??) plugin 
> > for firefox to cleanup GG's mess
> 
> >
> 
> > Since I dont pretend to know JS/greasemonkey, I have made a small emacs 
> > script.
> 
> > It involves
> 
> > 1. cut-pasting from browser to emacs
> 
> > 2. pressing a key
> 
> > 3. Cut pasting back
> 
> >
> 
> 
> 
> Getting off topic here, but if you use Firefox, there is an extension
> 
> that can do steps 1 and 3 for you:
> 
> https://github.com/docwhat/itsalltext/
> 
> 
> 
> > More details 
> > https://groups.google.com/forum/#!topic/comp.lang.python/Imo2m4GrS_I
> 
> >
> 
> > So...
> 
> > 4 choices:
> 
> >
> 
> > 1. Do it by hand
> 
> > 2. Do it by emacs
> 
> > 3. Ignore and get unpopular
> 
> > 4. Dont use Google Groups
> 
> 
> 
> -- 
> 
> regards,
> 
> kushal




After replacement---




On Wednesday, October 30, 2013 10:00:47 PM UTC+5:30, Kushal Kumaran wrote:
> rusi  writes:

> > On Wednesday, October 30, 2013 9:05:29 PM UTC+5:30, Jonas Thornval wrote:
> >> Den onsdagen den 30:e oktober 2013 kl. 16:09:25 UTC+1 skrev Mark Lawrence:
> >> > On 30/10/2013 14:31, Jonas Thornval wrote:
> >> > Would you please be kind enough to read, digest and action this 
> >> > https://wiki.python.org/moin/GoogleGroupsPython
> >> > TIA.
> >> > -- 
> >> > Python is the second best programming language in the world.
> >> > But the best has yet to be invented.  Christian Tismer
> >> > Mark Lawrence
> >
> >> I am all for automatiation to be honest i rather go in change the code for 
> >> google than do it manual. Maybe those who complain should adress Google?
> >> There must be a simple solution or?
> >
> > A fully automatic solution would be for google to stop screwing up :-)
> > One step less is to have some kind of javascript (greasemonkey??) plugin 
> > for firefox to cleanup GG's mess
> >
> > Since I dont pretend to know JS/greasemonkey, I have made a small emacs 
> > script.
> > It involves
> > 1. cut-pasting from browser to emacs
> > 2. pressing a key
> > 3. Cut pasting back
> >

> Getting off topic here, but if you use Firefox, there is an extension
> that can do steps 1 and 3 for you:
> https://github.com/docwhat/itsalltext/

> > More details 
> > https://groups.google.com/forum/#!topic/comp.lang.python/Imo2m4GrS_I
> >
> > So...
> > 4 choices:
> >
> > 1. Do it by hand
> > 2. Do it by emacs
> > 3. Ignore and get unpopular
> > 4. Dont use Google Groups

> -- 
> regards,
> kushal

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


small regexp help

2013-10-30 Thread rusi
Well it seems that we are considerably closer to a solution to the GG 
double-spaced crap problem.

Just wondering if someone can suggest a cleanup of the regexp part

Currently I have (elisp)

(defun clean-gg () 
  (interactive)
1  (replace-regexp "^> *\n> *\n> *$" "-=\=-" nil 0 (point-max))
2  (flush-lines "> *$" 0 (point-max))
3  (replace-regexp "-=\=-" "" nil 0 (point-max)))

Which I spell out as:

1. Replace triplets of empty lines of the form

>
>
>

with only 1 (because this is an actual blank line and not a GG-crap line)
However then it gets mixed up with the others so put some strange string:
"-=\=-" as replacement

2. Remove the pure
> 
lines

3. Remove the strange string.

Not very robust since the strange string could occur in the text.
So what are the more proper regexp solution(s)?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread rurpy
On 10/30/2013 08:22 AM, Alister wrote:
> On Wed, 30 Oct 2013 13:42:37 +0100, Antoon Pardon wrote:
>> Op 30-10-13 13:17, Chris Angelico schreef:
>>> On Wed, Oct 30, 2013 at 11:01 PM, Antoon Pardon
>>>  wrote:
>>> I broadly agree with your post (I'm of the school of thought that
>>> braces are better than indentation for delimiting blocks), but I don't
>>> think this argument holds water. All you need to do is be consistent
>>> about tabs OR spaces (and I'd recommend tabs, since they're simpler and
>>> safer), and you'll never have this trouble.
>> 
>> Easier said than done. First of all I can be as consistent as possible,
>> I can't just take code from someone else and insert it because that
>> other person may be consistenly doing it different from me.
> 
> I disagree it is very easy.
>[...]
> 2) when importing code from someone else a simple search & replace of tab 
> with 4 spaces will instantly correct the formatting on code using tab 
> without breaking code that doesn't.

Tabs can occur in strings as well as tokens in Python 
code and such code will be broken by a global search and
replace:

print ("  %s" % message)
^^--- This is a literal tab.

Or:

CSVDATA = '''
itemqty cost
44522   100 30.25
44107   55  15.50
45229   100777.20
'''
where the spaces between the columns above need to be
tabs to be correctly processed as csv text.

Your "easy fix" will break code like the above.
(And please note that because you can write the above 
using "\t" or avoid literal tabs in other ways, that:
1) Does not negate the fact that the above code is
 legal python code that is broken by your suggestion.
2) Alternatives such as using '\t' have their own 
 downsides such as readability or lack of compatibility 
 with other parts of a larger system.

Note too that even replacing only leading tabs is not 
safe since the cvs data above could have leading tabs.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: trying to strip out non ascii.. or rather convert non ascii

2013-10-30 Thread Ned Batchelder

On 10/30/13 12:08 PM, [email protected] wrote:

Le mercredi 30 octobre 2013 13:44:47 UTC+1, Ned Batchelder a écrit :

On 10/30/13 4:49 AM, [email protected] wrote:


Le mardi 29 octobre 2013 06:24:50 UTC+1, Steven D'Aprano a écrit :

On Mon, 28 Oct 2013 09:23:41 -0500, Tim Chase wrote:

On 2013-10-28 07:01, [email protected] wrote:

Simply ignoring diactrics won't get you very far.

Right. As an example, these four French words : cote, côte, coté, côté
.

Distinct words with distinct meanings, sure.
But when a naïve (naive? ☺) person or one without the easy ability to
enter characters with diacritics searches for "cote", I want to return
possible matches containing any of your 4 examples.  It's slightly
fuzzier if they search for "coté", in which case they may mean "coté" or
they might mean be unable to figure out how to add a hat and want to
type "côté". Though I'd rather get more results, even if it has some
that only match fuzzily.

The right solution to that is to treat it no differently from other fuzzy
searches. A good search engine should be tolerant of spelling errors and
alternative spellings for any letter, not just those with diacritics.
Ideally, a good search engine would successfully match all three of
"naïve", "naive" and "niave", and it shouldn't rely on special handling
of diacritics.

--
This is a non sense. The purpose of a diacritical mark is to
make a letter a different letter. If a tool is supposed to
match an ô, there is absolutely no reason to match something
else.
jmf



jmf, Tim Chase described his use case, and it seems reasonable to me.

I'm not sure why you would describe it as nonsense.



--Ned.



My comment had nothing to do with Python, it was a
general comment. A diacritical mark just makes a letter
a different letter; a "ï " and a "i" are "as
diferent" as a "a" from a "z". A diacritical mark
is more than a simple ornementation.


Yes, we understand that.  Tim outlined a need that had to do with users' 
informal typing.  In his case, he needs to deal with that sloppiness.  
You can't simply insist that users be more precise.


Unicode is a way to represent text, and text gets used in many different 
ways.  Each of us has to acknowledge that our text needs may be 
different than someone else's.  jmf, I'm guessing from your comments 
over the last few months that you are doing detailed linguistic work 
with corpora in many languages.  That work leads to one style of Unicode 
use.  In your domain, it is "nonsense" to ignore diacriticals.


Other people do different kinds of work with Unicode, and that leads to 
different needs.  In Tim's system, it is important to ignore 
diacriticals.  You might not have a use personally for Tim's system.  
That doesn't make it nonsense.


--Ned.

 From a unicode perspective.
Unicode.org "knows", these chars a very important, that's
the reason why they exist in two forms, precomposed and
composed forms.

 From a software perspective.
Luckily for the end users, all the serious software
are considering all these chars in an equal way. They
are all belonging to the BMP plane. An "Ą" is treated
as an "ê", same memory consumption, same performance,
==> very smooth software.

jmf



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


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread MRAB

On 30/10/2013 16:31, [email protected] wrote:

Den onsdagen den 30:e oktober 2013 kl. 17:22:23 UTC+1 skrev Mark Lawrence:
No that is not my problem, apparently so it is that the newsreader constructors 
do not like the competition of Google groups otherwise they would had written 
the five lines of codes necessary to remove the empty linebreaks.
I like web based features, and i will use them until "they get it right, 
understood?"
End of story


Google Groups aren't following the standard. Everybody else is. Why
should everybody else have to add a fix to correct what Google Groups
keeps getting wrong?
--
https://mail.python.org/mailman/listinfo/python-list


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread jonas . thornvall
Den onsdagen den 30:e oktober 2013 kl. 18:44:20 UTC+1 skrev MRAB:
> On 30/10/2013 16:31, [email protected] wrote:
> 
> > Den onsdagen den 30:e oktober 2013 kl. 17:22:23 UTC+1 skrev Mark Lawrence:
> 
> > No that is not my problem, apparently so it is that the newsreader 
> > constructors do not like the competition of Google groups otherwise they 
> > would had written the five lines of codes necessary to remove the empty 
> > linebreaks.
> 
> > I like web based features, and i will use them until "they get it right, 
> > understood?"
> 
> > End of story
> 
> >
> 
> Google Groups aren't following the standard. Everybody else is. Why
> 
> should everybody else have to add a fix to correct what Google Groups
> 
> keeps getting wrong?

Honestly i do not understand why you direct this question to me.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread jonas . thornvall
Den onsdagen den 30:e oktober 2013 kl. 18:44:20 UTC+1 skrev MRAB:
> On 30/10/2013 16:31, [email protected] wrote:
> 
> > Den onsdagen den 30:e oktober 2013 kl. 17:22:23 UTC+1 skrev Mark Lawrence:
> 
> > No that is not my problem, apparently so it is that the newsreader 
> > constructors do not like the competition of Google groups otherwise they 
> > would had written the five lines of codes necessary to remove the empty 
> > linebreaks.
> 
> > I like web based features, and i will use them until "they get it right, 
> > understood?"
> 
> > End of story
> 
> >
> 
> Google Groups aren't following the standard. Everybody else is. Why
> 
> should everybody else have to add a fix to correct what Google Groups
> 
> keeps getting wrong?

I do see though this have to be something related to their database, nothing 
they do by purpose. So unless the database storing messages change, it probably 
would need an ugly fix like a script.

So probably you should direct your question to either the creators of googles 
database or beg the creators of google groups to do a fix...

I think the later is the way to go although i suspect this has something todo 
with the database storing the messages.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: trying to strip out non ascii.. or rather convert non ascii

2013-10-30 Thread Michael Torrie
On 10/30/2013 10:08 AM, [email protected] wrote:
> My comment had nothing to do with Python, it was a
> general comment. A diacritical mark just makes a letter
> a different letter; a "ï " and a "i" are "as
> diferent" as a "a" from a "z". A diacritical mark
> is more than a simple ornementation.

That's nice, but you didn't actually read what Ned said (or the OP).
The OP doesn't care that "ï " and a "i" are as different as "a" and "z".
 For the purposes of his search he wants them treated as the same
letter.  A fuzzy searching treats them all the same. For example, a
search for "Godel, Escher, Bach" should find "Gödel, Escher, Bach" just
fine.  Even though "o" and "ö" are different characters.  And lo and
behold Google actually does this!  Try it.  It's nice for those of use
who want to find something and our US keyboards don't have the right marks.

https://www.google.ca/search?q=godel+escher+bach

After all this nonsense, that's what the original poster is looking for
(I think... can't be sure since it's been so many days now).  Seems to
me a python module does this quite nicely:

https://pypi.python.org/pypi/Unidecode
-- 
https://mail.python.org/mailman/listinfo/python-list


Algorithm that makes maximum compression of completly diffused data.

2013-10-30 Thread jonas . thornvall
I am searching for the program or algorithm that makes the best possible of 
completly (diffused data/random noise) and wonder what the state of art 
compression is.

I understand this is not the correct forum but since i think i have an 
algorithm that can do this very good, and do not know where to turn for such 
question i was thinking to start here.

It is of course lossless compression i am speaking of.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread Antoon Pardon

Op 30-10-13 17:31, [email protected] schreef:

Den onsdagen den 30:e oktober 2013 kl. 17:22:23 UTC+1 skrev Mark Lawrence:


I have no need to implement a newsreader as I can quite happily send and

receive data using Thunderbird.  There are several other similar email

options available.  An alternative is for you to show others some

courtesy and follow the instructions that would show just a few lines up

from here, except that your insistence on using bug ridden technology

means it's actually light years away.



--

Python is the second best programming language in the world.

But the best has yet to be invented.  Christian Tismer



Mark Lawrence


No that is not my problem, apparently so it is that the newsreader constructors 
do not like the competition of Google groups otherwise they would had written 
the five lines of codes necessary to remove the empty linebreaks.
I like web based features, and i will use them until "they get it right, 
understood?"
End of story


If you persist, it will become your problem soon enough. Annoying the
people, you come to for help, will not motivate them in actually
helping you. Mark may be the loudest in making his annoyance clear, he
is not the only one that is annoyed.

You are misbehaving by burdening other people with the annoying results
of your choice of news reading tool. That the cause is buggy google ware
doesn't diminish your responsibility. As it is the mood is tense because
a number of people already feel that others are too patient with
annoying behaviour and your contributions are not helping.

So if you find it important to have a welcoming python community that in
general will gladly help you along, you may reconsider that end of
story.
--
https://mail.python.org/mailman/listinfo/python-list


sorting german characters äöü...

2013-10-30 Thread Ulrich Goebel

Hello,

for a SQLite database I would like to prepare a collating function in 
python. It has to compare two (unicode-)strings s, t and should return 
-1 if st.


The strings are german names/words, and what I would like is to have a 
case-insensitive ordering, which treates


  ä as a
  ö as ö
  ü as ü
  ß as ss

and a few more things.

What I did is to "normalize" the two strings and then compare them:

def normal (s):
  r = s
  r = r.strip()   # wir entfernen führende und folgende Leerzeichen
  r = r.replace(u' ', '')# wir entfernen alle Leerzeichen innerhalb
  r = r.replace(u'ß', u'ss')
  r = r.upper()   # alles in Großbuchstaben
  r = r.replace(u'Ä', u'A')   # Umlaute brauchen wir nicht...
  r = r.replace(u'Ö', u'O')   # "
  r = r.replace(u'Ü', u'U')   # "
  return r

def compare (a, b):
  aa = normal(a)
  bb = normal(b)
  if aa < bb:
return -1
  elif aa == bb:
return 0
  else:
return 1

That works, but my be there is a more intelligent way? Especially there 
could be much more r.replace to handle all the accents as ^ ° ´ ` and so on.


Any ideas? That would be great!

Ulrich

--
Ulrich Goebel
Paracelsusstr. 120, 53177 Bonn
--
https://mail.python.org/mailman/listinfo/python-list


Re: trying to strip out non ascii.. or rather convert non ascii

2013-10-30 Thread wxjmfauth
Le mercredi 30 octobre 2013 18:54:05 UTC+1, Michael Torrie a écrit :
> On 10/30/2013 10:08 AM, [email protected] wrote:
> 
> > My comment had nothing to do with Python, it was a
> 
> > general comment. A diacritical mark just makes a letter
> 
> > a different letter; a "ï " and a "i" are "as
> 
> > diferent" as a "a" from a "z". A diacritical mark
> 
> > is more than a simple ornementation.
> 
> 
> 
> That's nice, but you didn't actually read what Ned said (or the OP).
> 
> The OP doesn't care that "ï " and a "i" are as different as "a" and "z".
> 
>  For the purposes of his search he wants them treated as the same
> 
> letter.  A fuzzy searching treats them all the same. For example, a
> 
> search for "Godel, Escher, Bach" should find "Gödel, Escher, Bach" just
> 
> fine.  Even though "o" and "ö" are different characters.  And lo and
> 
> behold Google actually does this!  Try it.  It's nice for those of use
> 
> who want to find something and our US keyboards don't have the right marks.
> 
> 
> 
> https://www.google.ca/search?q=godel+escher+bach
> 
> 
> 
> After all this nonsense, that's what the original poster is looking for
> 
> (I think... can't be sure since it's been so many days now).  Seems to
> 
> me a python module does this quite nicely:
> 
> 
> 
> https://pypi.python.org/pypi/Unidecode


Ok. You are right. I recognize my mistake. Independently
from the top poster's task, I did not understand in that
way.

Let say it depends on the context, for a general
search engine, it's good that diacritics are ignored.
For, let say, a text processing system, it's good
to have only precised matches. It does not mean, other
matching possibilities may exist.

jmf

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


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread jonas . thornvall
Den onsdagen den 30:e oktober 2013 kl. 19:01:40 UTC+1 skrev Antoon Pardon:
> Op 30-10-13 17:31, [email protected] schreef:
> 
> > Den onsdagen den 30:e oktober 2013 kl. 17:22:23 UTC+1 skrev Mark Lawrence:
> 
> >>
> 
> >> I have no need to implement a newsreader as I can quite happily send and
> 
> >>
> 
> >> receive data using Thunderbird.  There are several other similar email
> 
> >>
> 
> >> options available.  An alternative is for you to show others some
> 
> >>
> 
> >> courtesy and follow the instructions that would show just a few lines up
> 
> >>
> 
> >> from here, except that your insistence on using bug ridden technology
> 
> >>
> 
> >> means it's actually light years away.
> 
> >>
> 
> >>
> 
> >>
> 
> >> --
> 
> >>
> 
> >> Python is the second best programming language in the world.
> 
> >>
> 
> >> But the best has yet to be invented.  Christian Tismer
> 
> >>
> 
> >>
> 
> >>
> 
> >> Mark Lawrence
> 
> >
> 
> > No that is not my problem, apparently so it is that the newsreader 
> > constructors do not like the competition of Google groups otherwise they 
> > would had written the five lines of codes necessary to remove the empty 
> > linebreaks.
> 
> > I like web based features, and i will use them until "they get it right, 
> > understood?"
> 
> > End of story
> 
> >
> 
> If you persist, it will become your problem soon enough. Annoying the
> 
> people, you come to for help, will not motivate them in actually
> 
> helping you. Mark may be the loudest in making his annoyance clear, he
> 
> is not the only one that is annoyed.
> 
> 
> 
> You are misbehaving by burdening other people with the annoying results
> 
> of your choice of news reading tool. That the cause is buggy google ware
> 
> doesn't diminish your responsibility. As it is the mood is tense because
> 
> a number of people already feel that others are too patient with
> 
> annoying behaviour and your contributions are not helping.
> 
> 
> 
> So if you find it important to have a welcoming python community that in
> 
> general will gladly help you along, you may reconsider that end of
> 
> story.

Well i like help, i like explanations, i like logic, i like smartness.
But what i do not understand is how simple problems can not be solved without 
manual work. Do you like brackets, do you like indentations i don't..

I may come across like a buffon that now nothing but that is not the case, i am 
actually pretty smart i could say fucking smart but that would annoy the anal 
monkeys to know there is people a lot smarter than them that is not anal, so 
let us play it causal. 

I  simply want things done (and i certainly have had things done) both inside 
and outside the pyphoone community, i have no intention to steer things up, i 
just want everything for the better.

And ***that is not by having every stupid anal monkey sitting manually removing 
linebreaks by hand***

Is that understood?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: sorting german characters äöü...

2013-10-30 Thread Skip Montanaro
> That works, but my be there is a more intelligent way? Especially there
> could be much more r.replace to handle all the accents as ^ ° ´ ` and so on.

Perhaps this? 
http://stackoverflow.com/questions/816285/where-is-pythons-best-ascii-for-this-unicode-database

There is also a rather long-ish recent topic on a similar topic that
might be worth scanning as well.

I've no direct/recent experience with this topic. I'm just an
interested bystander.

Skip
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Algorithm that makes maximum compression of completly diffused data.

2013-10-30 Thread Mark Lawrence

On 30/10/2013 18:21, [email protected] wrote:

I am searching for the program or algorithm that makes the best possible of 
completly (diffused data/random noise) and wonder what the state of art 
compression is.

I understand this is not the correct forum but since i think i have an 
algorithm that can do this very good, and do not know where to turn for such 
question i was thinking to start here.

It is of course lossless compression i am speaking of.



I can't help with compression but I can help with a marvellous source of 
the opposite, expansion, it's google groups.


--
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

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


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread Antoon Pardon

Op 30-10-13 16:50, Grant Edwards schreef:

On 2013-10-30, Antoon Pardon  wrote:


Because it is a pain in the ass. Now suddenly my program doesn't work
because I somehow inserted a tab instead of spaces.


Then don't do that.

I'm only half-kidding.  Inserting incorrect tokens into program source
breaks programs in all languages.  The tricky bit is that in many
editors spaces and tabs look the same.  You can pick an editor that
provides a visual difference, or you can pick an editor that always
does the right thing, or you can stick with it until your fingers
learn to do the right thing.


But tab and spaces are not tokens. They are token seperators. You can
add as many tabs and spaces at the end of a line or between an
identifier and an operator and it won't make any difference.I can even
write the following.

a = (
 b+   c )

where I can freely choose to use any number of tabs and spaces at the
start of the second line and python will not complain. So comparing
mixing tabs and spaces with inserting an incorrect token in other
languages doesn't make much sense to me.



Python made it's choice and I can live with that, but telling people
who prefer it had made an other choice that their brain is poisoned,
only shows you are unable to see the disadvantages.


Those of us who've been using Python for more than a few days think it
is you who are unable to see the advantages. ;)


I started using python when it was still 1.5.2, so I think I am using
it for more than a few days too.

--
Antoon Pardon
--
https://mail.python.org/mailman/listinfo/python-list


Re: Algorithm that makes maximum compression of completly diffused data.

2013-10-30 Thread jonas . thornvall
Den onsdagen den 30:e oktober 2013 kl. 19:53:59 UTC+1 skrev Mark Lawrence:
> On 30/10/2013 18:21, [email protected] wrote:
> 
> > I am searching for the program or algorithm that makes the best possible of 
> > completly (diffused data/random noise) and wonder what the state of art 
> > compression is.
> 
> >
> 
> > I understand this is not the correct forum but since i think i have an 
> > algorithm that can do this very good, and do not know where to turn for 
> > such question i was thinking to start here.
> 
> >
> 
> > It is of course lossless compression i am speaking of.
> 
> >
> 
> 
> 
> I can't help with compression but I can help with a marvellous source of 
> 
> the opposite, expansion, it's google groups.
> 
> 
> 
> -- 
> 
> Python is the second best programming language in the world.
> 
> But the best has yet to be invented.  Christian Tismer
> 
> 
> 
> Mark Lawrence

And your still a stupid monkey i dare you to go test your IQ.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread Mark Lawrence

On 30/10/2013 18:43, [email protected] wrote:

And ***that is not by having every stupid anal monkey sitting manually removing 
linebreaks by hand***

Is that understood?



Nobody would have to remove line breaks by hand if you, yes you 
jonasthornvall at GMAIL.COM didn't use a tool that inserts them in the 
first place.


Is that understood?

--
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

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


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread Antoon Pardon

Op 30-10-13 19:02, [email protected] schreef:

Den onsdagen den 30:e oktober 2013 kl. 18:44:20 UTC+1 skrev MRAB:

On 30/10/2013 16:31, [email protected] wrote:


Den onsdagen den 30:e oktober 2013 kl. 17:22:23 UTC+1 skrev Mark Lawrence:



No that is not my problem, apparently so it is that the newsreader constructors 
do not like the competition of Google groups otherwise they would had written 
the five lines of codes necessary to remove the empty linebreaks.



I like web based features, and i will use them until "they get it right, 
understood?"



End of story






Google Groups aren't following the standard. Everybody else is. Why

should everybody else have to add a fix to correct what Google Groups

keeps getting wrong?


I do see though this have to be something related to their database, nothing 
they do by purpose. So unless the database storing messages change, it probably 
would need an ugly fix like a script.

So probably you should direct your question to either the creators of googles 
database or beg the creators of google groups to do a fix...


You are wrong. If you use a service that is faulty, then the annoyance
that creates, is your responsibilty.

Just suppose your neighbours rented a paint pistol that was faulty and 
because of that they sprayed paint on some of your valuables. Would you

agree that it wouldn't be their problem. Would you agree they could
just continue using that paint pistol spraying paint on your possession
and telling you, you should go to the firm where they rented the paint
pistol with your complaints?

You are using faulty news software that contributes hard to read 
messages and thus pollutes the newsgroup. I understand this is not

your intention but it sure is the effect of your behaviour. So
you are polluting this newsgroup and now you have been made aware of
it. Continueing with the same behaviour will not encourage others to
help you in the future.

--
Antoon Pardon

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


Re: Algorithm that makes maximum compression of completly diffused data.

2013-10-30 Thread Mark Lawrence

On 30/10/2013 19:01, [email protected] wrote:


And your still a stupid monkey i dare you to go test your IQ.



It's you're as in you are and not your as in belongs to me.

I have no intention of getting my IQ tested, but I do know that it's a 
minimum of 120 as that was required for me to pass the old UK 11+ 
examination.  Given that I spent my time at a grammar school in the top 
stream I'd guess that my IQ is actually higher, but there you go.


Not that that really matters.  What does is that I'm smart enough to be 
able to follow a set of instructions when requested to do so, for 
example I could probably follow these 
https://wiki.python.org/moin/GoogleGroupsPython if I needed to.  I'm 
therefore assuming that you're not bright enough to follow these 
instructions and so have annoyed thousands of people with your double 
spaced crap, which I've again snipped.


--
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

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


Re: Algorithm that makes maximum compression of completly diffused data.

2013-10-30 Thread jonas . thornvall
Den onsdagen den 30:e oktober 2013 kl. 20:18:30 UTC+1 skrev Mark Lawrence:
> On 30/10/2013 19:01, [email protected] wrote:
> 
> >
> 
> > And your still a stupid monkey i dare you to go test your IQ.
> 
> >
> 
> 
> 
> It's you're as in you are and not your as in belongs to me.
> 
> 
> 
> I have no intention of getting my IQ tested, but I do know that it's a 
> 
> minimum of 120 as that was required for me to pass the old UK 11+ 
> 
> examination.  Given that I spent my time at a grammar school in the top 
> 
> stream I'd guess that my IQ is actually higher, but there you go.
> 
> 
> 
> Not that that really matters.  What does is that I'm smart enough to be 
> 
> able to follow a set of instructions when requested to do so, for 
> 
> example I could probably follow these 
> 
> https://wiki.python.org/moin/GoogleGroupsPython if I needed to.  I'm 
> 
> therefore assuming that you're not bright enough to follow these 
> 
> instructions and so have annoyed thousands of people with your double 
> 
> spaced crap, which I've again snipped.
> 
> 
> 
> -- 
> 
> Python is the second best programming language in the world.
> 
> But the best has yet to be invented.  Christian Tismer
> 
> 
> 
> Mark Lawrence

I do not follow instructions, i make them accesible to anyone. And you just 
following them is a clear example to your lack of IQ.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Algorithm that makes maximum compression of completly diffused data.

2013-10-30 Thread jonas . thornvall
Den onsdagen den 30:e oktober 2013 kl. 20:18:30 UTC+1 skrev Mark Lawrence:
> On 30/10/2013 19:01, [email protected] wrote:
> 
> >
> 
> > And your still a stupid monkey i dare you to go test your IQ.
> 
> >
> 
> 
> 
> It's you're as in you are and not your as in belongs to me.
> 
> 
> 
> I have no intention of getting my IQ tested, but I do know that it's a 
> 
> minimum of 120 as that was required for me to pass the old UK 11+ 
> 
> examination.  Given that I spent my time at a grammar school in the top 
> 
> stream I'd guess that my IQ is actually higher, but there you go.
> 
> 
> 
> Not that that really matters.  What does is that I'm smart enough to be 
> 
> able to follow a set of instructions when requested to do so, for 
> 
> example I could probably follow these 
> 
> https://wiki.python.org/moin/GoogleGroupsPython if I needed to.  I'm 
> 
> therefore assuming that you're not bright enough to follow these 
> 
> instructions and so have annoyed thousands of people with your double 
> 
> spaced crap, which I've again snipped.
> 
> 
> 
> -- 
> 
> Python is the second best programming language in the world.
> 
> But the best has yet to be invented.  Christian Tismer
> 
> 
> 
> Mark Lawrence

What i actually saying is that you are indeed... an anal code monkey that never 
ever had a selfsustained thought of your own.

Think about it.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Algorithm that makes maximum compression of completly diffused data.

2013-10-30 Thread Dan Stromberg
xz compression is pretty hard, if a little bit slow.  Also, if you want
really stellar compression ratios and you don't care about time to
compress, you might check out one of the many paq implementations.

I have a module that does xz compression in 4 different ways:
http://stromberg.dnsalias.org/svn/backshift/tags/1.20/xz_mod.py
It's only for smallish chunks in the ctypes version, because that was all I
needed.  The others should be able to handle relatively large inputs.

On Wed, Oct 30, 2013 at 11:21 AM,  wrote:

> I am searching for the program or algorithm that makes the best possible
> of completly (diffused data/random noise) and wonder what the state of art
> compression is.
>
> I understand this is not the correct forum but since i think i have an
> algorithm that can do this very good, and do not know where to turn for
> such question i was thinking to start here.
>
> It is of course lossless compression i am speaking of.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Algorithm that makes maximum compression of completly diffused data.

2013-10-30 Thread Tim Delaney
On 31 October 2013 05:21,  wrote:

> I am searching for the program or algorithm that makes the best possible
> of completly (diffused data/random noise) and wonder what the state of art
> compression is.
>
> I understand this is not the correct forum but since i think i have an
> algorithm that can do this very good, and do not know where to turn for
> such question i was thinking to start here.
>
> It is of course lossless compression i am speaking of.
>

This is not an appropriate forum for this question. If you know it's an
inappropriate forum (as you stated) then do not post the question here. Do
a search with your preferred search engine and look up compression on
lossless Wikipedia. And read and understand the following link:

http://www.catb.org/esr/faqs/smart-questions.html

paying special attention to the following parts:

http://www.catb.org/esr/faqs/smart-questions.html#forum
http://www.catb.org/esr/faqs/smart-questions.html#prune
http://www.catb.org/esr/faqs/smart-questions.html#courtesy
http://www.catb.org/esr/faqs/smart-questions.html#keepcool
http://www.catb.org/esr/faqs/smart-questions.html#classic

If you have *python* code implementing this algorithm and want help, post
the parts you want help with (and preferably post the entire algorithm in a
repository).

However, having just seen the following from you in a reply to Mark ("I do
not follow instructions, i make them accesible to anyone"), I am not not
going to give a second chance - fail to learn from the above advice and
you'll meet my spam filter.

If the data is truly completely random noise, then there is very little
that lossless compression can do. On any individual truly random data set
you might get a lot of compression, a small amount of compression, or even
expansion, depending on what patterns have randomly occurred in the data
set. But there is no current lossless compression algorithm that can take
truly random data and systematically compress it to be smaller than the
original.

If you think you have an algorithm that can do this on truly random data,
you're probably wrong - either your data is has patterns the algorithm can
exploit, or you've simply been lucky with the randomness of your data so
far.

Tim Delaney
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Algorithm that makes maximum compression of completly diffused data.

2013-10-30 Thread Mark Lawrence

On 30/10/2013 19:22, [email protected] wrote:

Den onsdagen den 30:e oktober 2013 kl. 20:18:30 UTC+1 skrev Mark Lawrence:

On 30/10/2013 19:01, [email protected] wrote:






And your still a stupid monkey i dare you to go test your IQ.








It's you're as in you are and not your as in belongs to me.



I have no intention of getting my IQ tested, but I do know that it's a

minimum of 120 as that was required for me to pass the old UK 11+

examination.  Given that I spent my time at a grammar school in the top

stream I'd guess that my IQ is actually higher, but there you go.



Not that that really matters.  What does is that I'm smart enough to be

able to follow a set of instructions when requested to do so, for

example I could probably follow these

https://wiki.python.org/moin/GoogleGroupsPython if I needed to.  I'm

therefore assuming that you're not bright enough to follow these

instructions and so have annoyed thousands of people with your double

spaced crap, which I've again snipped.



--

Python is the second best programming language in the world.

But the best has yet to be invented.  Christian Tismer



Mark Lawrence


I do not follow instructions, i make them accesible to anyone. And you just 
following them is a clear example to your lack of IQ.



I suggest that you reread what I wrote above, assuming that you can find 
it amongst the double spaced crap.  I said I would follow the 
instructions if I needed to.  So clearly I'm not just following them, as 
I've no need to, as I'm smart enough to use a vastly superior tool.


--
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

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


Re: Algorithm that makes maximum compression of completly diffused data.

2013-10-30 Thread Mark Lawrence

On 30/10/2013 19:23, [email protected] wrote:

Den onsdagen den 30:e oktober 2013 kl. 20:18:30 UTC+1 skrev Mark Lawrence:

On 30/10/2013 19:01, [email protected] wrote:






And your still a stupid monkey i dare you to go test your IQ.








It's you're as in you are and not your as in belongs to me.



I have no intention of getting my IQ tested, but I do know that it's a

minimum of 120 as that was required for me to pass the old UK 11+

examination.  Given that I spent my time at a grammar school in the top

stream I'd guess that my IQ is actually higher, but there you go.



Not that that really matters.  What does is that I'm smart enough to be

able to follow a set of instructions when requested to do so, for

example I could probably follow these

https://wiki.python.org/moin/GoogleGroupsPython if I needed to.  I'm

therefore assuming that you're not bright enough to follow these

instructions and so have annoyed thousands of people with your double

spaced crap, which I've again snipped.



--

Python is the second best programming language in the world.

But the best has yet to be invented.  Christian Tismer



Mark Lawrence


What i actually saying is that you are indeed... an anal code monkey that never 
ever had a selfsustained thought of your own.

Think about it.



I just have to bow down to your vast superiority over me.

How is your job with your country's diplomatic corp going by the way?

--
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

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


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread jonas . thornvall
Den onsdagen den 30:e oktober 2013 kl. 20:05:07 UTC+1 skrev Mark Lawrence:
> On 30/10/2013 18:43, [email protected] wrote:
> 
> > And ***that is not by having every stupid anal monkey sitting manually 
> > removing linebreaks by hand***
> 
> >
> 
> > Is that understood?
> 
> >
> 
> 
> 
> Nobody would have to remove line breaks by hand if you, yes you 
> 
> jonasthornvall at GMAIL.COM didn't use a tool that inserts them in the 
> 
> first place.
> 
> 
> 
> Is that understood?
> 
> 
> 
> -- 
> 
> Python is the second best programming language in the world.
> 
> But the best has yet to be invented.  Christian Tismer
> 
> 
> 
> Mark Lawrence

No it isn't...
The programmers of the tools on either of side will have to adapt.
I wish it would be Google but it could be a database problem, but what do i 
know maybe their fucking with you.



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


Re: Algorithm that makes maximum compression of completly diffused data.

2013-10-30 Thread jonas . thornvall
Den onsdagen den 30:e oktober 2013 kl. 20:35:59 UTC+1 skrev Tim Delaney:
> On 31 October 2013 05:21,   wrote:
> 
> I am searching for the program or algorithm that makes the best possible of 
> completly (diffused data/random noise) and wonder what the state of art 
> compression is.
> 
> 
> 
> 
> I understand this is not the correct forum but since i think i have an 
> algorithm that can do this very good, and do not know where to turn for such 
> question i was thinking to start here.
> 
> 
> 
> It is of course lossless compression i am speaking of.
> 
> 
> 
> This is not an appropriate forum for this question. If you know it's an 
> inappropriate forum (as you stated) then do not post the question here. Do a 
> search with your preferred search engine and look up compression on lossless 
> Wikipedia. And read and understand the following link:
> 
> 
> 
> http://www.catb.org/esr/faqs/smart-questions.html
> 
> 
> 
> paying special attention to the following parts:
> 
> 
> 
> http://www.catb.org/esr/faqs/smart-questions.html#forum
> http://www.catb.org/esr/faqs/smart-questions.html#prune
> 
> 
> http://www.catb.org/esr/faqs/smart-questions.html#courtesy
> 
> http://www.catb.org/esr/faqs/smart-questions.html#keepcool
> 
> 
> http://www.catb.org/esr/faqs/smart-questions.html#classic
> 
> 
> 
> If you have *python* code implementing this algorithm and want help, post the 
> parts you want help with (and preferably post the entire algorithm in a 
> repository).
> 
> 
> 
> 
> However, having just seen the following from you in a reply to Mark ("I do 
> not follow instructions, i make them accesible to anyone"), I am not not 
> going to give a second chance - fail to learn from the above advice and 
> you'll meet my spam filter.
> 
> 
> 
> If the data is truly completely random noise, then there is very little that 
> lossless compression can do. On any individual truly random data set you 
> might get a lot of compression, a small amount of compression, or even 
> expansion, depending on what patterns have randomly occurred in the data set. 
> But there is no current lossless compression algorithm that can take truly 
> random data and systematically compress it to be smaller than the original.
> 
> 
> 
> If you think you have an algorithm that can do this on truly random data, 
> you're probably wrong - either your data is has patterns the algorithm can 
> exploit, or you've simply been lucky with the randomness of your data so far.
> 
> 
> 
> Tim Delaney

No i am not wrong.
End of story
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread jonas . thornvall
Den onsdagen den 30:e oktober 2013 kl. 20:09:45 UTC+1 skrev Antoon Pardon:
> Op 30-10-13 19:02, [email protected] schreef:
> 
> > Den onsdagen den 30:e oktober 2013 kl. 18:44:20 UTC+1 skrev MRAB:
> 
> >> On 30/10/2013 16:31, [email protected] wrote:
> 
> >>
> 
> >>> Den onsdagen den 30:e oktober 2013 kl. 17:22:23 UTC+1 skrev Mark Lawrence:
> 
> >>
> 
> >>> No that is not my problem, apparently so it is that the newsreader 
> >>> constructors do not like the competition of Google groups otherwise they 
> >>> would had written the five lines of codes necessary to remove the empty 
> >>> linebreaks.
> 
> >>
> 
> >>> I like web based features, and i will use them until "they get it right, 
> >>> understood?"
> 
> >>
> 
> >>> End of story
> 
> >>
> 
> >>>
> 
> >>
> 
> >> Google Groups aren't following the standard. Everybody else is. Why
> 
> >>
> 
> >> should everybody else have to add a fix to correct what Google Groups
> 
> >>
> 
> >> keeps getting wrong?
> 
> >
> 
> > I do see though this have to be something related to their database, 
> > nothing they do by purpose. So unless the database storing messages change, 
> > it probably would need an ugly fix like a script.
> 
> >
> 
> > So probably you should direct your question to either the creators of 
> > googles database or beg the creators of google groups to do a fix...
> 
> 
> 
> You are wrong. If you use a service that is faulty, then the annoyance
> 
> that creates, is your responsibilty.
> 
> 
> 
> Just suppose your neighbours rented a paint pistol that was faulty and 
> 
> because of that they sprayed paint on some of your valuables. Would you
> 
> agree that it wouldn't be their problem. Would you agree they could
> 
> just continue using that paint pistol spraying paint on your possession
> 
> and telling you, you should go to the firm where they rented the paint
> 
> pistol with your complaints?
> 
> 
> 
> You are using faulty news software that contributes hard to read 
> 
> messages and thus pollutes the newsgroup. I understand this is not
> 
> your intention but it sure is the effect of your behaviour. So
> 
> you are polluting this newsgroup and now you have been made aware of
> 
> it. Continueing with the same behaviour will not encourage others to
> 
> help you in the future.
> 
> 
> 
> -- 
> 
> Antoon Pardon

No certainly not you are incorrect, either annoyed readers, newsreaders or you 
chose to filter out the annoyance, or you implement the fucking 5 lines of code 
making it. And one certainly can wonder why Google have not done that.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Algorithm that makes maximum compression of completly diffused data.

2013-10-30 Thread jonas . thornvall
Den onsdagen den 30:e oktober 2013 kl. 20:46:57 UTC+1 skrev Modulok:
> On Wed, Oct 30, 2013 at 12:21 PM,   wrote:
> 
> 
> 
> I am searching for the program or algorithm that makes the best possible of 
> completly (diffused data/random noise) and wonder what the state of art 
> compression is.
> 
> 
> 
> 
> I understand this is not the correct forum but since i think i have an 
> algorithm that can do this very good, and do not know where to turn for such 
> question i was thinking to start here.
> 
> 
> 
> It is of course lossless compression i am speaking of.
> 
> --
> 
> https://mail.python.org/mailman/listinfo/python-list
> 
> 
>  
> 
> >> I am searching for the program or algorithm that makes the best possible of
> >> completly (diffused data/random noise) and wonder what the state of art
> 
> >> compression is.
> 
> 
> None. If the data to be compressed is truly homogeneous, random noise as you
> describe (for example a 100mb file read from cryptographically secure random
> 
> bit generator such as /dev/random on *nix systems), the state-of-the-art
> lossless compression is zero and will remain that way for the foreseeable
> 
> future.
> 
> 
> There is no lossless algorithm that will reduce truly random (high entropy)
> data by any significant margin. In classical information theory, such an
> 
> algorithm can never be invented. See: Kolmogorov complexity
> 
> 
> Real world data is rarely completely random. You would have to test various
> 
> algorithms on the data set in question. Small things such as non-obvious
> statistical clumping can make a big difference in the compression ratio from
> 
> one algorithm to another. Data that might look "random", might not actually be
> random in the entropy sense of the word.
> 
> 
> 
> >> I understand this is not the correct forum but since i think i have an
> >> algorithm that can do this very good, and do not know where to turn for 
> >> such
> 
> >> question i was thinking to start here.
> 
> 
> Not to sound like a downer, but I would wager that the data you're testing 
> your
> 
> algorithm on is not as truly random as you imply or is not a large enough body
> of test data to draw such conclusions from. It's akin to inventing a perpetual
> 
> motion machine or an inertial propulsion engine or any other classically
> impossible solutions. (This only applies to truly random data.)
> 
> 
> 
> -Modulok-

Well then i have news for you.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Algorithm that makes maximum compression of completly diffused data.

2013-10-30 Thread Modulok
On Wed, Oct 30, 2013 at 12:21 PM,  wrote:

> I am searching for the program or algorithm that makes the best possible
> of completly (diffused data/random noise) and wonder what the state of art
> compression is.
>
> I understand this is not the correct forum but since i think i have an
> algorithm that can do this very good, and do not know where to turn for
> such question i was thinking to start here.
>
> It is of course lossless compression i am speaking of.
> --
> https://mail.python.org/mailman/listinfo/python-list



>> I am searching for the program or algorithm that makes the best possible
of
>> completly (diffused data/random noise) and wonder what the state of art
>> compression is.

None. If the data to be compressed is truly homogeneous, random noise as you
describe (for example a 100mb file read from cryptographically secure random
bit generator such as /dev/random on *nix systems), the state-of-the-art
lossless compression is zero and will remain that way for the foreseeable
future.

There is no lossless algorithm that will reduce truly random (high entropy)
data by any significant margin. In classical information theory, such an
algorithm can never be invented. See: Kolmogorov complexity

Real world data is rarely completely random. You would have to test various
algorithms on the data set in question. Small things such as non-obvious
statistical clumping can make a big difference in the compression ratio from
one algorithm to another. Data that might look "random", might not actually
be
random in the entropy sense of the word.

>> I understand this is not the correct forum but since i think i have an
>> algorithm that can do this very good, and do not know where to turn for
such
>> question i was thinking to start here.

Not to sound like a downer, but I would wager that the data you're testing
your
algorithm on is not as truly random as you imply or is not a large enough
body
of test data to draw such conclusions from. It's akin to inventing a
perpetual
motion machine or an inertial propulsion engine or any other classically
impossible solutions. (This only applies to truly random data.)

-Modulok-
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Algorithm that makes maximum compression of completly diffused data.

2013-10-30 Thread jonas . thornvall
Den onsdagen den 30:e oktober 2013 kl. 20:46:57 UTC+1 skrev Modulok:
> On Wed, Oct 30, 2013 at 12:21 PM,   wrote:
> 
> 
> 
> I am searching for the program or algorithm that makes the best possible of 
> completly (diffused data/random noise) and wonder what the state of art 
> compression is.
> 
> 
> 
> 
> I understand this is not the correct forum but since i think i have an 
> algorithm that can do this very good, and do not know where to turn for such 
> question i was thinking to start here.
> 
> 
> 
> It is of course lossless compression i am speaking of.
> 
> --
> 
> https://mail.python.org/mailman/listinfo/python-list
> 
> 
>  
> 
> >> I am searching for the program or algorithm that makes the best possible of
> >> completly (diffused data/random noise) and wonder what the state of art
> 
> >> compression is.
> 
> 
> None. If the data to be compressed is truly homogeneous, random noise as you
> describe (for example a 100mb file read from cryptographically secure random
> 
> bit generator such as /dev/random on *nix systems), the state-of-the-art
> lossless compression is zero and will remain that way for the foreseeable
> 
> future.
> 
> 
> There is no lossless algorithm that will reduce truly random (high entropy)
> data by any significant margin. In classical information theory, such an
> 
> algorithm can never be invented. See: Kolmogorov complexity
> 
> 
> Real world data is rarely completely random. You would have to test various
> 
> algorithms on the data set in question. Small things such as non-obvious
> statistical clumping can make a big difference in the compression ratio from
> 
> one algorithm to another. Data that might look "random", might not actually be
> random in the entropy sense of the word.
> 
> 
> 
> >> I understand this is not the correct forum but since i think i have an
> >> algorithm that can do this very good, and do not know where to turn for 
> >> such
> 
> >> question i was thinking to start here.
> 
> 
> Not to sound like a downer, but I would wager that the data you're testing 
> your
> 
> algorithm on is not as truly random as you imply or is not a large enough body
> of test data to draw such conclusions from. It's akin to inventing a perpetual
> 
> motion machine or an inertial propulsion engine or any other classically
> impossible solutions. (This only applies to truly random data.)
> 
> 
> 
> -Modulok-

My algorithm will compress data from any random data source.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Algorithm that makes maximum compression of completly diffused data.

2013-10-30 Thread Antoon Pardon

Op 30-10-13 20:01, [email protected] schreef:

Den onsdagen den 30:e oktober 2013 kl. 19:53:59 UTC+1 skrev Mark Lawrence:

On 30/10/2013 18:21, [email protected] wrote:


I am searching for the program or algorithm that makes the best possible of 
completly (diffused data/random noise) and wonder what the state of art 
compression is.







I understand this is not the correct forum but since i think i have an 
algorithm that can do this very good, and do not know where to turn for such 
question i was thinking to start here.







It is of course lossless compression i am speaking of.








I can't help with compression but I can help with a marvellous source of

the opposite, expansion, it's google groups.



--

Python is the second best programming language in the world.

But the best has yet to be invented.  Christian Tismer



Mark Lawrence


And your still a stupid monkey i dare you to go test your IQ.


Are you sure it is this game you want to play? Please consider
carefully: For what purpose did you come to this group? Is your
behaviour accomplishing that purpose?

You were asked to take responsibility for the detrimental effect your
choice of news reader software has on this newsgroup. Your answer boiled
down to a very clear "I don't care about the detrimental effect I cause"
Well until you start caring and adapt your behaviour, people will tend
not to care about your questions/problems and the most likely responses
you will get is people pointing to your anti-social behaviour.

You may feel very righteous in your response to Mark but you will just
further alienate the regulars. If that is your goal you can continue
as you did before and soon you will be in a lot of kill file or if
you hope for some cooperation from the regulars, you'd better show
you can be cooperative too.

--
Antoon Pardon
--
https://mail.python.org/mailman/listinfo/python-list


Re: personal library

2013-10-30 Thread patrick vrijlandt
Chris Angelico  wrote:
> On Wed, Oct 30, 2013 at 3:33 PM, Ben Finney  
> wrote:
>> Chris Angelico  writes:
>> 
>>> *Definitely* use source control.
>> 
>> +1, but prefer to call it a “version control system” which is (a) more
>> easily searched on the internet, and (b) somewhat more accurate.
> 
> Right. I've picked up some bad habits, and I think Dave may also
> have... but yes, "distributed version control system" is what I'm
> talking about here.
> 
> ChrisA

Thanks. Do you all agree that Mercurial is the way to go, or is there
another "distributed version control system" that I should shortlist?

-- 
patrick
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: First day beginner to python, add to counter after nested loop

2013-10-30 Thread Antoon Pardon

Op 30-10-13 20:13, [email protected] schreef:

Den onsdagen den 30:e oktober 2013 kl. 20:05:07 UTC+1 skrev Mark Lawrence:

On 30/10/2013 18:43, [email protected] wrote:


And ***that is not by having every stupid anal monkey sitting manually removing 
linebreaks by hand***







Is that understood?








Nobody would have to remove line breaks by hand if you, yes you

jonasthornvall at GMAIL.COM didn't use a tool that inserts them in the

first place.



Is that understood?



--

Python is the second best programming language in the world.

But the best has yet to be invented.  Christian Tismer



Mark Lawrence


No it isn't...
The programmers of the tools on either of side will have to adapt.
I wish it would be Google but it could be a database problem, but what do i 
know maybe their fucking with you.


Why should people who are using good functioning tools have to adapt to
someone, in this case being you, who is using tools that are behaving 
faulty and as an effect is polluting the news group with hard to read

contributions?

--
Antoon Pardon
--
https://mail.python.org/mailman/listinfo/python-list


Re: personal library

2013-10-30 Thread Tim Delaney
On 31 October 2013 07:02, patrick vrijlandt wrote:

> Chris Angelico  wrote:
> > On Wed, Oct 30, 2013 at 3:33 PM, Ben Finney 
> wrote:
> >> Chris Angelico  writes:
> >>
> >>> *Definitely* use source control.
> >>
> >> +1, but prefer to call it a “version control system” which is (a) more
> >> easily searched on the internet, and (b) somewhat more accurate.
> >
> > Right. I've picked up some bad habits, and I think Dave may also
> > have... but yes, "distributed version control system" is what I'm
> > talking about here.
> >
> > ChrisA
>
> Thanks. Do you all agree that Mercurial is the way to go, or is there
> another "distributed version control system" that I should shortlist?


There are huge arguments all over the net on this topic. Having extensively
used the top two contenders (Git and Mercurial) I would strongly advise you
to use Mercurial.

What it comes down to for me is that Mercurial usage fits in my head and I
rarely have to go to the docs, whereas with Git I have to constantly go to
the docs for anything but the most trivial usage - even when it's something
I've done many times before. I'm always afraid that I'm going to do
something *wrong* in Git.

Tim Delaney
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: sorting german characters äöü... solved

2013-10-30 Thread Ulrich Goebel

Hi,

Am 30.10.2013 19:48, schrieb Skip Montanaro:

Perhaps this? 
http://stackoverflow.com/questions/816285/where-is-pythons-best-ascii-for-this-unicode-database


There I found the module unidecode
(http://pypi.python.org/pypi/Unidecode),
and I found it very helpful. Thanks a lot!

So my function normal() now looks like this:

from unidecode import unidecode

def normal (s):
  r = s
  r = r.strip()  # take away blanks at the ends
  r = r.replace(u' ', '')# take away all other blanks
  r = unidecode(r)   # makes the main work
 # - see the docu of unidecode
  r = r.upper()  # changes all to uppercase letters
  return r

def compare (a, b):
  aa = normal(a)
  bb = normal(b)
  if aa < bb:
return -1
  elif aa == bb:
return 0
  else:
return 1

For the "normal" cases, that works quiet perfect - as I want it to do. 
For more (extreme) difficult cases there are even limits, but they are 
even wide limits, I would say. For example,

  print normal(u'-£-¥-Ć-û-á-€-Đ-ø-ț-ff-ỗ-Ể-ễ-ḯ-ę-ä-ö-ü-ß-')
gives
  -PS-Y=-C-U-A-EU-D-O-T-FF-O-E-E-I-E-A-O-U-SS-
That shows a bit of what unidecode does - and what it doesn't.


There is also a rather long-ish recent topic on a similar topic that
might be worth scanning as well.


Sorry, I didn't find that.


I've no direct/recent experience with this topic. I'm just an
interested bystander.


But even a helpful bystander. Thank You!

Ulrich

--
Ulrich Goebel
Paracelsusstr. 120, 53177 Bonn
--
https://mail.python.org/mailman/listinfo/python-list


shared libraries symbols visibility

2013-10-30 Thread David Froger
Hi list,

Python documentation on Extending Python with C or C++ says [1]:
When modules are used as shared libraries, however, the symbols defined
in one module may not be visible to another module.

Suppose I have an extension module that call functions provided by a shared
library, for example blas. Do I meet the same portability issue? If not, Why?

Thanks for your replies.
David

[1] 
http://docs.python.org/2/extending/extending.html#providing-a-c-api-for-an-extension-module
-- 
https://mail.python.org/mailman/listinfo/python-list


  1   2   >