Re: Python 3.5.0: python.exe is not a valid Windows 32 application

2015-12-02 Thread Ian Kelly
On Wed, Dec 2, 2015 at 4:09 PM, wrote: > Hi. > > https://mail.python.org/pipermail/python-dev/2015-July/140823.html > Python 3.5 was dropped the support Windows XP and 2003. > > > > It's just an aside, but Python 3.5.1 works on my customized Windows 2000 :P > http://blog.livedoor.jp/blackwingcat/

Re: Subclassing tuple and introspection

2015-12-02 Thread Ian Kelly
On Wed, Dec 2, 2015 at 4:32 PM, Joseph L. Casale wrote: > I need to return a collection of various types, since python doesn't > have the terse facility of extension methods like C#, subclassing tuple > and adding a method seems like a terse way to accommodate this. If you're not already familiar

Re: 'string.join' is wrong in my Python console

2015-12-03 Thread Ian Kelly
On Thu, Dec 3, 2015 at 9:00 AM, Robin Koch wrote: > Now *I* am confused. > > Shouldn't it be > > ", ".join(['1', '2', '4', '8', '16']) > > instead? Without any importing? That would be the normal way to write it. The FAQ entry is suggesting the string module function as an alternative for those w

Re: [Python-ideas] Missing Core Feature: + - * / | & do not call __getattr__

2015-12-04 Thread Ian Kelly
On Fri, Dec 4, 2015 at 7:20 AM, Stephan Sahm wrote: > Dear all, > > I just stumbled upon a very weird behaviour of python 2 and python 3. At > least I was not able to find a solution. > > The point is to dynamically define __add__, __or__ and so on via __getattr__ > (for example by deriving them f

Re: Frozen apps (py2exe, cx_freeze) built with Python 3.5

2015-12-04 Thread Ian Kelly
On Fri, Dec 4, 2015 at 10:21 AM, d...@forestfield.co.uk wrote: > Python 3.5 will not run under Windows XP, but what about applications created > using py2exe or cx_freeze under Windows 7, 8 or 10, is there any knowledge of > whether they will run under XP? I wouldn't expect them to. Those bundl

Re: [Python-ideas] Using functools.lru_cache only on some arguments of a function

2015-12-04 Thread Ian Kelly
On Fri, Dec 4, 2015 at 2:44 PM, Bill Winslow wrote: > This is a question I posed to reddit, with no real resolution: > https://www.reddit.com/r/learnpython/comments/3v75g4/using_functoolslru_cache_only_on_some_arguments/ > > The summary for people here is the following: > > Here's a pattern I'm us

Re: Issue

2015-12-07 Thread Ian Kelly
On Sun, Dec 6, 2015 at 5:16 PM, Steven D'Aprano wrote: > Oh, I can make one guess... if you're using Windows XP, I'm afraid that > Python 3.5 is not supported. You'll have to either downgrade to Python 3.4, > or upgrade to Windows 7 or higher, or another operating system. For the sake of accuracy

Re: Accessing container's methods

2015-12-07 Thread Ian Kelly
On Mon, Dec 7, 2015 at 11:10 AM, Tony van der Hoff wrote: > Hi, > > I have a class A, containing embedded embedded classes, which need to access > methods from A. > . > A highly contrived example, where I'm setting up an outer class in a Has-a > relationship, containing a number of Actors. The inn

Re: Understanding Python from a PHP coder's perspective

2015-12-07 Thread Ian Kelly
On Mon, Dec 7, 2015 at 2:07 PM, wrote: > Hello all! Just started getting into Python, and am very excited about the > prospect. > > I am struggling on some general concepts. My past experience with > server-side code is mostly limited to PHP and websites. I have some file > called "whatever

Re: Understanding Python from a PHP coder's perspective

2015-12-07 Thread Ian Kelly
On Mon, Dec 7, 2015 at 2:40 PM, Chris Angelico wrote: > So that's a quick potted summary of why the URLs don't reflect the > language used. Python is event-driven, but instead of defining events > at the file level, the way PHP does, they're defined at the function > level. Of course, if you *want

Re: Understanding Python from a PHP coder's perspective

2015-12-07 Thread Ian Kelly
On Mon, Dec 7, 2015 at 3:27 PM, wrote: > Thank you all! > > Okay, the concept of a WSGI along with a framework provides insight on my > main questions. > > In regards to Chris's statement: "It openly and honestly does NOT reset its > state between page requests" > > With PHP, I have sessions to

Re: increment/decrement operators

2015-12-07 Thread Ian Kelly
On Dec 5, 2015 10:21 AM, "BartC" wrote: > > > The latter is not the same. Some of the differences are: > > * ++ and -- are often inside inside expressions and return values (unlike x+=1 in Python) > > * x++ and x-- return the /current/ value of x, unlike x+=1 even if it were to return a val

Re: Accessing container's methods

2015-12-08 Thread Ian Kelly
On Tue, Dec 8, 2015 at 3:37 PM, Erik wrote: > On 08/12/15 19:02, Thomas 'PointedEars' Lahn wrote: >> >> Erik wrote: >> >> Please fix, Erik #75656. > > > Fixed(*) [SNIP] > (*) In the sense that it's not going to change ;) Then I think you mean "Working as Intended", not "Fixed". B-) -- ht

Re: Python variable assigning problems...

2015-12-11 Thread Ian Kelly
On Fri, Dec 11, 2015 at 9:10 AM, ICT Ezy wrote: > Dear All, > Very Sorry for the my mistake here. I code here with mu question ... > > My Question: > > A,B=C,D=10,11 > print(A,B,C,D) > #(10,11,10,11) --> This is OK! > > a=1; b=2 > a,b=b,a > print(a,b) > # (1,2) --> This is OK! This actually resul

Re: Python variable assigning problems...

2015-12-11 Thread Ian Kelly
On Fri, Dec 11, 2015 at 9:24 AM, Robin Koch wrote: > Assigning goes from right to left: > > x,y=y,x=2,3 > > <=> > > y, x = 2, 3 > x, y = y, x > > Otherwise the assignment x, y = y, x would not make any sense, since x and y > haven't any values yet. > > And the execution from right to left is also

Re: python 351x64

2015-12-11 Thread Ian Kelly
On Fri, Dec 11, 2015 at 9:30 AM, Jay Hamm wrote: > Hi > > I was trying to use your windows version of python 3.5.1 x64. > > It has a conflict with a notepad++ plugin NppFTP giving > api-ms-win-crt-runtime-I1-1-0.dll error on start up. > > This seems pretty well documented on the web. The work aro

Re: Hello

2015-12-11 Thread Ian Kelly
On Fri, Dec 11, 2015 at 11:43 AM, Seung Kim wrote: > See message below. > > On Fri, Dec 11, 2015 at 1:13 PM, Seung Kim wrote: > >> I would like to have Python 3.5.1 MSI installer files for both 32-bit and >> 64-bit so that I can deploy the software on managed computers on campus. >> >> When I ran

Re: Calling a list of functions

2015-12-13 Thread Ian Kelly
On Sun, Dec 13, 2015 at 10:26 AM, Ganesh Pal wrote: > Hi Team, > > Iam on linux and python 2.7 . I have a bunch of functions which I > have run sequentially . > I have put them in a list and Iam calling the functions in the list as > shown below , this works fine for me , please share your > op

Re: Weird list conversion

2015-12-13 Thread Ian Kelly
On Sun, Dec 13, 2015 at 12:45 PM, wrote: > Hi all, > > f = open("stairs.bin", "rb") > data = list(f.read(16)) > print data > > returns > > ['=', '\x04', '\x00', '\x05', '\x00', '\x01', '\x00', '\x00', '\x00', '\x00', > '\x00', '\x00', '\x00', '\x00', '\x00', '\x00'] > > The fir

Re: Weird list conversion

2015-12-13 Thread Ian Kelly
On Sun, Dec 13, 2015 at 1:05 PM, KP wrote: > On Sunday, 13 December 2015 11:57:57 UTC-8, Laura Creighton wrote: >> In a message of Sun, 13 Dec 2015 11:45:19 -0800, KP writes: >> >Hi all, >> > >> > f = open("stairs.bin", "rb") >> > data = list(f.read(16)) >> > print data >> > >> >re

Re: Try: rather than if :

2015-12-14 Thread Ian Kelly
On Mon, Dec 14, 2015 at 3:38 PM, Vincent Davis wrote: > In the code below try is used to check if handle has the attribute name. It > seems an if statement could be used. Is there reason one way would be > better than another? http://www.oranlooney.com/lbyl-vs-eafp/ -- https://mail.python.org/ma

Re: Try: rather than if :

2015-12-14 Thread Ian Kelly
On Mon, Dec 14, 2015 at 4:48 PM, Vincent Davis wrote: > On Mon, Dec 14, 2015 at 4:14 PM, Cameron Simpson wrote: > >> First, notice that the code inside the try/except _only_ fetches the >> attribute. Your version calls the "write" attribute, and also accesses >> handle.name. Either of those migh

Re: subclassing collections.Counter

2015-12-15 Thread Ian Kelly
On Tue, Dec 15, 2015 at 8:49 AM, Pavlos Parissis wrote: > Hi, > > I need to store values for metrics and return the average for some > and the sum for the rest. Thus, I thought I could extend > collections.Counter class by returning averages for some keys. Leave Counter out of it, as this is not

Re: subclassing collections.Counter

2015-12-15 Thread Ian Kelly
On Tue, Dec 15, 2015 at 9:20 AM, Pavlos Parissis wrote: > On 15/12/2015 05:11 μμ, Ian Kelly wrote: >> On Tue, Dec 15, 2015 at 8:49 AM, Pavlos Parissis >> wrote: >>> Hi, >>> >>> I need to store values for metrics and return the average for some >&

Re: subclassing collections.Counter

2015-12-15 Thread Ian Kelly
On Tue, Dec 15, 2015 at 10:43 AM, Pavlos Parissis wrote: >> If you want your metrics container to act like a dict, then my >> suggestion would be to just use a dict, with pseudo-collections for >> the values as above. >> > > If I understood you correctly, you are saying store all metrics in a > di

Re: error reading api with urllib

2015-12-16 Thread Ian Kelly
On Tue, Dec 15, 2015 at 7:46 PM, Simian wrote: > I added > > except urllib.error.HTTPError as e: > print('HTTP Errpr') > print('Error code: ', e.code) > > to my try and I recieve... > > 400: ('Bad Request', > 'Bad request syntax or unsupported method'), > > but processing the string

Re: error reading api with urllib

2015-12-16 Thread Ian Kelly
On Wed, Dec 16, 2015 at 3:12 PM, John Gordon wrote: > In <9aa21642-765b-4666-8c66-a6dab9928...@googlegroups.com> > simian...@gmail.com writes: > >> Bad Request >> b'' > > > That probably means you aren't using one of the recognized methods > (i.e. GET, POST, etc.) > > It doesn't look like you are

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

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