Re: User Interface Suggestions? (newbie)

2016-10-05 Thread Brendan Abel
You should look into using PyQt or PySide. They are python bindings for the very popular Qt GUI framework. On Wed, Oct 5, 2016 at 2:33 PM, Beverly Howard wrote: > >> if it is a pi controlling the system I would tend towards controlling it > from a web page via the network. to keep it updating

Re: Passing Variable to Function

2016-10-05 Thread Brendan Abel
Define your colors as actual number variables instead of a string color = (255,0,0) color2 = (0,0,255) Then use argument expansion to pass them in as separate arguments to the function colorFunction(*color) Brendan On Wed, Oct 5, 2016 at 12:17 PM, John McKenzie wrote: > > Hello, all. > > I

Re: unintuitive for-loop behavior

2016-09-30 Thread Brendan Abel
> a = 1 if condition: print(a) # UnboundLocalError: local 'a' referenced before assignment a += 1 For-loops are no different. Making them their own namespace is a very strange thing to do, it would mean you couldn't re-bind a value inside a for-loop: count = 0 for x in sequence: cou

Re: unintuitive for-loop behavior

2016-09-29 Thread Brendan Abel
Yes, loops don't have their own scope. Indeed, very few flow elements in python -- if, with, try/except -- create a new scope. In that sense, it's fairly consistent, but can be unexpected for people that have used languages with many nested scopes. The lambda behavior is a common gotcha - there

Re: How to import all things defined the files in a module directory in __init__.py?

2016-09-24 Thread Brendan Abel
> Splitting it up would make it slower to load. It's usually the opposite. When packages are split up, you only have to load the specific portions you need. Putting it all in a single module forces you to always load everything. On Fri, Sep 23, 2016 at 11:59 PM, Lawrence D’Oliveiro < lawrenced.

Re: What is the correct form for saying "licensed under the same terms as Python itself"?

2016-09-14 Thread Brendan Abel
Unless you're actually distributing python (as in, the interpreter or it's source code), you don't need to include the python license or the copyright notice. You also don't need a Contributor agreement just to distribute a python library. That is more for people who are contributing to core Pyth

Re: Python inner function parameter shadowed

2016-09-13 Thread Brendan Abel
unction is concerned.) On Tue, Sep 13, 2016 at 11:31 AM, Chris Angelico wrote: > On Wed, Sep 14, 2016 at 4:28 AM, Brendan Abel <007bren...@gmail.com> > wrote: > > This looks like a decorator function that optionally accepts arguments to > > change the behavior. > &g

Re: Python inner function parameter shadowed

2016-09-13 Thread Brendan Abel
This looks like a decorator function that optionally accepts arguments to change the behavior. You can safely ignore the warning form PyCharm. the variable won't be shadowed it's included in the function signature of the inner function. A lot of times, the outside decorator will just use the *ar

Re: Unittest

2016-07-25 Thread Brendan Abel
Generally, all your unittests will be inside a "tests" directory that lives outside your package directory. That directory will be excluded when you build or install your project using your setup.py script. Take a look at some popular 3rd party python packages to see how they structure their proj

Re: reversed(enumerate(x))

2016-07-20 Thread Brendan Abel
You could create your own generator that wraps enumerate def reverse_enumerate(iterable): for i, val in enumerate(reversed(iterable)): yield len(iterable) - 1 - i, val for i, val in reverse_enumerate(x): ... On Wed, Jul 20, 2016 at 10:42 AM, Ian Kelly wrote: > I had occasion to

Re: Were is a great place to Share your finished projects?

2016-07-14 Thread Brendan Abel
A lot of these arguments and points have already been made and hashed out on the python-dev list. There's a very good article that one of the python core developers wrote about the decision to move to github http://www.snarky.ca/the-history-behind-the-decision-to-move-python-to-github Basically,

Are imports supposed to be like this?

2016-05-09 Thread Brendan Abel
Consider the following example python package where `a.py` and `b.py` depend on each other: /package __init__.py a.py b.py There are several ways I could import the "a.py" module in "b.py" import package.a # Absolute import import package.a as a_mod

Imports and cyclical dependencies

2013-11-13 Thread Brendan Abel
I have a relatively large python package that has several cyclical dependencies. The cyclical dependencies typically aren't a problem so long as I'm just importing modules, and not named attributes (ie. function, class, globals), which may not be defined at a given point in the import routine

Re: The real problem with Python 3 - no business case for conversion (was "I strongly dislike Python 3")

2010-07-07 Thread Brendan Abel
On Jul 7, 3:00 pm, MRAB wrote: > Brendan Abel wrote: > >>>> One thing that would be very useful is how to maintain something that > >>>> works on 2.x and 3.x, but not limiting yourself to 2.6. Giving up > >>>> versions below 2.6 is out of the ques

Re: The real problem with Python 3 - no business case for conversion (was "I strongly dislike Python 3")

2010-07-07 Thread Brendan Abel
> > > One thing that would be very useful is how to maintain something that > > > works on 2.x and 3.x, but not limiting yourself to 2.6. Giving up > > > versions below 2.6 is out of the question for most projects with a > > > significant userbase IMHO. As such, the idea of running the python 3 > >

Re: Picking a license

2010-05-13 Thread Brendan Abel
While I think most of the disagreement in this long thread results from different beliefs in what "freedom" means, I wanted to add, that most of the responses that argue that the MIT license permits the user more freedom than the GPL, suffer from the broken window fallacy. This fallacy results from

Re: Python dot-equals (syntax proposal)

2010-04-30 Thread Brendan Abel
On Apr 30, 9:04 am, Jabapyth wrote: > At least a few times a day I wish python had the following shortcut > syntax: > > vbl.=func(args) > > this would be equivalent to > > vbl = vbl.func(args) > > example: > > foo = "Hello world" > foo.=split(" ") > print foo > # ['Hello', 'world'] > > and I guess

Re: function name

2010-04-28 Thread Brendan Abel
On Apr 28, 11:44 am, Richard Lamboj wrote: > Hello, > > is there any way to get the name from the actual called function, so that the > function knows its own name? > > Kind Regards, > > Richi If you want to get the function name from within the function itself, check out the inspect module. http

Re: assigning multi-line strings to variables

2010-04-27 Thread Brendan Abel
On Apr 27, 7:20 pm, goldtech wrote: > Hi, > > This is undoubtedly a newbie question. How doI assign variables > multiline strings? If I try this i get what's cited below. Thanks. > > >>> d="d > d" > >>> d > > Traceback (most recent call last): >   File "", line 1, in > NameError: name 'd'