Re: pyinstaller and Python 3.5 on Windows?

2015-11-18 Thread Ulli Horlacher
Christian Gollwitzer wrote: > Am 18.11.15 um 23:46 schrieb Ulli Horlacher: > > To run my Python programs on other Windows systems without a Python > > installation I must create standalone Windows executables. > > > > pyinstaller runs without any problems with Python 2.7.10 on Windows 7, but > > w

Re: Question about 'print' in a loop

2015-11-18 Thread dieter
fl writes: > Hi, > > From previous post, I get many helpful replies. Now I have a new question > when I run this example code: > > > - > sq=[] > for xx in range(5): > print 'here' > sq.append(lambda:xx**2) > ... > sq[2]() > Out[151]: 16 > > sq[3]() > Out[152]: 16 > / Same rea

Re: Could you explain why the following generates 4 same elements list?

2015-11-18 Thread dieter
fl writes: > Hi, > > I cannot reason out why the code: > > def mpl(): > return [lambda x : i * x for i in range(4)] > > print [m(2) for m in mpl()] > / > > has result: > > [6, 6, 6, 6] The "i" in your lambda definition is a variable reference which is not dereferenced (

Re: pyinstaller and Python 3.5 on Windows?

2015-11-18 Thread Christian Gollwitzer
Am 18.11.15 um 23:46 schrieb Ulli Horlacher: To run my Python programs on other Windows systems without a Python installation I must create standalone Windows executables. pyinstaller runs without any problems with Python 2.7.10 on Windows 7, but with Python 3.5 I get: [stack trace] Are you u

Re: Question about 'print' in a loop

2015-11-18 Thread fl
On Wednesday, November 18, 2015 at 10:11:24 PM UTC-5, Chris Angelico wrote: > On Thu, Nov 19, 2015 at 1:55 PM, fl wrote: > > There are only one time 5 'here' printed out, but there is no 'here' print > > out in thereafter call sq[2]() etc. How to understand this phenomenon? > > Code does what cod

Re: Question about 'print' in a loop

2015-11-18 Thread Chris Angelico
On Thu, Nov 19, 2015 at 1:55 PM, fl wrote: > There are only one time 5 'here' printed out, but there is no 'here' print > out in thereafter call sq[2]() etc. How to understand this phenomenon? Code does what code should. Before you ask for comprehension of "this phenomenon", why don't you tell u

Question about 'print' in a loop

2015-11-18 Thread fl
Hi, >From previous post, I get many helpful replies. Now I have a new question when I run this example code: - sq=[] for xx in range(5): print 'here' sq.append(lambda:xx**2) here here here here here xx Out[150]: 4 sq[2]() Out[151]: 16 sq[3]() Out[152]: 16 / There are

Re: Public key encryption example.

2015-11-18 Thread Vincent Davis
Found an example, needs a little updating but then it works (appears to) in python 3.5. http://coding4streetcred.com/blog/post/Asymmetric-Encryption-Revisited-(in-PyCrypto) Vincent Davis 720-301-3003 On Wed, Nov 18, 2015 at 5:04 PM, Chris Angelico wrote: > On Thu, Nov 19, 2015 at 10:56 AM, Paul

Re: What is a function parameter =[] for?

2015-11-18 Thread Chris Angelico
On Thu, Nov 19, 2015 at 1:08 PM, Ben Finney wrote: >> Nope. Mutable objects are never guaranteed to retain the same values. >> That's kinda the point. > > Well, they are the *same value*, if by “value” you mean “a particular > object”. > > On the other hand, the value can *change* over time, while

Re: What is a function parameter =[] for?

2015-11-18 Thread Ben Finney
Chris Angelico writes: > On Thu, Nov 19, 2015 at 12:41 PM, BartC wrote: > > On 18/11/2015 23:22, Chris Angelico wrote: > >> On the contrary, it is certain always to be that exact object. > > > > But, not the same value that appears as the default? It depends what you mean by “the same value”.

Re: What is a function parameter =[] for?

2015-11-18 Thread Chris Angelico
On Thu, Nov 19, 2015 at 12:41 PM, BartC wrote: > On 18/11/2015 23:22, Chris Angelico wrote: >> On the contrary, it is certain always to be that exact object. > > But, not the same value that appears as the default? Nope. Mutable objects are never guaranteed to retain the same values. That's kinda

Re: What is a function parameter =[] for?

2015-11-18 Thread BartC
On 18/11/2015 23:22, Chris Angelico wrote: On Thu, Nov 19, 2015 at 10:14 AM, BartC wrote: On 18/11/2015 22:11, Ian Kelly wrote: On Wed, Nov 18, 2015 at 2:08 PM, fl wrote: Hi, I have tried the below function and find that it can remember the previous setting value to 'val'. I think the sec

Re: What is a function parameter =[] for?

2015-11-18 Thread Ben Finney
MRAB writes: > On 2015-11-19 00:34, fl wrote: > > What does 'del' do? It does not look like a thorough list deletion > > from the effect. > > No, "del list1" doesn't delete the list, it deletes the name "list1". > The list still exists as the default parameter. More generally, ‘del’ deletes a *r

Re: What is a function parameter =[] for?

2015-11-18 Thread MRAB
On 2015-11-19 00:34, fl wrote: On Wednesday, November 18, 2015 at 7:15:05 PM UTC-5, Chris Angelico wrote: On Thu, Nov 19, 2015 at 11:02 AM, Ian Kelly wrote: > On Wed, Nov 18, 2015 at 4:22 PM, Chris Angelico wrote: >> On Thu, Nov 19, 2015 at 10:14 AM, BartC wrote: >>> So, looking at some sourc

Re: What is a function parameter =[] for?

2015-11-18 Thread Ian Kelly
On Wed, Nov 18, 2015 at 5:34 PM, fl wrote: > After I try with > > list1 = eList(12, [2]) > > and > > list1 = eList(12) > > it gives me new surprises. Even though I delete list1, the subsequent > list1 = eList(12) > will remember the number of '12' of the previous sequence. This is my new > questio

Re: Could you explain why the following generates 4 same elements list?

2015-11-18 Thread Ian Kelly
On Wed, Nov 18, 2015 at 5:05 PM, fl wrote: > Hi, > > I cannot reason out why the code: > > def mpl(): > return [lambda x : i * x for i in range(4)] > > print [m(2) for m in mpl()] > / > > has result: > > [6, 6, 6, 6] > > > I have tried to simplify the above code to an easy und

Re: What is a function parameter =[] for?

2015-11-18 Thread fl
On Wednesday, November 18, 2015 at 7:15:05 PM UTC-5, Chris Angelico wrote: > On Thu, Nov 19, 2015 at 11:02 AM, Ian Kelly wrote: > > On Wed, Nov 18, 2015 at 4:22 PM, Chris Angelico wrote: > >> On Thu, Nov 19, 2015 at 10:14 AM, BartC wrote: > >>> So, looking at some source code, a default value fo

Re: pyinstaller and Python 3.5 on Windows?

2015-11-18 Thread Thomas 'PointedEars' Lahn
Ulli Horlacher wrote: > To run my Python programs on other Windows systems without a Python > installation I must create standalone Windows executables. > > pyinstaller runs without any problems with Python 2.7.10 on Windows 7, but > with Python 3.5 I get: > > [b0rked stack trace] > > Is there

Re: What is a function parameter =[] for?

2015-11-18 Thread Chris Angelico
On Thu, Nov 19, 2015 at 11:02 AM, Ian Kelly wrote: > On Wed, Nov 18, 2015 at 4:22 PM, Chris Angelico wrote: >> On Thu, Nov 19, 2015 at 10:14 AM, BartC wrote: >>> So, looking at some source code, a default value for certain types is only >>> certain to be that value for the very first call of tha

Could you explain why the following generates 4 same elements list?

2015-11-18 Thread fl
Hi, I cannot reason out why the code: def mpl(): return [lambda x : i * x for i in range(4)] print [m(2) for m in mpl()] / has result: [6, 6, 6, 6] I have tried to simplify the above code to an easy understanding form, but fails. Either the modified code does not work

Re: Public key encryption example.

2015-11-18 Thread Chris Angelico
On Thu, Nov 19, 2015 at 10:56 AM, Paul Rubin wrote: > Vincent Davis writes: >> I am looking for the "simplest" example of sending(encrypting) and >> receiving(decrypting) using public key encryption. I am think of something >> along the lines of having all the keys in local files and saving and >

Re: What is a function parameter =[] for?

2015-11-18 Thread Ian Kelly
On Wed, Nov 18, 2015 at 4:22 PM, Chris Angelico wrote: > On Thu, Nov 19, 2015 at 10:14 AM, BartC wrote: >> So, looking at some source code, a default value for certain types is only >> certain to be that value for the very first call of that function? > > On the contrary, it is certain always to

Re: Public key encryption example.

2015-11-18 Thread Paul Rubin
Vincent Davis writes: > I am looking for the "simplest" example of sending(encrypting) and > receiving(decrypting) using public key encryption. I am think of something > along the lines of having all the keys in local files and saving and > reading the message from a local file. It's very easy to

Re: What is a function parameter =[] for?

2015-11-18 Thread Chris Angelico
On Thu, Nov 19, 2015 at 10:14 AM, BartC wrote: > On 18/11/2015 22:11, Ian Kelly wrote: >> >> On Wed, Nov 18, 2015 at 2:08 PM, fl wrote: >>> >>> Hi, >>> >>> I have tried the below function and find that it can remember the >>> previous >>> setting value to 'val'. I think the second parameter has s

Public key encryption example.

2015-11-18 Thread Vincent Davis
This might be a "Let me Google that for you question", I tried. I am looking for the "simplest" example of sending(encrypting) and receiving(decrypting) using public key encryption. I am think of something along the lines of having all the keys in local files and saving and reading the message from

Re: What is a function parameter =[] for?

2015-11-18 Thread BartC
On 18/11/2015 22:11, Ian Kelly wrote: On Wed, Nov 18, 2015 at 2:08 PM, fl wrote: Hi, I have tried the below function and find that it can remember the previous setting value to 'val'. I think the second parameter has something on this effect, but I don't know the name and function of '=[]' in

pyinstaller and Python 3.5 on Windows?

2015-11-18 Thread Ulli Horlacher
To run my Python programs on other Windows systems without a Python installation I must create standalone Windows executables. pyinstaller runs without any problems with Python 2.7.10 on Windows 7, but with Python 3.5 I get: S:\python>pyinstaller.exe --onefile tk.py Traceback (most recent call la

Re: What is a function parameter =[] for?

2015-11-18 Thread fl
On Wednesday, November 18, 2015 at 5:38:45 PM UTC-5, fl wrote: > On Wednesday, November 18, 2015 at 5:12:44 PM UTC-5, Ian wrote: > > On Wed, Nov 18, 2015 at 2:08 PM, fl wrote: > > > Hi, > > > > > > I have tried the below function and find that it can remember the previous > > > setting value to 'v

Re: What is a function parameter =[] for?

2015-11-18 Thread Ian Kelly
On Wed, Nov 18, 2015 at 3:38 PM, fl wrote: > On Wednesday, November 18, 2015 at 5:12:44 PM UTC-5, Ian wrote: >> On Wed, Nov 18, 2015 at 2:08 PM, fl wrote: >> > Hi, >> > >> > I have tried the below function and find that it can remember the previous >> > setting value to 'val'. I think the second

Re: handling of non-ASCII filenames?

2015-11-18 Thread Ulli Horlacher
Chris Angelico wrote: > >> If you can use Python 3 > > > > I cannot use it, because the Python compiler pyinstaller does not work > > with it on Windows: > > > > S:\python>pyinstaller.exe --onefile tk.py > > Traceback (most recent call last): > > File "C:\Python35\Scripts\pyinstaller-script.py"

Re: What is a function parameter =[] for?

2015-11-18 Thread fl
On Wednesday, November 18, 2015 at 5:12:44 PM UTC-5, Ian wrote: > On Wed, Nov 18, 2015 at 2:08 PM, fl wrote: > > Hi, > > > > I have tried the below function and find that it can remember the previous > > setting value to 'val'. I think the second parameter has something on this > > effect, but I d

Re: What is a function parameter =[] for?

2015-11-18 Thread Grant Edwards
On 2015-11-18, Ian Kelly wrote: > On Wed, Nov 18, 2015 at 2:08 PM, fl wrote: >> def eList(val, list0=[]): > The list0 parameter has a default value, which is [], an initially > empty list. The default value is evaluated when the function is > defined, not when it is called, so the same list obj

Re: What is a function parameter =[] for?

2015-11-18 Thread Ian Kelly
On Wed, Nov 18, 2015 at 2:08 PM, fl wrote: > Hi, > > I have tried the below function and find that it can remember the previous > setting value to 'val'. I think the second parameter has something on this > effect, but I don't know the name and function of '=[]' in this application. > > Could you

Re: What is a function parameter =[] for?

2015-11-18 Thread John Gordon
In fl writes: > Hi, > I have tried the below function and find that it can remember the previous > setting value to 'val'. I think the second parameter has something on this > effect, but I don't know the name and function of '=[]' in this application. > Could you explain a little to me? > T

Re: How to create a folder using IMAPLib?

2015-11-18 Thread Laura Creighton
In a message of Thu, 19 Nov 2015 07:35:36 +1100, Chris Angelico writes: >On Thu, Nov 19, 2015 at 7:01 AM, Anthony Papillion > wrote: >> I'm writing a program to help migrate mail from one host to another >> with a few special circumstances. I'm able to get a list off of the >> source IMAP server us

Re: How can I export data from a website and write the contents to a text file?

2015-11-18 Thread Random832
ryguy7272 writes: > text_file = open("C:/Users/rshuell001/Desktop/excel/Text1.txt", "wb") Remove the "b" from this line. This is causing it to omit the platform-specific translation of "\n", which means some Windows applications will not recognize the line endings. -- https://mail.python.org/ma

What is a function parameter =[] for?

2015-11-18 Thread fl
Hi, I have tried the below function and find that it can remember the previous setting value to 'val'. I think the second parameter has something on this effect, but I don't know the name and function of '=[]' in this application. Could you explain a little to me? Thanks, def eList(val, list0=

Re: How to create a folder using IMAPLib?

2015-11-18 Thread Chris Angelico
On Thu, Nov 19, 2015 at 7:01 AM, Anthony Papillion wrote: > I'm writing a program to help migrate mail from one host to another > with a few special circumstances. I'm able to get a list off of the > source IMAP server using the .list() command but I'm not quite sure > how to create a folder on th

Re: handling of non-ASCII filenames?

2015-11-18 Thread Chris Angelico
On Thu, Nov 19, 2015 at 5:09 AM, Ulli Horlacher wrote: > Chris Angelico wrote: > >> > As I am Python newbie I have not quite understood the Python character >> > encoding scheme :-} >> > >> > Where can I find a good introduction of this topic? >> >> Here are a couple of articles on the basics of

Re: Mapping between python packages and distro packages?

2015-11-18 Thread Chris Angelico
On Thu, Nov 19, 2015 at 6:30 AM, Laura Creighton wrote: > apt-cache search works reasonably well, as long as you are > willing to put up with some false hits. And it assumes you have a debian > system handy, of course. I suspect the most common case is "how can I get this on _this exact system_

How to create a folder using IMAPLib?

2015-11-18 Thread Anthony Papillion
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 I'm writing a program to help migrate mail from one host to another with a few special circumstances. I'm able to get a list off of the source IMAP server using the .list() command but I'm not quite sure how to create a folder on the target machine.

Re: Mapping between python packages and distro packages?

2015-11-18 Thread Laura Creighton
In a message of Wed, 18 Nov 2015 17:44:51 +1100, Chris Angelico writes: >I don't know how the program would detect it, but I'd be thinking "the >one where 'sudo apt-get install PACKAGENAME' gets the same code that >'pip install THING' gets". In a lot of cases, PACKAGENAME will simply >be python-TH

Re: non-blocking getkey?

2015-11-18 Thread eryksun
On Wed, Nov 18, 2015 at 3:14 AM, Christian Gollwitzer wrote: > The standard terminal on Windows is very ugly, can't resize the width, and > pasting works only if you right-click -> paste. The console UI is improved in Windows 10: http://blogs.windows.com/buildingapps/2014/10/07/console-improvemen

Re: handling of non-ASCII filenames?

2015-11-18 Thread Ulli Horlacher
Chris Angelico wrote: > > As I am Python newbie I have not quite understood the Python character > > encoding scheme :-} > > > > Where can I find a good introduction of this topic? > > Here are a couple of articles on the basics of Unicode: > > http://www.joelonsoftware.com/articles/Unicode.htm

Re: How can I export data from a website and write the contents to a text file?

2015-11-18 Thread Rob Gaddi
On Wed, 18 Nov 2015 09:40:58 -0800, ryguy7272 wrote: > > It doesn't seem like the '\n' is doing anything useful. All the text is > jumbled together. When I open the file in Excel, or Notepad++, it is > easy to read. However, when I open it in as a regular text file, > everything is jumbled toge

Re: Launcher, and ftype Python.File

2015-11-18 Thread eryksun
On Wed, Nov 18, 2015 at 8:45 AM, Christian Ullrich wrote: > Apparently %L is always the long file name, and %1 is the short name unless > the shell can prove that the executable can handle long names. Specifically old Win16 programs (identified by the file header) aren't aware of long filenames.

Re: non-blocking getkey?

2015-11-18 Thread Terry Reedy
On 11/18/2015 11:50 AM, Ulli Horlacher wrote: Ulli Horlacher wrote: from Tkinter import Tk from tkFileDialog import askopenfilename Tk().withdraw() file = askopenfilename() I found another glitch: After termination of askopenfilename() the window focus i

Re: How can I export data from a website and write the contents to a text file?

2015-11-18 Thread ryguy7272
On Wednesday, November 18, 2015 at 12:41:19 PM UTC-5, ryguy7272 wrote: > On Wednesday, November 18, 2015 at 12:21:47 PM UTC-5, Denis McMahon wrote: > > On Wed, 18 Nov 2015 08:37:47 -0800, ryguy7272 wrote: > > > > > I'm trying the script below... > > > > The problem isn't that you're over-writing

Re: How can I export data from a website and write the contents to a text file?

2015-11-18 Thread ryguy7272
On Wednesday, November 18, 2015 at 12:21:47 PM UTC-5, Denis McMahon wrote: > On Wed, 18 Nov 2015 08:37:47 -0800, ryguy7272 wrote: > > > I'm trying the script below... > > The problem isn't that you're over-writing the lines (although it may > seem that way to you), the problem is that you're ove

Re: handling of non-ASCII filenames?

2015-11-18 Thread Christian Gollwitzer
Am 18.11.15 um 17:45 schrieb Ulli Horlacher: This is my encoding function: def url_encode(s): u = '' for c in list(s): if match(r'[_=:,;<>()+.\w\-]',c): u += c else: u += '%' + c.encode("hex").upper() return u The quoting is applied to a UTF8 string. But I th

Re: How can I export data from a website and write the contents to a text file?

2015-11-18 Thread Denis McMahon
On Wed, 18 Nov 2015 08:37:47 -0800, ryguy7272 wrote: > I'm trying the script below... The problem isn't that you're over-writing the lines (although it may seem that way to you), the problem is that you're overwriting the whole file every time you write a link to it. This is because you open an

Re: How can I export data from a website and write the contents to a text file?

2015-11-18 Thread ryguy7272
On Wednesday, November 18, 2015 at 12:04:16 PM UTC-5, ryguy7272 wrote: > On Wednesday, November 18, 2015 at 11:58:17 AM UTC-5, Chris Angelico wrote: > > On Thu, Nov 19, 2015 at 3:37 AM, ryguy7272 <> wrote: > > > text_file = open("C:/Users/rshuell001/Desktop/excel/Text1.txt", > > > "wb") > >

Re: How can I export data from a website and write the contents to a text file?

2015-11-18 Thread ryguy7272
On Wednesday, November 18, 2015 at 11:58:17 AM UTC-5, Chris Angelico wrote: > On Thu, Nov 19, 2015 at 3:37 AM, ryguy7272 wrote: > > text_file = open("C:/Users/rshuell001/Desktop/excel/Text1.txt", "wb") > > z = str(link) > > text_file.write(z + "\n") > > text_file.writ

Re: How can I export data from a website and write the contents to a text file?

2015-11-18 Thread Chris Angelico
On Thu, Nov 19, 2015 at 3:37 AM, ryguy7272 wrote: > text_file = open("C:/Users/rshuell001/Desktop/excel/Text1.txt", "wb") > z = str(link) > text_file.write(z + "\n") > text_file.write("\n") > text_file.close() You're opening the file every time you go through

Re: non-blocking getkey?

2015-11-18 Thread Ulli Horlacher
Ulli Horlacher wrote: > from Tkinter import Tk > from tkFileDialog import askopenfilename > > Tk().withdraw() > file = askopenfilename() I found another glitch: After termination of askopenfilename() the window focus is not returned to the calling window (xterm

Re: handling of non-ASCII filenames?

2015-11-18 Thread Chris Angelico
On Thu, Nov 19, 2015 at 3:45 AM, Ulli Horlacher wrote: > As I am Python newbie I have not quite understood the Python character > encoding scheme :-} > > Where can I find a good introduction of this topic? Here are a couple of articles on the basics of Unicode: http://www.joelonsoftware.com/arti

handling of non-ASCII filenames?

2015-11-18 Thread Ulli Horlacher
I have written a program (Python 2.7) which reads a filename via tkFileDialog.askopenfilename() (was a good hint here, other thread). This filename may contain non-ASCII characters (German Umlauts). In this case my program crashes with: File "S:\python\fexit.py", line 1177, in url_encode

How can I export data from a website and write the contents to a text file?

2015-11-18 Thread ryguy7272
I'm trying the script below, and it simple writes the last line to a text file. I want to add a '\n' after each line is written, so I don't overwrite all the lines. from bs4 import BeautifulSoup import urllib2 var_file = urllib2.urlopen("http://www.imdb.com/chart/top";) var_html = var_file.

link a treeview to a list

2015-11-18 Thread durozoyp
So I am currently making a little program that generates a list of characters with different stats. Now I would like to display those characters in a list and when the user clicks on one of them display all the stats for that character. Here is my code for my GUI so far: class CTABLE: def

Re: Launcher, and ftype Python.File

2015-11-18 Thread Christian Ullrich
* Terry Reedy wrote: On 11/18/2015 3:12 AM, Glenn Linderman wrote: d:\>ftype Python.File Python.File="C:\Windows\py.exe" "%L" %* Verified on my Win 10 I'm surprised by the "%L" where usually programs have "%1". Is this a new Windows feature I don't know about yet, or is it a bug in the in

Re: non-blocking getkey?

2015-11-18 Thread Jussi Piitulainen
Ulli Horlacher writes: > Steven D'Aprano wrote: > >> >> The limitation is that this will not work if any of the file names >> >> contain astral (non-BMP) chars because tk cannot handle such >> >> characters. >> > >> > What are "astral chars"? >> >> Unicode characters beyond U+. > > I see, for

Re: non-blocking getkey?

2015-11-18 Thread Chris Angelico
On Thu, Nov 19, 2015 at 12:51 AM, Ulli Horlacher wrote: > Steven D'Aprano wrote: > >> >> The limitation is that this will not work if any of the file names >> >> contain astral (non-BMP) chars because tk cannot handle such characters. >> > >> > What are "astral chars"? >> >> Unicode characters be

Re: non-blocking getkey?

2015-11-18 Thread Ulli Horlacher
Chris Angelico wrote: > > In my application the user MUST select files and directories (in one go). > > It's extremely uncommon to be able to select a combination of files > and directories. I have an uncommon application :-) Filetransfer of ANY size: http://fex.rus.uni-stuttgart.de:8080/ >

Re: non-blocking getkey?

2015-11-18 Thread Ulli Horlacher
Steven D'Aprano wrote: > >> The limitation is that this will not work if any of the file names > >> contain astral (non-BMP) chars because tk cannot handle such characters. > > > > What are "astral chars"? > > Unicode characters beyond U+. I see, for very exotic character sets, like Klingo

Re: Which type should be used when testing static structure appartenance

2015-11-18 Thread Chris Angelico
On Thu, Nov 19, 2015 at 12:30 AM, Steven D'Aprano wrote: > On Wed, 18 Nov 2015 11:40 pm, Chris Angelico wrote: >> All the questions of performance should be >> secondary to code clarity, though; > > "All"? Surely not. The OP's example was checking if a string was equal to either of two strings. E

Re: non-blocking getkey?

2015-11-18 Thread Steven D'Aprano
On Thu, 19 Nov 2015 12:06 am, Ulli Horlacher wrote: > Terry Reedy wrote: > >> > from Tkinter import Tk >> > from tkFileDialog import askopenfilename >> > >> > Tk().withdraw() >> > file = askopenfilename() >> >> To get multiple names, add 's'. > > I have found it already

Re: Which type should be used when testing static structure appartenance

2015-11-18 Thread Jon Ribbens
On 2015-11-18, Steven D'Aprano wrote: > On Wed, 18 Nov 2015 11:40 pm, Chris Angelico wrote: >> so I would say the choices are: Set >> literal if available, else tuple. Forget the performance. > > It seems rather strange to argue that we should ignore performance when the > whole reason for using

Re: Which type should be used when testing static structure appartenance

2015-11-18 Thread Steven D'Aprano
On Wed, 18 Nov 2015 11:40 pm, Chris Angelico wrote: > On Wed, Nov 18, 2015 at 10:37 PM, Steven D'Aprano > wrote: >> How about Python 3? Python 3 has the advantage of using set literals. > > 2.7 has set literals too. Ah, so it does. I forgot about that. Most of my code has to run on multiple ve

Re: non-blocking getkey?

2015-11-18 Thread Chris Angelico
On Thu, Nov 19, 2015 at 12:06 AM, Ulli Horlacher wrote: >> The limitation is that this will not work if any of the file names >> contain astral (non-BMP) chars because tk cannot handle such characters. > > What are "astral chars"? Characters not on the Basic Multilingual Plane (BMP). The Unicode

Re: non-blocking getkey?

2015-11-18 Thread Ulli Horlacher
Terry Reedy wrote: > > from Tkinter import Tk > > from tkFileDialog import askopenfilename > > > > Tk().withdraw() > > file = askopenfilename() > > To get multiple names, add 's'. I have found it already, thanks. > The limitation is that this will not work if any of t

EuroPython 2016: Dates and URL available

2015-11-18 Thread M.-A. Lemburg
The EuroPython 2016 Team is pleased to account the dates for EuroPython 2016 in Bilbao, Basque Country, Spain: Sunday, July 17 - Sunday, July 24 2016 Pre-launch Website -- To keep you updated, we have put together a pre-launch website for the conference:

Re: Writing SOME class methods in C

2015-11-18 Thread Oscar Benjamin
On 18 November 2015 at 07:50, Daniel Haude wrote: > > I'm trying to implement some (but not all) methods of a Python class in C. > What I've found on the Net is: > - how to implement entire modules in C so that I can import that module and >use the C functions (successfully done it, too). >

Re: Which type should be used when testing static structure appartenance

2015-11-18 Thread Chris Angelico
On Wed, Nov 18, 2015 at 10:37 PM, Steven D'Aprano wrote: > How about Python 3? Python 3 has the advantage of using set literals. 2.7 has set literals too. All the questions of performance should be secondary to code clarity, though; so I would say the choices are: Set literal if available, else t

Re: non-blocking getkey?

2015-11-18 Thread Terry Reedy
On 11/18/2015 6:01 AM, Ulli Horlacher wrote: Ulli Horlacher wrote: it is too complicated to rewrite my application from CLI to GUI. But... is there a windows program with which one can select files and the result is written to STDOUT? Found it: from Tkinter import Tk from tk

Re: Which type should be used when testing static structure appartenance

2015-11-18 Thread Steven D'Aprano
On Wed, 18 Nov 2015 01:27 am, Nicolas Évrard wrote: > Hello, > > I saw the following retweet by Raymond Hettinger in this morning: > > https://twitter.com/sanityinc/status/666485814214287360 > > Programming tip: many of those arrays and hashes in your code > should actually be sets.

Re: non-blocking getkey?

2015-11-18 Thread Christian Gollwitzer
Am 18.11.15 um 12:01 schrieb Ulli Horlacher: Ulli Horlacher wrote: it is too complicated to rewrite my application from CLI to GUI. But... is there a windows program with which one can select files and the result is written to STDOUT? Found it: from Tkinter import Tk from tk

Re: non-blocking getkey?

2015-11-18 Thread Ulli Horlacher
Ulli Horlacher wrote: > it is too complicated to rewrite my application from CLI to GUI. > But... is there a windows program with which one can select files and the > result is written to STDOUT? Found it: from Tkinter import Tk from tkFileDialog import askopenfilename

Re: Launcher, and ftype Python.File

2015-11-18 Thread Terry Reedy
On 11/18/2015 3:12 AM, Glenn Linderman wrote: Setting up a new machine with Windows 10, I installed Python 3.5.0 and the Launcher. Invoking python files from batch files as foo.py -a -bunch -of -parameters Didn't seem to do _anything_ so I checked: d:\>assoc .py .py=Python.File d:\>ftype Pyth

Re: non-blocking getkey?

2015-11-18 Thread Ulli Horlacher
Christian Gollwitzer wrote: > > How can I implement such a get_paste() function? > > I need a non-blocking getkey() function. > > It must work on Windows and Linux. > > Non-blocking I/O from the commandline is OS specific. There are > different solutions, and it's usually hacky (stty on Linux,

Re: cPickle.load vs. file.read+cPickle.loads on large binary files

2015-11-18 Thread andrea . gavana
Hi, On Wednesday, November 18, 2015 at 10:00:43 AM UTC+1, Nagy László Zsolt wrote: > > Perhaps there is a size threshold? You could experiment with different > > block > > sizes in the following f.read() replacement: > > > > def read_chunked(f, size=2**20): > > read = functools.partial(f.rea

Re: Is there any reason to introduce this intermediate variable (sz)?

2015-11-18 Thread Terry Reedy
On 11/17/2015 3:51 PM, fl wrote: n_iter = 50 sz = (n_iter,) # size of array x = -0.37727 z = np.random.normal(x,0.1,size=sz) Q = 1e-5 # process variance # allocate space for arrays xhat=np.zeros(sz) P=np.zeros(sz) I learn Python now and the above code seems from an experienced author. The cu

Re: Writing SOME class methods in C

2015-11-18 Thread Terry Reedy
On 11/18/2015 2:50 AM, Daniel Haude wrote: Hello, I'm trying to implement some (but not all) methods of a Python class in C. What I've found on the Net is: - how to implement entire modules in C so that I can import that module and use the C functions (successfully done it, too). - how t

Re: non-blocking getkey?

2015-11-18 Thread Christian Gollwitzer
Am 18.11.15 um 09:39 schrieb Ulli Horlacher: In my program (for python 2.7) the user must enter file names with mouse copy+paste. I use: while True: file = raw_input(prompt) if file == '': break files.append(file) How can I implement such a get_paste() function? I need a non-blocking g

Re: cPickle.load vs. file.read+cPickle.loads on large binary files

2015-11-18 Thread Nagy László Zsolt
> Perhaps there is a size threshold? You could experiment with different block > sizes in the following f.read() replacement: > > def read_chunked(f, size=2**20): > read = functools.partial(f.read, size) > return "".join(iter(read, "")) > Under win32 platform, my experience is that the fa

non-blocking getkey?

2015-11-18 Thread Ulli Horlacher
In my program (for python 2.7) the user must enter file names with mouse copy+paste. I use: while True: file = raw_input(prompt) if file == '': break files.append(file) The problem now is: my users do not hit ENTER after pasting. The file names are pasted together in one single line w

Launcher, and ftype Python.File

2015-11-18 Thread Glenn Linderman
Setting up a new machine with Windows 10, I installed Python 3.5.0 and the Launcher. Invoking python files from batch files as foo.py -a -bunch -of -parameters Didn't seem to do _anything_ so I checked: d:\>assoc .py .py=Python.File d:\>ftype Python.File Python.File="C:\Windows\py.exe" "%L" %

Re: Is there any reason to introduce this intermediate variable (sz)?

2015-11-18 Thread Dave Farrance
fl wrote: >Hi, >I find the following code snippet, which is useful in my project: > ... >correctly. Could you see something useful with variable 'sz'? So that's example code in "An Introduction to the Kalman Filter" by Greg Welch and Gary Bishop, and no, that construct was unnecessary. As you've