Re: Should stdlib files contain 'narrow non breaking space' U+202F?

2015-12-17 Thread Ian Kelly
On Thu, Dec 17, 2015 at 4:05 PM, Mark Lawrence wrote: > The culprit character is hidden between "Issue #" and "20540" at line 400 of > C:\Python35\Lib\multiprocessing\connection.py. > https://bugs.python.org/issue20540 and > https://hg.python.org/cpython/rev/125c24f47f3c refers. > > I'm asking as

Re: Catogorising strings into random versus non-random

2015-12-21 Thread Ian Kelly
On Mon, Dec 21, 2015 at 9:40 AM, duncan smith wrote: > Finite state machine / transition matrix. Learn from some English text > source. Then process your strings by lower casing, replacing underscores > with spaces, removing trailing numeric characters etc. Base your score > on something like the

Re: Ignore error with non-zero exit status

2015-12-21 Thread Ian Kelly
On Sun, Dec 20, 2015 at 3:46 PM, Thomas 'PointedEars' Lahn wrote: > Chris Angelico wrote: > >> On Mon, Dec 21, 2015 at 8:22 AM, Thomas 'PointedEars' Lahn >> wrote: > > It is supposed to be an attribution *line*, _not_ an attribution novel. > Also, the “(was: …)” part is to be removed from the Sub

Re: Meaning and purpose of the Subject field (was: Ignore error with non-zero exit status)

2015-12-21 Thread Ian Kelly
On Mon, Dec 21, 2015 at 1:58 PM, Ben Finney wrote: > Ian Kelly writes: >> This isn't just a Usenet group; it's also a mailing list, and many >> MUAs rely on the Subject header for proper threading. > > If such MUAs do that, they're misinterpreting the Subject

Re: Meaning and purpose of the Subject field (was: Ignore error with non-zero exit status)

2015-12-21 Thread Ian Kelly
On Mon, Dec 21, 2015 at 4:24 PM, Jon Ribbens wrote: > On 2015-12-21, Steven D'Aprano wrote: >> The whole purpose of the change of subject is to indicate in a human-visible >> way that the subject of the thread has changed, i.e. that it is a new >> thread derived from the old one. If that breaks t

Re: Ignore error with non-zero exit status

2015-12-21 Thread Ian Kelly
On Dec 21, 2015 4:55 PM, "Terry Reedy" wrote: > > Nothing has changed since except for > https://www.python.org/dev/peps/pep-0498/ > already added to 3.6. https://xkcd.com/927/ -- https://mail.python.org/mailman/listinfo/python-list

Re: Meaning and purpose of the Subject field (was: Ignore error with non-zero exit status)

2015-12-22 Thread Ian Kelly
On Tue, Dec 22, 2015 at 8:17 AM, Grant Edwards wrote: > On 2015-12-21, Steven D'Aprano wrote: > >> So as far as I am concerned, if changes of subject line breaks threading for >> you, so sad, too bad. Go without threading or use a better mail client. > > Same here. After getting what is effectiv

Re: Importing constantly changing variables

2015-12-26 Thread Ian Kelly
On Sat, Dec 26, 2015 at 8:14 AM, wrote: > As you can see, I want the program to print all values each 5 seconds. > When I run the file "main.py" it does print values every 5 seconds, BUT when > I manually change > the values (e.g. airTemperture = 30 instead of 24) and save the file, nothing > c

Re: using __getitem()__ correctly

2015-12-30 Thread Ian Kelly
On Dec 30, 2015 7:46 AM, "Charles T. Smith" wrote: > As is so often the case, in composing my answer to your question, I discovered > a number of problems in my class (e.g. I was calling __getitem__() myself!), > but > I'm puzzled now how to proceed. I thought the way you avoid triggering > __g

Re: using __getitem()__ correctly

2015-12-30 Thread Ian Kelly
On Wed, Dec 30, 2015 at 9:58 AM, Charles T. Smith wrote: > On Wed, 30 Dec 2015 08:35:57 -0700, Ian Kelly wrote: > >> On Dec 30, 2015 7:46 AM, "Charles T. Smith" >> wrote: >>> As is so often the case, in composing my answer to your question, I >>> di

Re: Newbie: How to convert a tuple of strings into a tuple of ints

2015-12-30 Thread Ian Kelly
On Wed, Dec 30, 2015 at 3:46 PM, wrote: > How do I get from here > > t = ('1024', '1280') > > to > > t = (1024, 1280) Deja vu: https://mail.python.org/pipermail/python-list/2015-December/701017.html -- https://mail.python.org/mailman/listinfo/python-list

Re: using __getitem()__ correctly

2015-12-30 Thread Ian Kelly
On Wed, Dec 30, 2015 at 3:54 PM, Charles T. Smith wrote: > On Wed, 30 Dec 2015 13:40:44 -0700, Ian Kelly wrote: > >> On Wed, Dec 30, 2015 at 9:58 AM, Charles T. Smith >>> The problem is that then triggers the __getitem__() method and I don't >>> know h

Re: Consistent error

2016-01-03 Thread Ian Kelly
On Sun, Jan 3, 2016 at 8:59 AM, wrote: > Thanks Chris! > Don't worry about the indent, will fix it > I've rewritten it to this- > > def get_algorithm_result( numlist ): >> largest = numlist[0] >> i = 1 >> while ( i < len(numlist) ): > i = i + 1 >>if ( largest < numlist[i]): >> l

Re: What is the fastest way to do 400 HTTP requests using requests library?

2016-01-04 Thread Ian Kelly
On Mon, Jan 4, 2016 at 4:38 PM, Steven D'Aprano wrote: > On Tue, 5 Jan 2016 07:50 am, livems...@gmail.com wrote: > >> So what is the fastest way to make 400 HTTP requests using "requests" >> library and also using tor proxy? > > > Since this will be I/O bound, not CPU bound, probably use separate

Re: Is there a way importing a string object?

2016-01-04 Thread Ian Kelly
On Mon, Jan 4, 2016 at 5:49 PM, wrote: > For example, > > name = "test" # test.py is a module's file > import name Yes, use the importlib.import_module function. -- https://mail.python.org/mailman/listinfo/python-list

Re: What is the fastest way to do 400 HTTP requests using requests library?

2016-01-05 Thread Ian Kelly
On Tue, Jan 5, 2016 at 10:02 AM, Paul Rubin wrote: > Steven D'Aprano writes: >> Maybe they're stress-testing a web server, or they just want to download >> things in a rush. > > They're stress-testing a web server through a tor proxy? This sounds > abusive to me. > > I also wonder whether 400 re

Re: What use is '__reduce__'?

2016-01-08 Thread Ian Kelly
As you found by searching, __reduce__ is used to determine how instances of the class are pickled. If the example you're using doesn't do any pickling, then it's not really relevant to the example. It's probably included so that it won't be missed when the code is copied. On Fri, Jan 8, 2016 at 9:

Re: I'm missing something here...

2016-01-12 Thread Ian Kelly
On Mon, Jan 11, 2016 at 6:04 PM, Skip Montanaro wrote: > Sorry, I should have been explicit. prob_dates (the actual argument of the > call) is a set. As far as I know pylint does no type inference, so pylint > can't tell if the LHS and RHS of the |= operator are appropriate, nor can > it tell if i

Re: subscripting Python 3 dicts/getting the only value in a Python 3 dict

2016-01-12 Thread Ian Kelly
On Tue, Jan 12, 2016 at 10:12 AM, Terry Reedy wrote: > Using the values views at intended (as an iterable): > dv = d.values() next(iter(dv)) > 1 Good coding practice also dictates that whenever next is called, the potential StopIteration exception must be caught unless it is clearly int

Re: When I need classes?

2016-01-12 Thread Ian Kelly
On Mon, Jan 11, 2016 at 5:53 PM, Bernardo Sulzbach wrote: > I have never gone "seriously OO" with Python though. I never wrote > from scratch an application with more than 10 classes as far as I can > remember. However, I would suppose that the interpreter can handle > thousands of user-defined cl

Re: [Python-ideas] Password masking for getpass.getpass

2016-01-13 Thread Ian Kelly
On Wed, Jan 13, 2016 at 3:19 AM, Chris Angelico wrote: > You're quite probably right that obfuscating the display is security > theatre; but it's the security theatre that people are expecting. If > you're about to enter your credit card details into a web form, does > it really matter whether or

Re: Stop writing Python 4 incompatible code

2016-01-14 Thread Ian Kelly
On Thu, Jan 14, 2016 at 8:52 AM, Rick Johnson wrote: > So you're suggesting that GvR *WILLINGLY* left a global, and > well established giant, to work for a tiny start-up because > his bosses refused to switch from Python2 to (his new baby) > Pyhton3? > > So, let me get this strait: he wasn't fired

Re: wxpython strange behaviour

2016-01-15 Thread Ian Kelly
On Fri, Jan 15, 2016 at 10:05 AM, Shiva Upreti wrote: > https://gist.github.com/anonymous/4baa67aafd04555eb4e6 > > I wrote the above code to display a toasterbox, and I didnt want it to > display any frames on the screen, just a toasterbox. The problem with this > code is that it runs fine when

Re: Pyton install Landmine

2016-01-16 Thread Ian Kelly
On Jan 16, 2016 3:02 AM, "JeffP" wrote: > > Hi > I installed pyth3.5 on my Windows machine and had some complications trying to connect other components. > I installed to the default directory chosen by the installer but that included a folder with an embedded space in the name. BIG NO NO Pr

Re: Keen eyes

2016-01-16 Thread Ian Kelly
On Jan 17, 2016 12:16 AM, "Steven D'Aprano" wrote: > > On Sun, 17 Jan 2016 10:25 am, jonas.thornv...@gmail.com wrote: > > > double use of j in two different functions > > Are you using a global variable called "j" as a loop variable? That sounds > like a terrible idea. > > You should use local var

Re: parallel (concurrent) eventlet

2016-01-18 Thread Ian Kelly
On Mon, Jan 18, 2016 at 8:03 AM, David Gabriel wrote: > Dears, > > Let me add one more detail: When I add these two lines to check whether my > modules are monkey_patched or not I get *False* as a result. > I think it is strange to get this result since I patched my modules at the > beginning usin

Re: When is an int not an int? Who can explain this?

2016-01-18 Thread Ian Kelly
On Mon, Jan 18, 2016 at 9:51 AM, Chris Angelico wrote: > On Tue, Jan 19, 2016 at 3:28 AM, Charles T. Smith >> Okay, I think I understand it now: >> >> (PDB)type (int) >> >> >> (PDB)type (float) >> > > And that's pretty strong evidence right there! So the next question > is... what got imported u

Re: importing: what does "from" do?

2016-01-21 Thread Ian Kelly
On Jan 21, 2016 7:31 AM, "Charles T. Smith" wrote: > > What does "from (module) import (func)" do? Approximately equivalent to: import module func = module.func Except that it doesn't bind "module" to anything. > Please don't tell me that I shouldn't ask because real programmers > know not to

Re: importing: what does "from" do?

2016-01-21 Thread Ian Kelly
On Thu, Jan 21, 2016 at 8:12 AM, Charles T. Smith wrote: >>> would you explain to me why I get this: >>> >>> (PDB)hexdump(msg) >>> *** NameError: name 'hexdump' is not defined >> >> Probably because the name 'hexdump' is not defined. > > > If indeed it's not defined, then I wouldn't think there'

Re: Deprecation warnings for the future async and await keywords

2016-01-22 Thread Ian Kelly
On Fri, Jan 22, 2016 at 4:12 AM, Marco Buttu wrote: > I enabled the deprecation warnings in Python 3.5.1 and Python 3.6 dev, and I > noticed that assigning to async or await does not issue any deprecation > warning: > > $ python -Wd -c "import sys; print(sys.version); async = 33" > 3.5.1 (default,

Re: Question about asyncio and blocking operations

2016-01-23 Thread Ian Kelly
On Sat, Jan 23, 2016 at 7:38 AM, Frank Millman wrote: > Here is the difficulty. The recommended way to handle a blocking operation > is to run it as task in a different thread, using run_in_executor(). This > method is a coroutine. An implication of this is that any method that calls > it must als

Re: Question about asyncio and blocking operations

2016-01-23 Thread Ian Kelly
On Sat, Jan 23, 2016 at 8:44 AM, Ian Kelly wrote: > This is where it would make sense to me to use callbacks instead of > subroutines. You can structure your __init__ method like this: Doh. s/subroutines/coroutines -- https://mail.python.org/mailman/listinfo/python-list

Re: Question about asyncio and blocking operations

2016-01-25 Thread Ian Kelly
On Jan 25, 2016 2:04 AM, "Frank Millman" wrote: > > "Ian Kelly" wrote in message news:calwzidngogpx+cpmvba8vpefuq4-bwmvs0gz3shb0owzi0b...@mail.gmail.com... >> >> This seems to be a common misapprehension about asyncio programming. >> While coroutines

Re: Question about asyncio and blocking operations

2016-01-25 Thread Ian Kelly
On Mon, Jan 25, 2016 at 8:32 AM, Ian Kelly wrote: > > On Jan 25, 2016 2:04 AM, "Frank Millman" wrote: >> >> "Ian Kelly" wrote in message >> news:calwzidngogpx+cpmvba8vpefuq4-bwmvs0gz3shb0owzi0b...@mail.gmail.com... >>> >>> This

Re: .format won't display my value with 2 decimal places: Why?

2016-01-25 Thread Ian Kelly
On Sun, Jan 24, 2016 at 2:20 PM, MRAB wrote: > The format method, on the other hand, belongs to the format string it's > attached to. In this example: > > 'The new price is {}' .format(newPrice, '.2f') > > the format string is 'The new price is {}' and you're calling its 'format' > method with

Re: Re[2]: .format won't display my value with 2 decimal places: Why?

2016-01-25 Thread Ian Kelly
On Mon, Jan 25, 2016 at 10:19 AM, MRAB wrote: > > > On 2016-01-25 16:51:36, "Ian Kelly" wrote: > >> >> Why doesn't str.format raise an exception when passed extra positional >> arguments? >> > That format string uses auto-numbering, and i

Re: Question about asyncio and blocking operations

2016-01-26 Thread Ian Kelly
On Tue, Jan 26, 2016 at 7:15 AM, Frank Millman wrote: > I am making some progress, but I have found a snag - possibly unavoidable, > but worth a mention. > > Usually when I retrieve rows from a database I iterate over the cursor - > >def get_rows(sql, params): >cur.execute(sql, params)

Re: Question about asyncio and blocking operations

2016-01-27 Thread Ian Kelly
On Wed, Jan 27, 2016 at 7:40 AM, Frank Millman wrote: > "Ian Kelly" wrote in message > news:CALwzidk-RBkB-vi6CgcEeoFHQrsoTFvqX9MqzDD=rny5boc...@mail.gmail.com... > >> You probably want an asynchronous iterator here. If the cursor doesn't >> provide that,

Re: Question about asyncio and blocking operations

2016-01-27 Thread Ian Kelly
On Wed, Jan 27, 2016 at 9:15 AM, Ian Kelly wrote: > class CursorWrapper: > > def __init__(self, cursor): > self._cursor = cursor > > async def __aiter__(self): > return self > > async def __anext__(self): > loop = asyncio.get_event

Re: Question about asyncio and blocking operations

2016-01-27 Thread Ian Kelly
On Wed, Jan 27, 2016 at 10:14 AM, Ian Kelly wrote: > Unfortunately this doesn't actually work at present. > EventLoop.run_in_executor swallows the StopIteration exception and > just returns None, which I assume is a bug. http://bugs.python.org/issue26221 -- https://mail.pyth

Re: Question about asyncio and blocking operations

2016-01-28 Thread Ian Kelly
On Thu, Jan 28, 2016 at 9:40 AM, Frank Millman wrote: > I have hit a snag. It feels like a bug in 'await q.get()', though I am sure > it is just me misunderstanding how it works. > > I can post some working code if necessary, but here is a short description. > > Here is the database handler - 'req

Re: Question about asyncio and blocking operations

2016-01-28 Thread Ian Kelly
On Jan 28, 2016 4:13 AM, "Frank Millman" wrote: > > "Chris Angelico" wrote in message news:captjjmr162+k4lzefpxrur6wxrhxbr-_wkrclldyr7kst+k...@mail.gmail.com... >> >> >> On Thu, Jan 28, 2016 at 8:13 PM, Frank Millman wrote: >> > Run the database handler in a separate thread. Use a queue.Queue to

Re: Question about asyncio and blocking operations

2016-01-28 Thread Ian Kelly
On Thu, Jan 28, 2016 at 2:23 PM, Maxime S wrote: > > 2016-01-28 17:53 GMT+01:00 Ian Kelly : >> >> On Thu, Jan 28, 2016 at 9:40 AM, Frank Millman wrote: >> >> > The caller requests some data from the database like this. >> > >> >r

Re: Question about asyncio and blocking operations

2016-01-28 Thread Ian Kelly
On Jan 28, 2016 3:07 PM, "Maxime Steisel" wrote: > > But it is a pretty strange idea to call two fetch*() method concurrently anyways. If you want to process rows concurrently and aren't concerned with processing them in order, it may be attractive to create multiple threads / coroutines, pass th

Re: Cannot step through asynchronous iterator manually

2016-01-30 Thread Ian Kelly
On Jan 29, 2016 11:04 PM, "Frank Millman" wrote: > > Hi all > > To loop though an iterator one usually uses a higher-level construct such as a 'for' loop. However, if you want to step through it manually you can do so with next(iter). > > I expected the same functionality with the new 'asynchronou

Re: The computer that mastered Go

2016-01-30 Thread Ian Kelly
On Fri, Jan 29, 2016 at 1:38 PM, mm0fmf via Python-list wrote: > On 29/01/2016 19:46, Seymore4Head wrote: >> >> https://www.youtube.com/watch?v=g-dKXOlsf98 >> > > Is it written in Python? Given the game, and the fact that it's Google, I would be very disappointed if it's not written in Go. -- ht

Re: Cannot step through asynchronous iterator manually

2016-01-30 Thread Ian Kelly
On Jan 30, 2016 7:13 AM, "Oscar Benjamin" wrote: > > I haven't used PEP 492 yet but what about: > > async def aslice(asynciterator, end): > if end == 0: > return [] >items = [] >async for item in asynciterator: >items.append(item) >if len(items) == end: >

Re: eval( 'import math' )

2016-02-04 Thread Ian Kelly
On Thu, Feb 4, 2016 at 6:33 AM, 阎兆珣 wrote: >Excuse me for the same problem in Python 3.4.2-32bit > >I just discovered that function does not necessarily take the >string input and transfer it to a command to execute. > >So is there a problem with my assumption? eval evaluates an

Re: Multiprocess videoplayer

2016-02-04 Thread Ian Kelly
On Thu, Feb 4, 2016 at 2:45 AM, wrote: > I have coded a program with python and vlc that plays some videos, but > whenever I try to play 3 videos at once, Windows closes the program, I'm > guessing that the reason is that one process can't play 3 videos at once (but > I don't really know). My

Re: Daemon strategy

2016-02-05 Thread Ian Kelly
On Fri, Feb 5, 2016 at 4:10 PM, Ben Finney wrote: > Sorry to learn that. The PyPI metadata for ‘python-daemon’ > https://pypi.python.org/pypi/python-daemon/> explicitly declares > the supported OS limited to “Operating System :: POSIX”, which MS > Windows is not compatible with. Depends on the ve

Re: Daemon strategy

2016-02-06 Thread Ian Kelly
On Sat, Feb 6, 2016 at 1:15 AM, Ben Finney wrote: > Ian Kelly writes: > >> Depends on the version: >> https://en.wikipedia.org/wiki/Windows_Services_for_UNIX >> https://en.wikipedia.org/wiki/POSIX#POSIX_for_Windows >> >> Linux and FreeBSD are also not POSIX-c

Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO

2016-02-08 Thread Ian Kelly
On Sat, Feb 6, 2016 at 1:54 PM, Rick Johnson wrote: > On Wednesday, February 3, 2016 at 12:02:35 AM UTC-6, John Ladasky wrote: > >> Rick, you don't like Python? > > If i didn't like Python, then i would happily let it self- > destruct, yes? The problem is, i *DO* like Python. Python2 > was a great

Re: Set Operations on Dicts

2016-02-08 Thread Ian Kelly
On Mon, Feb 8, 2016 at 5:47 AM, Grobu wrote: > You can use dictionary comprehension : > > Say : > dict1 = {'a': 123, 'b': 456} > set1 = {'a'} > > intersection : { key:dict1[key] for key in dict1 if key in set1 } > {'a': 123} > > difference : { key:dict1[key] for key in dict1 if not key i

Re: A question about imports in wxpython

2016-02-08 Thread Ian Kelly
On Mon, Feb 8, 2016 at 8:44 AM, wrote: > I'm playing with some code that uses the wxpython grid. *Every* > example I have seen starts with the imports:- > > import wx > import wx.grid as Gridlib > > As Gridlib is exactly the same number of characters as wx.grid I > really don't see the p

Re: Confused by wxpython documentation

2016-02-08 Thread Ian Kelly
On Mon, Feb 8, 2016 at 8:36 AM, wrote: > I'm playing around with some existing code that uses wxpython. I've > been trying to understand a basic bit about the import statement and > so went to the beginning of the wxPython on line documents. > > Going from the top to the "Hello World Example" (c

Re: coroutine, throw, yield, call-stack and exception handling

2016-02-08 Thread Ian Kelly
On Mon, Feb 8, 2016 at 2:17 AM, Veek. M wrote: > > Exceptions can be raised inside a coroutine using the throw( > > Exceptions raised in this manner will originate at the currently > executing yield state-ment in the coroutine.A coroutine can elect to > catch exception

Re: Set Operations on Dicts

2016-02-09 Thread Ian Kelly
On Tue, Feb 9, 2016 at 12:21 AM, Grobu wrote: > On 08/02/16 17:12, Ian Kelly wrote: > >> dict does already expose set-like views. How about: >> >> {k: d[k] for k in d.keys() & s} # d & s >> {k: d[k] for k in d.keys() - s} # d - s >> > Inte

Re: ImportError: cannot import name 'RAND_egd'

2016-02-09 Thread Ian Kelly
On Tue, Feb 9, 2016 at 7:55 AM, wrote: > Hi, > > I am trying to run a 60 lines Python code which is running on a mac machine > but on windows machine, I am getting this error when I run on it on > shell(open file and run module). I have Python 3.5 installed. > >from _ssl import RAND_status,

Re: Copying void * string to

2016-02-10 Thread Ian Kelly
On Wed, Feb 10, 2016 at 5:07 AM, Martin Phillips wrote: > I am writing a Python wrapper to go around a C library. I have encountered a > problem that I have been unable to resolve with > countless web searches. > > > > Several functions in the C library return pointers to dynamically allocated >

Re: Passing data across callbacks in ThreadPoolExecutor

2016-02-17 Thread Ian Kelly
On Tue, Feb 16, 2016 at 2:48 PM, Joseph L. Casale wrote: > What is the pattern for chaining execution of tasks with ThreadPoolExecutor? > Callbacks is not an adequate facility as each task I have will generate new > output. Can you specify in more detail what your use case is? If you don't mind

Re: Passing data across callbacks in ThreadPoolExecutor

2016-02-18 Thread Ian Kelly
On Thu, Feb 18, 2016 at 12:06 PM, Joseph L. Casale wrote: > On Thur, Feb 17, 2016 at 9:24 AM, Ian Kelly wrote: >>> What is the pattern for chaining execution of tasks with ThreadPoolExecutor? >>> Callbacks is not an adequate facility as each task I have will generate new

Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO

2016-02-18 Thread Ian Kelly
On Mon, Feb 15, 2016 at 7:02 PM, Rick Johnson wrote: > WxPython is not ported either, much to my chagrin. If wxPython "Classic" had just been ported to Python 3, I'm sure it would be all done by now. But it was decided to rebuild wxPython from the ground up instead. Last I've heard, people gener

Re: Passing data across callbacks in ThreadPoolExecutor

2016-02-19 Thread Ian Kelly
On Fri, Feb 19, 2016 at 10:18 AM, Joseph L. Casale wrote: >> It's still not clear to me specifically what you're trying to do. It >> would really help if you would describe the problem in more detail. >> Here's what I think you're trying to do: >> >> 1) Submit a task to a ThreadPoolExecutor and ge

Re: How to properly override the default factory of defaultdict?

2016-02-19 Thread Ian Kelly
On Thu, Feb 18, 2016 at 10:41 AM, Herman wrote: > From: Ben Finney >> >> you are using the inheritance hierarchy but thwarting it by not using >> ‘super’. Instead:: >> >> super().__init__(self, default_factory, *a, **kw) >> >> and:: >> >> super().__getitem__(self, key) >> -- >> \ "

Re: How the heck does async/await work in Python 3.5

2016-02-19 Thread Ian Kelly
On Fri, Feb 19, 2016 at 10:24 PM, Rustom Mody wrote: > Less snarkily looks like a series of bolt-ons after bolt-ons > > IMHO Guido's (otherwise) uncannily sound intuitions have been wrong right from > 2001 when he overloaded def for generators. > And after that its been slippery-slope down: reusin

Re: How the heck does async/await work in Python 3.5

2016-02-20 Thread Ian Kelly
On Sat, Feb 20, 2016 at 12:57 AM, Chris Angelico wrote: > On Sat, Feb 20, 2016 at 6:48 PM, Ian Kelly wrote: >> As another point that happens to be fresh in my mind, awaiting a >> Future on which an exception gets set is supposed to propagate the >> exception. I recently foun

Re: How the heck does async/await work in Python 3.5

2016-02-20 Thread Ian Kelly
On Sat, Feb 20, 2016 at 1:49 AM, Chris Angelico wrote: > Definitely seems like it should be fixed, then; the current behaviour > is that Future.result() raises RuntimeError if you raise > StopIteration, so having await do the same would make sense. Future.result() itself simply raises the StopIte

Re: How the heck does async/await work in Python 3.5

2016-02-20 Thread Ian Kelly
On Sat, Feb 20, 2016 at 1:49 AM, Chris Angelico wrote: > Actually, that mightn't be a bad thing. Maybe raise that as a tracker > issue? I just tested, and slapping "from __future__ import > generator_stop" at the top of Lib/asyncio/futures.py causes your > example to raise an exception instead of

Re: can try expect have if else.

2016-02-21 Thread Ian Kelly
On Feb 21, 2016 9:13 AM, "Ganesh Pal" wrote: > > Hi Team, > > Iam on python 2.6 , need input on the below piece of code. Python 2.6 isn't supported and hasn't been since October 2013. Is there something preventing you from upgrading to 2.7? > EXIT_STATUS_ERROR=1 > > def create_dataset(): > "

Re: avoid for loop calling Generator function

2016-02-22 Thread Ian Kelly
On Mon, Feb 22, 2016 at 8:38 AM, Arshpreet Singh wrote: > On Monday, 22 February 2016 19:05:24 UTC+5:30, Peter Otten wrote: >> or the slightly less convoluted >> >> sys.stdout.writelines(map("{}\n".format, read_pdf("book.pdf"))) > > Actually I am using this function in Android App which is being

Re: How the heck does async/await work in Python 3.5

2016-02-22 Thread Ian Kelly
On Mon, Feb 22, 2016 at 3:16 PM, Sven R. Kunze wrote: > Is something like shown in 12:50 ( cout << tcp_reader(1000).get() ) possible > with asyncio? (tcp_reader would be async def) loop = asyncio.get_event_loop() print(loop.run_until_complete(tcp_reader(1000))) -- https://mail.python.org/mailman

Re: How the heck does async/await work in Python 3.5

2016-02-23 Thread Ian Kelly
On Tue, Feb 23, 2016 at 9:50 AM, Sven R. Kunze wrote: > On 23.02.2016 01:48, Ian Kelly wrote: >> >> On Mon, Feb 22, 2016 at 3:16 PM, Sven R. Kunze wrote: >>> >>> Is something like shown in 12:50 ( cout << tcp_reader(1000).get() ) >>> possible

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: [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: [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". >

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

2016-02-25 Thread Ian Kelly
On Thu, Feb 25, 2016 at 5:40 PM, Steven D'Aprano wrote: > If you take "Special cases are not special enough" seriously, you will not > use `import os.path` since os is not a package: > > py> os.__package__ > '' > > and os.path is not part of os, it's just a publicly exposed attribute which > merel

Re: Bug in Python?

2016-02-26 Thread Ian Kelly
On Fri, Feb 26, 2016 at 3:08 PM, Sven R. Kunze wrote: > Python sometimes seems not to hop back and forth between C and Python code. C code as a rule tends to ignore dunder methods. Those are used to implement Python operations, not C operations. > _siftup(heap, 0)# that's C Your com

Re: Reason for not allowing import twice but allowing reload()

2016-02-28 Thread Ian Kelly
On Sun, Feb 28, 2016 at 11:40 PM, wrote: > Hello list, > > We can not import a module twice in a session of Python (subsequent attempts > to import same module don't result in any error though, but it is > not-effective). > > However after making change to module, we can reload() it (if not rel

Re: General computer language, syntax question.

2016-02-29 Thread Ian Kelly
On Feb 29, 2016 7:11 AM, wrote: > > Sorry but would not if (array==empty) suffice and be alot clearer? In Python, you can just do "if len(array) == 0" or "if not array". In JavaScript you have "if (array.length === 0)". Is there some problem with that? I would prefer this over your suggestion s

Re: common mistakes in this simple program

2016-02-29 Thread Ian Kelly
On Mon, Feb 29, 2016 at 8:18 AM, Ganesh Pal wrote: > Iam on python 2.6 Python 2.6 has been unsupported since October 2013. Among other things, that means it is no longer receiving security updates like more recent versions. Unless you have an extremely strong reason for wanting to stay to Python

Re: Dynamic object attribute creation

2016-02-29 Thread Ian Kelly
On Mon, Feb 29, 2016 at 9:06 AM, Random832 wrote: > On Mon, Feb 29, 2016, at 10:36, ast wrote: >> but why doesn't it work with built-in classes int, float, list ? >> >> L = [1, 8, 0] >> L.test = 'its a list !' >> >> (however lists are mutable, int, float ... are not) > > Because those classes

Re: [Off-topic] Requests author discusses MentalHealthError exception

2016-02-29 Thread Ian Kelly
On Mon, Feb 29, 2016 at 9:21 AM, Larry Martell wrote: > On Sat, Feb 27, 2016 at 4:37 AM, Steven D'Aprano wrote: >> The author of Requests, Kenneth Reitz, discusses his recent recovery from a >> MentalHealthError exception. >> >> http://www.kennethreitz.org/essays/mentalhealtherror-an-exception-oc

Re: common mistakes in this simple program

2016-02-29 Thread Ian Kelly
On Mon, Feb 29, 2016 at 10:26 AM, Ganesh Pal wrote: > On Mon, Feb 29, 2016 at 9:59 PM, Ian Kelly wrote: >> On Mon, Feb 29, 2016 at 8:18 AM, Ganesh Pal wrote: >>> Iam on python 2.6 > >>> 1. usage of try- expect >> >> try-except in every single funct

Re: Loop awareness

2016-02-29 Thread Ian Kelly
On Mon, Feb 29, 2016 at 1:07 PM, wrote: > This program creates a uniform linktree of x nodes, and it knows when it get > stuck in a loop generating random values. > > Because the networks random generated, only a subset of the permutations will > generate a uniform network most get stuck in loo

Re: common mistakes in this simple program

2016-02-29 Thread Ian Kelly
On Mon, Feb 29, 2016 at 4:14 PM, Cameron Simpson wrote: > Another remark here: if you're going to log, log the exception as well: > > logging.error("something went wrong: %s", e) > > Ian's example code is nice and simple to illustrate "log and then reraise" > but few things are as annoying as

Re: Condition fullfilled to early but only "sometimes"

2016-02-29 Thread Ian Kelly
It's not at all clear what the problem is from your description. What is it that you expect the code to do? What is it doing instead that violates your expectation? Why are you asking for Javascript help on a Python mailing list? On Mon, Feb 29, 2016 at 10:40 PM, wrote: > I've been looking at th

Re: Reason for not allowing import twice but allowing reload()

2016-03-01 Thread Ian Kelly
On Mar 1, 2016 4:41 AM, "Chris Angelico" wrote: > > On Tue, Mar 1, 2016 at 10:18 PM, Steven D'Aprano wrote: > > I cannot imagine why you would want to reload() in production code. That > > would imply that your production code is modifying already-imported > > modules, then wanting to import them

Re: Reason for not allowing import twice but allowing reload()

2016-03-01 Thread Ian Kelly
On Tue, Mar 1, 2016 at 3:02 PM, Chris Angelico wrote: > On Wed, Mar 2, 2016 at 8:53 AM, Ian Kelly wrote: >> I have a hard time understanding the appeal of super-long uptimes. I'm not >> even comfortable running a single kernel version that long. What's so awful >&g

Re: Reason for not allowing import twice but allowing reload()

2016-03-01 Thread Ian Kelly
On Tue, Mar 1, 2016 at 6:19 PM, Steven D'Aprano wrote: > On Wed, 2 Mar 2016 09:29 am, Ian Kelly wrote: > >> There's a big difference between >> that and clocking a year of uptime just because you can, though. > > What other reason is there for having a year

Re: Explaining names vs variables in Python

2016-03-02 Thread Ian Kelly
On Wed, Mar 2, 2016 at 2:35 AM, Jussi Piitulainen wrote: > The following are too delicate for me. I suppose the answers could have > been different, but I can't guess what mechanism actually leads to these > results. Just idle curiosity on my part. > 890 is 890 > True id(890) == id(890)

Re: What arguments are passed to the __new__ method ?

2016-03-02 Thread Ian Kelly
On Wed, Mar 2, 2016 at 10:57 AM, Rob Gaddi wrote: > Peter Pearson wrote: > >> On Tue, 1 Mar 2016 18:24:12 +0100, ast wrote: >>> >>> It's not clear to me what arguments are passed to the >>> __new__ method. Here is a piece of code: >>> >>> >>> class Premiere: >>> >>> def __new__(cls, price): >>

Re: [Off-topic] Requests author discusses MentalHealthError exception

2016-03-02 Thread Ian Kelly
On Mar 2, 2016 9:01 PM, "Rustom Mody" wrote: > > On Thursday, March 3, 2016 at 7:59:13 AM UTC+5:30, Steven D'Aprano wrote: > > On Thu, 3 Mar 2016 04:02 am, Rustom Mody wrote: > > > > > And how is [1]'s starting different from Kenneth's finding his weight > > > to be the weight of the universe? > >

Re: [Off-topic] Requests author discusses MentalHealthError exception

2016-03-03 Thread Ian Kelly
On Thu, Mar 3, 2016 at 10:21 AM, alister wrote: > On Thu, 03 Mar 2016 13:35:12 +1100, Chris Angelico wrote: >> 1) No physical object can have negative mass. >> 2) I am a part of the universe and have positive mass. >> 3) I am not Kenneth. >> 4) The sum of my mass and Kenneth's mass must exceed Ken

Re: Explaining names vs variables in Python

2016-03-03 Thread Ian Kelly
On Thu, Mar 3, 2016 at 10:03 AM, Rustom Mody wrote: > Is it so damn hard to be a bit honest and when asked about is in python to > reply: > > If you dont know what you are doing, dont use 'is' (None excepted) > If you know why are you asking? That seems like a rather unhelpful response. -- http

Re: [Off-topic] Requests author discusses MentalHealthError exception

2016-03-03 Thread Ian Kelly
On Thu, Mar 3, 2016 at 1:20 PM, alister wrote: > On Thu, 03 Mar 2016 11:03:55 -0700, Ian Kelly wrote: > >> On Thu, Mar 3, 2016 at 10:21 AM, alister >> wrote: >>> On Thu, 03 Mar 2016 13:35:12 +1100, Chris Angelico wrote: >>>> 1) No physical object can hav

Re: Caching function results

2016-03-03 Thread Ian Kelly
On Thu, Mar 3, 2016 at 1:28 PM, Pavel Volkov wrote: > Suppose, I have some resource-intensive tasks implemented as functions in > Python. > Those are called repeatedly in my program. > It's guranteed that a call with the same arguments always produces the same > return value. > I want to cache the

Re: Continuing indentation

2016-03-04 Thread Ian Kelly
On Fri, Mar 4, 2016 at 7:03 AM, alister wrote: > On Fri, 04 Mar 2016 10:12:58 +, cl wrote: > >> Steven D'Aprano wrote: >>> On Fri, 4 Mar 2016 12:23 pm, INADA Naoki wrote: >>> >>> >>> >> >>> >> Indeed. I don't understand why, when splitting a condition such as >>> >> this, >>> >> people tend t

Re: creating zipfile with symlinks

2016-03-04 Thread Ian Kelly
On Fri, Mar 4, 2016 at 11:50 AM, crankypuss wrote: > I don't know about that, but you've certainly shown that what I was told > about this group being helpful and non-combative is bullshit. Look in a mirror much? -- https://mail.python.org/mailman/listinfo/python-list

Re: Can I find the class of a method in a decorator.

2016-03-05 Thread Ian Kelly
On Sat, Mar 5, 2016 at 9:21 AM, Antoon Pardon wrote: > Op 05-03-16 om 16:18 schreef Chris Angelico: >> On Sun, Mar 6, 2016 at 2:05 AM, Antoon Pardon >> wrote: >>> Using python 3.4/3.5 >>> >>> Suppose I have the following class: >>> >>> class Tryout: >>> >>> @extern >>> def method(self, ..

Re: Phyton

2016-03-06 Thread Ian Kelly
On Sun, Mar 6, 2016 at 10:05 AM, Mark Lawrence wrote: > Why in the year 2016 are people still giving links to the Luddite Python 2 > docs? Maybe because it's the version that comes up when googling for "python if statement". -- https://mail.python.org/mailman/listinfo/python-list

<    12   13   14   15   16   17   18   19   20   21   >