How to define what a class is ?

2016-02-24 Thread ast
Hi Since a class is an object, I ask myself how to define rigorously what a class is. classes are instances from type, but not all, since a class may be an instance of a metaclass A class is always callable A class inherit from some others classes, so they have a bases attribute any thing e

Re: How to define what a class is ?

2016-02-24 Thread Ian Kelly
On Wed, Feb 24, 2016 at 1:08 AM, ast wrote: > Hi > > Since a class is an object, I ask myself how to define rigorously what a > class is. > > classes are instances from type, but not all, since > a class may be an instance of a metaclass All metaclasses are subclasses of type, so all classes are

Re: How to define what a class is ?

2016-02-24 Thread Ben Finney
"ast" writes: > Since a class is an object, I ask myself how to define rigorously what > a class is. A class is a type. This bears stating, because for a large part of Python's history, the two were distinct. A lot of Python documentation that has its roots in that history still is careful to m

Re: exit from Tkinter mainloop Python 2.7

2016-02-24 Thread Dave Farrance
kevind0...@gmail.com wrote: >from Tkinter import * > >def butContinue(): >root1.destroy() As Christian said, you're destroying the root window and its children, so instead use root1.quit() here. > ... > >root1.mainloop() > >print entryName.get("1.0", "end-1c" ) >print entryPWord.get("1.0", "

Re: [Python-ideas] How the heck does async/await work in Python 3.5

2016-02-24 Thread Joao S. O. Bueno
Today I also stumbled on this helpful "essay" from Brett Cannon about the same subject http://www.snarky.ca/how-the-heck-does-async-await-work-in-python-3-5 On 23 February 2016 at 18:05, Sven R. Kunze wrote: > On 20.02.2016 07:53, Christian Gollwitzer wrote: > > If you have difficulties wit hthe

Re: [Python-ideas] How the heck does async/await work in Python 3.5

2016-02-24 Thread Paul Moore
On 24 February 2016 at 02:37, Terry Reedy wrote: > > In this essay, Brett says that asyncio added an event loop to Python. It > did, but it was the second. The tk event loop was added about 20 years ago > with tkinter. One of the things I would love to see (but don't have the time to work on) is

Re: [Python-ideas] How the heck does async/await work in Python 3.5

2016-02-24 Thread Victor Stinner
See also Doug Hellmann article on asyncio, from its serie of "Python 3 Module of the Week" articles: https://pymotw.com/3/asyncio/index.html Victor 2016-02-23 22:25 GMT+01:00 Joao S. O. Bueno : > Today I also stumbled on this helpful "essay" from Brett Cannon about > the same subject > > http://w

Re: [Python-ideas] How the heck does async/await work in Python 3.5

2016-02-24 Thread 王珺
It seems an event loop is required for all async programs in python, but sometimes I need only lazy i/o. Is it possible with asyncio? Suppose io_operation() takes 3 seconds, then how can I write something like future = io_operation() print('Start') time.sleep(1) print('Something') time.sleep(2)

Could not find suitable distribution for Requirement.parse('urllib2')

2016-02-24 Thread jdege
I've been running a simple python program on my Linux Mint 13 box for some years that depends upon https://github.com/ryazwinski/pythings. I'm currently moving to a new Linux Mint 17 box, and I'm trying to move the program. I'm having a problem with installing python.py. The package comes with

Re: Could not find suitable distribution for Requirement.parse('urllib2')

2016-02-24 Thread Mark Lawrence
On 24/02/2016 14:02, jd...@jdege.us wrote: I've been running a simple python program on my Linux Mint 13 box for some years that depends upon https://github.com/ryazwinski/pythings. I'm currently moving to a new Linux Mint 17 box, and I'm trying to move the program. I'm having a problem with i

Re: Could not find suitable distribution for Requirement.parse('urllib2')

2016-02-24 Thread Peter Otten
jd...@jdege.us wrote: > I've been running a simple python program on my Linux Mint 13 box for some > years that depends upon https://github.com/ryazwinski/pythings. > > I'm currently moving to a new Linux Mint 17 box, and I'm trying to move > the program. I'm having a problem with installing pyth

HELP

2016-02-24 Thread Reeves, Andrew
I don't know what's going on. I am running windows 10 64 bit and per the pictures I am providing. I am also running Replicator G 0040. Just built a new computer with a fresh windows install. All drivers for the USB interface are up to date. But what ever is trying to install on your end is faili

Re: [Python-ideas] How the heck does async/await work in Python 3.5

2016-02-24 Thread Tem Pl
Here are some concurrency benchmarks for python vs other languages. https://github.com/atemerev/skynet/pull/53 Is there something wrong with this implementation? "Hope I suck at coroutines, because the results are abysmal. I get around 63s on my i5 MacBook Air Early 2015. For reference, the go

Re: HELP

2016-02-24 Thread Mark Lawrence
On 24/02/2016 14:08, Reeves, Andrew wrote: I don't know what's going on. I am running windows 10 64 bit and per the pictures I am providing. I am also running Replicator G 0040. Just built a new computer with a fresh windows install. All drivers for the USB interface are up to date. But what e

Re: [Python-ideas] How the heck does async/await work in Python 3.5

2016-02-24 Thread Marko Rauhamaa
Tem Pl : > Here are some concurrency benchmarks for python vs other languages. > > https://github.com/atemerev/skynet/pull/53 > > Is there something wrong with this implementation? It's a "fork bomb". Marko -- https://mail.python.org/mailman/listinfo/python-list

Re: [Python-ideas] How the heck does async/await work in Python 3.5

2016-02-24 Thread Ian Kelly
On Wed, Feb 24, 2016 at 8:23 AM, Marko Rauhamaa wrote: > Tem Pl : > >> Here are some concurrency benchmarks for python vs other languages. >> >> https://github.com/atemerev/skynet/pull/53 >> >> Is there something wrong with this implementation? > > It's a "fork bomb". Isn't that the point of the

Re: HELP

2016-02-24 Thread Igor Korot
Hi, On Wed, Feb 24, 2016 at 10:04 AM, Mark Lawrence wrote: > On 24/02/2016 14:08, Reeves, Andrew wrote: >> >> I don't know what's going on. I am running windows 10 64 bit and per the >> pictures I am providing. I am also running Replicator G 0040. Just built a >> new computer with a fresh windows

child.before taking almost 1 minute to execute

2016-02-24 Thread pyfreek
The following snippet alone is taking 1 minute to execute. is there any best way to find 'No such file' other than using child.before if not scrutinFile.startswith('/') : scrutinFile = '/'+ scrutinFile scrutinFileFtp = directory + scrutinFil

Re: HELP

2016-02-24 Thread Mark Lawrence
On 24/02/2016 15:43, Igor Korot wrote: Hi, On Wed, Feb 24, 2016 at 10:04 AM, Mark Lawrence wrote: On 24/02/2016 14:08, Reeves, Andrew wrote: I don't know what's going on. I am running windows 10 64 bit and per the pictures I am providing. I am also running Replicator G 0040. Just built a new

Re: Network Simulator

2016-02-24 Thread Martin A. Brown
>Hi...I need help to design a network simulator consisting for 5 >routers in python...Any help would be appretiated... Have you looked at existing network simulators? On two different ends of the spectrum are: Switchyard, a small network simulator intended for pedagogy https://github.com/j

Re: [Python-ideas] How the heck does async/await work in Python 3.5

2016-02-24 Thread Marko Rauhamaa
Ian Kelly : > On Wed, Feb 24, 2016 at 8:23 AM, Marko Rauhamaa wrote: >> Tem Pl : >>> Is there something wrong with this implementation? >> >> It's a "fork bomb". > > Isn't that the point of the benchmark? I don't quite see the point of the program as it doesn't resemble anything I'd ever have an

Re: [Python-ideas] How the heck does async/await work in Python 3.5

2016-02-24 Thread Ian Kelly
On Wed, Feb 24, 2016 at 9:13 AM, Marko Rauhamaa wrote: > Ian Kelly : > >> On Wed, Feb 24, 2016 at 8:23 AM, Marko Rauhamaa wrote: >>> Tem Pl : Is there something wrong with this implementation? >>> >>> It's a "fork bomb". >> >> Isn't that the point of the benchmark? > > I don't quite see the

Re: Setting up/authenticating Google API?

2016-02-24 Thread Skip Montanaro
> > Your question seems quite cinfusing to me but I think following may is what > you are asking for.(Read the source) > > https://google-mail-oauth2-tools.googlecode.com/svn/trunk/python/oauth2.py > > After getting the authentication you can use imaplib to get all the gmail > Data. Thanks, I wi

Re: Network Simulator

2016-02-24 Thread Aaron Christensen
On Feb 23, 2016 9:55 PM, "nikhil amraotkar" wrote: > > Hi...I need help to design a network simulator consisting for 5 routers in python...Any help would be appretiated... > Thanks.. > -- > https://mail.python.org/mailman/listinfo/python-list What is the purpose for designing it in Python? I'm a

Re: How to define what a class is ?

2016-02-24 Thread Gregory Ewing
Ian Kelly wrote: All metaclasses are subclasses of type, so all classes are instances of type. I think that's about the most general definition you can find. Almost everything else that you might think of as being part of the classness of a class can be overridden. Another definition might be

Re: child.before taking almost 1 minute to execute

2016-02-24 Thread Emile van Sebille
On 2/24/2016 7:42 AM, pyfreek wrote: The following snippet alone is taking 1 minute to execute. is there any best way to find 'No such file' other than using child.before if not scrutinFile.startswith('/') : scrutinFile = '/'+ scrutinFile

Nested List question

2016-02-24 Thread grsmith
All, Can you have a phython list like: ['George', 'Soros', ['99 First Street', '33 Broadway Avenue', ['Apt 303'], '1 Park Avenue'], 'New York', 'NY'] In other words how do you correctly nest the ['Apt 303'] so it goes with 33 Broadway Avenue. Also, I tried several ways and could not figure

Re: [Python-ideas] How the heck does async/await work in Python 3.5

2016-02-24 Thread Gregory Ewing
王珺 wrote: Suppose io_operation() takes 3 seconds, then how can I write something like future = io_operation() print('Start') time.sleep(1) print('Something') time.sleep(2) print(future.result()) that print 'Start' immediately and the result of io_operation() 3 seconds later. Yes, Python can d

Re: child.before taking almost 1 minute to execute

2016-02-24 Thread Gregory Ewing
pyfreek wrote: The following snippet alone is taking 1 minute to execute. is there any best way to find 'No such file' other than using child.before if not scrutinFile.startswith('/') : scrutinFile = '/'+ scrutinFile scrutinFileFtp = direc

Re: Nested List question

2016-02-24 Thread Grant Edwards
On 2016-02-24, wrote: > All, > > Can you have a phython list like: > ['George', > 'Soros', > ['99 First Street', > '33 Broadway Avenue', ['Apt 303'], > '1 Park Avenue'], > 'New York', 'NY'] Sure: $ python3 Python 3.4.3 (default, Feb 12 2016, 15:58:12) [GCC 4.9.3] on linux Type "help", "c

Re: Nested List question

2016-02-24 Thread Andrew Farrell
you can indeed have a nested list. One way you could do that looks like donor = [ 'George', 'Soros', [ #<- 2nd element of outermost list '99 First Street', [ #<- 1st element of middling list '33 Broadway Av

Re: Nested List question

2016-02-24 Thread Erik
On 24/02/16 20:59, grsm...@atlanticbb.net wrote: Can you have a phython list like: ['George', 'Soros', ['99 First Street', '33 Broadway Avenue', ['Apt 303'], '1 Park Avenue'], 'New York', 'NY'] In other words how do you correctly nest the ['Apt 303'] so it goes with 33 Broadway Avenue.

Re: Nested List question

2016-02-24 Thread Mark Lawrence
On 24/02/2016 20:59, grsm...@atlanticbb.net wrote: All, Can you have a phython list like: ['George', 'Soros', ['99 First Street', '33 Broadway Avenue', ['Apt 303'], '1 Park Avenue'], 'New York', 'NY'] In other words how do you correctly nest the ['Apt 303'] so it goes with 33 Broadway

Re: Nested List question

2016-02-24 Thread grsmith
Erik, Works perfectly, thanks much !!! Mark, I am tied to data structure. for address in addresses: if isinstance(address, str): apt = None print(address, apt) else: address, apt = address print(address, apt) 99 First Street None 33 Broadway Avenue Apt 303 1 P

Python used in several places in LIGO effort

2016-02-24 Thread Mike S via Python-list
https://www.reddit.com/r/IAmA/comments/45g8qu/we_are_the_ligo_scientific_collaboration_and_we/czxnlux?imm_mid=0e0d97&cmp=em-data-na-na-newsltr_20160224 -- https://mail.python.org/mailman/listinfo/python-list

Re: [Python-ideas] How the heck does async/await work in Python 3.5

2016-02-24 Thread 王珺
I think this is possible if I understand what happens under the hood. I wonder how event loop and async io functions such as asyncio.open_connection cooperate to do async io in one thread. Maybe it exploits low-level details and is OS or even device specific. I think I should take a look at the sou

Re: Make a unique filesystem path, without creating the file

2016-02-24 Thread Steven D'Aprano
On Tue, 23 Feb 2016 07:22 pm, Paul Rubin wrote: > Mark Lawrence writes: >> https://mail.python.org/pipermail/python-ideas/2015-September/036333.html >> then http://www.gossamer-threads.com/lists/python/dev/1223780 > > Thanks. It would be nice if those were gatewayed to usenet like this > group

"from module import data; print(data)" vs "import module; print(module.data)"

2016-02-24 Thread Dan Stromberg
Could people please compare and contrast the two ways of doing imports in the Subject line? I've long favored the latter, but I'm working in a code base that prefers the former. Is it fair to say that the former increases the surface area of your shared (sometimes mutable) state? It's clear that

Re: How to get all IP addresses in python?

2016-02-24 Thread kdiegorsantos
On Friday, July 11, 2003 at 1:54:47 AM UTC-3, Yun Mao wrote: > Hi. I did a little homework on google for this question. The answer was: > >>> import socket > >>> hostname = socket.gethostname() > >>> ip = socket.gethostbyname(hostname) > >>> print ip > 192.168.55.101 > But what if I have several in

Re: HELP

2016-02-24 Thread Steven D'Aprano
On Thu, 25 Feb 2016 01:08 am, Reeves, Andrew wrote: > I don't know what's going on. And neither do we. Andrew, can you please describe using words: * what you are trying to do * what you expect to happen * what actually happens * if it is not obvious, what it has to do with Python Don't use sc

Import collisions (was Re: "from module import data; print(data)")

2016-02-24 Thread Chris Angelico
On Thu, Feb 25, 2016 at 12:07 PM, Dan Stromberg wrote: > PS: Haskell seems better at the former than Python; Haskell tells you > if you import two identical symbols from two different places, when > you try to use one of them - not at import time. I believe in Python, > whichever symbol you impor

Re: "from module import data; print(data)" vs "import module; print(module.data)"

2016-02-24 Thread Cameron Simpson
On 24Feb2016 17:07, Dan Stromberg wrote: Could people please compare and contrast the two ways of doing imports in the Subject line? I've long favored the latter, but I'm working in a code base that prefers the former. I largely use the former "from module import name, name..." over "import

How to get all IP addresses in python?

2016-02-24 Thread MrJean1
Try function getIPs from this module /Jean -- https://mail.python.org/mailman/listinfo/python-list

Re: "from module import data; print(data)" vs "import module; print(module.data)"

2016-02-24 Thread Steven D'Aprano
On Thursday 25 February 2016 12:07, Dan Stromberg wrote: > Could people please compare and contrast the two ways of doing imports > in the Subject line? from module import data; print(data) import module; print(module.data) > I've long favored the latter, but I'm working in a code base that >

Re: [Newbie] Tkinter Question

2016-02-24 Thread Wildman via Python-list
On Tue, 23 Feb 2016 16:19:43 -0600, Wildman wrote: > Thanks to Christian and Chris. You both gave me much to think about and to experiment with. That adds to my on-going learning experience. This is the first thing I tried: The Exit button has this: command=self.quit Then I have this: def

Re: Make a unique filesystem path, without creating the file

2016-02-24 Thread Steven D'Aprano
On Wednesday 24 February 2016 18:20, Marko Rauhamaa wrote: > Steven D'Aprano : > >> On Tue, 23 Feb 2016 05:54 pm, Marko Rauhamaa wrote: >>> However, when you are generating signing or encryption keys, you >>> should use /dev/random. >> >> And that is where you repeat something which is rank super

How to read from a file to an arbitrary delimiter efficiently?

2016-02-24 Thread Steven D'Aprano
I have a need to read to an arbitrary delimiter, which might be any of a (small) set of characters. For the sake of the exercise, lets say it is either ! or ? (for example). I want to read from files reasonably efficiently. I don't mind if there is a little overhead, but my first attempt is 100

Re: Make a unique filesystem path, without creating the file

2016-02-24 Thread Marko Rauhamaa
Steven D'Aprano : > On Wednesday 24 February 2016 18:20, Marko Rauhamaa wrote: >> Steven D'Aprano : >>> And that is where you repeat something which is rank superstition. >> >> Can you find info to back that up. > > The links already provided go through the evidence. For example, they > explain

Re: How to read from a file to an arbitrary delimiter efficiently?

2016-02-24 Thread Chris Angelico
On Thu, Feb 25, 2016 at 5:50 PM, Steven D'Aprano wrote: > > # Read a chunk of bytes/characters from an open file. > def chunkiter(f, delim): > buffer = [] > b = f.read(1) > while b: > buffer.append(b) > if b in delim: > yield ''.join(buffer) > bu

Re: How to read from a file to an arbitrary delimiter efficiently?

2016-02-24 Thread Wolfgang Maier
On 25.02.2016 07:50, Steven D'Aprano wrote: I have a need to read to an arbitrary delimiter, which might be any of a (small) set of characters. For the sake of the exercise, lets say it is either ! or ? (for example). You are not alone with your need. http://bugs.python.org/issue1152248 discu

Re: How to read from a file to an arbitrary delimiter efficiently?

2016-02-24 Thread Paul Rubin
Steven D'Aprano writes: > while b: > buffer.append(b) This looks bad because of the overhead of list elements, and also the reading of 1 char at a time. If it's bytes that you're reading, try using bytearray instead of list: def chunkiter(f,delim): buf = bytearray()