Re: How do I check all variables returned buy the functions exists

2017-09-15 Thread Rob Gaddi
ser with Python 2.7 Regards, Ganesh Don't unpack them yet, you still want them to be aggregated. vals = return_x_values() if all(vals): v1, v2, v3 = vals print "all values true" else: print "at least one false value" -- Rob Gaddi, Highland Technology -- www

Re: Boolean Expressions

2017-09-26 Thread Rob Gaddi
would actually be an xnor (not xor) operation, a fairly rare usage case. Python doesn't even provide an operator for that, the closest thing would be (bool(x) == bool(y)). "And" means "and". This is true AND that is true. -- Rob Gaddi, Highland Technology -- www.highla

Real Programmers Write Docs

2017-09-27 Thread Rob Gaddi
Anyone have any good references on using Sphinx to generate a mix of autogenerated API docs and hand-written "Yeah, but this is what you DO with it" docs? Free is good but I'm happy to drop money on books if they're worthwhile. -- Rob Gaddi, Highland Technology -- www.hi

Re: Real Programmers Write Docs

2017-09-28 Thread Rob Gaddi
On 09/27/2017 04:15 PM, Ned Batchelder wrote: On 9/27/17 6:55 PM, Rob Gaddi wrote: Anyone have any good references on using Sphinx to generate a mix of autogenerated API docs and hand-written "Yeah, but this is what you DO with it" docs?  Free is good but I'm happy to drop mo

Re: Line terminators in Python?

2017-09-29 Thread Rob Gaddi
he only time I've ever needed to explicitly worry about '\r' is communicating over sockets or serial ports to devices. And in those cases you need to stuff them with bytes rather than str anyhow, so you're already down in the gory bits. -- Rob Gaddi, Highland Technology --

Re: Is there a function of ipaddress to get the subnet only from input like 192.168.1.129/25

2017-10-17 Thread Rob Gaddi
built in module so there are less dependencies. Any ideas? You mean, other than .split('/')? -- 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 used list, def. why li += [100,200] , and li = li + [100,200] is different

2017-10-23 Thread Rob Gaddi
The second time, however, you take the existing value that "li" refers to [1,2,3,4,5], create a new object that is ([1,2,3,4,5] + [100,200]), and reassign the local reference "li" to point to that new object. Then your function ends, "li" goes out of scope, nothing

Re: h5py.File() gives error message

2017-10-24 Thread Rob Gaddi
older with file is there. Why error message? Is it h5py.File() or is it my file? Everything seems pretty simple, what's going on? Thank you! Be 100% sure your directory is correct. Try it again with an absolute path to the file. Windows makes it far too easy for the working director

Re: Easiest way to access C module in Python

2017-11-07 Thread Rob Gaddi
ightforward and I've made it do some very heavy lifting over the years. Cython is definitely more work. SWIG makes sense if you've got a huge number of interfaces you're trying to map and need to automate the process, but if you've got south of 20 I'd just do it n

Re: Python Learning

2017-12-18 Thread Rob Gaddi
e some kind of portfolio, just as a bar of "This is what I consider my good work to be." The idea that someone is going to have years of experience, but not a single page of code that they can let me look over always strikes me as odd. -- Rob Gaddi, Highland Technology -- www.highlandtec

Re: Python Learning

2017-12-18 Thread Rob Gaddi
On 12/18/2017 01:52 PM, Gene Heskett wrote: On Monday 18 December 2017 16:05:10 Rob Gaddi wrote: On 12/18/2017 08:45 AM, Larry Martell wrote: On Mon, Dec 18, 2017 at 11:33 AM, Marko Rauhamaa wrote: However, one great way to stand out is a portfolio of GitHub projects. Several people have

Re: property decorator?

2017-12-20 Thread Rob Gaddi
ance stored in variable name foobar. That method assigns the new method to the "_setter" of that property instance and returns the updated property, which is assigned redundantly to the variable name foobar. -- 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 goto

2018-01-02 Thread Rob Gaddi
etc. Though it appears some wag has used function decorators to implement goto statements: https://pypi.python.org/pypi/goto-statement/1.1 Rather clever, it seems. Skip If only all that power had been used for good instead of evil... -- Rob Gaddi, Highland Technology -- www.highlandtechnolo

Native object exposing buffer protocol

2018-01-05 Thread Rob Gaddi
something that should be doable easily without having to throw around a lot of extraneous copies. -- 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: Native object exposing buffer protocol

2018-01-08 Thread Rob Gaddi
On 01/05/2018 04:27 PM, Ben Finney wrote: Rob Gaddi writes: I'd like to create a native Python object that exposes the buffer protocol. Basically, something with a ._data member which is a bytearray that I can still readinto, make directly into a numpy array, etc. The “etc.” seems p

Re: pip --user by default

2018-01-15 Thread Rob Gaddi
#x27;s the difference between a --user install and a system one? -- 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 work on a package

2018-02-07 Thread Rob Gaddi
I write a single line of code, I've got a setup.py and the directory framework. Then you install the package using pip -e (or in practice --user -e). That's the missing piece. That way you can import your module from the interpreter, because it's now on the path, but its physical loca

Re: How to work on a package

2018-02-07 Thread Rob Gaddi
On 02/07/2018 03:17 PM, Grant Edwards wrote: On 2018-02-07, Rob Gaddi wrote: When I'm working on a module, the trick is to write a setup.py (using setuptools) from the very get-go. Before I write a single line of code, I've got a setup.py and the directory framework. Then you i

Re: Is there are good DRY fix for this painful design pattern?

2018-02-26 Thread Rob Gaddi
uto-default behavior" from the rest of them. Yeah, **kwargs is clumsy, but it gets the job done. -- 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: RFC: Proposal: Deterministic Object Destruction (Posting On Python-List Prohibited)

2018-03-01 Thread Rob Gaddi
tion with intelligent cyclical reference breaking. -- 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: What's the best way to minimize the need of run time checks?

2016-08-09 Thread Rob Gaddi
def add2list(lst, elem): lst.extend([elem, elem]) return lst I did all the type checking I needed to there; none whatsoever. If passed a list, or something that behaves like one, that does the expected thing. If passed an ExtensionLadder, it probably does the wrong thing, but that is n

Re: Invalid Syntax

2016-08-09 Thread Rob Gaddi
; > Hal A missing colon, the appropriate location of which is left as an exercise to the reader. -- 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: What's the best way to minimize the need of run time checks?

2016-08-09 Thread Rob Gaddi
Juan Pablo Romero Méndez wrote: > 2016-08-09 13:18 GMT-07:00 Rob Gaddi : > >> Juan Pablo Romero Méndez wrote: >> >> > 2016-08-09 12:06 GMT-07:00 Paul Rubin : >> > >> >> Juan Pablo Romero Méndez writes: >> >> > In online forums so

Re: Python 3: Launch multiple commands(subprocesses) in parallel (but upto 4 any time at same time) AND store each of their outputs into a variable

2016-08-24 Thread Rob Gaddi
ults. For older Python, create a subprocess.Popen (again with stdout and stderr=subprocess.PIPE) and call the communicate() method. There's probably a dozen other ways. That one there, that's your easiest. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is curr

Re: degrees and radians.

2016-08-24 Thread Rob Gaddi
ctangular or vice versa in > polar. > I have never seen it done. > While I fully admit to thinking in degrees, any time I'm actually doing any mathematical work my units are either radians or cycles. The representation of angle in fixed point cycles actually comes o

Re: Alternatives to XML?

2016-08-24 Thread Rob Gaddi
t; > This seems even worse from a readability point of view. The arguments to > 'compare' are a long way away from the block to be executed. > > Can anyone offer an alternative which is closer to my original intention? > > Thanks > > Frank Millman > You&#

Re: Multimeter USB output

2016-08-29 Thread Rob Gaddi
that weeks manage to fall into with nothing to show for them. If this is an exercise in learning to work with libusb then have at. But if what you actually need from this is to talk to the meter? You're talking to it already. Take the win and walk. -- Rob Gaddi, Highland Technology -- ww

Re: Linear Time Tree Traversal Generator

2016-09-20 Thread Rob Gaddi
yield node._value yield from iter(node._right) I think there's a little bit of optimization that goes on using yield from. That said, all this has a serious stink of premature optimization. -- 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: Counting words in a string??

2016-09-30 Thread Rob Gaddi
e. > > It would help if you could comment the code. > Thankyou in advance!! I'm sure it would help; your professor will probably take points off otherwise. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order.

Re: Python and ssh for remote login

2016-10-05 Thread Rob Gaddi
Noah wrote: > Hello folk, > > I would like to use a python script to ssh into a server using a username > and password and perhaps ass port. > > Any ideas on how to script that. > > Thanks > > Noah paramiko -- Rob Gaddi, Highland Technology -- www.highlandtechnolo

Re: How to process syntax errors

2016-10-12 Thread Rob Gaddi
I want to >> grab that error and process. >> >> Regards, Puneet > > Steve, You are absolutely right. I am trying to eliminate the method of using > parenthesis while calling in my file. Especially when I call it from a > instance. There's a simple solution the

Re: need help for an assignment plz noob here

2016-10-17 Thread Rob Gaddi
ers in the shell and seeing what you can do with it. The word you're looking for is 'slices'. Figure out interactively what you need to do, then write it up. -- 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

System-wide module path

2016-10-24 Thread Rob Gaddi
s to /usr/highland/python3.4/site-packages, and put all the executable stubs that pip creates into /usr/highland/bin, then I can just rsync all of /usr/highland. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. -- https

Re: Why keys method does not work with MutableMapping?

2016-11-11 Thread Rob Gaddi
) > md.keys() > ==> KeysView() Nope, that's exactly right. That's the python3 behavior. >>> d = {'a': 1, 'b':2} >>> d.keys() dict_keys(['b', 'a']) Keys returns a dedicated keys object now, not just a list. That thin

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

2016-11-14 Thread Rob Gaddi
#x27;] > ... > > > but what magic do I need? globals() is no good, because it returns the > library's global namespace, not the caller's. > > > Any solution ought to work for CPython, IronPython and Jython, at a minimum. > class Library: SPAMIFY = False def make_spam(m): ... import library Library = library.Library() result = Library.make_spam(99) -- 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 does this list swap fail?

2016-11-14 Thread Rob Gaddi
s that's one thing, but I certainly hope that's not actually going to be production code. Even if it were right it's unreadable. -- 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: PyQt pass data from class

2016-11-15 Thread Rob Gaddi
at is in the class Form > > in wich way i can have access to the lineedit of class Form without event > from class Cornice > > Many Thanks Traditionally you'd have Cornice emit a Signal, which when you __init__the Form you'd connect to the appropriate slot. I don'

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
<1392737302.749065.1459024715818.javamail.ya...@mail.yahoo.com> > 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

  1   2   3   >