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 'asynchronous iterator' in
Python 3.5, but I cannot find it.
I ca
Christian Gollwitzer wrote:
> Am 30.01.16 um 05:58 schrieb Random832:
>> On Fri, Jan 29, 2016, at 23:46, Hongyi Zhao wrote:
>>> awk '{a[NR]=$0} END {while (NR) print a[NR--]}' input_file
>>> perl -e 'print reverse<>' input_file
>>
>> Well, both of those read the whole file into memory - tac is som
On Sat, Jan 30, 2016 at 7:22 PM, Frank Millman wrote:
> We had a recent discussion about the best way to do this, and ChrisA
> suggested the following, which I liked -
>
>cur.execute('SELECT ...)
>try:
>row = next(cur)
>except StopIteration:
># row does not exist
>e
On 01/28/2016 04:01 PM, Fillmore wrote:
I learned myself Perl as a scripting language over two decades ago. All through
this time, I
would revert to it from time to time whenever I needed some text manipulation
and data analysis
script.
My problem? maybe I am stupid, but each time I have to g
Am 30.01.16 um 08:56 schrieb Jussi Piitulainen:
Christian Gollwitzer writes:
Am 30.01.16 um 05:58 schrieb Random832:
On Fri, Jan 29, 2016, at 23:46, Hongyi Zhao wrote:
awk '{a[NR]=$0} END {while (NR) print a[NR--]}' input_file
perl -e 'print reverse<>' input_file
Well, both of those read th
Christian Gollwitzer writes:
> Am 30.01.16 um 05:58 schrieb Random832:
>> On Fri, Jan 29, 2016, at 23:46, Hongyi Zhao wrote:
>>> awk '{a[NR]=$0} END {while (NR) print a[NR--]}' input_file
>>> perl -e 'print reverse<>' input_file
>>
>> Well, both of those read the whole file into memory - tac is so
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
On Sat, Jan 30, 2016 at 7:02 PM, Ian Kelly wrote:
> 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).
>>
"Ian Kelly" wrote in message
news:CALwzid=ssdsm8hdan+orj54a_jeu9wc8103iqgkaah8mrj-...@mail.gmail.com...
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 t
On Sat, 30 Jan 2016 09:47 am, Ben Finney wrote:
> Steven D'Aprano writes:
>
>> You should have started with the official tutorial:
>>
>> https://docs.python.org/2/tutorial/
>
> And these days the default recommendation should be to start with the
> official tutorial for the current stable versi
On 1/30/2016 1:03 AM, Christian Gollwitzer wrote:
Am 30.01.16 um 05:58 schrieb Random832:
On Fri, Jan 29, 2016, at 23:46, Hongyi Zhao wrote:
awk '{a[NR]=$0} END {while (NR) print a[NR--]}' input_file
perl -e 'print reverse<>' input_file
Well, both of those read the whole file into memory - ta
2016-01-30 11:51 GMT+01:00 Frank Millman :
> "Chris Angelico" wrote in message
> news:CAPTjJmoAmVNTCKq7QYaDRNQ67Gcg9TxSXYXCrY==s9djjna...@mail.gmail.com...
>
>
>> On Sat, Jan 30, 2016 at 7:22 PM, Frank Millman
>> wrote:
>> > We had a recent discussion about the best way to do this, and ChrisA
>>
On Friday, 29 January 2016 17:32:58 UTC+11, Sayth Renshaw wrote:
> Hi
>
> This may seem an odd request, however i thought i would ask do you have any
> diagrams, scribbles, presentations you have done when coaching someone at
> work that just seems to work for others consistently?
>
> In coach
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
Howdy all,
I am pleased to announce the release of version 2.1.1 of the
‘python-daemon’ library.
The current release is always available at
https://pypi.python.org/pypi/python-daemon/>.
Significant changes since the previous version
==
Version 2.1.0
To address the original question, I don't believe a next() equivalent for
async iterables has been added to the standard library yet. Here's an
implementation from one of my projects that I use to manually get the next
value: https://bpaste.net/show/e4bd209fc067. It exposes the same interface
as th
"Maxime S" wrote in message
news:CAGqiJR8yUdd1u7j0YHS-He_v4uUT-ui=PpiX=n_G=ntt8zn...@mail.gmail.com...
I might be a bit off-topic, but why don't you simply use cursor.rowcount?
I just tried that on sqlite3 and pyodbc, and they both return -1.
I think that it only works with insert/update/
On 29.01.2016 23:49, Ben Finney wrote:
"Sven R. Kunze" writes:
On 29.01.2016 01:01, Fillmore wrote:
How was the Python 2.7 vs Python 3.X solved? which version should I
go for?
Python 3 is the new and better one.
More importantly: Python 2 will never improve; Python 3 is the only one
that is
"Chris Angelico" wrote in message
news:CAPTjJmoAmVNTCKq7QYaDRNQ67Gcg9TxSXYXCrY==s9djjna...@mail.gmail.com...
On Sat, Jan 30, 2016 at 7:22 PM, Frank Millman wrote:
> We had a recent discussion about the best way to do this, and ChrisA
> suggested the following, which I liked -
>
>cur.execut
> Any particular reason not to use the classic sentinel object model?
None that I can remember. I would use the sentinel pattern if I were
writing it again today.
> Also curious is that you raise a new StopAsyncIteration from the original
one, rather than just reraising the original. I assume the
On Sat, Jan 30, 2016 at 11:35 PM, Kevin Conway
wrote:
> To address the original question, I don't believe a next() equivalent for
> async iterables has been added to the standard library yet. Here's an
> implementation from one of my projects that I use to manually get the next
> value: https://bp
On 30 January 2016 at 08:22, Frank Millman wrote:
> There are times when I want to execute a SELECT statement, and test for
> three possibilities -
>- if no rows are returned, the object does not exist
>- if one row is returned, the object does exist
>- if more that one row is returned
"Oscar Benjamin" wrote in message
news:cahvvxxsa0yq4voyy6qycgxxvpl5zzgm8muui+1vmezd8crg...@mail.gmail.com...
The simplest thing would just be to call list(cur) but I realise that
you don't want to consume more than 2 rows from the database so just
use islice:
rows = list(islice(cur, 2)) # p
On 30 January 2016 at 13:45, Frank Millman wrote:
> "Oscar Benjamin" wrote in message
> news:cahvvxxsa0yq4voyy6qycgxxvpl5zzgm8muui+1vmezd8crg...@mail.gmail.com...
>>
>>
>> The simplest thing would just be to call list(cur) but I realise that
>
> you don't want to consume more than 2 rows from the
On 30 January 2016 at 16:42, Ian Kelly wrote:
>> AFAICT there's no generator-function-style syntax for writing an async
>> iterator so you'd have to make a class with the appropriate methods if
>> you wanted to be able to loop over aslice with async for.
>
> Before you go any further with this, be
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:
>
On 01/30/2016 01:22 AM, Frank Millman wrote:
> There are times when I want to execute a SELECT statement, and test for
> three possibilities -
> - if no rows are returned, the object does not exist
> - if one row is returned, the object does exist
> - if more that one row is returned,
On 27/01/2016 04:57, toluagbo...@gmail.com wrote:
[...]
Here is what the python code looks like and I am to make a Unittest for it
Just a few ideas: first of all, you have to make your code more modular,
for it to be unit-testable.
There are a few areas in your code that need testing:
- com
So, the python plotting packages mentioned can create files that hold your
graphs. As to whether you want to display them on the web or send them
around as attachments to your coworkers, or build some local application to
display them is your choice
Sorry for my confusion :D
I'm still not sur
On Sun, Jan 31, 2016 at 6:42 AM, Michael Torrie wrote:
> On 01/30/2016 01:22 AM, Frank Millman wrote:
>> There are times when I want to execute a SELECT statement, and test for
>> three possibilities -
>> - if no rows are returned, the object does not exist
>> - if one row is returned, the
On 01/30/2016 02:19 PM, Chris Angelico wrote:
> Efficiency. That's a fine way of counting actual rows in an actual
> table. However, it's massive overkill to perform an additional
> pre-query for something that's fundamentally an assertion (this is a
> single-row-fetch API like "select into", and i
On Sun, Jan 31, 2016 at 8:52 AM, Michael Torrie wrote:
> On 01/30/2016 02:19 PM, Chris Angelico wrote:
>> Efficiency. That's a fine way of counting actual rows in an actual
>> table. However, it's massive overkill to perform an additional
>> pre-query for something that's fundamentally an assertio
On 01/30/2016 02:57 PM, Michael Torrie wrote:
> SELECT count(some_id_field),field1,field2,field3 FROM wherever WHERE
> conditions
>
> If the first column (or whatever you decide to alias it as) contains a
> count, and the rest of the information is still there. If count is 1,
> then the row is wh
On Sun, Jan 31, 2016 at 8:57 AM, Michael Torrie wrote:
> On 01/30/2016 02:19 PM, Chris Angelico wrote:
>> where the ... is the full original query. In other words, the whole
>> query has to be run twice - once to assert that there's exactly one
>> result, and then a second time to get that result.
On 01/30/2016 03:06 PM, Chris Angelico wrote:
> That actually violates the SQL spec. Some servers will accept it,
> others won't. (You're not supposed to mix column functions and
> non-column functions.)
Are you sure? Wikipedia is not always the most accurate place, but they
have several clear e
Rustom Mody wrote:
1. One can use string-re's instead of compiled re's
And I gather that string REs are compiled on first use and
cached, so you don't lose much by using them most of the
time.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
On Sun, Jan 31, 2016 at 9:19 AM, Michael Torrie wrote:
> On 01/30/2016 03:06 PM, Chris Angelico wrote:
>> That actually violates the SQL spec. Some servers will accept it,
>> others won't. (You're not supposed to mix column functions and
>> non-column functions.)
>
> Are you sure? Wikipedia is no
Hi again,
as the topic of the old thread actually was fully discussed, I dare to
open a new one.
I finally managed to finish my heap implementation. You can find it at
https://pypi.python.org/pypi/xheap + https://github.com/srkunze/xheap.
I described my motivations and design decisions at
Michael Torrie wrote:
I'm not sure how SQLite handles it, or even what the SQL spec says, but
I know in MySQL you could do something like this:
SELECT count(id) as row_count,`tablename`.* FROM `tablename` WHERE condition
I don't think that's strictly valid SQL. I know of at least
one SQL imple
On 30/01/2016 20:50, mustang wrote:
So, the python plotting packages mentioned can create files that hold
your
graphs. As to whether you want to display them on the web or send them
around as attachments to your coworkers, or build some local
application to
display them is your choice
Sorry
On 01/30/2016 02:19 PM, Chris Angelico wrote:
> where the ... is the full original query. In other words, the whole
> query has to be run twice - once to assert that there's exactly one
> result, and then a second time to get that result. The existing
> algorithm ("try to fetch a row - if it fails
On Sun, Jan 31, 2016 at 9:05 AM, Michael Torrie wrote:
> On 01/30/2016 02:57 PM, Michael Torrie wrote:
>> SELECT count(some_id_field),field1,field2,field3 FROM wherever WHERE
>> conditions
>>
>> If the first column (or whatever you decide to alias it as) contains a
>> count, and the rest of the in
On Friday, January 29, 2016 at 9:38:23 PM UTC-6, Rustom Mody wrote:
> JustForTheRecord[1]: Rick is someone who I sometimes agree with...
Thanks for reacting in a rational, cool-headed manner.
Many folks, especially the new members of this group, may
not understand *WHY* i react so passionately w
Hi again,
as the topic of the old thread actually was fully discussed, I dare to
open a new one.
I finally managed to finish my heap implementation. You can find it at
https://pypi.python.org/pypi/xheap + https://github.com/srkunze/xheap.
I described my motivations and design decisions at
On Sunday 31 January 2016 09:47, Sven R. Kunze wrote:
> @all
> What's the best/standardized tool in Python to perform benchmarking?
timeit
--
Steve
--
https://mail.python.org/mailman/listinfo/python-list
On Sunday 31 January 2016 09:18, Gregory Ewing wrote:
> Rustom Mody wrote:
>> 1. One can use string-re's instead of compiled re's
>
> And I gather that string REs are compiled on first use and
> cached, so you don't lose much by using them most of the
> time.
Correct. The re module keeps a cache
On Sunday, January 31, 2016 at 7:27:06 AM UTC+5:30, Steven D'Aprano wrote:
> On Sunday 31 January 2016 09:18, Gregory Ewing wrote:
>
> > Rustom Mody wrote:
> >> 1. One can use string-re's instead of compiled re's
> >
> > And I gather that string REs are compiled on first use and
> > cached, so yo
On Sunday, January 31, 2016 at 9:18:31 AM UTC+5:30, Cameron Simpson wrote:
> On 30Jan2016 19:22, rusi wrote:
> >Python 3.4.3+ (default, Oct 14 2015, 16:03:50)
> >[GCC 5.2.1 20151010] on linux
> >Type "help", "copyright", "credits" or "license" for more information.
> python.el: native completi
I'm parsing html and i'm doing:
x = root.find_class(...
y = root.find_class(..
z = root.find_class(..
all 3 are likely to fail so typically i'd have to stick it in a try. This is
a huge pain for obvious reasons.
try:
except something:
x = 'default_1'
(repeat 3 times)
Is there some other
On Sun, Jan 31, 2016 at 3:58 PM, Veek. M wrote:
> I'm parsing html and i'm doing:
>
> x = root.find_class(...
> y = root.find_class(..
> z = root.find_class(..
>
> all 3 are likely to fail so typically i'd have to stick it in a try. This is
> a huge pain for obvious reasons.
>
> try:
>
> exc
On 2016-01-31 01:56:51, "Steven D'Aprano"
wrote:
On Sunday 31 January 2016 09:18, Gregory Ewing wrote:
Rustom Mody wrote:
1. One can use string-re's instead of compiled re's
And I gather that string REs are compiled on first use and
cached, so you don't lose much by using them most of
On 30Jan2016 19:22, rusi wrote:
Python 3.4.3+ (default, Oct 14 2015, 16:03:50)
[GCC 5.2.1 20151010] on linux
Type "help", "copyright", "credits" or "license" for more information.
python.el: native completion setup loaded
import re
re._MAXCACHE
512
Have you ever seen a program that uses 512
Chris Angelico wrote:
> On Sun, Jan 31, 2016 at 3:58 PM, Veek. M wrote:
>> I'm parsing html and i'm doing:
>>
>> x = root.find_class(...
>> y = root.find_class(..
>> z = root.find_class(..
>>
>> all 3 are likely to fail so typically i'd have to stick it in a try. This
>> is a huge pain for obviou
Veek. M wrote:
> Chris Angelico wrote:
>
>> On Sun, Jan 31, 2016 at 3:58 PM, Veek. M wrote:
>>> I'm parsing html and i'm doing:
>>>
>>> x = root.find_class(...
>>> y = root.find_class(..
>>> z = root.find_class(..
>>>
>>> all 3 are likely to fail so typically i'd have to stick it in a try.
>>> T
@Sven
actually you are not sweeping at all, as i remember from my last post
what i meant by sweeping is periodically deleting the elements which
were marked as popped items.
kudos on that __setitem__ technique,
instead of using references to the items like in HeapDict, it is
brilliant of you to si
On Sun, 31 Jan 2016 03:58 pm, Veek. M wrote:
> Is there some other nice way to wrap this stuff up?
The answer to "how do I wrap this stuff up?" is nearly always:
- refactor your code so you don't need to;
- subclass and extend the method;
- write a function;
- write a delegate class.
Pick whi
56 matches
Mail list logo