Path-like objects in the standard library

2018-08-24 Thread Torsten Bronger
Hallöchen!

Path-like objects are accepted by all path-processing functions in
the standard library since Python 3.6.  Unfortunately, this is not
made explicit everywhere.  In particular, if I pass a Path in the
first argument of subprocess.run, do I use an implementation detail
of CPython?  Because on
https://docs.python.org/3.6/library/subprocess.html, only for the
cwd argument the acceptance of Paths is stated explicitly.

The same goes for all functions in the shutil module.
https://docs.python.org/3.6/library/shutil.html does not mention the
path-like protocol anywhere, but the CPython modules seem to accept
them anyway.

Regards,
Torsten.

-- 
Torsten Bronger
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Path-like objects in the standard library

2018-08-24 Thread Paul Moore
On Fri, 24 Aug 2018 at 09:57, Torsten Bronger
 wrote:
>
> Hallöchen!
>
> Path-like objects are accepted by all path-processing functions in
> the standard library since Python 3.6.  Unfortunately, this is not
> made explicit everywhere.  In particular, if I pass a Path in the
> first argument of subprocess.run, do I use an implementation detail
> of CPython?  Because on
> https://docs.python.org/3.6/library/subprocess.html, only for the
> cwd argument the acceptance of Paths is stated explicitly.
>
> The same goes for all functions in the shutil module.
> https://docs.python.org/3.6/library/shutil.html does not mention the
> path-like protocol anywhere, but the CPython modules seem to accept
> them anyway.

I would imagine that doc fixes would be gratefully accepted. Or if
they are rejected, that rejection would be confirmation that the
support is intended as an implementation detail (and a fix to the
documentation to explicitly state that would be reasonable).

Personally, I'd expect that the intention is that you can rely on it.
Paul
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fetch data from two dates query in python and mongoengine

2018-08-24 Thread Kunal Jamdade
Hi Mahesh,

Import Q from queryset.

from mongoengine.queryset.visitor import Q

ProcessedEmails.objects(Q(first_date) & Q(second_date))



On Fri, Aug 24, 2018 at 12:41 PM mahesh d  wrote:

> [image: Boxbe]  This message is eligible
> for Automatic Cleanup! (mahesh.tec...@gmail.com) Add cleanup rule
> 
> | More info
> 
> Hii
> My model like this
> class ProcessedEmails(Document):
>   subject = StringField(max_length=200)
> fromaddress =StringField(max_length=200)
>  dateofprocessing = StringField(max_length=25)
> How can find out the records between two dates ??
> Note: date of processing is string field
>  Mongodb database using .
> How to write the query in python by using mongoengine
>
> Thanks
> Mahesh D.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fetch data from two dates query in python and mongoengine

2018-08-24 Thread mahesh d
Thanks!

On Fri 24 Aug, 2018, 9:01 PM Kunal Jamdade, 
wrote:

> Hi Mahesh,
>
> Import Q from queryset.
>
> from mongoengine.queryset.visitor import Q
>
> ProcessedEmails.objects(Q(first_date) & Q(second_date))
>
>
>
> On Fri, Aug 24, 2018 at 12:41 PM mahesh d  wrote:
>
>> [image: Boxbe]  This message is eligible
>> for Automatic Cleanup! (mahesh.tec...@gmail.com) Add cleanup rule
>> 
>> | More info
>> 
>> Hii
>> My model like this
>> class ProcessedEmails(Document):
>>   subject = StringField(max_length=200)
>> fromaddress =StringField(max_length=200)
>>  dateofprocessing = StringField(max_length=25)
>> How can find out the records between two dates ??
>> Note: date of processing is string field
>>  Mongodb database using .
>> How to write the query in python by using mongoengine
>>
>> Thanks
>> Mahesh D.
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Path-like objects in the standard library

2018-08-24 Thread Terry Reedy

On 8/24/2018 5:28 AM, Paul Moore wrote:

On Fri, 24 Aug 2018 at 09:57, Torsten Bronger
 wrote:


Hallöchen!

Path-like objects are accepted by all path-processing functions in
the standard library since Python 3.6.  Unfortunately, this is not
made explicit everywhere.  In particular, if I pass a Path in the
first argument of subprocess.run, do I use an implementation detail
of CPython?  Because on
https://docs.python.org/3.6/library/subprocess.html, only for the
cwd argument the acceptance of Paths is stated explicitly.

The same goes for all functions in the shutil module.
https://docs.python.org/3.6/library/shutil.html does not mention the
path-like protocol anywhere, but the CPython modules seem to accept
them anyway.


I would imagine that doc fixes would be gratefully accepted. Or if
they are rejected, that rejection would be confirmation that the
support is intended as an implementation detail (and a fix to the
documentation to explicitly state that would be reasonable).

Personally, I'd expect that the intention is that you can rely on it.
Paul




--
Terry Jan Reedy


--
https://mail.python.org/mailman/listinfo/python-list


Generating a specific list of intsgers

2018-08-24 Thread tomusatov
I am looking for a program able to output a set of integers meeting the 
following requirement:

a(n) is the minimum k > 0 such that n*2^k - 3 is prime, or 0 if no such k exists

Could anyone get me started? (I am an amateur)

Thanks,
Musatov 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Generating a specific list of intsgers

2018-08-24 Thread Ian Kelly
On Fri, Aug 24, 2018 at 3:47 PM  wrote:
>
> I am looking for a program able to output a set of integers meeting the 
> following requirement:
>
> a(n) is the minimum k > 0 such that n*2^k - 3 is prime, or 0 if no such k 
> exists
>
> Could anyone get me started? (I am an amateur)

Is there some known method of determining that no such k exists? The
obvious approach would be to try every possible value of k in order.
The problem is that there are infinitely many possible values of k, so
the program would not output 0; it would just never complete.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Generating a specific list of intsgers

2018-08-24 Thread MRAB

On 2018-08-24 22:54, Ian Kelly wrote:

On Fri, Aug 24, 2018 at 3:47 PM  wrote:


I am looking for a program able to output a set of integers meeting the 
following requirement:

a(n) is the minimum k > 0 such that n*2^k - 3 is prime, or 0 if no such k exists

Could anyone get me started? (I am an amateur)


Is there some known method of determining that no such k exists? The
obvious approach would be to try every possible value of k in order.
The problem is that there are infinitely many possible values of k, so
the program would not output 0; it would just never complete.

Well, if n <= 0, there is definitely no value of k that could produce a 
prime, but in general...

--
https://mail.python.org/mailman/listinfo/python-list


Re: zpifile.py error - no crc 32 attribute

2018-08-24 Thread jacob m
Hi all,
Thanks for your help, I reinstalled my Python and now it seems to be
working :)
Before building Python3 i uncommented:
#zlib zlibmodule.c -I$(prefix)/include
in Modules/Setup.dist and then I enabled ipv6 during the configuration.
Regards

On Thu, 23 Aug 2018 at 01:59, MRAB  wrote:

> On 2018-08-22 23:43, jacob m wrote:
> > " import zlib
> > print(zlib.__file__)"
> >
> > When I don't have the zlib uploaded to my Python3.7 library, I have the
> > following error:
> > "Traceback (most recent call last):
> >File "./testx.py", line 2, in 
> >  import zlib
> > ModuleNotFoundError: No module named 'zlib'"
> >
> > When I download the zlib 1.2.11 from http://www.zlib.net/, rename the
> > "zlib-1.2.11" folder into "zlib" (after unpacking) and upload it into
> > Python library, the result is:
> > "# ./testx.py
> > None
> > "
> > In the second case I still have the AttributeError with crc32.
> >
> In the first case, without the downloaded zlip, can you import zipfile?
>
> If yes, try:
>
> zipfile.zlib
>
>  From what I've seen, zlib is a built-in.
> >
> >
> > On 22 August 2018 at 23:09, Ashok Arora 
> wrote:
> >
> >> Test this in the interpreter:-
> >>
> >> import zlib
> >> zlib.__file__
> >>
> >> It will return the location of zlib module.
> >>
> >> On 8/22/18, jacob m  wrote:
> >> >  Hi,
> >> > " Is there perhaps a different zlib on
> >> > your path, hiding the real zlib?" - I'm unsure of that.
> >> >
> >> > "sudo apt-get install zlib1g-dev
> >> > Reading package lists... Done
> >> > Building dependency tree
> >> > Reading state information... Done
> >> > zlib1g-dev is already the newest version.
> >> > 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded."
> >> > Regards
> >> >
> >> >
> >> > On 22 August 2018 at 13:12, jacob m  wrote:
> >> >
> >> >> Hi guys,
> >> >> I have a problem with zipfile and zlib module, and hope to get some
> >> help.
> >> >>
> >> >> That's my error:
> >> >> "import zipfile
> >> >>   File "/home/lib/python3.7/lib/python3.7/zipfile.py", line 19, in
> >> >> 
> >> >> crc32 = zlib.crc32
> >> >> AttributeError: module 'zlib' has no attribute 'crc32' "
> >> >>
> >> >> I have no idea what to do with that :/ I use this version of zipfile:
> >> >> https://github.com/python/cpython/blob/3.7/Lib/zipfile.py
> >> >>
> >> >> Somebody knows how to solve it?
> >> >> Regards
> >> >>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Bottle framework references

2018-08-24 Thread Jason Friedman
>
>
> > On 22 Aug 2018, at 8:38 am, Jason Friedman  wrote:
> >
> >>
> >> I am building up the microsite based on Bottle framework now.
> >> Any references/books? I am unfamiliar with this framework yet.
> >>
> >> I have used it with success.  The online documentation was sufficient
> for
> > my needs, at least.
> > --
>
> https://bottlepy.org/docs/dev/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Generating a specific list of intsgers

2018-08-24 Thread Steven D'Aprano
On Fri, 24 Aug 2018 14:40:00 -0700, tomusatov wrote:

> I am looking for a program able to output a set of integers meeting the
> following requirement:
> 
> a(n) is the minimum k > 0 such that n*2^k - 3 is prime, or 0 if no such
> k exists
> 
> Could anyone get me started? (I am an amateur)


That's more a maths question than a programming question. Find out how to 
tackle it mathematically, and then we can code it.



-- 
Steven D'Aprano
"Ever since I learned about confirmation bias, I've been seeing
it everywhere." -- Jon Ronson

-- 
https://mail.python.org/mailman/listinfo/python-list