Re: 2.7.9: PhotoImage get/put
On 10/21/2015 1:50 AM, Randy Day wrote: When I read your post, I realized I'm doing a crude animation. After a bit of searching on 'python canvas animation', I found a reference to how it's done: I made my 'root' Tk instance global, and call root.update_idletasks() after the .put I did not see the original post, but the alternative way to animate is to use root.after(milliseconds, callback, *args) at the end of callbacks to allow the event loop to process other events before re-calling the same or another callback. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Defamation
On 10/21/2015 2:53 AM, Laura Creighton wrote: In a message of Wed, 21 Oct 2015 10:30:35 +1100, "Steven D'Aprano" writes: On Wed, 21 Oct 2015 01:44 am, Laura Creighton wrote: No, we are removing them because we want to. Who are "we"? You're not talking about *you and me*. Anybody who was involved in deciding whether or not to remove them. You, me, Ralf, Skip, Tim Golden, Terry, anybody else who is interested. If that's the case, that would be fantastic, but are you *sure* it works like that? Skip Montanaro made it clear that removing posts from the archives regenerates URLs for the whole month: http://www.gossamer-threads.com/lists/python/python/1176035 Yes. And if you read the rest of the thread you will see how it was proposed to avoid that problem, with a placeholder, and thereafter Skip wrote a script that implemented exactly that. The moderators intend and try to delete such posts as those under discussion before they reach the list, by both automatic and manual filtering. They are doing pretty well, but some posters have actively evaded this process (and give us training examples to improve the process). I think that posts that would have unquestionably been deleted before being distributed are fair game to be replaced at least in our archive after the fact. I appreciate the people who have done this cleanup work. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Defamation
> According to Ralf, python.org is hosted in the Netherlands, One could change that. > I want to buy peanut butter, but I don't, because I know that when it comes > to peanut butter I have no self-control and would eat the entire jar in a > single sitting. So I simply don't buy it in the first place, and the > problem is solved. That's what I do when it comes to candy in general ) -- Ralf Hildebrandt Charite Universitätsmedizin Berlin ralf.hildebra...@charite.deCampus Benjamin Franklin http://www.charite.de Hindenburgdamm 30, 12203 Berlin Geschäftsbereich IT, Abt. Netzwerk fon: +49-30-450.570.155 -- https://mail.python.org/mailman/listinfo/python-list
PyPi bug?
Today I have tried to register and upload a new package by executing setup.py register I was asked if I want to save the creditentials in a .pypirc file and I answered yes. Next I wanted to run setup.py upload and I got this error: Traceback (most recent call last): File "C:\Python\Projects\some_package\setup.py", line 15, in classifiers=['Topic :: Security', 'Topic :: Internet :: WWW/HTTP'], File "C:\Python35\lib\distutils\core.py", line 148, in setup dist.run_commands() File "C:\Python35\lib\distutils\dist.py", line 955, in run_commands self.run_command(cmd) File "C:\Python35\lib\distutils\dist.py", line 973, in run_command cmd_obj.ensure_finalized() File "C:\Python35\lib\distutils\cmd.py", line 107, in ensure_finalized self.finalize_options() File "C:\Python35\lib\distutils\command\upload.py", line 46, in finalize_options config = self._read_pypirc() File "C:\Python35\lib\distutils\config.py", line 83, in _read_pypirc current[key] = config.get(server, key) File "C:\Python35\lib\configparser.py", line 798, in get d) File "C:\Python35\lib\configparser.py", line 396, in before_get self._interpolate_some(parser, option, L, value, section, defaults, 1) File "C:\Python35\lib\configparser.py", line 445, in _interpolate_some "found: %r" % (rest,)) configparser.InterpolationSyntaxError: '%' must be followed by '%' or '(', found : *' Instead of the many stars, of course there is the password. The problem might be that the password contains a % character, and it was incorrectly saved by distutils. Can somebody please confirm that this is a bug in distutils? The we probably have to submit a bug report. Thanks, Laszlo -- https://mail.python.org/mailman/listinfo/python-list
Re: 2.7.9: PhotoImage get/put
In article , tjre...@udel.edu says... [snip] > > I made my 'root' Tk instance global, and > > call root.update_idletasks() after the > > .put > I did not see the original post, but the alternative way to animate is > to use root.after(milliseconds, callback, *args) at the end of callbacks > to allow the event loop to process other events before re-calling the > same or another callback. I could see that being useful for creating a steady frame rate in longer animations. I'll put that one in my Python toolbox as well. --- news://freenews.netfront.net/ - complaints: n...@netfront.net --- -- https://mail.python.org/mailman/listinfo/python-list
If one IF is satisfied, skip the rest in the nest...
So here what I have, I have a 3 IF's within the same level. If one IF is satisfied, I would like to "skip" the other IFs and continue with my code. # 4 second open if wb1_sheet1.cell(row=cell + 1, column=2).value == 0 and wb1_sheet1.cell(row=cell + 1, column=3).value == 0 and wb1_sheet1.cell(row=cell + 2, column=2).value == 0 and wb1_sheet1.cell(row=cell + 2, column=3).value == 0 and wb1_sheet1.cell(row=cell + 3, column=2).value == 0 and wb1_sheet1.cell(row=cell + 3, column=3).value == 0: open += 3 open_seconds += 4 start = wb1_sheet1.cell(row=cell + 4, column=2).coordinate break # 3 second open if wb1_sheet1.cell(row=cell + 1, column=2).value == 0 and wb1_sheet1.cell(row=cell + 1, column=3).value == 0 and wb1_sheet1.cell(row=cell + 2, column=2).value == 0 and wb1_sheet1.cell(row=cell + 2, column=3).value == 0: open += 3 start = wb1_sheet1.cell(row=cell + 3, column=2).coordinate open_seconds += 3 continue # 2 second open if wb1_sheet1.cell(row=cell + 1, column=2).value == 0 and wb1_sheet1 .cell(row=cell + 1, column=3).value == 0: open += 3 start = wb1_sheet1.cell(row=cell + 2, column=2).coordinate open_seconds += 2 if any but the last IF is true, then all IFs will be true...that's my problem. any help would be great -- https://mail.python.org/mailman/listinfo/python-list
Re: If one IF is satisfied, skip the rest in the nest...
On Wed, Oct 21, 2015 at 11:31 AM, wrote: > So here what I have, I have a 3 IF's within the same level. If one IF is > satisfied, I would like to "skip" the other IFs and continue with my code. I think you're looking for the elif keyword. An elif branch will only be considered if the previous branches were false. if a: do_something() elif b: do_something_else() elif c: do_something_different() -- https://mail.python.org/mailman/listinfo/python-list
Re: If one IF is satisfied, skip the rest in the nest...
In <50a6789a-3965-430b-9a91-b08adcedf...@googlegroups.com> bigred04...@gmail.com writes: > So here what I have, I have a 3 IF's within the same level. If one IF is s= > atisfied, I would like to "skip" the other IFs and continue with my code. > # 4 second open > if wb1_sheet1.cell(row=cell + 1, column=2).value == 0 and > wb1_sheet1.cell(row=cell + 1, column=3).value == 0 and > wb1_sheet1.cell(row=cell + 2, column=2).value == 0 and > wb1_sheet1.cell(row=cell + 2, column=3).value == 0 and > wb1_sheet1.cell(row=cell + 3, column=2).value == 0 and > wb1_sheet1.cell(row=cell + 3, column=3).value == 0: > open += 3 > open_seconds += 4 > start = wb1_sheet1.cell(row=cell + 4, column=2).coord= > inate > break > # 3 second open > if wb1_sheet1.cell(row=cell + 1, column=2).value == 0 a= > nd wb1_sheet1.cell(row=cell + 1, column=3).value == 0 and wb1_sheet= > 1.cell(row=cell + 2, column=2).value == 0 and wb1_sheet1.cell(row= > =cell + 2, column=3).value == 0: > open += 3 > start = wb1_sheet1.cell(row=cell + 3, column=2).coord= > inate > open_seconds += 3 > continue > # 2 second open > if wb1_sheet1.cell(row=cell + 1, column=2).value == 0 a= > nd wb1_sheet1 .cell(row=cell + 1, column=3).value == = > 0: > open += 3 > start = wb1_sheet1.cell(row=cell + 2, column=2).coord= > inate > open_seconds += 2 > if any but the last IF is true, then all IFs will be true...that's my probl= > em. It looks like all three of your if statements start out with this condition: if wb1_sheet1.cell(row=cell + 1, column=2).value == 0 and wb1_sheet1.cell(row=cell + 1, column=3).value == 0 So you could reorganize your code by putting an if statement at the top that only checks this condition. Then, indented underneath, you can check for the other conditions. And be sure to use "else" and "elif" when they are appropriate. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" -- https://mail.python.org/mailman/listinfo/python-list
Re: If one IF is satisfied, skip the rest in the nest...
O...MG I cannot believe I just asked this question ha. I ended up realizing I need to use an elif after I took a break from it and re read everything...Brain fart, thanks for replies. Brice -- https://mail.python.org/mailman/listinfo/python-list
A high-level cross-platform API for terminal/console access
I have recently been working on a terminal/console animation package (https://github.com/peterbrittain/asciimatics). Beyond the high-level animation methods/objects it provides, it also needed to be cross-platform and and simple to install with pip (including any dependencies). This cross-platform requirement meant I needed a curses equivalent for Windows. This appears to have been a regular issue over the years and I've looked around at previous answers on the web and this newsgroup. Now while there's some pretty neat stuff out there, nothing actually gave me everything I needed. 1) colorama only gives you colours and cursor positioning, but no input, resizing or screen-scraping options. 2) blessings/blessed provide better (but incomplete) APIs than the curses package, but no Windows support unless you use colorama (which is still limited as above). 3) console (from effbot.org) is a native installer and so fails the pip test. It does however show direct use of the win32 API is a tenable approach. 4) The other packages I found were either dead projects or relied on a native installation of an open source implementation of curses - with no pip install option available. I therefore started writing a consistent wrapper API (the Screen object) that uses the curses package on Unix variants and pywin32 to access the Windows console API. Over the last few months I've rounded out the features and proved that asciimatics works identically on Linux (various distros), OSX and Windows 7-10. I know that there are still some rough edges due to the history of the project and so I've been deprecating old APIs in preparation for creating a completely clean API when I create the next major (v2.x) release. I suspect that it could be even better though, so am looking for feedback and ideas from the community - both on the high-level animation features and the low-level cross-platform terminal API. Is there something you can see that could be usefully improved? All feedback welcome. -- https://mail.python.org/mailman/listinfo/python-list
Re: How to rearrange array using Python?
Den 2015-10-20 skrev Ian Kelly : >> >> Anyone into CSP willing to offer me a hint? > > I assume that your variables are the individuals and the domains of > those variables are the rooms. Based on the python-constraint docs, > your constraint could look something like this: > > from collections import Counter > > ROOM_SIZE = { > 'A': 3, > 'B': 3, > 'C': 4, > 'D': 4, > 'E': 5, > } > > def room_size_constraint(*v): > counter = Counter(v.values()) > return all(count <= ROOM_SIZE[room] > for room, count in counter.items()) > > problem.addConstraint(room_size_constraint) Bingo! Just what I needed but didn't know where to look for. Now I 'only' have to read https://docs.python.org/dev/library/collections.html#counter-objects to understand what's really going on in the code :-) Then I will try less benign examples. /Martin -- https://mail.python.org/mailman/listinfo/python-list
Re: A high-level cross-platform API for terminal/console access
In a message of Wed, 21 Oct 2015 11:30:25 -0700, Peter Brittain writes: >I have recently been working on a terminal/console animation package >(https://github.com/peterbrittain/asciimatics). Beyond the high-level >animation methods/objects it provides, it also needed to be cross-platform and >and simple to install with pip (including any dependencies). > >This cross-platform requirement meant I needed a curses equivalent for >Windows. This appears to have been a regular issue over the years and I've >looked around at previous answers on the web and this newsgroup. Now while >there's some pretty neat stuff out there, nothing actually gave me everything >I needed. > >1) colorama only gives you colours and cursor positioning, but no input, >resizing or screen-scraping options. > >2) blessings/blessed provide better (but incomplete) APIs than the curses >package, but no Windows support unless you use colorama (which is still >limited as above). > >3) console (from effbot.org) is a native installer and so fails the pip test. >It does however show direct use of the win32 API is a tenable approach. > >4) The other packages I found were either dead projects or relied on a native >installation of an open source implementation of curses - with no pip install >option available. > >I therefore started writing a consistent wrapper API (the Screen object) that >uses the curses package on Unix variants and pywin32 to access the Windows >console API. > >Over the last few months I've rounded out the features and proved that >asciimatics works identically on Linux (various distros), OSX and Windows >7-10. I know that there are still some rough edges due to the history of the >project and so I've been deprecating old APIs in preparation for creating a >completely clean API when I create the next major (v2.x) release. > >I suspect that it could be even better though, so am looking for feedback and >ideas from the community - both on the high-level animation features and the >low-level cross-platform terminal API. > >Is there something you can see that could be usefully improved? All feedback >welcome. >-- Did you try https://pypi.python.org/pypi/UniCurses ? Laura -- https://mail.python.org/mailman/listinfo/python-list
Re: If one IF is satisfied, skip the rest in the nest...
On Wed, 21 Oct 2015 10:31:04 -0700, bigred04bd3 wrote: > So here what I have, I have a 3 IF's within the same level. If one IF > is satisfied, I would like to "skip" the other IFs and continue with my > code. c1 = wb1_sheet1.cell(row=cell + 1, column=2).value == 0 and wb1_sheet1.cell(row=cell + 1, column=3).value == 0 c2 = wb1_sheet1.cell(row=cell + 2, column=2).value == 0 and wb1_sheet1.cell(row=cell + 2, column=3).value == 0 c3 = wb1_sheet1.cell(row=cell + 3, column=2).value == 0 and wb1_sheet1.cell(row=cell + 3, column=3).value == 0 if c1: if c2: if c3: # c1 && c2 && c3 # 4 second open else: # c1 && c2 # 3 second open else: # only c1 # 2 second open Each condition only gets evaluated once. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: If one IF is satisfied, skip the rest in the nest...
On 2015-10-21, Denis McMahon wrote: > On Wed, 21 Oct 2015 10:31:04 -0700, bigred04bd3 wrote: > >> So here what I have, I have a 3 IF's within the same level. If one IF >> is satisfied, I would like to "skip" the other IFs and continue with my >> code. > > c1 = wb1_sheet1.cell(row=cell + 1, column=2).value == 0 and > wb1_sheet1.cell(row=cell + 1, column=3).value == 0 > > c2 = wb1_sheet1.cell(row=cell + 2, column=2).value == 0 and > wb1_sheet1.cell(row=cell + 2, column=3).value == 0 > > c3 = wb1_sheet1.cell(row=cell + 3, column=2).value == 0 and > wb1_sheet1.cell(row=cell + 3, column=3).value == 0 > > if c1: > if c2: > if c3: > # c1 && c2 && c3 > # 4 second open > else: > # c1 && c2 > # 3 second open > else: > # only c1 > # 2 second open if c1 && c2 && c3: pass # 4 seconds elif c1 && c2: pass # 3 seconds elif c1: pass # 2 seconds Or if you want to be particulary obtuse: seconds = {0b111:4, 0b110:3, 0b100:2}.get(c1<<2 | c2<<1 | c3<<0, None) > Each condition only gets evaluated once. OK. -- Grant Edwards grant.b.edwardsYow! You were s'posed at to laugh! gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: A high-level cross-platform API for terminal/console access
> > Did you try https://pypi.python.org/pypi/UniCurses ? > Yes - it failed to install with pip and also looked like a dead project when I followed the project home page URL. -- https://mail.python.org/mailman/listinfo/python-list
Re: A high-level cross-platform API for terminal/console access
On 10/21/15, Peter Brittain wrote: >> >> Did you try https://pypi.python.org/pypi/UniCurses ? >> > > Yes - it failed to install with pip and also looked like a dead project when > I followed the project home page URL. > -- > https://mail.python.org/mailman/listinfo/python-list > Also check out the curses module that's available on Christoph Gohlke's site: http://www.lfd.uci.edu/~gohlke/pythonlibs/#curses -- https://mail.python.org/mailman/listinfo/python-list
Re: variable scope of class objects
@Dennis, Thanks for your example. My structure is very similar. Perhaps I was reading too much into Luca's below statement regarding declaring variables. Regards, JonRob Luca wrote... >Please, note that declaring a variable in the constructor is only a >convention: in Python you can add a variable to an object of a class >wherever you want in your code (even if it is very dangerous and >discouraged). On Tue, 20 Oct 2015 20:18:35 -0400, Dennis Lee Bieber wrote: >On Tue, 20 Oct 2015 17:33:21 -0400, jon...@mail.python.org declaimed the >following: > >> >> >>Hello Luca, >> >>I very much appreciated your comments. And I understand the >>importance of "doing something right" (i.e. convention). >> >>This leads me to another question. >> >>Because I am interfacing with an I2C sensor I have many register >>definations to include (30 register addresses and 26 Variables to be >>red from some of those registers. >>In your comment you mentioned that convention is to declare variables >>(and constants?) in the construction (__ini__). >>I am concerned that the sheer number of varialbe / constants would >>make it difficult to read. >> > > "Constants" are typically defined at module level, using all capitals >as a hint to the reader (Python does not have anything that one might >consider a true constant -- other than the language defined singletons: >None, and maybe by now True and False). > > Register addresses are likely "constants". Not sure about your "26 >Variables"... Do they map directly to registers, or are they extracted as >fields from the values returned -- that is, a register may have two or more >"variables"? Do you read ALL registers on command and hold the values (note >my usage -- values can be held in lists or dictionaries using a single >"variable") for later retrieval by the user, or only read A register on >command by the user and return that value. > >-=-=-=-=- ># registers for a fictitious motion sensor >GYROXREG = 0x0010 >GYROYREG = 0x0011 >GYROZREG = 0x0001 >... >MAGZREG = 0x0100 > >class SensorA(I2C):#I'm assuming class I2C provides read/write functions > _registers = [GYROXREG, GYROYREG, GYROZREG, > ..., MAGZREG] > def __init__(self, SCLpin, SDApin, slaveAddress): > self._SCL = SCLpin > self._SDA = SDApin > self._addr = slaveAddress > self.update() #initial load of values > def update(self): > #basically a loop over all addresses > #I'm not going to try to pseudo code the full I2C protocol > self.values = {}#yes, a dictionary > for reg in _registers: > aValue = self.read(self._SCL, self._SDA, self._addr, > reg) > #inherited from I2C class > self.values[reg] = aValue > > >mySensor = SensorA(21, 22, 0x6) > >while True > mySensor.update() > print ("Gyro X: %s, Y: %s, Z: %s" > % (mySensor.values[GYROXREG], > mySensor.values[GYROYREG], > mySensor.values[GYROZREG])) > time.sleep(1.0) > > > > -- https://mail.python.org/mailman/listinfo/python-list
Re: If one IF is satisfied, skip the rest in the nest...
On Wed, 21 Oct 2015 20:07:21 +, Grant Edwards wrote: > On 2015-10-21, Denis McMahon wrote: >> On Wed, 21 Oct 2015 10:31:04 -0700, bigred04bd3 wrote: >> >>> So here what I have, I have a 3 IF's within the same level. If one IF >>> is satisfied, I would like to "skip" the other IFs and continue with >>> my code. >> >> c1 = wb1_sheet1.cell(row=cell + 1, column=2).value == 0 and >> wb1_sheet1.cell(row=cell + 1, column=3).value == 0 >> >> c2 = wb1_sheet1.cell(row=cell + 2, column=2).value == 0 and >> wb1_sheet1.cell(row=cell + 2, column=3).value == 0 >> >> c3 = wb1_sheet1.cell(row=cell + 3, column=2).value == 0 and >> wb1_sheet1.cell(row=cell + 3, column=3).value == 0 >> >> if c1: >> if c2: >> if c3: >> # c1 && c2 && c3 # 4 second open >> else: >> # c1 && c2 # 3 second open >> else: >> # only c1 # 2 second open > > if c1 && c2 && c3: > pass # 4 seconds > elif c1 && c2: > pass # 3 seconds > elif c1: > pass # 2 seconds > > Or if you want to be particulary obtuse: > > seconds = {0b111:4, 0b110:3, 0b100:2}.get(c1<<2 | c2<<1 | c3<<0, None) Not really valid, because #seconds n is simply a marker to indicate which branch of the OP's code to execute. >> Each condition only gets evaluated once. > > OK. Yes, but in the structure I suggest, you can move the conditions back into the if statements and they still only each get evaluated once. Viz my alternative to the OP's code: if wb1_sheet1.cell(row=cell + 1, column=2).value == 0 and wb1_sheet1.cell (row=cell + 1, column=3).value == 0: if wb1_sheet1.cell(row=cell + 2, column=2).value == 0 and wb1_sheet1.cell(row=cell + 2, column=3).value == 0: if wb1_sheet1.cell(row=cell + 3, column=2).value == 0 and wb1_sheet1.cell(row=cell + 3, column=3).value == 0: open += 3 open_seconds += 4 start = wb1_sheet1.cell(row=cell + 4, column=2).coordinate else: open += 3 open_seconds += 3 start = wb1_sheet1.cell(row=cell + 3, column=2).coordinate else: open += 3 open_seconds += 2 start = wb1_sheet1.cell(row=cell + 2, column=2).coordinate Not trying to be obtuse here, trying to suggest a practical solution. Of course, the benefit of reducing the number of times each lookup into the worksheet is performed by reducing the number of times each comparison evaluated is going to depend on the computational and memory manipulation cost of doing so (I assume the workbook is loaded in memory, so no IO costs), and how frequently this set of comparisons is being performed. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
select.poll and ppoll
Using Python 2.6, don't hate me. I have select.poll, but I'm looking for something like ppoll instead. From the Linux man page: ppoll() The relationship between poll() and ppoll() is analogous to the relationship between select(2) and pselect(2): like pselect(2), ppoll() allows an application to safely wait until either a file descriptor becomes ready or until a signal is caught. Technically, *I* don't want this, it's one of my work-colleagues. He says: "My high-level goal is to run a callback function whenever the alsa mixer level changes. The C alsa API provides snd_mixer_elem_set_callback, but the Python API (import alsaaudio) seems to need me to get poll(2) descriptors" -- Steve -- https://mail.python.org/mailman/listinfo/python-list
Re: variable scope of class objects
Il 20/10/2015 23:33, JonRob ha scritto: Hello Luca, I very much appreciated your comments. And I understand the importance of "doing something right" (i.e. convention). This leads me to another question. Because I am interfacing with an I2C sensor I have many register definations to include (30 register addresses and 26 Variables to be red from some of those registers. In your comment you mentioned that convention is to declare variables (and constants?) in the construction (__ini__). I am concerned that the sheer number of varialbe / constants would make it difficult to read. In your opinion, what would be the best method to structure such code? Regards JonRob Let's start from constants. Constants, in Python, simply don't exist (and IMHO this is one of the few lacks of Python). All you can do is to declare a variable and treat it as a constant: you never change it! It doesn't make sense to put a constant declaration at instance level, declaring it in the __init__ part of a class. After all, a constant is an information you want to share. The choice is up to you as the project manager: if you think that your constant is deeply related to the class you're designing, declare it as a class variable; otherwise, declare it at global level (in this case, often I use a separate file dedicated to constant declaration). -- Ciao! Luca -- https://mail.python.org/mailman/listinfo/python-list