Re: asyncmongo + python 3: No module named 'errors'

2016-02-25 Thread Nagy László Zsolt


2016.02.25. 9:08 keltezéssel, Nagy László Zsolt írta:
> ayncmongo requirements are "pymongo" and "tornado".
>
> I have a fresh installation of Python 3.5, pymongo 3.2 and tornado 4.3,
> but I cannot import asyncmongo.
This seems to be the exact same bug report:

https://github.com/bitly/asyncmongo/issues/51

Last comment in 2013. There was no response.

Does it mean that asyncmongo does not work with Python 3?

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


Re: asyncmongo + python 3: No module named 'errors'

2016-02-25 Thread INADA Naoki
>
>
> Does it mean that asyncmongo does not work with Python 3?
>
>
Yes.
I recommend you to use motor [1].


* [1] https://github.com/mongodb/motor

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


asyncmongo + python 3: No module named 'errors'

2016-02-25 Thread Nagy László Zsolt
ayncmongo requirements are "pymongo" and "tornado".

I have a fresh installation of Python 3.5, pymongo 3.2 and tornado 4.3,
but I cannot import asyncmongo.

Tracelog below.


P:\WinPython-64bit-3.5.1.2\python-3.5.1.amd64>python
Python 3.5.1 (v3.5.1:37a07cee5969, Dec  6 2015, 01:54:25) [MSC v.1900 64
bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pymongo
>>> pymongo.version
'3.2'
>>> import tornado
>>> tornado.version
'4.3'
>>> import asyncmongo
Traceback (most recent call last):
  File "", line 1, in 
  File
"P:\WinPython-64bit-3.5.1.2\python-3.5.1.amd64\lib\site-packages\asyncmongo\__init__.py",
line 37, in 
from errors import (Error, InterfaceError, AuthenticationError,
DatabaseError, RSConnectionError,
ImportError: No module named 'errors'
>>>






















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


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

2016-02-25 Thread Steven D'Aprano
On Thursday 25 February 2016 17:54, Marko Rauhamaa wrote:

> Steven D'Aprano :
> 
>> On Wednesday 24 February 2016 18:20, Marko Rauhamaa wrote:
>>> Steven D'Aprano :
 And that is where you repeat something which is rank superstition.
>>> 
>>> Can you find info to back that up.
>>
>> The links already provided go through the evidence. For example, they
>> explain that /dev/random and /dev/urandom both use the exact same
>> CSPRNG.
> 
> A non-issue. The question is, after the initial entropy is collected and
> used to seed the CSPRNG, is any further entropy needed for any
> cryptographic purposes?

The short answer: "yes".

The long answer: "probably not, but it can't hurt".

The longer answer: "probably not, and it usually won't hurt, but it could".

If, somehow, an attacker manages to work out the state of your CSPRNG, 
including the entropy pool, then they can predict what values you get until 
they no longer know the state of the CSPRNG. The idea is that if, somehow, 
somebody knows the current state of the CSPRNG (including the entropy pool), 
but can't influence what future values go into the entropy pool, then they 
will only be able to predict the output values for a short time.

But it's hard to think of any actual attack where somebody can see what's in 
the entropy pool but can't influence the values going into it. It seems to 
me that this is an unrealistic attack:

"Assume that you're kidnapped by somebody with no arms or legs..."

The conventional wisdom is that adding poor sources of entropy into the pool 
will never hurt, but that is actually wrong. If an attacker knows what is in 
the entropy pool, and can craft the values going in, they can force the 
CSPRNG to return more predictable values. So sometimes adding more entropy 
can hurt. And it usually won't help. It *might* help if your system is 
compromised, but if so, it's not really clear how the attacker has 
compromised your current entropy pool but not the future ones.


> Are there any nagging fears that weaknesses
> could be found in the deterministic sequence?

Of course there are. Nobody really knows what capabilities the NSA have, but 
they almost surely aren't *that* advanced. CSPRNGs are subject to much the 
same sort of issues as other crypto, such as hash functions:

http://valerieaurora.org/hash.html

and encryption algorithms. (The main real difference between a hash function 
and encryption algorithm is that hashes don't have to be reversible.)

Expect the current crop of CSPRNGs (Yarrow, AES, whatever Linux uses) to be 
replaced long before there is a proven attack on them.


> /dev/random is supposed to be hardened against such concerns by stirring
> the pot constantly (if rather slowly).

As is /dev/urandom.


> Here's what Linus Torvalds said on the matter years back:
> 
>> No, it says /dev/random is primarily useful for generating large
>> (>>160 bit) keys.
> 
>Which is exactly what something like sshd would want to use for
>generating keys for the machine, right? That is _the_ primary reason
>to use /dev/random.
> 
>Yet apparently our /dev/random has been too conservative to be
>actually useful, because (as you point out somewhere else) even sshd
>uses /dev/urandom for the host key generation by default.
> 
>That is really sad. That is the _one_ application that is common and
>that should really have a reason to maybe care about /dev/random vs
>urandom. And that application uses urandom. To me that says that
>/dev/random has turned out to be less than useful in real life.
> 
>Is there anything that actually uses /dev/random at all (except for
>clueless programs that really don't need to)?

Most other Unixes have decided that /dev/random is unnecessary, and urandom 
is the right thing to do. SSH uses urandom by default, but allows the 
paranoid/clueless to use /dev/random if they insist. 



-- 
Steve

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


Re: asyncmongo + python 3: No module named 'errors'

2016-02-25 Thread Nagy László Zsolt

> Yes.
> I recommend you to use motor [1].
>
>
> * [1] https://github.com/mongodb/motor
Thanks. I have checked motor, and here are some problems with it:

* I cannot install it with "pip3 install motor", because it is trying to
downgrade (!!!) pymongo to version 2.8, but it fails to do so. There
might be a binary version available somewhere. Is there a reason why it
works with pymongo 2.8 only?
* The API works with callbacks. I would like to use an API that has
await-able method.

I'm at early stage of development, so I can migrate to a different nosql
database. Is there a good nosql alternative? My requirements are:

* scalable and fault tolerant - data can be distributed between multiple
nodes
* can be run as a portable application
* tornado compatible Python API with awaitable methods instead of callbacks

Facts:*

*- pymongo knows all, except that it is not async
- ayncmongo does not work with python 3
- motor requires downgraded pymongo, and it has no awaitable methods

I have found codernitydb https://pypi.python.org/pypi/CodernityDB/ 
which seems to be able to do sharding, but I'm not sure if it can be
setup as a fault tolerant server.

Thanks,

   Laszlo

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


Re: How to define what a class is ?

2016-02-25 Thread ast


"Ian Kelly"  a écrit dans le message de 
news:[email protected]...

On Wed, Feb 24, 2016 at 1:08 AM, ast  wrote:




All metaclasses are subclasses of type, so all classes are instances of type.


Ah ! I didn't know that if an object Obj is an instance of Myclass and
MyClass inherit from MyClass2, then Ojb is an instance of MyClass2 too


from enum import Enum, EnumMeta

isinstance(Enum, EnumMeta)

True

isinstance(EnumMeta, type)

True

isinstance(Enum, type)

True

that's correct



Suppose I provide to you an object and that I
ask to you to tell me if it is a class or not. How
would you proceed ?


import inspect
inspect.isclass(x)


So we can conclude that inspect.isclass(x) is equivalent
to isinstance(x, type)

lets have a look at the source code of isclass:

def isclass(object):
   """Return true if the object is a class.

   Class objects provide these attributes:
   __doc__ documentation string
   __module__  name of module in which this class was defined"""
   return isinstance(object, type)


correct




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


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

2016-02-25 Thread Jon Ribbens
On 2016-02-25, Steven D'Aprano  wrote:
> The links already provided go through the evidence. For example, they 
> explain that /dev/random and /dev/urandom both use the exact same CSPRNG. If 
> you don't believe that, you can actually read the source to Linux, FreeBSD, 
> OpenBSD and NetBSD. (But not OS X, sorry.)

Actually yes OS X:

http://www.opensource.apple.com/source/xnu/xnu-3248.20.55/bsd/dev/random/
http://www.opensource.apple.com/source/xnu/xnu-3248.20.55/osfmk/prng/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to define what a class is ?

2016-02-25 Thread eryk sun
On Thu, Feb 25, 2016 at 3:54 AM, ast  wrote:
> So we can conclude that inspect.isclass(x) is equivalent
> to isinstance(x, type)
>
> lets have a look at the source code of isclass:
>
> def isclass(object):
>"""Return true if the object is a class.
>
>Class objects provide these attributes:
>__doc__ documentation string
>__module__  name of module in which this class was defined"""
>return isinstance(object, type)

Except Python 2 old-style classes (i.e. 2.x classes that aren't a
subclass of `object`) are not instances of `type`. Prior to new-style
classes, only built-in types were instances of `type`. An old-style
class is an instance of "classobj", and its instances have the
"instance" type.

>>> class A: pass
...
>>> type(A)

>>> type(A())


Note that "classobj" and "instance" are instances of `type`.

The `isclass` check in Python 2 has to instead check
isinstance(object, (type, types.ClassType)).

>>> types.ClassType

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


Computational Chemistry Analysis

2016-02-25 Thread Feagans, Mandy
Dear Python,


Hi! I am a student interested in conducting computational analysis of 
protein-ligand binding for drug development analysis. Recently, I read of an 
individual using a python program for their studies of protein-ligand binding. 
As I have been reading about Python programs, however, all I have been able to 
find are programs that use the python script (i.e. Autodock). I was hoping to 
see if there were any programs specifically run through the python programming 
that ran similar analysis to Autodock?


Thank you for any assistance you may be able to provide!


Thank you,

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


Re: Computational Chemistry Analysis

2016-02-25 Thread Mark Lawrence

On 25/02/2016 01:01, Feagans, Mandy wrote:

Dear Python,

Hi! I am a student interested in conducting computational analysis of 
protein-ligand binding for drug development analysis. Recently, I read of an 
individual using a python program for their studies of protein-ligand binding. 
As I have been reading about Python programs, however, all I have been able to 
find are programs that use the python script (i.e. Autodock). I was hoping to 
see if there were any programs specifically run through the python programming 
that ran similar analysis to Autodock?

Thank you for any assistance you may be able to provide!

Thank you,

Mandy Feagans



I'll guess that you start here http://biopython.org/wiki/Main_Page

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: Testing whether the VPN is running?

2016-02-25 Thread Adam Funk
On 2016-02-23, Cameron Simpson wrote:

> On 18Feb2016 10:03, Adam Funk  wrote:
>>On 2016-02-18, Ervin Hegedüs wrote:
>>> I think that the psutil modul could be better for you for this
>>> task:
>>> https://pypi.python.org/pypi/psutil/
>>>
>>> and see the "Network" section.
>>
>>if 'tun0' in psutil.net_if_addrs():
>>   # vpn is running
>>
>>Brilliant!  I've used psutil for something else, but I didn't know it
>>did that too.  My excuse is that the version on my system was 2.2.1,
>>which does not do that, so I installed the newer version with pip3.
>>Thanks for pointing me to that.
>
> You might also want to check that the interface is up.
>
> My personal hack (not for a VPN, but for "being online", which turns my ssh 
> tunnels on and off) is to look in the output of "netstat -rn" for a default 
> route. This may imply that an alternative test for you is to test for a route 
> to your VPN's address range?  Just an idea.

Also interesting to know, thanks.


-- 
Mrs CJ and I avoid clichés like the plague.
-- 
https://mail.python.org/mailman/listinfo/python-list


Pyraf problem

2016-02-25 Thread Sapna Mishra
Dear Sir/Mam, 

I am using python for my astronomy purpose, for that I want to use PyRaf, but 
strange thing is occurring that pyraf is getting open as a root but out side my 
root user directory when I am typing pyraf I am getting like; 
No graphics/display possible for this session. 
Tkinter import failed. 
The numpy package is required by PyRAF and was not found. Please visit 
http://numpy.scipy.org 

I have added bath of pyraf in my bashrc file , I have even downloaded numpy but 
again it is showing same error. 

Any help will be highly appreciated. 
Thanks and regards, 
*
 
Sapna Mishra 
JRF 
Aryabhatta Research Institute of Observational Sciences (ARIES) 
Manora Peak 
Nainital-263002 
Uttarakhand (India) 
email: [email protected] 
[email protected] 

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


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

2016-02-25 Thread Random832
On Tue, Feb 23, 2016, at 03:22, Paul Rubin wrote:
> Thanks.  It would be nice if those were gatewayed to usenet like this
> group is.  I can't bring myself to subscribe to mailing lists.

Have you tried gmane?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: child.before taking almost 1 minute to execute

2016-02-25 Thread sruthi223
On Wednesday, February 24, 2016 at 3:59:01 PM UTC-5, Emile van Sebille wrote:
> On 2/24/2016 7:42 AM, pyfreek wrote:
> > The following snippet alone is taking 1 minute to execute. is there any 
> > best way to find 'No such file' other than using child.before
> >
> >  if not scrutinFile.startswith('/') :
> >  scrutinFile = '/'+ scrutinFile
> >  scrutinFileFtp = directory + scrutinFile
> >  filePath, file = os.path.split(scrutinFileFtp)
> >  p.sendline('cd %s'%(filePath))
> >  p.expect([pexpect.EOF,pexpect.TIMEOUT])
> >  if 'No such file' in p.before:
> >  print "No such directory exists!!"
> >  sys.exit(1)
> 
> I'd guess that you've got your p.expect line wrong -- it looks to me 
> like you're allowing that line to complete only upon seeing an EOF or 
> TIMEOUT, and that it's timing out as a result.
> 
> Emile

HI EMile,

Thanks for the reply. If I exit based only on EOF, then does it work?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: child.before taking almost 1 minute to execute

2016-02-25 Thread sruthi223
On Wednesday, February 24, 2016 at 4:10:13 PM UTC-5, Gregory Ewing wrote:
> pyfreek wrote:
> > The following snippet alone is taking 1 minute to execute. is there any 
> > best way to find 'No such file' other than using child.before
> > 
> > if not scrutinFile.startswith('/') :
> > scrutinFile = '/'+ scrutinFile
> > scrutinFileFtp = directory + scrutinFile
> > filePath, file = os.path.split(scrutinFileFtp)
> > p.sendline('cd %s'%(filePath))
> > p.expect([pexpect.EOF,pexpect.TIMEOUT])
> > if 'No such file' in p.before:
> > print "No such directory exists!!"
> > sys.exit(1)
> 
> If you're talking to an ftp client here, you might like
> to consider using the ftplib module in the standard
> library. It ought to take care of the messy details
> of error detection for you.
> 
> -- 
> Greg

Thanks greg, but my organization is using pexpect as a part of its libraries. 
so I am trying to use the same.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Computational Chemistry Analysis

2016-02-25 Thread Oscar Benjamin
On 25 February 2016 at 01:01, Feagans, Mandy  wrote:
> Hi! I am a student interested in conducting computational analysis of 
> protein-ligand binding for drug development analysis. Recently, I read of an 
> individual using a python program for their studies of protein-ligand 
> binding. As I have been reading about Python programs, however, all I have 
> been able to find are programs that use the python script (i.e. Autodock). I 
> was hoping to see if there were any programs specifically run through the 
> python programming that ran similar analysis to Autodock?


You may have better luck asking on the scipy user list:
http://www.scipy.org/scipylib/mailing-lists.html

Those lists are specifically for people doing scientific work with Python.

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


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

2016-02-25 Thread Dan Stromberg
On Wed, Feb 24, 2016 at 7:39 PM, Steven D'Aprano
 wrote:
> On Thursday 25 February 2016 12:07, Dan Stromberg wrote:
>
>> Could people please compare and contrast the two ways of doing imports
>> in the Subject line?
>
> from module import data; print(data)
>
> import module; print(module.data)

>> Is it fair to say that the former increases the surface area of your
>> shared (sometimes mutable) state?
>
> No, I can't say that it is. If anything, the opposite is the case: it
> decreases the surface area, because `data` now is local to the importing
> (not imported) module. Rebinding data will not affect anything else.

> There are two scenarios (`from module import...` versus `import ...`), each
> with two cases: mutation, and rebinding:
>
> (1) from module import data
>
> (a) Mutation (only applies to mutable data like lists, dicts etc)
>
> In place mutation affects everything relying on module.data regardless of
> how or where it is accessed.

We have some scenarios where "data" is an instance of a class, and we
need to monkey patch it for unit testing.

My intuition is telling me that "module.data; data.mutate()" would be
easier to monkey patch in a way that all modules will see.  Is that
fair to say?

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


Re: Pyraf problem

2016-02-25 Thread Steven D'Aprano
On Fri, 26 Feb 2016 01:37 am, Sapna Mishra wrote:

> Dear Sir/Mam,
> 
> I am using python for my astronomy purpose, for that I want to use PyRaf,
> but strange thing is occurring that pyraf is getting open as a root but


I am sorry, I don't understand what "getting open as a root" means.


> out side my root user directory when I am typing pyraf I am getting like;
> No graphics/display possible for this session. Tkinter import failed. The
> numpy package is required by PyRAF and was not found. Please visit
> http://numpy.scipy.org

Where are you getting this? Is it a Python traceback? If so, please copy and
paste the entire traceback, starting with the line:

Traceback

and ending with the last of the error message.

Where are you typing pyraf? In the Python interpreter or the operating
system shell? Is the prompt >>> or $ or something else?

Are you using the default Python interactive interpreter, IDLE, or some
third party IDE?

Please explain how you launch Python, e.g.:

"I double-click on the Python icon on the desktop"

"I open a terminal, and enter python at the shell prompt"


Or something else?

What version of Python are you using? What operating system?



> I have added bath of pyraf in my bashrc file , I have even downloaded
> numpy but again it is showing same error.

What have you added to your bashrc file? Did you add it to the PATH or the
PYTHONPATH?

What happens if you run this at the bash prompt?


python -c "import sys; print(sys.path)"


Do you see the path to pyraf in Python's path? (Python does not use the same
path as bash.)




-- 
Steven

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


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

2016-02-25 Thread Dan Stromberg
On Thu, Feb 25, 2016 at 8:15 AM, Dan Stromberg  wrote:
> On Wed, Feb 24, 2016 at 7:39 PM, Steven D'Aprano
>  wrote:
>> On Thursday 25 February 2016 12:07, Dan Stromberg wrote:
>>
>>> Could people please compare and contrast the two ways of doing imports
>>> in the Subject line?
>>
>> from module import data; print(data)
>>
>> import module; print(module.data)
>
>>> Is it fair to say that the former increases the surface area of your
>>> shared (sometimes mutable) state?
>>
>> No, I can't say that it is. If anything, the opposite is the case: it
>> decreases the surface area, because `data` now is local to the importing
>> (not imported) module. Rebinding data will not affect anything else.
>
>> There are two scenarios (`from module import...` versus `import ...`), each
>> with two cases: mutation, and rebinding:
>>
>> (1) from module import data
>>
>> (a) Mutation (only applies to mutable data like lists, dicts etc)
>>
>> In place mutation affects everything relying on module.data regardless of
>> how or where it is accessed.
>
> We have some scenarios where "data" is an instance of a class, and we
> need to monkey patch it for unit testing.
>
> Please ignore: My intuition is telling me that "module.data; data.mutate()" 
> would be
> easier to monkey patch in a way that all modules will see.  Is that
> fair to say?
>
> Thanks.

Correction!
My intuition is telling me that "module.data; module.data.mutate()"
would be easier to monkey patch in a way that all modules will see.
Is that fair to say?
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2016-02-25 Thread Ethan Furman

On 02/24/2016 07:39 PM, Steven D'Aprano wrote:


(2) import module

(a) Mutation is no different from (1)(a) above. No change.

(b) Rebinding `module.data = []` affects the imported module, and therefore
everything that relies on it.


More accurate: and therefore everything that has not already done a 
`from module import data` as those will be unaffected by the rebinding.


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


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

2016-02-25 Thread Ethan Furman

On 02/25/2016 08:20 AM, Dan Stromberg wrote:


My intuition is telling me that "module.data; module.data.mutate()"
would be easier to monkey patch in a way that all modules will see.
Is that fair to say?


It is fair to say that if you need to monkey-patch a module, you should 
import the module.  :)


You should also import it before anything else does to make sure your 
change is visible to all other code.


--
~Ethan~

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


ANN: pytest-nodev v0.9.3 - Test-driven code search

2016-02-25 Thread Alessandro Amici
I am pleased to announce the release of the new beta release of
pytest-nodev (was pytest-wish) a test-driven code search plugin for pytest:

https://pytest-nodev.readthedocs.org/en/stable/quickstart.html

Changes:
- renamed the package to pytest-nodev from pytest-wish (sorry!)
- refuse to run potentially dangerous `--wish-from-all` by default and...
- ... document how to run inside a container to safely enable all the
features
- simpler command line usage
- more documentation and references to the academic research on the
test-driven code search subject

Development effort is directed to fixing bugs and writing better
documentation before the 1.0 release. Help is welcomed and appreciated:

https://github.com/nodev-io/pytest-nodev

User questions are best directed to
http://stackoverflow.com/search?q=pytest-nodev and general questions can be
sent to [email protected].

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


Re: [Newbie] Tkinter Question

2016-02-25 Thread Randy Day
In article , 
[email protected] says...

[snip]

> Anyway, I am happy with the outcome even though I have
> not found a way to detect when the program is force
> killed.  It is unlikely that would ever occur as long

When your peogram starts, have it create
a small file. As part of your graceful
shutdown, delete the file.

Any subsequent processes can test for 
the existence of the file; if it exists, 
your program did not exit gracefully.

--- news://freenews.netfront.net/ - complaints: [email protected] ---
-- 
https://mail.python.org/mailman/listinfo/python-list


tcp networking question (CLOSE_WAIT)

2016-02-25 Thread Ray
hi,

I'm new to python networking. I am waiting TCP server/client app by using 
python built-in SocketServer. My problem is if client get killed, then the tcp 
port will never get released, in CLOSE_WAIT

maybe I didn't do the handler right? or anyway I can catch the client get 
killed?

I wrote following simple code to explain the issue I have, server listen on 
127.0.0.1:1234
client need to send multi-messages (I am sending 2 in this test) if client get 
killed (I just do kill client_pid) then if I check lsof, I will see the new 
allocated tcp do not get released 

server.py

#!/usr/bin/python
import threading
import SocketServer
import time

class TCPServerRequestHandler(SocketServer.BaseRequestHandler):

def handle(self):
while True:
data=self.request.recv(1024)
if not data:
time.sleep(0.1)
continue
print data
self.request.send(data)
if data=='end':
break

def main():
server = TCPServer(('127.0.0.1', 1234), TCPServerRequestHandler)
ip, port = server.server_address
server_thread = threading.Thread(target=server.serve_forever)
server_thread.daemon = True
server_thread.start()
time.sleep(600)
server.shutdown()
server.server_close()
if __name__=='__main__':
main()

client.py
import socket
import time

def client():
sock=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(('127.0.0.1', 1234))
sock.sendall('hello')
response=sock.recv(1024)
print "Received:", response
time.sleep(60)
sock.sendall('end')
response=sock.recv(1024)
print "Received:", response
sock.close()

if __name__=='__main__':
client()


when I run it, client has 60 seconds sleep, so I just kill the process from OS
kill 93948

then I'm running lsof to find my TCP/UDP 
lsof -n -p $(ps -ef|grep serve[r]|awk '{print $2}')|egrep '(TCP|UDP)'|awk 
'{print $NF}'

TCP 127.0.0.1:search-agent (LISTEN)
TCP 127.0.0.1:search-agent->127.0.0.1:59411 (CLOSE_WAIT)

I will see the CLOSE_WAIT, this is where the client get killed.


any help would be great!

Thanks a lot!
 
-- 
https://mail.python.org/mailman/listinfo/python-list


New Module: Bond - A Spy-Based Testing and Mocking Library

2016-02-25 Thread erikkrogen
Hi all -

As part of my work as a Computer Science Masters student at UC Berkeley I've 
been working with Prof. George Necula to develop a new testing library, called 
Bond, which introduces a new style of test assertions that we refer to as 
spy-based testing. Essentially, rather than explicitly coding all assertions 
about your test data, you allow the library to take observations of your 
state/variables/objects at specified "spy" points, and you can simply approve 
these observations when your code runs correctly to have them saved as 
reference observations for future runs of the test. This saves time when 
initially writing tests, but really shines when updating tests to new behavior, 
as we have an interactive flow that allows you to quickly reconcile differences 
in new behavior and old behavior (often without changing any code at all). 
There is a blog post with much more detailed information and examples available 
here: 
http://dreaming-neptune.blogspot.com/2016/02/bond-spy-based-testing-and-moc
 king.html, and the package is available on PyPI here: 
https://pypi.python.org/pypi/bond/ (you can `pip install bond` to install). 
Work on the library is ongoing so any feedback here or as comments on the blog 
would be much appreciated!

Thanks and enjoy!
Erik
-- 
https://mail.python.org/mailman/listinfo/python-list


Job opportunity - Sr. Python Developer - Morrisville, NC

2016-02-25 Thread Rohit Koul
Title: Senior Python Developer
Location: Morrisville, NC, United States
Contract : 6+ months

Description: 
Qualifications:

The Senior Python Developer will lead and serve as part of a team supporting 
established projects and creating products from the ground up. The ideal 
candidate is leader, a team player and is passionate about learning and 
applying their technical skills and experience to solve real-world problems.
Responsibilities:
- Contribute to the Architecture, Design and Development across the full stack 
of products.
- Work with multiple teams to guide and influence the architecture and design 
of the various products
- Investigating technologies that could benefit our development and success of 
our products

Thanks and regards,
Rohit

Rohit Koul 
Technical Recruiter
Email:[email protected]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: tcp networking question (CLOSE_WAIT)

2016-02-25 Thread Martin A. Brown

>I'm new to python networking. I am waiting TCP server/client app by 
>using python built-in SocketServer. My problem is if client get 
>killed, then the tcp port will never get released, in CLOSE_WAIT

I did not thoroughly review your code (other than to see that you 
are not using SO_REUSEADDR).  This is the most likely problem.

Suggestion:

  man 7 socket

Look for SO_REUSEADDR.  Then, apply what you have learned to your 
code.

-Martin

-- 
Martin A. Brown
http://linux-ip.net/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: tcp networking question (CLOSE_WAIT)

2016-02-25 Thread Ray
On Thursday, February 25, 2016 at 1:18:05 PM UTC-5, Martin A. Brown wrote:
> >I'm new to python networking. I am waiting TCP server/client app by 
> >using python built-in SocketServer. My problem is if client get 
> >killed, then the tcp port will never get released, in CLOSE_WAIT
> 
> I did not thoroughly review your code (other than to see that you 
> are not using SO_REUSEADDR).  This is the most likely problem.
> 
> Suggestion:
> 
>   man 7 socket
> 
> Look for SO_REUSEADDR.  Then, apply what you have learned to your 
> code.
> 
> -Martin
> 
> -- 
> Martin A. Brown
> http://linux-ip.net/

it's not I can't bind the address, my problem is: server is long run. if client 
die without "disconnect" then server will leak one socket. 

by using the built-in thread socket server. the extra tcp port are opened by 
built-in class itself.
if the handler() is finish correctly (the line with break) then this socket 
will get cleaned up. but if client dies, then I am never get out from that True 
loop. so the socket will keep in close_wait 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: tcp networking question (CLOSE_WAIT)

2016-02-25 Thread Ray
On Thursday, February 25, 2016 at 12:56:10 PM UTC-5, Ray wrote:
> hi,
> 
> I'm new to python networking. I am waiting TCP server/client app by using 
> python built-in SocketServer. My problem is if client get killed, then the 
> tcp port will never get released, in CLOSE_WAIT
> 
> maybe I didn't do the handler right? or anyway I can catch the client get 
> killed?
> 
> I wrote following simple code to explain the issue I have, server listen on 
> 127.0.0.1:1234
> client need to send multi-messages (I am sending 2 in this test) if client 
> get killed (I just do kill client_pid) then if I check lsof, I will see the 
> new allocated tcp do not get released 
> 
> server.py
> 
> #!/usr/bin/python
> import threading
> import SocketServer
> import time
> 
> class TCPServerRequestHandler(SocketServer.BaseRequestHandler):
> 
> def handle(self):
> while True:
> data=self.request.recv(1024)
> if not data:
> time.sleep(0.1)
> continue
> print data
> self.request.send(data)
> if data=='end':
> break
> 
> def main():
> server = TCPServer(('127.0.0.1', 1234), TCPServerRequestHandler)
> ip, port = server.server_address
> server_thread = threading.Thread(target=server.serve_forever)
> server_thread.daemon = True
> server_thread.start()
> time.sleep(600)
> server.shutdown()
> server.server_close()
> if __name__=='__main__':
> main()
> 
> client.py
> import socket
> import time
> 
> def client():
> sock=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> sock.connect(('127.0.0.1', 1234))
> sock.sendall('hello')
> response=sock.recv(1024)
> print "Received:", response
> time.sleep(60)
> sock.sendall('end')
> response=sock.recv(1024)
> print "Received:", response
> sock.close()
> 
> if __name__=='__main__':
> client()
> 
> 
> when I run it, client has 60 seconds sleep, so I just kill the process from OS
> kill 93948
> 
> then I'm running lsof to find my TCP/UDP 
> lsof -n -p $(ps -ef|grep serve[r]|awk '{print $2}')|egrep '(TCP|UDP)'|awk 
> '{print $NF}'
> 
> TCP 127.0.0.1:search-agent (LISTEN)
> TCP 127.0.0.1:search-agent->127.0.0.1:59411 (CLOSE_WAIT)
> 
> I will see the CLOSE_WAIT, this is where the client get killed.
> 
> 
> any help would be great!
> 
> Thanks a lot!


I fond the issue. it's my own stupid issue.
i did "continue" if no data received.
just break from it then it will be fine
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: tcp networking question (CLOSE_WAIT)

2016-02-25 Thread Martin A. Brown

Hello again Ray,

>> >I'm new to python networking. I am waiting TCP server/client app by 
>> >using python built-in SocketServer. My problem is if client get 
>> >killed, then the tcp port will never get released, in CLOSE_WAIT
>> 
>> I did not thoroughly review your code (other than to see that you 
>> are not using SO_REUSEADDR).  This is the most likely problem.
>>
>> Suggestion:
>> 
>>   man 7 socket
>> 
>> Look for SO_REUSEADDR.  Then, apply what you have learned to your 
>> code.
>
>it's not I can't bind the address, my problem is: server is long 
>run. if client die without "disconnect" then server will leak one 
>socket.

Sorry for my trigger-happy, and incorrect reply.

After so many years, I should know better than to reply without 
completely processing questions.  Apologies.

>by using the built-in thread socket server. the extra tcp port are 
>opened by built-in class itself. if the handler() is finish 
>correctly (the line with break) then this socket will get cleaned 
>up. but if client dies, then I am never get out from that True 
>loop. so the socket will keep in close_wait
>
>I fond the issue. it's my own stupid issue.
>i did "continue" if no data received.
>just break from it then it will be fine

Well, I'm glad you found the issue.

Best of luck,

-Martin

-- 
Martin A. Brown
http://linux-ip.net/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: tcp networking question (CLOSE_WAIT)

2016-02-25 Thread Ray
On Thursday, February 25, 2016 at 1:56:21 PM UTC-5, Martin A. Brown wrote:
> Hello again Ray,
> 
> >> >I'm new to python networking. I am waiting TCP server/client app by 
> >> >using python built-in SocketServer. My problem is if client get 
> >> >killed, then the tcp port will never get released, in CLOSE_WAIT
> >> 
> >> I did not thoroughly review your code (other than to see that you 
> >> are not using SO_REUSEADDR).  This is the most likely problem.
> >>
> >> Suggestion:
> >> 
> >>   man 7 socket
> >> 
> >> Look for SO_REUSEADDR.  Then, apply what you have learned to your 
> >> code.
> >
> >it's not I can't bind the address, my problem is: server is long 
> >run. if client die without "disconnect" then server will leak one 
> >socket.
> 
> Sorry for my trigger-happy, and incorrect reply.
> 
> After so many years, I should know better than to reply without 
> completely processing questions.  Apologies.
> 
> >by using the built-in thread socket server. the extra tcp port are 
> >opened by built-in class itself. if the handler() is finish 
> >correctly (the line with break) then this socket will get cleaned 
> >up. but if client dies, then I am never get out from that True 
> >loop. so the socket will keep in close_wait
> >
> >I fond the issue. it's my own stupid issue.
> >i did "continue" if no data received.
> >just break from it then it will be fine
> 
> Well, I'm glad you found the issue.
> 
> Best of luck,
> 
> -Martin
> 
> -- 
> Martin A. Brown
> http://linux-ip.net/


Thank you very much for reply and help.

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


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

2016-02-25 Thread sohcahtoa82
On Wednesday, February 24, 2016 at 5:07:57 PM UTC-8, Dan Stromberg wrote:
> Could people please compare and contrast the two ways of doing imports
> in the Subject line?
> 
> I've long favored the latter, but I'm working in a code base that
> prefers the former.
> 
> Is it fair to say that the former increases the surface area of your
> shared (sometimes mutable) state?
> 
> It's clear that the former saves keystrokes.
> 
> I find the latter a little more clear, because you don't have to go
> look for where a symbol came from.
> 
> Anything else?
> 
> Thanks!

If I'm only importing a single class or function from a module AND that class 
or function has a very meaningful name, I will use "from MyModule import 
MyUsefulClass".  Otherwise, I just use "import MyModule".

Now, I've noticed people talking about importing os.path.  Is there any reason 
to use "import os.path" rather than "import os"?  Both of them will still put 
the "os" module into the global namespace.
-- 
https://mail.python.org/mailman/listinfo/python-list


Use the Python Job Board for recruitment (was: Job opportunity - Sr. Python Developer - Morrisville, NC)

2016-02-25 Thread Ben Finney
Rohit Koul  writes:

> Title: Senior Python Developer
> Location: Morrisville, NC, United States

Please do not use the Python discussion forum for recruitment.

Instead, use the Python Job Board which is explicitly for this purpose
https://www.python.org/jobs/>.

-- 
 \   “One of the most important things you learn from the internet |
  `\   is that there is no ‘them’ out there. It's just an awful lot of |
_o__)‘us’.” —Douglas Adams |
Ben Finney 
-- 
https://mail.python.org/mailman/listinfo/python-list


Looking for examples of using aiopg with aiohttp and non-async startup.

2016-02-25 Thread Ray Cote
Hello:

I have an aiohttp project that starts in the usual way:

app = web.Application()
app.router.add_route(‘POST”, ‘/‘, handler)
web.run_app(app)

My question is, how do I work with an aiopg.pool with aiohttp?
There only seems to be async interfaces into aiopg — but I don’t want to
create the pool in my handler since that requires a connection on each
transaction.

I found one example that was
  app[“db”] = await aiopg.create_pool(dsn)
but that doesn’t seen correct since we’re not yet in a loop.

Can someone please provide an example showing the proper way to integrate
aiopg pool into an aiohttp web application?

Regards
—Ray

-- 
Raymond Cote, President
voice: +1.603.924.6079 email: [email protected] skype:
ray.cote
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2016-02-25 Thread Gregory Ewing

[email protected] wrote:

Now, I've noticed people talking about importing os.path.  Is there any
reason to use "import os.path" rather than "import os"?  Both of them will
still put the "os" module into the global namespace.


In the case of os.path it doesn't matter, because the
os module imports the appropriate path module automatically.

But in general, importing a package won't necessarily
import submodules under it, so sometimes you need to
import somepackage.somemodule explicitly.

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


Re: Testing whether the VPN is running?

2016-02-25 Thread Dan Stromberg
On Thu, Feb 18, 2016 at 1:45 AM, Ervin Hegedüs  wrote:
> Hi Adam,
>
> On Thu, Feb 18, 2016 at 09:26:58AM +, Adam Funk wrote:
>> I'd like to test (inside a python 3 program) whether the VPN is
>> running or not.  The only thing I can think of so far is to use
>> subprocess to run the 'ifconfig' command, then check its output for
>> 'tun0'.  Is there a better way?
>
> you didn't wrote, which system (OS) you want to use - based on
> the "ifconfig" and "tun0" keywords, possible that's a Linux.
>
> I think that the psutil modul could be better for you for this
> task:
>
> https://pypi.python.org/pypi/psutil/
>
> and see the "Network" section.

psutil is probably clean on Linux.

However, using the subprocess module to run ifconfig -a and check for
tun0 / utun0 should get you compatibility with both Linux and Mac.

Note that if I'm running a Linux in a VMware, and it's hosted on a
Mac, and the Mac has one of my VPN's up, then the Linux doesn't have a
tun0, but it can still see stuff only accessible via that VPN.

For that, it might be better to try ping'ing some host that's behind
the VPN.  In a way, that's a better test anyway.
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2016-02-25 Thread Ben Finney
Gregory Ewing  writes:

> [email protected] wrote:
> > Now, I've noticed people talking about importing os.path.  Is there any
> > reason to use "import os.path" rather than "import os"?  Both of them will
> > still put the "os" module into the global namespace.
>
> In the case of os.path it doesn't matter, because the
> os module imports the appropriate path module automatically.

My position is that behaviour violates one of the principles of the Zen
of Python: “Special cases aren't special enough to break the rules.”

> But in general, importing a package won't necessarily
> import submodules under it, so sometimes you need to
> import somepackage.somemodule explicitly.

Because that's normally the case, I choose not to rely on that special
behaviour of ‘os’. If I need ‘os.path’, I import it explicitly so no
reader needs to guess::

import os
import os.path

-- 
 \   “Crime is contagious… if the government becomes a lawbreaker, |
  `\  it breeds contempt for the law.” —Justice Louis Brandeis |
_o__)  |
Ben Finney

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


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

2016-02-25 Thread Steven D'Aprano
On Fri, 26 Feb 2016 10:38 am, Ben Finney wrote:

> Gregory Ewing  writes:
> 
>> [email protected] wrote:
>> > Now, I've noticed people talking about importing os.path.  Is there any
>> > reason to use "import os.path" rather than "import os"?  Both of them
>> > will still put the "os" module into the global namespace.
>>
>> In the case of os.path it doesn't matter, because the
>> os module imports the appropriate path module automatically.
> 
> My position is that behaviour violates one of the principles of the Zen
> of Python: “Special cases aren't special enough to break the rules.”


But it's not special. It's the standard behaviour of any module which offers
a public name: `import os` makes all the names in the os name space
available. There's no difference between (say) `os.listdir` and `os.path`
except that listdir happens to be a function and path happens to be a
module.

`path` has been a documented public attribute of the `os` module since at
least Python 1.5:

[steve@ando ~]$ python1.5 -c "import os; print os.path"



and likely older. The documentation from help(os) says:

DESCRIPTION
This exports:
  - all functions from posix, nt, os2, mac, or ce, e.g. unlink, 
stat, etc.
  - os.path is one of the modules posixpath, ntpath, or macpath

(The above is from 2.4, the oldest Python I have that supports docstrings;
in 3.3 it is substantially the same except macpath is removed.)


Since `os` is not a package, the fact that importing `os.path` works at all
is surprising. The os module has to make a special effort to support
importing os.path. From the source code:

sys.modules['os.path'] = path

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
merely happens to be a module. Being a module doesn't make it special, it's
just another name in the os namespace. I trust that you wouldn't insist on
writing:

import os.listdir

(especially since that doesn't work). Neither should you insist on writing
`import os.path`, since path is documented as a public part of the os
module. It has done so since at least Python 1.5.


>> But in general, importing a package won't necessarily
>> import submodules under it, so sometimes you need to
>> import somepackage.somemodule explicitly.
> 
> Because that's normally the case, I choose not to rely on that special
> behaviour of ‘os’. If I need ‘os.path’, I import it explicitly so no
> reader needs to guess::
> 
> import os
> import os.path

As I have shown above, the fact that os.path is importable at all is the
special case.



-- 
Steven

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


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
> merely happens to be a module. Being a module doesn't make it special, it's
> just another name in the os namespace. I trust that you wouldn't insist on
> writing:
>
> import os.listdir
>
> (especially since that doesn't work). Neither should you insist on writing
> `import os.path`, since path is documented as a public part of the os
> module. It has done so since at least Python 1.5.

I disagree. The fact that os is not a package is an implementation
detail. I for one wasn't even aware of it prior to reading your post.

The name of the concurrent.futures module is "concurrent.futures". If
you want to use it, you import concurrent.futures, not concurrent.

Likewise, the name of the os.path module is "os.path". If you want to
use it, you import os.path, not os.

The fact that concurrent and os are two different types of things is irrelevant.

Besides, packages *are* modules. To take another example, collections
is a package (I checked), and collections.abc is a module. But
collections also contains things that aren't modules. If you want to
use collections.abc, you have to import it, but at the same time you
don't import collections.Counter. This demonstrates that the analog
you suggest between os.path and os.listdir is flawed.
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2016-02-25 Thread Chris Angelico
On Fri, Feb 26, 2016 at 2:56 PM, Ian Kelly  wrote:
> 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
>> merely happens to be a module. Being a module doesn't make it special, it's
>> just another name in the os namespace. I trust that you wouldn't insist on
>> writing:
>>
>> import os.listdir
>>
>> (especially since that doesn't work). Neither should you insist on writing
>> `import os.path`, since path is documented as a public part of the os
>> module. It has done so since at least Python 1.5.
>
> I disagree. The fact that os is not a package is an implementation
> detail. I for one wasn't even aware of it prior to reading your post.
>
> The name of the concurrent.futures module is "concurrent.futures". If
> you want to use it, you import concurrent.futures, not concurrent.
>
> Likewise, the name of the os.path module is "os.path". If you want to
> use it, you import os.path, not os.
>
> The fact that concurrent and os are two different types of things is 
> irrelevant.
>
> Besides, packages *are* modules. To take another example, collections
> is a package (I checked), and collections.abc is a module. But
> collections also contains things that aren't modules. If you want to
> use collections.abc, you have to import it, but at the same time you
> don't import collections.Counter. This demonstrates that the analog
> you suggest between os.path and os.listdir is flawed.

Steven is right, though. You can "from module import X" and it doesn't
matter whether 'module' is a package or a non-package module; but if
you say "import module.X", aside from special cases like os.path,
you're asserting that 'module' is a package and 'X' is a module within
that package. Yes, a package is a module, but the dotted lookup
requires a package.

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


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

2016-02-25 Thread Ben Finney
Steven D'Aprano  writes:

> On Fri, 26 Feb 2016 10:38 am, Ben Finney wrote:
>
> > Gregory Ewing  writes:
> > 
> >> [email protected] wrote:
> >> > Now, I've noticed people talking about importing os.path.  Is there any
> >> > reason to use "import os.path" rather than "import os"?  Both of them
> >> > will still put the "os" module into the global namespace.
> >>
> >> In the case of os.path it doesn't matter, because the
> >> os module imports the appropriate path module automatically.
> > 
> > My position is that behaviour violates one of the principles of the Zen
> > of Python: “Special cases aren't special enough to break the rules.”
>
> But it's not special. It's the standard behaviour of any module which offers
> a public name

That is the special behaviour. ‘os’ is a package that has a sub-module
‘path’. Normally, to get at a module inside a package, you import it
with a qualified name::

import os.path

The special case is that ‘os’ also wants the ‘path’ module itself, and
so the name happens to be available as a module attribute. That's a
special case that can not be depended on for other cases.

> `import os` makes all the names in the os name space available.

Since ‘os.path’ is a sub-module of the ‘os’ package, it should not also
be exported from the ‘os’ module attributes. The special case is confusing.

> There's no difference between (say) `os.listdir` and `os.path` except
> that listdir happens to be a function and path happens to be a module.

There's no difference between ‘logging.info’ and ‘logging.config’ except
that ‘info’ happens to be a function and ‘config’ happens to be a
module.

The difference is salient::

>>> import logging
>>> logging.info

>>> logging.config
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: module 'logging' has no attribute 'config'

That's the case normally, when one name is primarily an attribute and
another name is primarily a sub-module. The ‘os.path’ case is not
special enough to break that rule IMO.

> `path` has been a documented public attribute of the `os` module since at
> least Python 1.5:

Then it's been violating that principle for that long :-)

> If you take "Special cases are not special enough" seriously, you will
> not use `import os.path` since os is not a package

The implementation is special. That doesn't exempt it from the principle
that a special case isn't special enough to break expectations.

> and os.path is not part of os, it's just a publicly exposed attribute
> which merely happens to be a module.

You seem to be making my case for me: ‘os’ is indeed special. It goes to
some legth to hide that specialness; I think it doesn't go far enough.

-- 
 \ “If you don't want your beliefs to be ridiculed, don't have |
  `\such ridiculous beliefs.” —Greta Christina, 2011-10-22 |
_o__)  |
Ben Finney

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


Re: Computational Chemistry Analysis

2016-02-25 Thread Mike S via Python-list

On 2/25/2016 7:31 AM, Oscar Benjamin wrote:

On 25 February 2016 at 01:01, Feagans, Mandy  wrote:

Hi! I am a student interested in conducting computational analysis of 
protein-ligand binding for drug development analysis. Recently, I read of an 
individual using a python program for their studies of protein-ligand binding. 
As I have been reading about Python programs, however, all I have been able to 
find are programs that use the python script (i.e. Autodock). I was hoping to 
see if there were any programs specifically run through the python programming 
that ran similar analysis to Autodock?



You may have better luck asking on the scipy user list:
http://www.scipy.org/scipylib/mailing-lists.html
Those lists are specifically for people doing scientific work with Python.
Oscar


HtH
http://www.ncbi.nlm.nih.gov/pmc/articles/PMC3607193/
--
https://mail.python.org/mailman/listinfo/python-list


Speech recognition and synthesi in Python

2016-02-25 Thread Mike S via Python-list

Pretty nice example code...

https://ggulati.wordpress.com/2016/02/24/coding-jarvis-in-python-3-in-2016/
--
https://mail.python.org/mailman/listinfo/python-list


Cycling through iterables diagonally

2016-02-25 Thread Pablo Lucena
Hello,

I am trying to accomplish the following:

Say I have a group of 4 lists as follows:

l1 = ['a1', 'a2', 'a3', 'a4']
l2 = ['b1', 'b2', 'b3', 'b4']
l3 = ['c1', 'c2', 'c3', 'c4']
l4 = ['d1', 'd2', 'd3', 'd4']

I would like to cycle through these lists "diagonally" in groups of
len(list) (in this example, each list has 4 items).

cycle1: a1, b2, b3, b4
cycle2: a2, b3, c4, d1
cycle3: a3, b4, c1, d2
cycle4: a4, b1, c2, d3

The way I thought about doing this is as follows:

from collections import deque
from itertools import cycle

l1 = deque(['a1', 'a2', 'a3', 'a4'])
l2 = deque(['b1', 'b2', 'b3', 'b4'])
l3 = deque(['c1', 'c2', 'c3', 'c4'])
l4 = deque(['d1', 'd2', 'd3', 'd4'])

l1.rotate(-0)
l2.rotate(-1)
l3.rotate(-2)
l4.rotate(-3)

groups = cycle([l1, l2, l3, l4])

In [115]: for group in groups:
   .: if not group:
   .: break
   .: print(group.popleft())
   .:
a1
b2
c3
d4
a2
b3
c4
d1
a3
b4
c1
d2
a4
b1
c2
d3

Prior to this I was mucking around with index counting while looping, and
popping lists out of a deque, popping an item out of the list, and
appending the list back into the deque during each iteration.

Is there a better/cleaner way to do this? I was hoping for some cool
itertools logic =)

Thanks!


-- 
*Pabl​o​*
-- 
https://mail.python.org/mailman/listinfo/python-list