Here is an MWE:
import io
from lxml import etree
test_node = etree.fromstring('''
http://schemas.xmlsoap.org/soap/envelope/";
xmlns:ns1="http://docs.oasis-open.org/ws-sx/ws-trust/200512";>
''')
output = io.BytesIO(b'')
test_node.getroottree().write(output,
enc
> Result:
>
> Traceback (most recent call last):
> File "C:/not_telling/c14n.py", line 16, in
> short_empty_elements=False
> File "lxml.etree.pyx", line 1869, in lxml.etree._ElementTree.write
> (src\lxml\lxml.etree.c:57004)
> TypeError: write() got an unexpected keyword argument 'short_em
> https://docs.python.org/3/library/xml.etree.elementtree.html#xml.etree.ElementTree.ElementTree.write
>
> The argument was added in Python 3.4. Presumably, lxml implemented the
> API before this change.
>
> Maybe this would be considered a bug by lxml. Maybe it won't.
Maybe it is not a bug, just
Hi!
I have a multi threaded Windows service written in Python. It is running
on 3.6.2. Sometimes I cannot stop the service, because on of the
threads won't exit. I have narrowed down the problem to request and
_lib.SSL_read. I have used a modified version of this gem:
http://code.activestate.com/
2018. 01. 13. 15:03 keltezéssel, Jon Ribbens írta:
> On 2018-01-13, Nagy László Zsolt wrote:
>> I have a multi threaded Windows service written in Python. It is running
>> on 3.6.2. Sometimes I cannot stop the service, because on of the
>> threads won't exit. I have
> (a) are you setting daemon=True on the thread?
> (b) are you setting a timeout on the requests call?
Hmm setting the timeout might not be the solution. This is from the docs
of the requests module:
>
> Note
>
> |timeout| is not a time limit on the entire response download; rather,
> an exception
> In other words: if the server starts to send the response, but then
> stops sending it (without closing the connection), then this will block
> forever anyway.
Or maybe I misunderstood the docs and the timeout means the max. time
elapsed between receiving two chunks of data from the server?
--
>> Or maybe I misunderstood the docs and the timeout means the max. time
>> elapsed between receiving two chunks of data from the server?
> Yes. It's documented better here:
> http://docs.python-requests.org/en/master/user/advanced/#timeouts
>
> You can't specify a "total time" within which the op
Hello,
I'm having problems finding the "preferrably one" way to convert a
datetime instance into an xs:datetime string.
Here is an example datetime instance with is format:
dt = datetime.now()
print(dt.isoformat()) # prints "2016-08-26 12:41:13.426081+02:00"
print(dt.strftime('%Y-%m-%dT%H:%M:
Example code:
class A:
def __init__(self, prop=0):
self.__prop = prop
@property
def prop(self):
return self.__prop
@prop.setter
def prop(self, value):
self.__prop = value
class B(A):
@A.prop.setter
def prop(self, value):
print
By the way, I know that I can use a "property virtualizer", something
like this:
import inspect
class A:
def __init__(self, prop=0):
self.__prop = prop
def _prop_get(self):
return self.__prop
def _prop_set(self, value):
self.prop_set(value)
> Even the problem seems to rather defeat the purpose of a property. A
> property should be very simple - why do you need to override it and
> call super()? Doesn't this rather imply that you've gone beyond the
> normal use of properties *already*?
I'm not sure about that. I'm going to send a USE
> Even the problem seems to rather defeat the purpose of a property. A
> property should be very simple - why do you need to override it and
> call super()? Doesn't this rather imply that you've gone beyond the
> normal use of properties *already*?
Here are some of my classes that can represent da
Yes, I believe it does. (Others may disagree. This is a design
question and very much a matter of style, not hard fact.) I would have
an explicit action "set_content" which will set the value of an input
field, the inner text of a textarea, the checked state of a check box,
etc.
In other words,
> Yes, the get part works. The set part is a pain, and a bit ugly:
>
> super(B, B).foo.__set__(self, value)
>
> There is an issue for this on the tracker:
> http://bugs.python.org/issue14965
>
Thank you Ethan!
The superprop pure Python implementation is very promising. (
http://bugs.python.or
The result that I need should be a real dict, not just a ChainMap. (It
is because I have to mutate it.)
d1 = {'a':1, 'b':2}
d2 = {'c':3, 'd':4}
d3 = {'e':5, 'f':6}
#1. My first naive approach was:
from collections import ChainMap
d = {}
for key,value in ChainMap(d1, d2, d3).items():
d[key]
On Wed, Sep 28, 2016 at 12:54 AM, Jussi Piitulainen
> wrote:
>> I wasn't sure if it makes a copy or just returns the dict. But it's
>> true: help(dict) says dict(mapping) is a "new dictionary initialized
>> from a mapping object's (key, value) pairs".
> Yep. With mutable objects, Python's docs ar
Hello,
Is it possible to write a win32 service with 64 bit python 3.5? The
pywin32 package does exist on 3.5 64bit, but missing some modules:
>>> import win32service
Traceback (most recent call last):
File "", line 1, in
ImportError: DLL load failed:The specified module could not be found.
>> Is it possible to write a win32 service with 64 bit python 3.5? The
>> pywin32 package does exist on 3.5 64bit, but missing some modules:
> Try pip installing the "pypiwin32" package.
That worked, thanks.
Do you have an explanation why to official build (
https://sourceforge.net/projects/pywi
>> def main(self):
>> self.ReportServiceStatus(win32service.SERVICE_RUNNING)
>> while not self.stop_requested.is_set():
>> time.sleep(1) # So something useful here
> Why don't you use the Windows Event (hWaitStop) with
> WaitForSingleObject instead of an additional
>> But again, that is not related to the question. Why does it not work?
>> What is missing?
> If you mean why running the service doesn't work, it should once you
> run the post-install script that copies pywintypes35.dll to the
> Windows System32 directory. This DLL is required by PythonService.
> On Wed, Oct 5, 2016 at 7:43 AM, Nagy László Zsolt
> wrote:
>> It did not help. I still get the same error message (service did not
>> respond in time).
> Can you run the service executable directly? From the command line
> check `sc qc TestService`. Run the BINARY_P
>
> The MWE I provided is so simple. By now, It should be obvious what is
> missing from it. :-(
>
>
The problem is NOT with my code. I just installed a new virtual machine,
and installed python3.5 amd64 + pypiwin32 on it. On that machine, the
test service works perfectly!
So it is with my machin
>> "C:\Users\Laci\AppData\Local\Programs\Python\Python35\lib\site-packages\win32\PythonService.exe"
> I wanted you to run the above executable, not python.exe. If it fails
> you'll get more information about why it's failing when run directly
> then when the service controller runs it. Since you'r
Hello!
I wonder what kind of XSD <-> Python class mapper should I use for my
project. I need something that can generate classes from XSD files, and
then parse XML to an objecttree and also dump object trees to XML. I'll
be using Python version 3.6 and I would prefer to use something that is
b
Hello,
I need to compare sets of datetime intervals, and make set operations on
them: intersect, union, difference etc. One element of a set would be an
interval like this:
element ::= (start_point_in_time, end_point_in_time)
intervalset ::= { element1, element2, }
Operations on element
Hi All,
If anyone is interested, a module was born:
https://bitbucket.org/nagylzs/intervalset
https://pypi.python.org/pypi/intervalset/0.1.1
I have some unit tests, but testers and comments are welcome.
Also see below.
>>
>> Hello,
>>
>> I need to compare sets of datetime intervals, and
>
> On Fri, Apr 1, 2016 at 1:32 AM Nagy László Zsolt <mailto:gand...@shopzeus.com>> wrote:
>
> Does anyone know a library that already implements these functions?
>
>
> What do you not like about the ones on PyPI?
> https://pypi.python.org/pypi?%3Aaction=s
>> element ::= (start_point_in_time, end_point_in_time)
>> intervalset ::= { element1, element2, }
>>
>> Operations on elements:
>
> Eh... I think these should be realized as operations on an intervalset
> with a single element, and that elements should simply have properties
> like the start
> Why do you limit the intervals to datetime? Are there any assumptions in
> your code that would make it fail with int values?
Just one. The empty interval is a singleton and I want it to be smaller
than any other interval.
UTC_ZERO = datetime.datetime.utcfromtimestamp(0)
EMPTY_INTERVAL = Inte
> Why do you limit the intervals to datetime? Are there any assumptions in
> your code that would make it fail with int values?
It has been generalized. Now it can be used with any immutable ordered
type. :-)
--
https://mail.python.org/mailman/listinfo/python-list
> I don't know if I like it being immutable. Maybe have separate mutable
> and immutable versions.
The reason for making it immutable is implementation specific. These
intervals are stored in an ordered list. Overlapping intervals are
unified by the constructor. This makes sure that sets with equa
> Yes, my question is why it's useful to have a single Interval as a
> *distinct* type, separate from the interval set type, which supports a
> sharply limited number of set-like operations (such as the union of two
> overlapping intervals but NOT two non-overlapping ones). This doesn't
> appear t
>> It is blurred by design. There is an interpretation where an interval
>> between [0..4] equals to a set of intervals ([0..2],[2..4]).
> No, because 2.5 is in one and not the other.
My notation was: 0..4 for any number between 0 and 4. And 2..4 for any
number between 2 and 4. So yes, 2.5 is in
>> How about creating two classes for this? One that supports zero sized
>> intervals, and another that doesn't?
> If you don't want zero sized intervals, just don't put any in it. You
> don't have a separate list type to support even integers vs one that
> supports all floats. What operations are
> Sorry to be late to the party--I applaud that you have already
> crafted something to attack your problem. When you first posted,
> there was a library that was tickling my memory, but I could not
> remember its (simple) name. It occurred to me this morning, after
> you posted your new lib
Today I come across this problem for the N+1st time. Here are some
classes for the example:
class Observable:
"""Implements the observer-observable pattern."""
def __init__(self):
# initialization code here...
super(Observable, self).__init__()
class AppServerSessionMixi
>
> In Python 3, that will be automatic and you don't need to worry about it.
I'm using Python 3. I'm aware of old style and new style classes in
Python 2.
>
>
> [...]
>> class BootstrapDesktop(BootstrapWidget, BaseDesktop):
>> def __init__(self, appserver, session):
>> # there is NOT
> Raymond Hettinger gives an excellent presentation where he describes various
> problems with MI and gives solutions for them. I think this might be it:
>
> http://pyvideo.org/video/1094/the-art-of-subclassing-0
This is a much better version from one year later:
https://www.youtube.com/watch?v=m
>> But I have to initialize some default attributes.
> Then the statement “there is NOTHING else here” must be false. Either
> the custom ‘__init__’ does something useful, or it doesn't.
Well... the custom __init__ method with nothing else just a super() call
was expressed there to show the super
>> That's overly strict. As Raymond shows, it is easy to deal with
>> changing method signatures in *cooperative* classes.
> I must watch that for sure.
All right, I have read this:
https://rhettinger.wordpress.com/2011/05/26/super-considered-super/
There is still something I don't get: how to
Is the problem that the attribute or parameter has the same name in both
base classes, but has different meanings in each?
If they had different meanings, a simple rename would solve the problem.
They have the same meaning.
If you can't change the base classes, I've got some other solutions,
def getsMeet(files=file_list):
"""Get a File or List of Files.
From the list of files determine
what meetings exist and prepare them
to be parsed
"""
pyqFiles = []
for filename in sorted(file_list):
pyqFiles = pyqFiles.append(pq(filename=my_dir + file
>
> Things to know about super:
> Part 1 http://www.artima.com/weblogs/viewpost.jsp?thread=236275
> Part 2 http://www.artima.com/weblogs/viewpost.jsp?thread=236278
> Part 3 http://www.artima.com/weblogs/viewpost.jsp?thread=237121
>
> The wonders of super:
> http://www.artima.com/weblogs/viewpost.j
class Test:
def test(self, child : Test):
pass
NameError: name 'Test' is not defined
I understand that the class "Test" is not defined until the class
definition is executed. But it is very very common to build recursive
data structures, and I have concrete use case where the IDE did
>> pass
>>
>> NameError: name 'Test' is not defined
> I think you can fix this by using a string annotation as follows:
>
> class Test:
> def test(self, child: "Test"):
> pass
Yes, you are right. It is not directly written in the official
documentation ( https://doc
class Test:
def __init__(self):
self._parent = None
@property
def parent(self):
return self._parent
@parent.setter
def set_parent(self, new_parent):
self._parent = new_parent
p, c = Test(), Test()
c.parent = p
>py -3 test.py
Traceback (most recent c
>> @parent.setter
>> def set_parent(self, new_parent):
>> self._parent = new_parent
> This creates a settable property with the name "set_parent" and leaves the
> read-only property "parent" alone.
Yes, and more. That property will also have a get method! Is it intentional?
--
h
Hi,
I would like to create a collections.UserList subclass that can notify
others when the list is mutated. I'm not sure which methods I need to
override. I have checked the sources, and it seems difficult to figure
out which methods needs to be overriden. For example,
MutableSequence.extend i
>> Yes, and more. That property will also have a get method! Is it
>> intentional?
> It's a logical effect of how the setter() method works. The above is
> syntactic sugar for
>
> def set_parent(...):
>...
> set_parent = parent.setter(set_parent)
>
> and parent.setter() creates a new property
>> Is there a way to easily find out which methods of are mutating the
>> collection? Other than going over the source and checking all (normal
>> and inherited) methods?
> How about
>
> set(dir(collections.UserList)) - set(dir(collections.Sequence))
Thanks. It narrows down the list of possible me
> Using the built-in list or dict is problematic because sometimes the
> subclass methods are ignored when the internal data is accessed (sorry, I
> don't have an example).
Are you suggesting that I should use UserList and UserDict instead of
list and dict? What is the truth? Was UserDict left i
> @wrap_notify('remove', 'clear', 'append', 'insert', 'sort'):
> class ObservableList(ObservableCollection, list):
> pass
>
> I just can't find out the right syntax.
>
>
All right, this is working.
from contextlib import contextmanager
class ObservableCollection:
@contextmanager
def
> [Looks like you made progress while I struggled to come up with the
> following. I'll post it anyway.]
Your version is much better. Thanks! :-)
--
https://mail.python.org/mailman/listinfo/python-list
2016.06.10. 0:38 keltezéssel, Michael Selik írta:
> On Thu, Jun 9, 2016 at 5:07 AM Nagy László Zsolt <mailto:gand...@shopzeus.com>> wrote:
>
> I would like to create a collections.UserList subclass that can notify
> others when the list is mutated.
>
>
> Wh
Does anyone know a module that can be used to write a before-queue,
smtpd time milter with Python 3?
Unfortunately, pymilter does not work with Python 3:
Downloading
https://pypi.python.org/packages/58/2f/d4799c9cade461177955ca19ade6ca55385286f066c0db9a0770a332ab8a/pymilter-1.0.tar.gz#md5=ec9b95f
On 2016-06-23, MRAB wrote:
>> On 2016-06-23 21:58, David Shi via Python-list wrote:
>>> Can any one tell me?
>>> Regards.
>>> David
>>>
>> There's one in the standard library.
> Which has always worked fine for me...
Which always reminds me:
>>> import json
>>> d = {0:1, False:2}
>>> d
{0: 2}
>>>
> Thanks, I'm in the same position as you, except that I'm in the position
> where I need it use the result, and if it ever returns INF my function will
> blow up. But it doesn't look like that can happen.
>
Doesn't atan2 relies on the C lib math floating point library? At least
in CPython. I thin
Hello!
We have a system where we have to create an exact copy of the original
database for testing. The database size is over 800GB. We have found
that using zfs snapshots and zfs clone is the best option. In order to
do this, you have to enable journaling in mongodb. Then you can take a
snap
Hello,
It depends on the operating system. For example on Ubuntu, the default
python version is still 2.7. When you install both python2.7 and python3
on a system, then usually the "pip" will be a symlink to pip version 2
or 3. The default python interpreter can be different on different system
Pure python module that let’s you upload *huge* files to a tornado web
server.
This project provides the
|tornadostreamform.multipart_streamer.MultiPartStreamer| class that
incrementally parses incoming multipart/form-data, splits it into form
fields, and streams the fields into file like objects
> PyPi: https://pypi.python.org/pypi/tornadostreamform
> Documentation: https://pypi.python.org/pypi/tornadostreamform
Wrong paste. Here is the good one:
https://pythonhosted.org/tornadostreamform/
--
https://mail.python.org/mailman/listinfo/python-list
> a=10
>
> 'a' is an integer. Is it an object too?
In Python, objects have an identity. When you do "a=10" then you *bind*
the object to the name *a*. By "variable", the documentation refers to a
name that was bound to an object. This is different from many other low
level languages. For example:
I ran into a problem today where I had to determine the mean point
between two datetimes. Here is an example:
>>> start = datetime.datetime(2016,2,11)
>>> stop = datetime.datetime.now()
>>> mean = start + (stop-start)*0.5
Traceback (most recent call last):
File "", line 1, in
TypeError: unsuppo
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 r
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
> 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
m
here ismy code in python
for i in range(0,60):
driver.execute_script("window.scrollTo(0,
document.body.scrollHeight);")
# i want status code here"
time.sleep(1)
Status of what? Are you asking the HTTP status of the page downloaded?
That has nothing to do with you
I have Python 3.3 installed on my Windows 7 x64 box. Today I had to
install Python 2.7 for an older app of mine.
Here is my problem: although "#!/usr/bin/env python3" is given in the
file and "py -3" program works fine, apparently the installation of
python 2 simply has overwritten my settings
From a cmd window:
ftype python.file="C:\Windows\py.exe" "%1" %*
ftype python.noconfile="C:\Windows\pyw.exe" "%1" %*
TJG
Thank you. It worked. Although I must note that it only works if you
start the cmd.exe as administrator (under Windows 7).
Is it the only thing that was possibly overw
From a cmd window:
ftype python.file="C:\Windows\py.exe" "%1" %*
ftype python.noconfile="C:\Windows\pyw.exe" "%1" %*
There is a serious problem with this! Example code test.py:
#!/usr/bin/env python3
import sys
print(sys.argv)
Test run:
C:\Temp>test.py 1 2 3
['C:\\Temp\\test.py']
This is
Just because I have a distrust of Windows's command interpreter, what
happens when you type:
ftype python.file
? Does it echo back what you thought it had, or has %* been eaten? If
the %* is missing, that would explain the loss of arguments.
Already tought of that:
C:\Temp>ftype python.fil
I should emphasize that this is with the /same/ x.y version...
Installing 3.3 when the previous was 3.2 won't overlay.
Though I don't see anything in the ActiveState builds (which are all
I've ever used) to handle the #! type selection of the desired version.
Just got done updat
I have a class hierarchy like this:
Widget <- VisualWidget <- BsWidget
and then BsWidget has many descendants: Desktop, Row, Column, Navbar etc.
Widgets can have children. They are stored in a tree. In order to manage
the order of widgets, I need methods to append children. (And later:
insert
Here is the problem: these methods should create instances of Row,
Column and Navbar. But this leads to circular imports.
It should not; Python is not Java.
Use modules to group your class definitions conceptually. There is no
need whatever to separate every class into a different module.
If t
I need to create an application for Windows 7 that runs from a flash
drive. This program would be used to create remote backups of the
pendrive. The pendrive contains sensitive data, so when I plug in the
pendrive and run the program to make a backup, it should not leave any
trace of operation
Anyone knows where to get a compiled cx_freeze that has already has this
patch?
http://hg.python.org/cpython/rev/7d20e30bd540
https://bitbucket.org/anthony_tuininga/cx_freeze/issue/81/python-34-venv-importlib-attributeerror
The installer on the sourceforge site still has this bug. :-( I don't
This might be a silly question. Documentation of os.stat:
The exact meaning and resolution of the st_atime, st_mtime, and
st_ctime attributes depend on the operating system and the file
system. For example, on Windows systems using the FAT or FAT32 file
systems, st_mtime has 2-second resolutio
Anyone knows where to get a compiled cx_freeze that has already has this
patch?
http://www.lfd.uci.edu/~gohlke/pythonlibs/#cx_freeze
Unfortunately, this is buggy too. Here is a test output from a compiled
console exe created with the above version of cx freeze:
Traceback (most recent call
>>> import win32service
Traceback (most recent call last):
File "", line 1, in
ImportError: DLL load failed: The specified module could not be found
I have no problem loading the same module with Python 2.7.
Strange thing is that win32serviceutil.py is part of the pywin32
distribution, so I
2014.05.25. 23:49 keltezéssel, Terry Reedy írta:
On 5/25/2014 1:40 PM, Nagy László Zsolt wrote:
>>> import win32service
Traceback (most recent call last):
File "", line 1, in
ImportError: DLL load failed: The specified module could not be found
I have no problem load
Let Christoph know, he is very responsive and extremely helpful.
He did help. The new version is available on his site and it works.
Thank you.
--
https://mail.python.org/mailman/listinfo/python-list
Strange thing is that win32serviceutil.py is part of the pywin32
distribution, so I guess I should be able to import it, right?
Make sure you have a pywin32 that matches ???. Matching includes python
version and bitness.
In addition, c:\python27\DLLs should also be on your %PATH%:
setx PAT
Python 3.4 does not run any bdist_wininst postinstall scripts. Try to run
`C:\Python34\python.exe C:\Python34\Scripts\pywin32_postinstall.py -install`
manually from an elevated command prompt.
Christoph
C:\>C:\Python34\python.exe C:\Python34\Scripts\pywin32_postinstall.py
-install
Copied py
Python 3.4 does not run any bdist_wininst postinstall scripts. Try to run
`C:\Python34\python.exe C:\Python34\Scripts\pywin32_postinstall.py -install`
manually from an elevated command prompt.
Much better when ran as an administrator:
C:\Python\Projects\test>C:\Python34\python.exe
C:\Python
When calling curl.perform() on a curl instance I get this:
pycurl.error: (55, 'select/poll returned error')
On the server side, there is no error message at all. I suppose that the
curl client tries to call select/poll on the socket. It fails and then
returns with an error.
This error happ
2015.03.28. 7:43 keltezéssel, dieter írta:
Nagy László Zsolt writes:
When calling curl.perform() on a curl instance I get this:
pycurl.error: (55, 'select/poll returned error')
This error happens only if the file to be POST-ed is big enough. Last
week files were und
When calling curl.perform() on a curl instance I get this:
pycurl.error: (55, 'select/poll returned error')
The same server is happily accepting files over 4GB from other
clients. Those other clients are exactly the same client programs, but
they are running on Windows. Only the one on t
After clicking on submit button, a message is displayed on the same page
whether login was successful or not.
However after clicking on submit button, I lose control over the web page. I
can't use any selenium functions now like 'driver.find_element_by_name()'.
You need to wait until the submi
Here is an MWE:
import certifi
import tornado.ioloop
import tornado.httpclient
io_loop = tornado.ioloop.IOLoop.current()
def test():
global io_loop
url =
"https://www.saaspass.com/sd/rest/applications/x/tokens?password=x";
# Just a test application!
ht
I would like to use async/await. The tornado latest documentation says
it is possible with tornado 4.3 and later:
http://tornadokevinlee.readthedocs.org/en/latest/guide/coroutines.html
However, it is not available yet.
c:\Python\Projects>pip3 install tornado -U
Requirement already up-to-date: to
I'm new to Python 3.5 async / await syntax. I would like to create a
class - let's call it AsyncBus - that can be used to listen for keys,
and send messages for keys ansynchronously.
class BusTimeoutError(Exception):
pass
class AsyncBus(object):
def __init__(self, add_timeout):
""
> async def waitfor(self, keys, timeout=None):
> """Wait for keys.
>
> :arg keys: An iterable of immutable keys.
> :arg timeout: Raise TimeoutError if nothing hits the
> bus for this amount of time.
> None means: wait indefinitely. It
> what would be a small thing that I could add to make this thing run again?
Something like this?
TERMINATOR = "STOP"
def read_int(prompt,minvalue,maxvalue):
while True:
answer = raw_input(prompt)
if answer.lower().strip() == TERMINATOR.lower().strip():
print "Us
>> async def waitfor(self, keys, timeout=None):
>> """Wait until a message comes in for any of the given key(s). Raise
>> BusTimeoutError after the given timedelta."""
>>
>>
>>
>> Internally, the waitfor method would use the add_timeout to resume itself
>> and raise the Bu
> Sorry, I didn't realize that you were using tornado and not asyncio.
> Presumably it should be on whatever loop the wait call was awaited in,
> but I have no idea how compatible asyncio constructs are with tornado
> event loops.
Exactly. I had the same doubts.
> I think it's a bad idea because t
>
> It is very annoying that async, await, yield, Future, Condition, Lock
> and almost all other async constructs work with any event loop; but
> simple things like "sleep for 10 seconds" are totally incompatible.
> But I guess I'll have to live with that for now.
>
Some more incompatibilty:
*
>>> try:
>>> return await waiter
>>> finally:
>>> # TODO: Use a context manager to add and remove the keys.
>>> for key in keys:
>>> self._waiters[key].discard(waiter)
>>> if handle:
>>> handle.cancel()
>>>
>>> def notify(self, key, m
>
> #!/usr/bin/python
> # -- developed using Python 2.7.3
>
> class BME280:
Not strictly related to the question, but you probably want to use so
called "new style classes" when developing a new program for Python
version 2. In other words, use:
class BME280(object):
instead of
class BME280:
> My questions are:
> What is the scope of class variables?
In Python, you bind values (objects) to names. It is conceptually
different from "setting the value of a variable". In Python, scope
applies to names, not variables.
When you say "class variable", what do you mean?
This may help:
A nam
1 - 100 of 147 matches
Mail list logo