Distributing "Python 3.4 for iOS"

2017-02-21 Thread pertoger
I distribute learning apps via an MDM server. There are two possibilities for 
deploying apps; either to users via their Apple-ID or directly to devices 
(iPads). Alas my users don’t have Apple-IDs, so I have to distribute apps 
directly to their devices.
Sadly «Python 3.4 for iOS» is in Appstore not set to distribute from Mobile 
Device Management servers to devices (iPads), only users. Does anybody know 
some means of contacting the right instance/person to alter this?
 
Gratefully,

Per-Johnny Tøgersen
IKT-manager for Vik and Berg schools in Sømna, Norway
perto...@gmail.com 
+47 951 38 649

Sent by E-mail for Windows 10

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python application launcher (for Python code)

2017-02-21 Thread BartC

On 20/02/2017 15:44, Deborah Swanson wrote:

Ben Finney wrote, on February 19, 2017 11:27 PM


"Deborah Swanson"  writes:


I could probably write this myself, but I'm wondering if this hasn't



already been done many times.


Can you describe what you are looking for, in enough detail
that we can know whether it's already been done as you want it?



I deliberately left the question open-ended because I'm curious what's
out there. I've studied and practiced Python for a little over a year,
but I've spent that time mostly writing my own code and I don't really
know much about what and where to look for in modules and packages.

Basically, I now have quite a few Python programs I use frequently, and
as time goes on my collection and uses of it will grow. Right now I just
want a way to select which one I'd like to run and run it. I'd like it
to be a standalone application and some sort of system of categories
would be nice.


If you use Windows, then the OS can take care of this. You don't need a 
separate application, just open up a directory showing a list of .py 
files, and click on one.


Then if '.py' is correctly associated with the right Python version, it 
will run Python on it.


To group into categories, just put the .py files into separate, aptly 
named directories.


The only problem I found, when launching in GUI mode, was that a 
console-mode Python program would briefly open a console window that 
would then promptly disappear if it finished immediately and there was 
no interaction.


--
bartc


--
https://mail.python.org/mailman/listinfo/python-list


Derivative timezone?

2017-02-21 Thread Skip Montanaro
Is it possible to create a timezone which is a derivative of an
existing timezone? I'd like to create one which is several hours
different ahead of America/Chicago, but follows Chicago's DST changes.
My initial attempt was to create a timezone object using pytz:

tz = pytz.timezone("America/Chicago")

then add eight hours to its _utcoffset attribute, but that doesn't
work. Is "creative" timezone construction possible, or am I limited to
what pytz finds in the Olson database?

Thx,

Skip
-- 
https://mail.python.org/mailman/listinfo/python-list


str.format fails with JSON?

2017-02-21 Thread carlopires
Hi,

When I run this piece of code:

'From {"value": 1}, value={value}'.format(value=1)

Python complains about the missing "value" parameter (2.7.12 and 3.6.x):

Traceback (most recent call last):
  File "test_format.py", line 1, in 
'From {"value": 1}, value={value}'.format(value=1)
KeyError: '"value"

But according to the format string syntax 
(https://docs.python.org/2/library/string.html): 

replacement_field ::=  "{" [field_name] ["!" conversion] [":" format_spec] "}"
field_name::=  arg_name ("." attribute_name | "[" element_index "]")*
arg_name  ::=  [identifier | integer]
attribute_name::=  identifier
element_index ::=  integer | index_string
index_string  ::=   +
conversion::=  "r" | "s"
format_spec   ::=  

The replacement_field, which in this case, is composed by an identifier, 
shouldn't have quotation marks. Here is the lexical definition for an 
identifier (according to the documentation):

identifier ::=  (letter|"_") (letter | digit | "_")*
letter ::=  lowercase | uppercase
lowercase  ::=  "a"..."z"
uppercase  ::=  "A"..."Z"
digit  ::=  "0"..."9"

So according to the specification, {value} should be recognized as a valid 
format string identifier and {"value"} should be ignored.

Python seems to not follow the specification in the documentation. Anything 
inside the keys is accepted as identifier.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Derivative timezone?

2017-02-21 Thread Skip Montanaro
I figured out that I can drop down to a lower level and use a manually
constructed tz file to create the desired timezone object. The pytz
package has a build_tzinfo() function which takes a zone name and an
open file object).

Skip


On Tue, Feb 21, 2017 at 8:06 AM, Skip Montanaro
 wrote:
> Is it possible to create a timezone which is a derivative of an
> existing timezone? I'd like to create one which is several hours
> different ahead of America/Chicago, but follows Chicago's DST changes.
> My initial attempt was to create a timezone object using pytz:
>
> tz = pytz.timezone("America/Chicago")
>
> then add eight hours to its _utcoffset attribute, but that doesn't
> work. Is "creative" timezone construction possible, or am I limited to
> what pytz finds in the Olson database?
>
> Thx,
>
> Skip
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: str.format fails with JSON?

2017-02-21 Thread Chris Angelico
On Wed, Feb 22, 2017 at 1:23 AM,   wrote:
> Hi,
>
> When I run this piece of code:
>
> 'From {"value": 1}, value={value}'.format(value=1)

Firstly, this code is in error; I suspect you wanted a couple of
literal braces, so what you want is:

>>> 'From {{"value": 1}}, value={value}'.format(value=1)
'From {"value": 1}, value=1'

So everything from here on is about exactly *what* error gets raised.

> Python complains about the missing "value" parameter (2.7.12 and 3.6.x):
>
> Traceback (most recent call last):
>   File "test_format.py", line 1, in 
> 'From {"value": 1}, value={value}'.format(value=1)
> KeyError: '"value"
>
> But according to the format string syntax 
> (https://docs.python.org/2/library/string.html):
>
> The replacement_field, which in this case, is composed by an identifier, 
> shouldn't have quotation marks.
>
> So according to the specification, {value} should be recognized as a valid 
> format string identifier and {"value"} should be ignored.
>
> Python seems to not follow the specification in the documentation. Anything 
> inside the keys is accepted as identifier.

I agree. It'd be beneficial to add that kind of a check, as a means of
detecting cases where someone forgot to double a brace. Something
like:

InvalidKeyError: '"value"' - did you intend to use {{ }} ?

Not sure how hard the check would be to write, but it'd help to
highlight a particular class of bug.

ChrisA
.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: str.format fails with JSON?

2017-02-21 Thread Peter Otten
carlopi...@gmail.com wrote:

> Hi,
> 
> When I run this piece of code:
> 
> 'From {"value": 1}, value={value}'.format(value=1)
> 
> Python complains about the missing "value" parameter (2.7.12 and 3.6.x):
> 
> Traceback (most recent call last):
>   File "test_format.py", line 1, in 
> 'From {"value": 1}, value={value}'.format(value=1)
> KeyError: '"value"
> 
> But according to the format string syntax
> (https://docs.python.org/2/library/string.html):
> 
> replacement_field ::=  "{" [field_name] ["!" conversion] [":" format_spec]
> "}"
> field_name::=  arg_name ("." attribute_name | "[" element_index
> "]")*
> arg_name  ::=  [identifier | integer]
> attribute_name::=  identifier
> element_index ::=  integer | index_string
> index_string  ::=   +
> conversion::=  "r" | "s"
> format_spec   ::=  
> 
> The replacement_field, which in this case, is composed by an identifier,
> shouldn't have quotation marks. Here is the lexical definition for an
> identifier (according to the documentation):
> 
> identifier ::=  (letter|"_") (letter | digit | "_")*
> letter ::=  lowercase | uppercase
> lowercase  ::=  "a"..."z"
> uppercase  ::=  "A"..."Z"
> digit  ::=  "0"..."9"
> 
> So according to the specification, {value} should be recognized as a valid
> format string identifier and {"value"} should be ignored.

I'd rather say '{"value"}' unspecified as "value" isn't a proper field_name 
and literal {} have to be escaped.
> 
> Python seems to not follow the specification in the documentation.
> Anything inside the keys is accepted as identifier.

It does not enforce that you follow the specification, but if you do and 
properly escape the braces by doubling them you get the correct result

>>> 'From {{"value": 1}}, value={value}'.format(value=1)
'From {"value": 1}, value=1'


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: str.format fails with JSON?

2017-02-21 Thread Jussi Piitulainen
carlopi...@gmail.com writes:

> Hi,
>
> When I run this piece of code:
>
> 'From {"value": 1}, value={value}'.format(value=1)
>
> Python complains about the missing "value" parameter (2.7.12 and
> 3.6.x):

Perhaps you know this, but just to be sure, and for the benefit of any
reader who doesn't: double the braces in the format string when you
don't mean them to be interpreted as a parameter.

> But according to the format string syntax
> (https://docs.python.org/2/library/string.html):

[- -]

> So according to the specification, {value} should be recognized as a
> valid format string identifier and {"value"} should be ignored.
>
> Python seems to not follow the specification in the documentation.
> Anything inside the keys is accepted as identifier.

I think raising an error is more helpful than ignoring it. I think.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: str.format fails with JSON?

2017-02-21 Thread Carlo Pires
Em terça-feira, 21 de fevereiro de 2017 11:39:13 UTC-3, Chris Angelico  
escreveu:
> On Wed, Feb 22, 2017 at 1:23 AM,  Carlo Pires wrote:
> > Hi,
> >
> > When I run this piece of code:
> >
> > 'From {"value": 1}, value={value}'.format(value=1)
> 
> Firstly, this code is in error; I suspect you wanted a couple of
> literal braces, so what you want is:

What I wanted was an output without errors, like:

From {"value": 1}, value=1

I think Python should ignore value not matching integers or identifiers. This 
will make str.format more robust and usable. It cannot be used if the text has 
JSON as string, for instance.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: str.format fails with JSON?

2017-02-21 Thread Chris Angelico
On Wed, Feb 22, 2017 at 2:19 AM, Carlo Pires  wrote:
> What I wanted was an output without errors, like:
>
> From {"value": 1}, value=1
>
> I think Python should ignore value not matching integers or identifiers. This 
> will make str.format more robust and usable. It cannot be used if the text 
> has JSON as string, for instance.

No, Python should most definitely not just ignore them. If the
behaviour is changed, it should be to catch the error in a more
friendly way, stating that a format directive was not a valid
identifier. To get the behaviour you want, double the braces that you
want to be literal, as I did in my example in my first reply.

Format strings are a mini-language. Like with any other, you need to
speak the grammar of that language. To include quotes and apostrophes
in a string literal, you need to either escape them with backslashes,
or use something else to surround the string; and since a backslash
can escape a quote, a backslash must itself be escaped. That's the
nature of the mini-language of string literals. When you layer in the
format codes, other characters gain meaning. If, instead, you layer in
printf formatting, braces won't be significant, but percent signs will
be. Etcetera. You can't escape this. (Pun intended.)

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Python application launcher (for Python code)

2017-02-21 Thread Deborah Swanson
Dennis Lee Bieber wrote, on February 21, 2017 4:19 AM
> 
> On Mon, 20 Feb 2017 18:16:14 -0800, "Deborah Swanson" 
>  declaimed the following:
> 
> 
> >Yes, I've used Powershell, a couple decades ago, but it would be a
> 
>   Uhm... PowerShell 1.0 only came out ONE decade ago...
> 
>   Be afraid -- PowerShell has supposedly gone open-source 
> with versions for OS-X and Ubuntu!
> -- 
>   Wulfraed Dennis Lee Bieber AF6VN
> wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.com/

Really?  We used software called Powershell a couple decades ago in the
90s, as an improvement on the DOS box. I didn't like it much and I was
going through software like candy those days. Maybe that version
disappeared. It may have re-emerged in an improved form a decade later. 

My health collapsed in 2003, and I was not using any unfamiliar software
until a couple years ago, so I guess I've never used something called
Powershell that appeared a decade ago.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python application launcher (for Python code)

2017-02-21 Thread Chris Angelico
On Wed, Feb 22, 2017 at 2:16 AM, Deborah Swanson
 wrote:
> Really?  We used software called Powershell a couple decades ago in the
> 90s, as an improvement on the DOS box. I didn't like it much and I was
> going through software like candy those days. Maybe that version
> disappeared. It may have re-emerged in an improved form a decade later.

With a name like that, there've almost certainly been multiple things
using it. The PowerShell that comes with modern Windowses came out in
2006, and IMO it's less of a shell language and more of a scripting
language. And if I want to use a scripting language for program flow
control, I'll use Python or Pike, fankyouwerrymuch.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Python application launcher (for Python code)

2017-02-21 Thread Deborah Swanson
BartC wrote, on February 21, 2017 5:52 AM
> 
> On 20/02/2017 15:44, Deborah Swanson wrote:
> > Ben Finney wrote, on February 19, 2017 11:27 PM
> >>
> >> "Deborah Swanson"  writes:
> >>
> >>> I could probably write this myself, but I'm wondering if 
> this hasn't
> >
> >>> already been done many times.
> >>
> >> Can you describe what you are looking for, in enough 
> detail that we 
> >> can know whether it's already been done as you want it?
> 
> > I deliberately left the question open-ended because I'm 
> curious what's 
> > out there. I've studied and practiced Python for a little 
> over a year, 
> > but I've spent that time mostly writing my own code and I 
> don't really 
> > know much about what and where to look for in modules and packages.
> >
> > Basically, I now have quite a few Python programs I use frequently, 
> > and as time goes on my collection and uses of it will grow. 
> Right now 
> > I just want a way to select which one I'd like to run and 
> run it. I'd 
> > like it to be a standalone application and some sort of system of 
> > categories would be nice.
> 
> If you use Windows, then the OS can take care of this. You 
> don't need a 
> separate application, just open up a directory showing a list of .py 
> files, and click on one.
> 
> Then if '.py' is correctly associated with the right Python 
> version, it 
> will run Python on it.
> 
> To group into categories, just put the .py files into separate, aptly 
> named directories.
> 
> The only problem I found, when launching in GUI mode, was that a 
> console-mode Python program would briefly open a console window that 
> would then promptly disappear if it finished immediately and 
> there was 
> no interaction.
> 
> -- 
> bartc

Yes, I can see that only one person who has responded so far is remotely
familiar with what an application launcher is, and that person only
alluded to one, and hinted at some features I saw that could possibly be
used as an application launcher. 

I like Linux for this job, as it has a number of capabilities that
Windows doesn't have, and I was looking for an improvement on what I can
do in Windows. If you do a lot of computing it's nice to have tools and
code you commonly use, and only the ones you've chosen, conveniently
available from one interface. This interface could have other
functionalities itself. 

I was asking if anyone knew of Python code that acts in this way, and it
appears so far that the answer is no. 

Deborah

-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Python application launcher (for Python code)

2017-02-21 Thread Deborah Swanson
Chris Angelico wrote, on February 21, 2017 7:30 AM
> 
> On Wed, Feb 22, 2017 at 2:16 AM, Deborah Swanson 
>  wrote:
> > Really?  We used software called Powershell a couple decades ago in 
> > the 90s, as an improvement on the DOS box. I didn't like it much and
I 
> > was going through software like candy those days. Maybe that version

> > disappeared. It may have re-emerged in an improved form a decade 
> > later.
> 
> With a name like that, there've almost certainly been 
> multiple things using it. The PowerShell that comes with 
> modern Windowses came out in 2006, and IMO it's less of a 
> shell language and more of a scripting language. And if I 
> want to use a scripting language for program flow control, 
> I'll use Python or Pike, fankyouwerrymuch.
> 
> ChrisA

Yes, the name "Powershell" would have an appeal to a certain kind of
would-be "power user", if anyone uses that term anymore. It makes sense
that the idea would keep cropping up.

And my sentiments exactly on scripting languages other than straight
Python, which is why I was originally asking if anyone knew of an
application launcher, written in Python for launching Python code.

-- 
https://mail.python.org/mailman/listinfo/python-list


problems installing pylab

2017-02-21 Thread Robert William Lunnon
Dear Python

I am trying to install pylab alongside python 3.6. However when I type

python -m pip install pylab

I get the message

No module named site

In the documentation [documentation for installing python modules in
python 3.6.0 documentation] it says: The above example assumes that the
option to adjust the system PATH environment variable was selected when
installing python.

How do I do this?

I am running Windows 10

Looking forward to hearing from you

Bob




-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python application launcher (for Python code)

2017-02-21 Thread Grant Edwards
On 2017-02-21, Deborah Swanson  wrote:

> Yes, I can see that only one person who has responded so far is remotely
> familiar with what an application launcher is, and that person only
> alluded to one, and hinted at some features I saw that could possibly be
> used as an application launcher. 

I think I've read every posting in this thread, and I _still_ don't
know what you mean by "application launcher".

> I like Linux for this job, as it has a number of capabilities that
> Windows doesn't have, and I was looking for an improvement on what I can
> do in Windows. If you do a lot of computing it's nice to have tools and
> code you commonly use, and only the ones you've chosen, conveniently
> available from one interface.

Isn't that what shortcuts and start menu and all the other shiny-bits
on GUI desktop environments do?  [I don't use a "desktop" so maybe I'm
wrong.]  The "root menu" provided by many window managers is also a
common way to do this (that's something I do use).  A command-line
shell like bash is also a common way to do this.  And yes, there are
plenty of them available for Windows.

> This interface could have other functionalities itself. 
>
> I was asking if anyone knew of Python code that acts in this way,

What way?  I can't figure out how what you want is not what's provided
by any of the standard GUI desktop/shells or command-line shells.  Are
you looking for a 1980s-style menu driven UI that were common before
GUIs came into widespread use?

> and it appears so far that the answer is no. 

I think the problem is that you're unable to describe what you want in
a way that's understandable to the people that might be able to answer
your question.

-- 
Grant Edwards   grant.b.edwardsYow! VICARIOUSLY experience
  at   some reason to LIVE!!
  gmail.com

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python application launcher (for Python code)

2017-02-21 Thread eryk sun
On Tue, Feb 21, 2017 at 1:25 AM, Steve D'Aprano
 wrote:
> (2) Add each category to the PYTHONPATH. One easy way to do so is by adding
> the directories to a .pth file.

PYTHONPATH isn't a synonym for sys.path. The PYTHONPATH environment
variable gets used by every installed interpreter, which can be a
problem if it's set permanently. Using .pth files, as suggested here,
is one way around this.

In general, virtual environments [1] are convenient for development.
Install what you need for a project from PyPI, a local wheel cache, or
directly from VCS. IDEs such as PyCharm have integrated support for
virtual environments. Entry-point scripts in a virtual environment
should have a shebang that executes the environment's interpreter, so
they can be run even when the environment isn't active.

[1]: https://docs.python.org/3/library/venv.html

The rest of this message is just for Windows.

To support shebangs, make sure that .py[w] files are associated with
the py launcher, which is installed with Python 3. The installer
defaults to associating .py[w] files with the Python.File and
Python.NoConFile program identifiers (ProgIds). Change it back if
you've modified it. Don't use the command prompt's assoc command for
this. Use the control panel "Default Programs -> Set Associations"
dialog (i.e. associate a file type or protocol with a program). The
descriptions for .py and .pyw in this dialog should be "Python File"
and "Python File (no console)". When you double click on the entries
for .py and .pyw, the associated program should be "Python" with a
rocket on the icon. If not, and you see it in the list, select it.

Otherwise ensure that the Python.File and Python.NoConFile ProgIds are
configured to use the py.exe and pyw.exe launchers. If the launcher
was installed for all users (i.e. per machine), you can use ftype in
an *elevated* command prompt to query and set Python.[NoCon]File. For
example:

C:\>ftype Python.File
Python.File="C:\Windows\py.exe" "%1" %*

C:\>ftype Python.NoConFile
Python.NoConFile="C:\Windows\pyw.exe" "%1" %*

If the launcher was installed for the current user only (i.e. per
user), then you cannot use the ftype command since it only accesses
the local-machine settings. Also, even if you've installed for all
users, maybe you have an old value in HKCU, which takes precedence
over HKLM when the system reads the merged HKCR view.

Use regedit to manually edit the per-user keys if they exist. If
"HKCU\Software\Classes\Python.File\shell\open\command" exists, its
default value should be a template command to run the fully-qualified
path to py.exe plus "%1" for the target script and %* for the
command-line arguments, as shown above. Similarly, if
"HKCU\Software\Classes\Python.NoConFile\shell\open\command" exists, it
should run the same command but with pyw.exe substituted for py.exe.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python application launcher (for Python code)

2017-02-21 Thread Jim

On 02/21/2017 09:43 AM, Deborah Swanson wrote:

BartC wrote, on February 21, 2017 5:52 AM


On 20/02/2017 15:44, Deborah Swanson wrote:

Ben Finney wrote, on February 19, 2017 11:27 PM


"Deborah Swanson"  writes:


I could probably write this myself, but I'm wondering if

this hasn't



already been done many times.


Can you describe what you are looking for, in enough

detail that we

can know whether it's already been done as you want it?



I deliberately left the question open-ended because I'm

curious what's

out there. I've studied and practiced Python for a little

over a year,

but I've spent that time mostly writing my own code and I

don't really

know much about what and where to look for in modules and packages.

Basically, I now have quite a few Python programs I use frequently,
and as time goes on my collection and uses of it will grow.

Right now

I just want a way to select which one I'd like to run and

run it. I'd

like it to be a standalone application and some sort of system of
categories would be nice.


If you use Windows, then the OS can take care of this. You
don't need a
separate application, just open up a directory showing a list of .py
files, and click on one.

Then if '.py' is correctly associated with the right Python
version, it
will run Python on it.

To group into categories, just put the .py files into separate, aptly
named directories.

The only problem I found, when launching in GUI mode, was that a
console-mode Python program would briefly open a console window that
would then promptly disappear if it finished immediately and
there was
no interaction.

--
bartc


Yes, I can see that only one person who has responded so far is remotely
familiar with what an application launcher is, and that person only
alluded to one, and hinted at some features I saw that could possibly be
used as an application launcher.

I like Linux for this job, as it has a number of capabilities that
Windows doesn't have, and I was looking for an improvement on what I can
do in Windows. If you do a lot of computing it's nice to have tools and
code you commonly use, and only the ones you've chosen, conveniently
available from one interface. This interface could have other
functionalities itself.

I was asking if anyone knew of Python code that acts in this way, and it
appears so far that the answer is no.

Deborah



If you switch to Linux you might look at a program called Drawers. I use 
it on Ubuntu 14.04 and 16.04. It sits on the launcher panel and if you 
click it it opens up and you can click on programs to start them. Most 
things you can drag and drop on it, some things you must do a little 
editing to get them to start. It is written in Python I think.


On Mint 18 I use a program called MyLauncher. It sits on the top panel 
and will drop down a menu of programs to start. It's a little more hands 
on as you must add your programs to a config file to get them in the 
launcher. Don't think this one is written in Python.


Both are in the OS's repositories.

Regards,  Jim



--
https://mail.python.org/mailman/listinfo/python-list


Re: Python application launcher (for Python code)

2017-02-21 Thread Pavol Lisy
On 2/21/17, Deborah Swanson  wrote:
> Chris Angelico wrote, on February 21, 2017 7:30 AM
>>
>> On Wed, Feb 22, 2017 at 2:16 AM, Deborah Swanson
>>  wrote:
>> > Really?  We used software called Powershell a couple decades ago in
>> > the 90s, as an improvement on the DOS box. I didn't like it much and
> I
>> > was going through software like candy those days. Maybe that version
>
>> > disappeared. It may have re-emerged in an improved form a decade
>> > later.
>>
>> With a name like that, there've almost certainly been
>> multiple things using it. The PowerShell that comes with
>> modern Windowses came out in 2006, and IMO it's less of a
>> shell language and more of a scripting language. And if I
>> want to use a scripting language for program flow control,
>> I'll use Python or Pike, fankyouwerrymuch.
>>
>> ChrisA
>
> Yes, the name "Powershell" would have an appeal to a certain kind of
> would-be "power user", if anyone uses that term anymore. It makes sense
> that the idea would keep cropping up.
>
> And my sentiments exactly on scripting languages other than straight
> Python, which is why I was originally asking if anyone knew of an
> application launcher, written in Python for launching Python code.
>
> --
> https://mail.python.org/mailman/listinfo/python-list

Maybe try to look at https://github.com/spyder-ide/spyder .

It could satisfy your expectations. You can edit, run, debug,
statically analyze python codes and more. And it is open source
written in python...
-- 
https://mail.python.org/mailman/listinfo/python-list


Request Help With ttk.Notebook Tabs

2017-02-21 Thread Wildman via Python-list
Python 3.4.2
Linux platform


I am working on a program that has tabs created with ttk.Notebook.
The code for creating the tabs is working but there is one thing I
have not been able to figure out.  As is, the tabs are located up
against the lower edge of the caption bar.  I would like to have
them a little lower to make room above the tabs for other widgets
such as labels and/or command buttons.  Here is the code I use to
create the window and tabs...

class Window(tk.Frame):
def __init__(self, master=None):
tk.Frame.__init__(self, master)
master.title("My Program")
nb = ttk.Notebook(root, width=600, height=340)
tab1 = tk.Frame(nb)
tab2 = tk.Frame(nb)
nb.add(tab1, text="Tab1")
nb.add(tab2, text="Tab2")
nb.pack(expand=1, fill="both")

I have tried the grid and place methods to move the tabs down but
neither works.  I have tried the methods both before and after the
pack method.  Here is an example of what I have tried...

nb.grid(row=2, column=2)
or
nb.place(x=10, y=10)

Would be appreciated if anyone could provide any guidance.

-- 
 GNU/Linux user #557453
Keyboard not detected! Press any key to continue...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python application launcher (for Python code)

2017-02-21 Thread Rob Gaddi

On 02/20/2017 06:16 PM, Deborah Swanson wrote:

> [snip lots about using Windows but rather be
> using Linux but not wanting to have to spend lots of
> energy switching right now]

You know, I'm always reluctant to recommend it, because it can 
definitely get you tied in knots.  But you're about the ideal candidate 
for looking into https://www.cygwin.com/


When my primary PC had to be Windows I used it fairly successfully for 
years.  It works quite well for many things, and can be bullied into 
working well enough for others.  It will probably do what you seem like 
you might want, which is a functioning shell under Windows, and yes it 
works all the way back to XP.  At the low low price of free, you'll 
definitely get your money's worth.


--
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: Request Help With ttk.Notebook Tabs

2017-02-21 Thread MRAB

On 2017-02-21 18:02, Wildman via Python-list wrote:

Python 3.4.2
Linux platform


I am working on a program that has tabs created with ttk.Notebook.
The code for creating the tabs is working but there is one thing I
have not been able to figure out.  As is, the tabs are located up
against the lower edge of the caption bar.  I would like to have
them a little lower to make room above the tabs for other widgets
such as labels and/or command buttons.  Here is the code I use to
create the window and tabs...

class Window(tk.Frame):
def __init__(self, master=None):
tk.Frame.__init__(self, master)
master.title("My Program")
nb = ttk.Notebook(root, width=600, height=340)
tab1 = tk.Frame(nb)
tab2 = tk.Frame(nb)
nb.add(tab1, text="Tab1")
nb.add(tab2, text="Tab2")
nb.pack(expand=1, fill="both")

I have tried the grid and place methods to move the tabs down but
neither works.  I have tried the methods both before and after the
pack method.  Here is an example of what I have tried...

nb.grid(row=2, column=2)
or
nb.place(x=10, y=10)

Would be appreciated if anyone could provide any guidance.

If you want other widgets above the Notebook widget, why don't you just 
put them there in a frame?


--
https://mail.python.org/mailman/listinfo/python-list


Re: Request Help With ttk.Notebook Tabs

2017-02-21 Thread Wildman via Python-list
On Tue, 21 Feb 2017 12:02:50 -0600, Wildman wrote:

> Python 3.4.2
> Linux platform
> 
> 
> I am working on a program that has tabs created with ttk.Notebook.
> The code for creating the tabs is working but there is one thing I
> have not been able to figure out.  As is, the tabs are located up
> against the lower edge of the caption bar.  I would like to have
> them a little lower to make room above the tabs for other widgets
> such as labels and/or command buttons.  Here is the code I use to
> create the window and tabs...
> 
> class Window(tk.Frame):
> def __init__(self, master=None):
> tk.Frame.__init__(self, master)
> master.title("My Program")
> nb = ttk.Notebook(root, width=600, height=340)
> tab1 = tk.Frame(nb)
> tab2 = tk.Frame(nb)
> nb.add(tab1, text="Tab1")
> nb.add(tab2, text="Tab2")
> nb.pack(expand=1, fill="both")
> 
> I have tried the grid and place methods to move the tabs down but
> neither works.  I have tried the methods both before and after the
> pack method.  Here is an example of what I have tried...
> 
> nb.grid(row=2, column=2)
> or
> nb.place(x=10, y=10)
> 
> Would be appreciated if anyone could provide any guidance.

I posted too quickly.  I found my answer...

nb.pack(expand=1, fill="both", padx=20, pady=20)

Sorry.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Request Help With ttk.Notebook Tabs

2017-02-21 Thread Wildman via Python-list
On Tue, 21 Feb 2017 18:22:31 +, MRAB wrote:

> On 2017-02-21 18:02, Wildman via Python-list wrote:
>> Python 3.4.2
>> Linux platform
>>
>>
>> I am working on a program that has tabs created with ttk.Notebook.
>> The code for creating the tabs is working but there is one thing I
>> have not been able to figure out.  As is, the tabs are located up
>> against the lower edge of the caption bar.  I would like to have
>> them a little lower to make room above the tabs for other widgets
>> such as labels and/or command buttons.  Here is the code I use to
>> create the window and tabs...
>>
>> class Window(tk.Frame):
>> def __init__(self, master=None):
>> tk.Frame.__init__(self, master)
>> master.title("My Program")
>> nb = ttk.Notebook(root, width=600, height=340)
>> tab1 = tk.Frame(nb)
>> tab2 = tk.Frame(nb)
>> nb.add(tab1, text="Tab1")
>> nb.add(tab2, text="Tab2")
>> nb.pack(expand=1, fill="both")
>>
>> I have tried the grid and place methods to move the tabs down but
>> neither works.  I have tried the methods both before and after the
>> pack method.  Here is an example of what I have tried...
>>
>> nb.grid(row=2, column=2)
>> or
>> nb.place(x=10, y=10)
>>
>> Would be appreciated if anyone could provide any guidance.
>>
> If you want other widgets above the Notebook widget, why don't you just 
> put them there in a frame?

Thanks for the reply.  That approach would work but I found
a simple method that serves the purpose using padx/pady.  I
was doing my research in the areas of grid and place.  Didn't
think about pack.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: problems installing pylab

2017-02-21 Thread Terry Reedy

On 2/21/2017 10:47 AM, Robert William Lunnon wrote:


I am trying to install pylab alongside python 3.6.


On Windows 10 as you said at the bottom.


However when I type

python -m pip install pylab


Try

py -3.6 -m pip install pylab

The '.6' should not be needed, but will make the command fail if you 
another 3.x but not 3.6.



I get the message

No module named site


If any python.exe ran, /Lib/site.py should be present and you should not 
see that.  What happens if you enter just 'python'?



In the documentation [documentation for installing python modules in
python 3.6.0 documentation] it says: The above example assumes that the
option to adjust the system PATH environment variable was selected when
installing python.


In most cases, one is better to just use the py command on Windows.  If 
there is only one python.exe installed


>py

will start it.  If multiple pythons are installed, the latest is the 
default but you can use the flags to select -2 or -3 to select the 
latest of each or -x.y to select a specific version that is not the 
latest of the x series.  (I still type 'python' (now for 3.6) because a) 
it works since I made the install selection, and b) 20 years of habit ;-).)



How do I do this? I am running Windows 10


You can repair or replace the existing install, but I don't suggest it.

--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


Re: Python application launcher (for Python code)

2017-02-21 Thread Grant Edwards
On 2017-02-21, Rob Gaddi  wrote:
> On 02/20/2017 06:16 PM, Deborah Swanson wrote:
>
> > [snip lots about using Windows but rather be
> > using Linux but not wanting to have to spend lots of
> > energy switching right now]
>
> You know, I'm always reluctant to recommend it, because it can 
> definitely get you tied in knots.  But you're about the ideal candidate 
> for looking into https://www.cygwin.com/

There are other ways to get "shell and unix-utilities" for Windows
that are less "drastic" than Cygwin: they don't try to provide a
complete a Unix development environment or the illusion of Unix
filesystem semantics.  [Remember: a Unix shell without a set of
accompanying utilitys is pretty useless, since Unix shells don't have
all of the "built-in" commands that Windows shells do.]

NB: I haven't used any of these lately...

  http://unxutils.sourceforge.net/
  http://www.mingw.org/  (look for msys)
  https://gist.github.com/evanwill/0207876c3243bbb6863e65ec5dc3f058  (git's 
bash-terminal)
  https://sourceforge.net/projects/ezwinports/   

There were a couple another very highly recommended commercial Unix
shell+utilities products (MKS Toolkit, Interix) that I used to
use. But AFAIK, they all got bought and killed by Microsoft.

-- 
Grant Edwards   grant.b.edwardsYow! Please come home with
  at   me ... I have Tylenol!!
  gmail.com

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python application launcher (for Python code)

2017-02-21 Thread Chris Warrick
On 21 February 2017 at 20:21, Grant Edwards  wrote:
> On 2017-02-21, Rob Gaddi  wrote:
>> On 02/20/2017 06:16 PM, Deborah Swanson wrote:
>>
>> > [snip lots about using Windows but rather be
>> > using Linux but not wanting to have to spend lots of
>> > energy switching right now]
>>
>> You know, I'm always reluctant to recommend it, because it can
>> definitely get you tied in knots.  But you're about the ideal candidate
>> for looking into https://www.cygwin.com/
>
> There are other ways to get "shell and unix-utilities" for Windows
> that are less "drastic" than Cygwin: they don't try to provide a
> complete a Unix development environment or the illusion of Unix
> filesystem semantics.  [Remember: a Unix shell without a set of
> accompanying utilitys is pretty useless, since Unix shells don't have
> all of the "built-in" commands that Windows shells do.]
>
> NB: I haven't used any of these lately...
>
>   http://unxutils.sourceforge.net/
>   http://www.mingw.org/  (look for msys)
>   https://gist.github.com/evanwill/0207876c3243bbb6863e65ec5dc3f058  (git's 
> bash-terminal)
>   https://sourceforge.net/projects/ezwinports/
>
> There were a couple another very highly recommended commercial Unix
> shell+utilities products (MKS Toolkit, Interix) that I used to
> use. But AFAIK, they all got bought and killed by Microsoft.

Git Bash, or basically msys, is pretty reasonable. But if you are on
Windows 10, you might like the built-in Windows Subsystem for Linux
(aka Bash on Ubuntu on Windows) more — it’s real Linux that runs
alongside Windows, but less crazy than Cygwin.

-- 
Chris Warrick 
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Request Help With ttk.Notebook Tabs

2017-02-21 Thread Terry Reedy

On 2/21/2017 1:02 PM, Wildman via Python-list wrote:

Python 3.4.2
Linux platform


I am working on a program that has tabs created with ttk.Notebook.
The code for creating the tabs is working but there is one thing I
have not been able to figure out.  As is, the tabs are located up
against the lower edge of the caption bar.  I would like to have
them a little lower to make room above the tabs for other widgets
such as labels and/or command buttons.  Here is the code I use to
create the window and tabs...

class Window(tk.Frame):
def __init__(self, master=None):
tk.Frame.__init__(self, master)
master.title("My Program")
nb = ttk.Notebook(root, width=600, height=340)
tab1 = tk.Frame(nb)
tab2 = tk.Frame(nb)
nb.add(tab1, text="Tab1")
nb.add(tab2, text="Tab2")
nb.pack(expand=1, fill="both")


This is too minimal.  If I copy, paste, and run the above, it will fail. 
I will not guess what other code (which you should minimize) you 
actually had to make this run.  See https://stackoverflow.com/help/mcve, 
which is *great* advice that most SO unfortunately ignore.



I have tried the grid and place methods to move the tabs down but
neither works.  I have tried the methods both before and after the
pack method.  Here is an example of what I have tried...

nb.grid(row=2, column=2)
or
nb.place(x=10, y=10)

Would be appreciated if anyone could provide any guidance.


I have not specifically used Notebook, but

0. You MUST NOT mix geometry methods within a particular toplevel or 
frame.  From what you wrote (without complete code), you might have.


1. All widgets that go within a particular container widget must have 
that container as parent.  Although you put the notebook code in the 
window(frame) init, its parent is root, so it will appear outside the 
window, if indeed the window is made visible (which it is not in the 
code you posted.  So either get rid of the window(frame) code or put the 
notebook in the windows instance


 nb = ttk.Notebook(self, width=600, height=340)

The former is easier for minimal proof-of-concept testing, the latter 
may be better for final development and maintenance.


2. Packing is order dependent.

3. Gridding is not order dependent, but empty rows and column take no space.

In any case, the following works for me on 3.6 and Win10.

import tkinter as tk
from tkinter import ttk

root = tk.Tk()

e = ttk.Label(root, text='Widget outside of notebook')

nb = ttk.Notebook(root, width=600, height=340)
tab1 = ttk.Frame(nb)
tab2 = ttk.Frame(nb)
ttk.Label(tab1, text='Text on notebook tab 1').pack()
ttk.Label(tab2, text='Tab 2 text').pack()
nb.add(tab1, text="Tab1")
nb.add(tab2, text="Tab2")

e.grid(row=0)
nb.grid(row=1)

#root.mainloop()  # not needed when run from IDLE

--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


RE: Python application launcher (for Python code)

2017-02-21 Thread Deborah Swanson
Jim wrote, on February 21, 2017 9:51 AM
> 
> On 02/21/2017 09:43 AM, Deborah Swanson wrote:
> > I like Linux for this job, as it has a number of capabilities that 
> > Windows doesn't have, and I was looking for an improvement on what I

> > can do in Windows. If you do a lot of computing it's nice to have 
> > tools and code you commonly use, and only the ones you've chosen, 
> > conveniently available from one interface. This interface could have

> > other functionalities itself.
> >
> > I was asking if anyone knew of Python code that acts in this way,
and 
> > it appears so far that the answer is no.
> >
> > Deborah
> >
> 
> If you switch to Linux you might look at a program called Drawers. I
use 
> it on Ubuntu 14.04 and 16.04. It sits on the launcher panel and if you

> click it it opens up and you can click on programs to start them. Most

> things you can drag and drop on it, some things you must do a little 
> editing to get them to start. It is written in Python I think.
> 
> On Mint 18 I use a program called MyLauncher. It sits on the top panel

> and will drop down a menu of programs to start. It's a little more
hands 
> on as you must add your programs to a config file to get them in the 
> launcher. Don't think this one is written in Python.
> 
> Both are in the OS's repositories.
> 
> Regards,  Jim

Thanks, Jim.  This is exactly the type of program I was looking for.

A number of people have made some very helpful suggestions on ways to
get a Linux shell installed in Windows, but since I really don't want to
burn up a lot of time (any time at all actually) for a Windows solution,
I think I'll have a go with Cooperative Linux first. It's a way of
installing Linux on a separate partition that runs concurrently with
Windows and doesn't require booting back and forth between them - why go
cheap when you can have the real thing, which is what you originally
wanted anyway? Might not be that much trouble either, though I think the
installation is tricky.

I'll try both Drawers and taking a look at MyLauncher's code. Chances
are MyLauncher, or the parts of it I want, can be rewritten in Python.
But if Drawers is sufficient and no better recommendations surface, I'll
probably just go with that.

Originally I wanted Python code that would run in Windows (for minimal
fuss to get an application launcher now), and I might look at Drawers
for that. But chances are that an application launcher would make heavy
use of the os, and in Drawers that would be Linux and not Windows.

I think Cooperative Linux should be my next stop for this project.

Deborah

-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Python application launcher (for Python code)

2017-02-21 Thread Deborah Swanson
Grant Edwards wrote, on February 21, 2017 11:21 AM
> 
> On 2017-02-21, Rob Gaddi  wrote:
> > On 02/20/2017 06:16 PM, Deborah Swanson wrote:
> >
> > > [snip lots about using Windows but rather be
> > > using Linux but not wanting to have to spend lots of
> > > energy switching right now]
> >
> > You know, I'm always reluctant to recommend it, because it can
> > definitely get you tied in knots.  But you're about the 
> ideal candidate 
> > for looking into https://www.cygwin.com/
> 
> There are other ways to get "shell and unix-utilities" for 
> Windows that are less "drastic" than Cygwin: they don't try 
> to provide a complete a Unix development environment or the 
> illusion of Unix filesystem semantics.  [Remember: a Unix 
> shell without a set of accompanying utilitys is pretty 
> useless, since Unix shells don't have all of the "built-in" 
> commands that Windows shells do.]
> 
> NB: I haven't used any of these lately...
> 
  http://unxutils.sourceforge.net/
  http://www.mingw.org/  (look for msys)
  https://gist.github.com/evanwill/0207876c3243bbb6863e65ec5dc3f058
(git's bash-terminal)
  https://sourceforge.net/projects/ezwinports/   

There were a couple another very highly recommended commercial Unix
shell+utilities products (MKS Toolkit, Interix) that I used to
use. But AFAIK, they all got bought and killed by Microsoft.


Thanks Grant for these suggestions. Microsoft may have killed them at
the time, but useful software can resurface a number of ways.  I'll keep
your list and go looking for them someday. I think something like
Drawers or MyLauncher that Jim mentioned would fit the bill for my
immediate use, but old Unix utilities sound kinda neat in themselves,
and well worth looking into in my free time. (haha, free time you say?
But seriously I'd like to check them out.)

Deborah

-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Python application launcher (for Python code)

2017-02-21 Thread Deborah Swanson
Chris Warrick wrote, on February 21, 2017 11:26 AM
> 
> On 21 February 2017 at 20:21, Grant Edwards 
>  wrote:
> > On 2017-02-21, Rob Gaddi  wrote:
> >> On 02/20/2017 06:16 PM, Deborah Swanson wrote:
> >>
> >> > [snip lots about using Windows but rather be
> >> > using Linux but not wanting to have to spend lots of energy 
> >> > switching right now]
> >>
> >> You know, I'm always reluctant to recommend it, because it can 
> >> definitely get you tied in knots.  But you're about the ideal 
> >> candidate for looking into https://www.cygwin.com/
> >
> > There are other ways to get "shell and unix-utilities" for Windows 
> > that are less "drastic" than Cygwin: they don't try to provide a 
> > complete a Unix development environment or the illusion of Unix 
> > filesystem semantics.  [Remember: a Unix shell without a set of 
> > accompanying utilitys is pretty useless, since Unix shells 
> don't have 
> > all of the "built-in" commands that Windows shells do.]
> >
> > NB: I haven't used any of these lately...
> >
> >   http://unxutils.sourceforge.net/
> >   http://www.mingw.org/  (look for msys)
> >   
> https://gist.github.com/evanwill/0207876c3243bbb6863e65ec5dc3f
058  (git's bash-terminal)
>   https://sourceforge.net/projects/ezwinports/
>
> There were a couple another very highly recommended commercial Unix
> shell+utilities products (MKS Toolkit, Interix) that I used to
> use. But AFAIK, they all got bought and killed by Microsoft.

Git Bash, or basically msys, is pretty reasonable. But if you are on
Windows 10, you might like the built-in Windows Subsystem for Linux (aka
Bash on Ubuntu on Windows) more - it's real Linux that runs alongside
Windows, but less crazy than Cygwin.

-- 
Chris Warrick 
PGP: 5EAAEA16


Thanks Chris, I kind of thought useful software like this would
resurface in some form, and you given me msys' new name (Git Bash), or
one of them anyway.

-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Python application launcher (for Python code)

2017-02-21 Thread Deborah Swanson

I wrote, on February 21, 2017 12:12 PM
> 
> Grant Edwards wrote, on February 21, 2017 11:21 AM
> > NB: I haven't used any of these lately...
> > 
>   http://unxutils.sourceforge.net/
>   http://www.mingw.org/  (look for msys)
>   https://gist.github.com/evanwill/0207876c3243bbb6863e65ec5dc3f058
> (git's bash-terminal)
>   https://sourceforge.net/projects/ezwinports/   
> 
> There were a couple another very highly recommended commercial Unix
> shell+utilities products (MKS Toolkit, Interix) that I used to
> use. But AFAIK, they all got bought and killed by Microsoft.
> 
> 
> Thanks Grant for these suggestions. Microsoft may have killed 
> them at the time, but useful software can resurface a number 
> of ways.  I'll keep your list and go looking for them 
> someday. I think something like Drawers or MyLauncher that 
> Jim mentioned would fit the bill for my immediate use, but 
> old Unix utilities sound kinda neat in themselves, and well 
> worth looking into in my free time. (haha, free time you say? 
> But seriously I'd like to check them out.)
> 
> Deborah

Whoops, I just noticed on rereading that only MKS Toolkit and Interix
were bought and killed by Microsoft, not your entire list. Guess they
can't buy open source code anyway.

While this is sad for MKS Toolkit and Interix, it does mean the others
are probably still available as open source.

I used to work in a partially Unix house in mechanical engineering at
Ingersoll-Rand. I did DOS and the brand new ever Windows (1.0?) at the
time, but I remember looking at MKS Toolkit on the Unix machines to see
if it could be adapted to Windows. Very sad if it is lost for good.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python application launcher (for Python code)

2017-02-21 Thread Ethan Furman

On 02/21/2017 11:59 AM, Deborah Swanson wrote:


I think I'll have a go with Cooperative Linux first


It certainly looks interesting, but doesn't seem to have any activity since 
late 2014.

--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list


RE: Python application launcher (for Python code)

2017-02-21 Thread Deborah Swanson
Ethan Furman wrote, on February 21, 2017 1:13 PM
> 
> On 02/21/2017 11:59 AM, Deborah Swanson wrote:
> 
> > I think I'll have a go with Cooperative Linux first
> 
> It certainly looks interesting, but doesn't seem to have any 
> activity since late 2014.
> 
> --
> ~Ethan~

I can't remember where I picked up the link for Cooperative Linux (aka
coLinux), but the newsletter Import Python is a good bet, and it would
have been in an issue no more than 2 weeks ago.  Maybe somebody's trying
to revive it, or just spread the word. The article certainly glowed
about how useful it is.

Guess I'll download and try it, it's a sourceforge page. So if it
downloads and installs (that may be the tricky part), I'm probably set
to go.

I don't have a problem with old software and it seems some open software
isn't updated for long periods of time. If it works and does something
useful for me, I'm fine with it. Some of my oldest spreadsheets I use
daily are about 15 years old, and so is the Excel I run them in.  ;)

Deborah

-- 
https://mail.python.org/mailman/listinfo/python-list


python decorator

2017-02-21 Thread alfredocabrera4
I have a python function and a decorator that works just fine.

def fun_cache(function):
memo = {}
def wrapper(*args):
if args in memo:
return memo[args]
else:
rv = function(*args)
memo[args] = rv
return rv
return wrapper


@fun_cache
def fib(n):
if (n < 2): return 1
else: return fib(n-1) + fib(n-2)

assert(fib(0) == 1)
assert(fib(3) == 3)
assert(fib(6) == 13)
assert(fib(10) == 89)
assert(fib(30) == 1346269)
assert(fib(100) == 573147844013817084101)
assert(fib(400) == 
284812298108489611757988937681460995615380088782304890986477195645969271404032323901)


Now I will like to call the @fun_cache decorator like this :

@fun_cache(cache={})

Any help?
-- 
https://mail.python.org/mailman/listinfo/python-list


[ANN] New Slack Group Dedicated to learning Python

2017-02-21 Thread Joe Anonimist
Hello all!

Me and a few other Python enthusiasts started a Slack group dedicated to 
learning Python. All of us know the basics of Python and our goal is to acquire 
new skills that would help us get jobs as Python developers. Our plan is to 
collaborate on Python projects to get experience and become Python 
professionals.

If you are interested send me your email address and I'll send you an 
invitation to join the group. If you have a Reddit account you can visit our 
subreddit https://www.reddit.com/r/pystudygroup/ and PM me your mail for an 
invitation.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [ANN] New Slack Group Dedicated to learning Python

2017-02-21 Thread Joe Anonimist
On Wednesday, 22 February 2017 08:07:01 UTC+1, Joe Anonimist  wrote:
> Hello all!
> 
> Me and a few other Python enthusiasts started a Slack group dedicated to 
> learning Python. All of us know the basics of Python and our goal is to 
> acquire new skills that would help us get jobs as Python developers. Our plan 
> is to collaborate on Python projects to get experience and become Python 
> professionals.
> 
> If you are interested send me your email address and I'll send you an 
> invitation to join the group. If you have a Reddit account you can visit our 
> subreddit https://www.reddit.com/r/pystudygroup/ and PM me your mail for an 
> invitation.

Invitation sent :)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python decorator

2017-02-21 Thread Cameron Simpson

On 21Feb2017 22:44, alfredocabre...@gmail.com  wrote:

I have a python function and a decorator that works just fine.

def fun_cache(function):
   memo = {}
   def wrapper(*args):
   if args in memo:
   return memo[args]
   else:
   rv = function(*args)
   memo[args] = rv
   return rv
   return wrapper


@fun_cache
def fib(n):
   if (n < 2): return 1
   else: return fib(n-1) + fib(n-2)

assert(fib(0) == 1)
assert(fib(3) == 3)
assert(fib(6) == 13)
assert(fib(10) == 89)
assert(fib(30) == 1346269)
assert(fib(100) == 573147844013817084101)
assert(fib(400) == 
284812298108489611757988937681460995615380088782304890986477195645969271404032323901)


Now I will like to call the @fun_cache decorator like this :

@fun_cache(cache={})

Any help?


You need to write "fun_cache" as a function accepting a cache argument, and 
returning a decorator that uses that cache.


Like:

   def fun_cache(cache):
   def fun_cache_decorator(function):
   def wrapper(*args):
   ... save things in cache instead of memo ...
   return wrapper
   return fun_cache_decorator

Cheers,
Cameron Simpson 
--
https://mail.python.org/mailman/listinfo/python-list


Re: python decorator

2017-02-21 Thread Argentinian Black ops lll
Thanks for the quick response...! you saved me a lot of time, thank you!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python decorator

2017-02-21 Thread Argentinian Black ops lll
*** SOLVED ***
-- 
https://mail.python.org/mailman/listinfo/python-list