Re: Access to the caller's globals, not your own

2016-11-16 Thread Rob Gaddi
t unskilled programmers won't understand. You can even create a default object in the main library with some sensible defaults and bind out the methods as functions just to provide a quick and easy answer for people who don't care. class Library: ... _defaultlib = Library() _

Re: Access to the caller's globals, not your own

2016-11-17 Thread Rob Gaddi
Steven D'Aprano wrote: > On Thursday 17 November 2016 04:52, Rob Gaddi wrote: > >>> import library >>> result = library.make_spam(arg) >>> >>> >>> versus: >>> >>> import library >>> make_spam = library.make_libr

Re: Simulating int arithmetic with wrap-around

2017-01-04 Thread Rob Gaddi
calculations on arbitrary sized signed/unsigned ints, figuring how to parallelize them into numpy arrays would save you a ton of time. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. -- https://mail.python.org

Re: Simulating int arithmetic with wrap-around

2017-01-06 Thread Rob Gaddi
; Agreed. If you had to do a lot of calculations on arbitrary sized signed/unsigned ints, figuring how to parallelize them into numpy arrays would save you a ton of time. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order.

Re: What library/package to use for parsing XML?

2017-01-30 Thread Rob Gaddi
;s amazing and very simple to use. And if you get halfway into your project and find ElementTree was insufficient, you can switch to lxml without changing practically anything you've already written. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain i

Re: Unnoticed traceback in a thread (Posting On Python-List Prohibited)

2018-03-08 Thread Rob Gaddi
nsive code is exactly the circumstance where Python threading lets you down. It really shines when you're I/O-bound. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. -- https://mail.python.org/mailman/listinfo/python-list

Re: I found strange thing while studying through idle

2018-03-09 Thread Rob Gaddi
yone have a use case in the modern (Py3) age for '\r'? I use b'\r' fairly regularly when talking to serial port devices. But the string version? -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix.

Re: Context manager on method call from class

2018-03-15 Thread Rob Gaddi
tmanager. Then you just use the @contextmanager decorator on a function, have it set up, yield the context you want, and clean up after. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. -- https://mail.python.org

Re: Thank you Python community!

2018-03-19 Thread Rob Gaddi
ed in greenbar paper ... "Look, you can make a filter out of the pinfeed!" -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. -- https://mail.python.org/mailman/listinfo/python-list

Re: Writing a C extension - borrowed references

2018-03-20 Thread Rob Gaddi
an API to these libraries, just a few functions. Cheers Tom If all you're doing is a thin-wrapper around a C library, have you thought about just using ctypes? -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above t

Re: Pip Version Confusion

2018-03-26 Thread Rob Gaddi
installing something --user for yourself, or are you using sudo to install it systemwide. Because 'sudo which pip' is probably still pointed to the APT installed one. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of orde

Re: try-except syntax

2018-04-05 Thread Rob Gaddi
all-through kicks in (the slightly non-identical case) is often the source of disastrous code errors. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. -- https://mail.python.org/mailman/listinfo/python-list

Re: RE newbie question

2018-04-18 Thread Rob Gaddi
t bogged down in regexes. They tend to be excellent solutions to only a very specific complexity of problem. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. -- https://mail.python.org/mailman/listinfo/python-list

Re: Looking for advice

2018-04-20 Thread Rob Gaddi
solutions will give you all manner of initial bootstrap issues. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. -- https://mail.python.org/mailman/listinfo/python-list

Re: seeking deeper (language theory) reason behind Python design choice

2018-05-10 Thread Rob Gaddi
print (...) and it displayed:    Ellipsis which wasn't very enlightening. No, but if you ever have difficulty remembering how to spell "ellipsis", it's good to know Python comes with a built-in reference. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email ad

Re: Print Failure or success based on the value of the standalone tool

2018-05-10 Thread Rob Gaddi
python.org/3/library/subprocess.html is your friend. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. -- https://mail.python.org/mailman/listinfo/python-list

Re: Numpy array

2018-05-21 Thread Rob Gaddi
rting with 0 and ending before 10, and columns to everything. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. -- https://mail.python.org/mailman/listinfo/python-list

Re: how to get INDEX count, or last number of Index

2018-05-23 Thread Rob Gaddi
faster than enumerating over the string just to get the last index. If what you want is the current index, though, you can look at the enumerate function s='kitti' for i, c in enumerate(s): print(i, ':', c) -- Rob Gaddi, Highland Technology -- www.highlandtechnology

Re: List replication operator

2018-05-24 Thread Rob Gaddi
didn't know they needed the special operator. [[] for _ in range(5)] works just as well without adding more syntax. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. -- https://mail.python.org/mailman/listinfo/python-list

Re: List replication operator

2018-05-25 Thread Rob Gaddi
[[{'swallow': 'unladen'}, {}], [{}, {}], [{}, {}]] >>> d = list.replicate(2, 3, fill=0) >>> d [[0, 0], [0, 0], [0, 0]] >>> d[0][0] = 5 >>> d [[5, 0], [0, 0], [0, 0]] """ if n: this

Re: List replication operator

2018-05-25 Thread Rob Gaddi
On 05/25/2018 10:13 AM, bartc wrote: On 25/05/2018 17:58, Rob Gaddi wrote: So, in the spirit of explicit being better than implicit, please assume that for actual implementation replicate would be a static method of actual list, rather than the conveniently executable hackjob below. _list

Re: Pink Floyd: is there anybody in here?

2018-05-30 Thread Rob Gaddi
On 05/30/2018 09:34 AM, Paul Rubin wrote: I think Usenet posts are no longer getting forwarded to the mailing list, but now I wonder if this is getting out at all, even to usenet. Does anyone see it? Can't speak for the mailing list, but this came out to Usenet just fine. -- Rob

Re: Override built in types... possible? or proposal.

2018-05-31 Thread Rob Gaddi
mply defining a function in the module that does the things you want done to strings? Not everything has to be an object method. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. -- https://mail.python.org/mailman/listinfo/python-list

Re: Python list vs google group

2018-06-15 Thread Rob Gaddi
is TWAIN Really? I always thought it didn't scan. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. -- https://mail.python.org/mailman/listinfo/python-list

Re: configparser v/s file variables

2018-06-27 Thread Rob Gaddi
x27;t you run your arbitrary code in my environment?" -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. -- https://mail.python.org/mailman/listinfo/python-list

Re: Something new which all programmers world wide will appreciate

2018-06-27 Thread Rob Gaddi
cious pizzas in the future ! ;) =D Bye, Skybuck. Or, you know, someone didn't bother putting limit checks in and a time out of 20 the thing gets lost and starts putting the sauce directly on the customer. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address

Re: Checking whether type is None

2018-07-24 Thread Rob Gaddi
pe test than in simply saying "is None". There are no other instances of NoneType. Don't try type-checking None; just check if the object is None. ChrisA I suppose one valid usage would be this sort of thing: fn = { int: dispatchInt, str: dispatchStr,

Re: regex pattern to extract repeating groups

2018-08-27 Thread Rob Gaddi
suited in the general case (though can be beaten into sufficiency in specific ones). Use https://docs.python.org/3.6/library/xml.etree.elementtree.html instead. Everything will just work. You'll be happier and more productive, with a brighter smile and glossier coat. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. -- https://mail.python.org/mailman/listinfo/python-list

Re: Question about floating point

2018-08-28 Thread Rob Gaddi
an really talk about is order of magnitude. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. -- https://mail.python.org/mailman/listinfo/python-list

Re: Object-oriented philosophy

2018-09-06 Thread Rob Gaddi
merely ask... -- Thomas Suddenly I'm filled with visions of pipe, fittings, and a herpetology degree. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. -- https://mail.python.org/mailman/listinfo/python-list

Re: Overwhelmed by the Simplicity of Python. Any Recommendation?

2018-10-12 Thread Rob Gaddi
eatures, or if the performance isn't optimized to within an inch of its life, well so be it. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. -- https://mail.python.org/mailman/listinfo/python-list

Important Language Choice Considerations

2018-10-18 Thread Rob Gaddi
https://boingboing.net/2018/10/15/python-falls-from-ceiling-in-b.html Say what you want about performance and linguistic elegance, but Julia almost never falls in through the ceiling. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of

Re: @staticmethod or def function()?

2018-10-31 Thread Rob Gaddi
the context of that class. It should be a stand-alone function if it provides stand-alone functionality. The decision is also almost certainly not worth the amount of thought you're giving it. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is current

Re: Overwhelmed by the Simplicity of Python. Any Recommendation?

2018-11-05 Thread Rob Gaddi
, the most popular, takes too long to start, and you have to setup folders and directories EVERY SINGLE TIME at startup. I've never been a fan of IDEs, but a code editor window on the left and the IPython QtConsole on the right is a pretty efficient way to blaze through code. -- Rob

Re: pandas read_csv

2018-11-09 Thread Rob Gaddi
_libs\parsers.c:28765)() ParserError: Error tokenizing data. C error: Expected 1 fields in line 8, saw 3 Offhand, and as a guess based on nothing, I would speculate that something about line 8 of your CSV file differs from lines 1-7. -- Rob Gaddi, Highland Technology -- www.hig

Re: error installing scipy on python 3.5, win 10 64 bit

2016-03-29 Thread Rob Gaddi
tribution to this conversation. Think long and hard on it. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. -- https://mail.python.org/mailman/listinfo/python-list

Re: Help with python code

2016-03-29 Thread Rob Gaddi
t; Howeve, it doesnt seem to be working. It doesnt calculate the bill. I dont > know what to do, as I'm less than average at this. > it comes up as IndexError: list index out of range at line42 > > Please help Don't know which one is line 42; but I'd bet your problem is there. As a rough guess, it might be the line that says: pizza_cost = pizzatype[menu] You're bounding that to the range 1-5. A Python list of length 5 has indices 0-4. But the error message is telling you everything you need to know; you're trying to get a list index that's out of range in line 42. Find line 42, figure out what index you're asking it for, and you'll have your answer. If you don't have an editor that shows you line numbers then your editor is fundamentally terrible and you should not use it (I personally like Notepad++ for Windows or Geany for Linux). -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. -- https://mail.python.org/mailman/listinfo/python-list

Re: Help with python code

2016-03-29 Thread Rob Gaddi
eter to look at the actual values of variables that you're creating. Also, as a mailing list/Usenet etiquette note: You get to have one name you go by. Going around changing the name you're posting under in the middle of the thread is a guaranteed way to piss folks off. You didn't kn

Re: Threading is foobared?

2016-03-29 Thread Rob Gaddi
<[email protected]> > Just read on Usenet instead of through the mailing list. That way you can accept broken threading as a given rather than wonder why it's happening in a particular case. -- Rob Gaddi, Highland Technology -- www.highlandte

Re: Convert set to list

2016-03-31 Thread Rob Gaddi
ck['relative_chart1']['vessel_names'])" Pdb takes the "list" command as a request to list source code. print list(block['relative_chart1']['vessel_names']) should work. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. -- https://mail.python.org/mailman/listinfo/python-list

Re: Strange range

2016-04-01 Thread Rob Gaddi
All (well-behaved) iterators are iterables, with their __iter__ method returning themselves. for x in y: ... implies: try: _it = iter(y) while True: x = next(_it) ... except StopIteration: pass That's true for any iterable y, including a y which is itself an iterator. Y

Re: Drowning in a teacup?

2016-04-01 Thread Rob Gaddi
teration is shooting at a moving target. How about: newlist = ( [x for x in mylist if x.startswith(key)] + [x for x in mylist if not x.startswith(key)] ) return newlist Or if you really insist on mutating the original list (which seems less clean to me, but you do you), then: newli

Python programs and relative imports

2016-04-04 Thread Rob Gaddi
Does anyone know the history of why relative imports are only available for packages and not for "programs"? It certainly complicates life. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix.

Re: recursive methods require implementing a stack?

2016-04-06 Thread Rob Gaddi
ou have been badly misled. Python local variables are frame local, and recursion just works. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. -- https://mail.python.org/mailman/listinfo/python-list

Re: Python programs and relative imports

2016-04-08 Thread Rob Gaddi
Rob Gaddi wrote: > Does anyone know the history of why relative imports are only available > for packages and not for "programs"? It certainly complicates life. > Really, no one? It seems like a fairly obvious thing to have included; all of the reasons that you want to be

Re: Python programs and relative imports

2016-04-08 Thread Rob Gaddi
Chris Angelico wrote: > On Sat, Apr 9, 2016 at 2:59 AM, Rob Gaddi > wrote: >> Rob Gaddi wrote: >> >>> Does anyone know the history of why relative imports are only available >>> for packages and not for "programs"? It certainly complicates life. >

Re: IdentationError; unexpected indent

2016-04-13 Thread Rob Gaddi
u in advance. Offhand, I'd say you should fix the error in your indentation, probably at the line number that the error specifies. Python cares about indentation, and uses it the way other languages use braces. Things that are at the same logical depth must be indented th

Re: Python path and append

2016-04-25 Thread Rob Gaddi
sequentially". f.read is both superfluous and also doesn't do that. Leave it out entirely. The next problem you'll have is that iterating over the lines of the file leaves the newline at the end of line, so your * will end up on the wrong line. Do yourself a favo

Re: Python path and append

2016-04-25 Thread Rob Gaddi
Seymore4Head wrote: > On Mon, 25 Apr 2016 18:24:02 - (UTC), Rob Gaddi > wrote: > >>Seymore4Head wrote: >> >>> On Tue, 19 Apr 2016 18:29:38 -0400, Seymore4Head >>> wrote: >>> >>> I am going to forget using a directory path. >>>

Re: How to get the closure environment in Python?

2016-04-28 Thread Rob Gaddi
gt; > How could I get the variable `x` in the environment of `func2()`? i.e. `f()`. > > Best regards, > Jin By using class instances instead of closures. class Foo: def __init__(self, x): self.x == x def __call__(self): return 0 def func1(): return Foo(10) -- Rob Gaddi, Highla

Re: How to become more motivated to learn Python

2016-05-03 Thread Rob Gaddi
that thing is Python, so be it. If you need a soldering iron, or a hammer and chisel, or a structural engineering degree instead, then go figure out how to use one of those and Python will still be waiting when you do need it. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email

Re: OT: limit number of connections from browser to my server?

2016-05-16 Thread Rob Gaddi
r some heavy math. After a lot of door knocking, poking, prodding, and hoping, the conclusion he reached was that what you want can't be done, and he had to gut and redesign the web server to support parallel connections. Turned a 45 second page load into south of one, but it wasn't pretty and chewed up a bunch of RAM. We had 256K to play in; I'm assuming you've got closer to 32K. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. -- https://mail.python.org/mailman/listinfo/python-list

Re: OT: limit number of connections from browser to my server?

2016-05-16 Thread Rob Gaddi
Grant Edwards wrote: > On 2016-05-16, Rob Gaddi wrote: > >> Grant, the bad news is that I know this because our firware guy had >> _exactly_ this problem, with exactly your scenario, about a month ago. >> http, not https, but the problem remains the same but for some he

Re: OT: limit number of connections from browser to my server?

2016-05-17 Thread Rob Gaddi
Steven D'Aprano wrote: > On Tue, 17 May 2016 02:52 am, Chris Angelico wrote: > >> On Tue, May 17, 2016 at 2:34 AM, Rob Gaddi >> wrote: >>>> The solution might actually be to move all your static files >>>> elsewhere. Slap 'em up onto github.i

Re: setrecursionlimit

2016-05-18 Thread Rob Gaddi
to look at a number and say "Yeah, no, that's CLEARLY too high." based on the minimum number of bytes a stack frame can require. Guaranteeing that some number lower than that is safe is almost certainly impossible. So you'd get an exception for truly stupid numbers, but a lack

Re: Education [was Re: for / while else doesn't make sense]

2016-05-23 Thread Rob Gaddi
27;s that, increasingly, programming is similar to carpentry. I can't reframe a house, and certainly can't build cabinetry, but I can do an adequate job putting up a simple wooden shelf. Looked at that way, it becomes a question of teaching people enough of the general prin

Re: Efficient handling of fast, real-time hex data

2016-05-31 Thread Rob Gaddi
load, and it's not like you need to see every sample. Are you going to be trying to use this data realtime, or are you just trying to datalog it and deal with it offline? Because at some point you'll need to decide, all in, how much data you're willing to try to hold in memory

Re: for / while else doesn't make sense

2016-06-02 Thread Rob Gaddi
the _canonical_ use case for for loopvar in range(initial_value, limit+1): processing if found_what_im_looking_for: break else: do_whatever_it_is_you_do_when_its_not_found The limited variable scoping is the only thing missing, and you can get around that by telling yourself

Re: Recommendation for GUI lib?

2016-06-02 Thread Rob Gaddi
w.eurion.net/python-snippets/snippet/Calendar_Date%20picker.html > > - Nick. I use PySide rather than PyQt, but definitely count me as another vote for Qt as the toolkit of choice. I started out on wx, but when I needed to move to Python3 it wasn't able to come with me. -- Rob Gaddi

Re: for / while else doesn't make sense

2016-06-03 Thread Rob Gaddi
Lawrence D’Oliveiro wrote: > On Friday, June 3, 2016 at 8:09:21 AM UTC+12, Rob Gaddi wrote: >> Although your loop is really the _canonical_ use case for >> >> for loopvar in range(initial_value, limit+1): >> processing >> if found_what_im_look

Re: Possible PEP - two dimensional arrays?

2016-06-07 Thread Rob Gaddi
d may contain privileged > information or confidential information or both. If you are not the intended > recipient please delete it and notify the sender. You're looking for numpy. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. -- https://mail.python.org/mailman/listinfo/python-list

Bulk Adding Methods Pythonically

2016-06-15 Thread Rob Gaddi
x27;min', 'VMIN'), ('ptp', 'VPP'), ('rms', 'VRMS'), ('top', 'VTOP')): def measmaker(p): def inner(self, cursorarea=False): region = 'CREG' if cursorarea else 'SCR' retur

Re: Bulk Adding Methods Pythonically

2016-06-15 Thread Rob Gaddi
Random832 wrote: > On Wed, Jun 15, 2016, at 13:37, Rob Gaddi wrote: >> I've got a whole lot of methods I want to add to my Channel class, all >> of which following nearly the same form. The below code works, but >> having to do the for loop outside of the main class d

Re: Bulk Adding Methods Pythonically

2016-06-21 Thread Rob Gaddi
Steven D'Aprano wrote: > On Thu, 16 Jun 2016 04:39 am, Rob Gaddi wrote: > >>> class Channel: >>> frequency = mkmeasure('frequency', 'FREQ') >>> falltime = mkmeasure('falltime', 'FTIM') >> >> Thought about

Clean Singleton Docstrings

2016-07-07 Thread Rob Gaddi
ry) gives me the _Registry documentation as expected. >From the (Linux) command line though: $ pydoc3 foobar._Registry [lots of good documentation stuff] $ pydoc3 foobar.Registry no Python documentation found for 'foobar.Registry' Is this a thing that can be fixed with a

Re: Clean Singleton Docstrings

2016-07-08 Thread Rob Gaddi
realised the implications. > As speedy problem resolutions go, before I mentioned it is pretty good. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. -- https://mail.python.org/mailman/listinfo/python-list

Re: Clean Singleton Docstrings

2016-07-08 Thread Rob Gaddi
Michael Selik wrote: > > >> On Jul 7, 2016, at 7:46 PM, Rob Gaddi >> wrote: >> >> I've got a package that contains a global ensmartened dict that allows >> all the various parts of my program to share state. > > The simplest solution would be to

Re: Don't understand why I'm getting this error

2016-07-14 Thread Rob Gaddi
quot;sound_recorder.py", line 21, in for i in range(0, > int(RATE / CHUNK * TIME)): OverflowError: range() result has too many items‬ > Offhand, I'll bet that you're getting TIME="2" instead of TIME=2. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.co

Re: Why not allow empty code blocks?

2016-07-22 Thread Rob Gaddi
ely that you have an indentation error than an intentional need for an empty code block, and Python's trying to prevent you shooting yourself in the foot. If you actually needed an empty code block, the langugage provides a way of marking that emptyness as intentional. That way is the

Re: Why not allow empty code blocks?

2016-07-28 Thread Rob Gaddi
to remove the redundant pass statement. > > How often do you actually need empty statements, adding stuff, > removing stuff, like that? Possibly there's a code smell here. > > ChrisA Yeah, all the time. try: return self.cache[key] except KeyError: pass lots... of... co

Python, the stack, and the heap

2018-12-17 Thread Rob Gaddi
Python objects are out on the heap? And that the references themselves may or may not wind up on the stack depending on what flavor you're running? Answers to these questions have very little bearing on how I actually write Python, mind, but now I'm curious. -- Rob G

Re: polar coordinates?

2018-12-17 Thread Rob Gaddi
e thread I will take under advisement, I suppose. If I recall correctly you can make the color argument a list with the same number of elements as you have points. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above t

Re: How can I find the indices of an array with float values in python?

2019-01-10 Thread Rob Gaddi
], [4, 3, 8]] >>> a = np.array([[2, 7, 6], [9, 5, 1], [4, 3, 8]]) >>> b = np.array([1, 5, 2, 6, 3, 7, 4, 8, 5, 9]) >>> (a > 5).nonzero() (array([0, 0, 1, 2]), array([1, 2, 0, 2])) >>> np.nonzero(b % 2) (array([0, 1, 4, 5, 8, 9]),) -- Rob Gaddi, Highland Techno

Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Rob Gaddi
ordering operators, since ordering is inherently undefined. In part, these decisions were made to make it possible to detect a NaN in C in the absence of an isnan() function. If (x != x), then x must be a NaN. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is cu

Re: What does "TypeError: unsupported operand type(s) for +: 'function' and 'int'" mean?

2019-03-25 Thread Rob Gaddi
n int. Which is only a problem because somewhere in your code, you're asking it to do that. In all likelihood, if you follow the line number provided in the traceback, you'll see that somewhere that you planned to use the result of calling a function you left out the parentheses and are

Re: Function to determine list max without itertools

2019-04-18 Thread Rob Gaddi
1:len(listarg)]: if myMax < i: myMax = i return myMax How would you simplify it? In English rather than Python, how do you find the maximum element in a list? -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currentl

Re: Function to determine list max without itertools

2019-04-19 Thread Rob Gaddi
): myMax = listarg[0] for item in listarg: if item > myMax: myMax = item return myMax Sayth When you understand what it is you intend to write (barring DL Neil's comments), and THEN write it, you write the correct thing. Thus endith the lesson.

Re: Function to determine list max without itertools

2019-04-19 Thread Rob Gaddi
ive? You could, of course, do some benchmarks to see if it makes a difference, but, personally, I'd just leave it. Personally yes, but because it allows it to execute on non-sequence iterables rather than because it saves a single near-instantaneous comparison. -- Rob G

Re: Using a Variable Inside the String

2019-05-07 Thread Rob Gaddi
comment can't be ignored because it's sitting there flagging your problem. Strings (in single or double quote) are strings; a sequence of characters as used to write words. Numbers are numbers. You can't add them together. This over here is my friend Bob. What's 31 + 18 +

Re: Instance vs Class variable oddity

2019-05-15 Thread Rob Gaddi
Sometimes when I'm feeling lazy it's a convenient way to set defaults on instance variables. I don't love it, but I also can't explain what I find wrong with it. Irv -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address d

Re: More CPUs doen't equal more speed

2019-05-24 Thread Rob Gaddi
t wrapper around all this stuff, and I feel like it often doesn't get enough love. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. -- https://mail.python.org/mailman/listinfo/python-list

Re: Why I am getting IndexError: tuple index out of range when converting a float value to a string?

2019-06-11 Thread Rob Gaddi
f to the autoindexed element. You could also explicitly index the 1st element (#0) as {0:6.5f}. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. -- https://mail.python.org/mailman/listinfo/python-list

Re: How control a GUI for an unrelated application from a Python script?

2019-06-14 Thread Rob Gaddi
On 6/14/19 8:49 AM, Christian Seberino wrote: Thanks for all the help. I'll definitely try to bypass the GUI first if possible. This is on Windows 7 so maybe AutoIt will do the trick if can't avoid the GUI. Thanks again everyone. Out of curiosity, what hardware? -- Rob Gaddi

Re: How control a GUI for an unrelated application from a Python script?

2019-06-14 Thread Rob Gaddi
e the provided software" that hasn't been updated since 2001 and doesn't actually let you test the thing you need to. The underlying FPGA board that it's built on has its own page at https://opalkelly.com/products/xem3010/ with an SDK. That may turn out to be your best way in.

Re: Use global, or not

2019-06-28 Thread Rob Gaddi
ation', 'version') as well as to pass device handles around, since an open connection to a given piece of physical hardware is an inherently global thing. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. -- https://mail.python.org/mailman/listinfo/python-list

Re: Pythonic custom multi-line parsers

2019-07-10 Thread Rob Gaddi
rser takes out of the file it passes to self.statefn, which processes the line in the current context and updates self.statefn to a different method if necessary. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. -- https://mail.python.org/mailman/listinfo/python-list

Re: Nesting Custom Errors in Classes

2019-07-23 Thread Rob Gaddi
aven't I seen it before? Can you see anything 'wrong' with this picture? I've used them sometimes for basic encapsulation principles without really gaining anything. I use inheritance of nested classes in my https://pypi.org/project/indexedproperty/ project, where subclasses o

Re: Boolean comparison & PEP8

2019-07-29 Thread Rob Gaddi
you do anything that modifies bar, and find that bar always points not to a new empty list each time but to the same empty list on each call. >>> def foo(bar=[]): ... bar.append(5) ... return bar ... >>> foo() [5] >>> foo() [5, 5] >>> foo() [5, 5, 5] A

Re: help with tkinter

2019-08-10 Thread Rob Walton
Doubly agreed. Avoid import * as it makes the code a nightmare to reason about later amongst other things On Fri, 9 Aug 2019 at 20:02, Peter J. Holzer wrote: > On 2019-08-09 12:43:45 -0600, Michael Torrie wrote: > > On 8/9/19 4:52 AM, Peter J. Holzer wrote: > > > You didn't import 'tkinter', you

Re: My pseudocode to Python?

2019-08-19 Thread Rob Gaddi
, but otherwise the list should only have six entries - without the entry directly behind "if x: ". mylist = ['a', 'b', 'c', 'd', 'e', 'f', 'g'] if not x: del mylist[3] -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. -- https://mail.python.org/mailman/listinfo/python-list

Re: itertools cycle() docs question

2019-08-21 Thread Rob Gaddi
g in iterable:     yield thing You assume that the initial iterable is reusable. If its not, the only way you can go back to the beginning is to have kept track of it yourself. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See

Re: Proper way to pass Queue to process when using multiprocessing.imap()?

2019-09-03 Thread Rob Gaddi
oes a fantastic job of handling this sort of parallelization in a straightforward way. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. -- https://mail.python.org/mailman/listinfo/python-list

Renaming an import

2019-09-05 Thread Rob Gaddi
b to graphing_module_a, that decision is made at a single central point in my package rather than scattered through 30 different import statements in a dozen files. Any ideas? -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above t

Re: OOP - how to abort an __init__ when the initialisation code fails ?

2019-11-04 Thread Rob Gaddi
ing None will specifically NOT accomplish the thing you want; nothing ever checks the return value of __init__. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. -- https://mail.python.org/mailman/listinfo/python-list

Re: OOP - how to abort an __init__ when the initialisation code fails ?

2019-11-04 Thread Rob Gaddi
File "", line 1, in TypeError: __init__() should return None, not 'int' Cheers, Luciano On Mon, Nov 4, 2019 at 2:31 PM Rob Gaddi wrote: >> [snip] Raise an exception. Returning None will specifically NOT accomplish the thing you want; nothing ever checks the return va

Re: OOP - how to abort an __init__ when the initialisation code fails ?

2019-11-04 Thread Rob Gaddi
On 11/4/19 10:59 AM, R.Wieser wrote: Rob, Returning None will specifically NOT accomplish the thing you want; nothing ever checks the return value of __init__. I thought to have read that when you return a none from it the object itself would return a placeholder singleton. Raise an

Re: OOP - how to abort an __init__ when the initialisation code fails ?

2019-11-05 Thread Rob Gaddi
On 11/5/19 11:52 AM, Peter J. Holzer wrote: On 2019-11-04 18:18:39 -0300, Luciano Ramalho wrote: In addition, as Rob said, it is usually a bad idea to wrap several lines of code in a single try/except block I disagree with this. While it is sometimes useful to wrap a single line, in my

Re: Launching a Script on the Linux Platform

2019-11-12 Thread Rob Gaddi
nu, not the command prompt. I personally start even GUI programs far more often from a prompt. To follow Linux conventions you'd put the shebang, make the file executable, and put the executable somewhere on the PATH. I'd stick to those conventions barring a particular reason not

Re: How to delay until a next increment of time occurs ?

2019-11-13 Thread Rob Gaddi
ormance than threads or vice versa. There's also async in the mix, which I still have no idea how to use. But this way if you strike out on one approach you've got some others to consider. Also, does the rPi have any PWM or counter pins that you can just set and forget, rather th

Re: How to delay until a next increment of time occurs ?

2019-11-14 Thread Rob Gaddi
terval then your lack of rigid control over what happens on your processor is a real problem and you're better off bare metal on a dedicated $2 Cortex-M than with random timeslices of the 1.4GHz beast on the rPi. Is what I was shorthanding with "realtime". -- Rob Gaddi, Highland T

<    1   2   3   4   5   6   7   8   9   10   >