Re: How to convert 'ö' to 'oe' or 'o' (or other similar things) in a string?

2016-09-25 Thread Martin Schöön
Den 2016-09-25 skrev wxjmfa...@gmail.com :
>
> As an European guy, I recommend to use the characters
> set used in the "official" font families used in Germany:
> BundesSerif / BundesSans.
>
> See
> https://styleguide.bundesregierung.de/Webs/SG/DE/PrintMedien/Basiselemente/Schriften/schriften_node.html?__site=SG
>
HTTP Status 404

Die Seite konnte leider nicht gefunden werden.

:-(

Manually poking around I still arrive at:
https://styleguide.bundesregierung.de/Webs/SG/DE/PrintMedien/Basiselemente/Schriften/schriften_node.html?__site=SG

Strange.

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


Re: How to convert 'ö' to 'oe' or 'o' (or other similar things) in a string?

2016-09-25 Thread Christian Gollwitzer

Am 25.09.16 um 01:08 schrieb Thomas 'PointedEars' Lahn:

Christian Gollwitzer wrote:


Am 17.09.16 um 23:19 schrieb Thomas 'PointedEars' Lahn:

Peng Yu wrote:

Hi, I want to convert strings in which the characters with accents
should be converted to the ones without accents.

[…]

[…]
./main.py Förstemann


AFAIK, “ä”, “ö”, and “ü” are not accented characters in any natural
language, but characters of their own (umlauts).

In particular, I know for certain that they are not accented in Germanic
languages.  Swedish has been mentioned; I can add my native language,
German, to that list.


In German, they are letters,


If you read more carefully, my point was: In German, umlauts are not
"accented characters".


but they collate as either ae, oe, ue
(rarely) or a, o, u (modern style).


Correct, but irrelevant.  The OP did not say anything about sorting.

Fallacy: Red herring.



Fallacy: Thinking that I disagree with you.

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


Re: How to convert 'ö' to 'oe' or 'o' (or other similar things) in a string?

2016-09-25 Thread Steve D'Aprano
On Sun, 25 Sep 2016 09:08 am, Thomas 'PointedEars' Lahn wrote:

> Christian Gollwitzer wrote:
> 
>> Am 17.09.16 um 23:19 schrieb Thomas 'PointedEars' Lahn:
>>> Peng Yu wrote:
 Hi, I want to convert strings in which the characters with accents
 should be converted to the ones without accents.
>>> […]
 […]
 ./main.py Förstemann
>>>
>>> AFAIK, “ä”, “ö”, and “ü” are not accented characters in any natural
>>> language, but characters of their own (umlauts).
>>>
>>> In particular, I know for certain that they are not accented in Germanic
>>> languages.  Swedish has been mentioned; I can add my native language,
>>> German, to that list.
>> 
>> In German, they are letters,
> 
> If you read more carefully, my point was: In German, umlauts are not
> "accented characters".

The umlauts themselves are not. But the combination of vowel-plus-umlaut is
surely an "accented character", is it not? If not, what do you call it in
German?

My understanding is that both officially and popularly, native German
speakers consider that the alphabet has 26 letters (same as English), and
that "accented characters" including the vowels which take umlauts are not
distinct letters of the alphabet but mere variations of the standard
vowels.

That's to be contrasted to (say) Swedish, where ä and ö are *not* "a and o
with an accent/diacritic/umlaut/diaeresis/trema" but distinct letters of
the alphabet in their own right. That's different from ü (the "German Y")
in Swedish, which is only used for loan words and names of German origin,
and *is* considered to be a variant of u.

I use the term "accented character" here in the ignorant, non-linguist,
English-speaker sense of any letter of the alphabet with "funny dots and
squiggles" on it. To people who know what they are talking about, there is
a difference between an accent, umlaut, trema, diaeresis and other
diacritics, but for the purposes of my question, I'm not too worried about
the technical difference between these modifiers, only whether or not they
are considered a modifier on a standard letter or not.



[...]
> And as you have mentioned phone books, in all German-speaking phone books
> I have come across so far, “ä” does sort like “ae”, “ö” like “oe”, and “ü”
> like “ue” (this is specified in DIN 5007 as “variant 1”).
> 
> (That does not mean, however, that it is a good idea to *convert* those
> letters this way.  And there is no good reason to; all modern operating
> systems, filesystems and name schemes support Unicode.)

Alas, if we only needed to deal with modern operating systems, file systems
and naming schemes, life would be much easier. But sadly we also have to
deal with *old* operating systems, file systems and naming schemes; as well
as ASCII-only or other non-Unicode applications, plus keyboards that give
the user no obvious or easy way to add "accents" (diacritics etc.) to base
letters. See, for example:

http://code.activestate.com/recipes/251871-latin1-to-ascii-the-unicode-hammer/

As the author says:

"One of my clients gets address data from Europe, but most of their systems
cannot handle Latin-1 characters. With all due respect to the umlaut,
scharfes s, cedilla, and all the other fine accented characters of Europe,
all I needed to do was to prepare addresses for a shipping system."


Post offices and freight companies are used to dealing with misspelled
addresses. They can usually cope with a few missing accents.



-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

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


Stompy

2016-09-25 Thread Jason Friedman
My goal is to send messages to an AMQ server using Python 3.3.  I found
Stompy and performed
2to3-3.3 before building.  I am open to non-Stompy solutions.

My code:
from stompy.stomp import Stomp
my_stomp = Stomp(AMQ_HOST, AMQ_PORT)
my_stomp.connect(AMQ_USERNAME, AMQ_PASSWORD)


My error:
Traceback (most recent call last):
  File "temp.py", line 8, in 
my_stomp.connect(AMQ_USERNAME, AMQ_PASSWORD)
  File "/lclapps/oppen/thirdparty/stompy/stomp.py", line 48, in connect
self.frame.connect(self.sock, username=username, password=password,
clientid=clientid)
  File "/lclapps/oppen/thirdparty/stompy/frame.py", line 92, in connect
self.send_frame(frame.as_string())
  File "/lclapps/oppen/thirdparty/stompy/frame.py", line 250, in send_frame
self.sock.sendall(frame)
TypeError: 'str' does not support the buffer interface
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Stompy

2016-09-25 Thread MRAB

On 2016-09-25 18:46, Jason Friedman wrote:

My goal is to send messages to an AMQ server using Python 3.3.  I found
Stompy and performed
2to3-3.3 before building.  I am open to non-Stompy solutions.

My code:
from stompy.stomp import Stomp
my_stomp = Stomp(AMQ_HOST, AMQ_PORT)
my_stomp.connect(AMQ_USERNAME, AMQ_PASSWORD)


My error:
Traceback (most recent call last):
  File "temp.py", line 8, in 
my_stomp.connect(AMQ_USERNAME, AMQ_PASSWORD)
  File "/lclapps/oppen/thirdparty/stompy/stomp.py", line 48, in connect
self.frame.connect(self.sock, username=username, password=password,
clientid=clientid)
  File "/lclapps/oppen/thirdparty/stompy/frame.py", line 92, in connect
self.send_frame(frame.as_string())
  File "/lclapps/oppen/thirdparty/stompy/frame.py", line 250, in send_frame
self.sock.sendall(frame)
TypeError: 'str' does not support the buffer interface

I expected you've used Unicode strings for AMQ_USERNAME and 
AMQ_PASSWORD, but if Stompy was written for Python 2, it'll be expecting 
bytestrings instead.


You'll need to do more work on Stompy to fix the parts that 2to3 missed.
--
https://mail.python.org/mailman/listinfo/python-list


Is 'learning python 5th edition' a good book to beginner?

2016-09-25 Thread 380162267qq
I want to find a python book like C++ primer which provides me details to 
understand the language.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Is 'learning python 5th edition' a good book to beginner?

2016-09-25 Thread Lawrence D’Oliveiro
Judging from the table of contents 
, it spends too much time 
(i.e. > 0) talking about Python 2.
-- 
https://mail.python.org/mailman/listinfo/python-list


Dynamically updating Graph in python

2016-09-25 Thread anujgupta82
 0
down vote
favorite


I have a M x N 2D array: ith row represents that value of N points at time i.

I want to visualize the points [1 row of the array] in the form of a graph 
where the values get updated after a small interval. Thus the graph shows 1 row 
at a time, then update the values to next row, so on and so forth.

I want to do this in a jupyter notebook. Looking for reference codes.

I tried following things but no success:

http://community.plot.ly/t/updating-graph-with-new-data-every-100-ms-or-so/812
https://pythonprogramming.net/live-graphs-matplotlib-tutorial/
http://stackoverflow.com/questions/5618620/create-dynamic-updated-graph-with-python
http://stackoverflow.com/questions/11371255/update-lines-in-matplotlib
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Is 'learning python 5th edition' a good book to beginner?

2016-09-25 Thread boB Stepp
On Sun, Sep 25, 2016 at 3:50 PM, Lawrence D’Oliveiro
 wrote:
> Judging from the table of contents 
> , it spends too much time 
> (i.e. > 0) talking about Python 2.

I own this book.  The 5th edition covers both Python 3.3 and 2.7.  Its
emphasis is slanted to 3.3, but it *thoroughly* covers the core
language for both.

As far as the OP's original question, if he is comfortable with
programming in other languages, then this book can serve him well if
he wants to know all the details of the language.  The author does use
a tutorial approach, but it is a massive text that tries to cover
everything in the core language with selected examination of parts of
the standard library.

HTH!
-- 
boB
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Stompy

2016-09-25 Thread Jason Friedman
>
> My error:
>> Traceback (most recent call last):
>>   File "temp.py", line 8, in 
>> my_stomp.connect(AMQ_USERNAME, AMQ_PASSWORD)
>>   File "/lclapps/oppen/thirdparty/stompy/stomp.py", line 48, in connect
>> self.frame.connect(self.sock, username=username, password=password,
>> clientid=clientid)
>>   File "/lclapps/oppen/thirdparty/stompy/frame.py", line 92, in connect
>> self.send_frame(frame.as_string())
>>   File "/lclapps/oppen/thirdparty/stompy/frame.py", line 250, in
>> send_frame
>> self.sock.sendall(frame)
>> TypeError: 'str' does not support the buffer interface
>>
>> I expected you've used Unicode strings for AMQ_USERNAME and AMQ_PASSWORD,
> but if Stompy was written for Python 2, it'll be expecting bytestrings
> instead.
>
> You'll need to do more work on Stompy to fix the parts that 2to3 missed.


Thanks for the advice, I will try that.

I will also try https://pypi.python.org/pypi/stompest/.
-- 
https://mail.python.org/mailman/listinfo/python-list


Nested for loops and print statements

2016-09-25 Thread Cai Gengyang
Why is it that you need a print() at the end to create the table for example 1:

Example 1 ---

>>> for row in range(10):
for column in range(10):
print("*",end=" ")
 
# Print a blank line for next row
print()


* * * * * * * * * * 
* * * * * * * * * * 
* * * * * * * * * * 
* * * * * * * * * * 
* * * * * * * * * * 
* * * * * * * * * * 
* * * * * * * * * * 
* * * * * * * * * * 
* * * * * * * * * * 
* * * * * * * * * * 

but not for Example 2 ---

for row in range(10):
print("*",end=" ")

* * * * * * * * * *

When I try to do example 1 without the print() statement at the end, I get this 
error :

for row in range(10):
for column in range(10):
print("*",end=" ")

SyntaxError: inconsistent use of tabs and spaces in indentation
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Nested for loops and print statements

2016-09-25 Thread Jussi Piitulainen
Cai Gengyang writes:

> Why is it that you need a print() at the end to create the table for
> example 1:
>
> Example 1 ---
>
 for row in range(10):
> for column in range(10):
> print("*",end=" ")
>  
> # Print a blank line for next row
> print()

[- -]

> When I try to do example 1 without the print() statement at the end, I
> get this error :
>
> for row in range(10):
> for column in range(10):
>   print("*",end=" ")
>   
> SyntaxError: inconsistent use of tabs and spaces in indentation

That error has absolutely nothing to do with nested loops, and
absolutely nothing to do with print statements. Nested loops and print
statements are entirely coincidental to the error.

You have managed to use a mixture of two different whitespace characters
to indent the lines: horizontal tabs (character code 9, hex 9) and
spaces (character code 32, hex 20). Different environments may interpret
and display the tabs as different amounts of indentation, depending on
their position in the line. That affects the meaning of a Python
program.

When you get this error, re-indent your lines.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Nested for loops and print statements

2016-09-25 Thread Terry Reedy

On 9/26/2016 1:59 AM, Cai Gengyang wrote:

Why is it that you need a print() at the end to create the table for example 1:

Example 1 ---


for row in range(10):

for column in range(10):
print("*",end=" ")
# Print a blank line for next row
print()


These indents are either 4 or 8 spaces.

The print provides a carriage return.
Each line ends with a space.


* * * * * * * * * *
* * * * * * * * * *
* * * * * * * * * *
* * * * * * * * * *
* * * * * * * * * *
* * * * * * * * * *
* * * * * * * * * *
* * * * * * * * * *
* * * * * * * * * *
* * * * * * * * * *


One can avoid both extra print and spaces with

for row in range(10):
for column in range(10):
print("*", end=" " if column<9 else '\n')

# or
for row in range(10):
print(' '.join(['*']*10))
# or
print((' '.join(['*']*10)+'\n')*10)

# or
for row in range(10):
print('* '*9 + '*')
# or
print(('* '*9 + '*\n')*10)



but not for Example 2 ---

for row in range(10):
print("*",end=" ")

* * * * * * * * * *

When I try to do example 1 without the print() statement at the end, I get this 
error :

for row in range(10):
for column in range(10):
print("*",end=" ")


These indents are 4 spaces and 1 tabs.


SyntaxError: inconsistent use of tabs and spaces in indentation


Because you mixed tabs and spaces.  Has nothing to do with print statement.


--
Terry Jan Reedy

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