Re: The hardest problem in computer science...

2017-01-06 Thread Steve D'Aprano
On Sat, 7 Jan 2017 12:03 am, Steve D'Aprano wrote:

> The second hardest problem in computer science is cache invalidation.
> 
> The *hardest* problem is naming things.

Thanks everyone who answered, but I think some of you misunderstood my
question. I know that the individual characters themselves are called some
variation of "line drawing characters", or "box drawing characters". But
the important part of the question was given by the Python code:

> XXX = namedtuple("XXX", "vline tee corner")
> 
> default_YYY = XXX("│  ", "├─ ", "└─ ")
> bold_YYY = XXX("┃  ", "┣━ ", "┗━ ")
> ascii_YYY = XXX("|  ", "|- ", "+- ")
> 
> def draw_tree(tree, YYY=default_YYY):
> ...
> 
> 
> but what do I call XXX and YYY?

After puzzling over this for three days, it suddenly hit me:

Theme = namedtuple("Theme", "vline tee corner")

DEFAULT = Theme("│  ", "├─ ", "└─ ")
BOLD = Theme("┃  ", "┣━ ", "┗━ ")
ASCII = Theme("|  ", "|- ", "+- ")
 
def draw_tree(tree, theme=DEFAULT):
...



Ethan's idea of "style" is also good.


Thanks for all your ideas!



-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

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


Re: Search a sequence for its minimum and stop as soon as the lowest possible value is found

2017-01-06 Thread Rustom Mody
On Saturday, January 7, 2017 at 12:26:04 PM UTC+5:30, Jussi Piitulainen wrote:
> Paul Rubin writes:
> 
> > Peter Otten writes:
> >> How would you implement stopmin()?
> >
> > Use itertools.takewhile
> 
> How? It consumes the crucial stop element:
> 
>it = iter('what?')
>list(takewhile(str.isalpha, it)) # ==> ['w', 'h', 'a', 't']
>next(it, 42) # ==> 42

I was also wondering how…
In a lazy language (eg haskell) with non-strict foldr (reduce but rightwards)
supplied non-strict operator this is trivial.
ie in python idiom with reduce being right_reduce
reduce(operator.mul, [1,2,0,4,...], 1)
the reduction would stop at the 0
Not sure how to simulate this in a strict language like python
Making fold(r) non-strict by using generators is ok
How to pass a non-strict operator?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Search a sequence for its minimum and stop as soon as the lowest possible value is found

2017-01-06 Thread Jussi Piitulainen
Paul Rubin writes:

> Peter Otten writes:
>> How would you implement stopmin()?
>
> Use itertools.takewhile

How? It consumes the crucial stop element:

   it = iter('what?')
   list(takewhile(str.isalpha, it)) # ==> ['w', 'h', 'a', 't']
   next(it, 42) # ==> 42
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Namedtuples: TypeError: 'str' object is not callable

2017-01-06 Thread Deborah Swanson
Chris Angelico wrote, on January 06, 2017 9:14 PM
> 
> On Sat, Jan 7, 2017 at 4:07 PM, Deborah Swanson 
>  wrote:
> >
> > I really don't know how long it would've taken me to think of that,
so 
> > thank you!
> 
> I have a well-trained crystal ball :)
> 
> ChrisA

More like a very experienced eye. I keep hoping I'll get one of those,
but it takes time.

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


Re: Namedtuples: TypeError: 'str' object is not callable

2017-01-06 Thread Chris Angelico
On Sat, Jan 7, 2017 at 4:07 PM, Deborah Swanson
 wrote:
> And you would be precisely correct. I have a variable named 'map', and I
> intended to delete it and the code that used it, but totally forgot
> about it. It's still in there somewhere, but a simple search will find
> it.
>
> I really don't know how long it would've taken me to think of that, so
> thank you!

I have a well-trained crystal ball :)

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


RE: Namedtuples: TypeError: 'str' object is not callable

2017-01-06 Thread Deborah Swanson
Chris Angelico wrote, on January 06, 2017 8:05 PM
> To: python-list@python.org
> Subject: Re: Namedtuples: TypeError: 'str' object is not callable
> 
> 
> On Sat, Jan 7, 2017 at 2:46 PM, Deborah Swanson 
>  wrote:
> > And here's the Traceback in PyCharm:
> >   File "E:/Coding projects/Pycharm/Moving/moving_numberedtuples.py",
> > line 139, in moving()
> > for lst in map(listings._make, csv.reader(open('E:\\Coding 
> > projects\\Pycharm\\Moving\\Moving 2017 in.csv',"r"))):
> > TypeError: 'str' object is not callable
> >
> > What str object is not callable, and how do I fix it?
> 
> Toss in a 'print' above that. You're calling map and open 
> (and csv.reader, but I doubt you've shadowed that). My money 
> would be on 'map' having been assigned something.
> 
> ChrisA

And you would be precisely correct. I have a variable named 'map', and I
intended to delete it and the code that used it, but totally forgot
about it. It's still in there somewhere, but a simple search will find
it.

I really don't know how long it would've taken me to think of that, so
thank you!

Deborah

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


Re: Namedtuples: TypeError: 'str' object is not callable

2017-01-06 Thread Chris Angelico
On Sat, Jan 7, 2017 at 2:46 PM, Deborah Swanson
 wrote:
> And here's the Traceback in PyCharm:
>   File "E:/Coding projects/Pycharm/Moving/moving_numberedtuples.py",
> line 139, in moving()
> for lst in map(listings._make, csv.reader(open('E:\\Coding
> projects\\Pycharm\\Moving\\Moving 2017 in.csv',"r"))):
> TypeError: 'str' object is not callable
>
> What str object is not callable, and how do I fix it?

Toss in a 'print' above that. You're calling map and open (and
csv.reader, but I doubt you've shadowed that). My money would be on
'map' having been assigned something.

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


Namedtuples: TypeError: 'str' object is not callable

2017-01-06 Thread Deborah Swanson
I'm not sure what Python is complaining about here, or why.
 
Here's the example from the Python docs: 
https://docs.python.org/3/library/collections.html#collections.namedtupl
e

EmployeeRecord = namedtuple('EmployeeRecord', 'name, age, title,
department, paygrade')

import csv
for emp in map(EmployeeRecord._make, csv.reader(open("employees.csv",
"rb"))):
print(emp.name, emp.title)

And here's my code:

listings = namedtuple('listings', ['CLDesc', 'url', 'desc',
'Description',  'Location', 'STco', 'miles', 'Kind', 'Rent', 'Date',
'br', 'Notes', 
'yesno', 'mark', 'arc'])
for lst in map(listings._make, csv.reader(open('Moving 2017.csv',
"r"))):
.
.

(['x', 'y'] is a valid format for the field names, and there are no
errors when the definition for listings executes.)


And here's the Traceback in PyCharm:
  File "E:/Coding projects/Pycharm/Moving/moving_numberedtuples.py",
line 139, in moving()
for lst in map(listings._make, csv.reader(open('E:\\Coding
projects\\Pycharm\\Moving\\Moving 2017 in.csv',"r"))):
TypeError: 'str' object is not callable

What str object is not callable, and how do I fix it?  I see an
iteration variable (lst), a namedtuples method call(listings._make,
which makes a new instance of listings) and a csv.reader call, a
variable and 2 method calls, none of which are bare strings, except
possibly 'listings._make', but there's no str it might be trying to call
that I can see. My 'for' statement looks like a good copy of the example
from the docs to me, and the example in the docs uses
'EmployeeRecord._make' with no parentheses.

Is the example from the docs possibly in error? I don't see any other
possibility, but maybe I'm not looking in the right place. 

I don't know enough about classes in Python yet to know if this is ok or
not. And when I tried again with 'listings._make()', I got:

TypeError: _make() missing 1 required positional argument: 'iterable'.

This suggests that maybe 'listings._make' is wrong, but if it should be
'listings._make()', what should the iterable be? 'listings'?

'listings._make(listings)' looks awfully redundant for Python, so 
'_make(listings)' would make more sense (pun not intended), and seems to
be what the error thinks it is. But when I change it to
'_make(listings)', I get:

NameError: name '_make' is not defined

'listings._make(listings)' gets "TypeError: 'type' object is not
iterable", which answers the question of whether a namedtuple instance
(if that's what 'listings' is) is an iterable. It isn't.

There might be a version problem here. I'm using Python 3.4.3, and the
url for this page simply indicates version 3. As most of us know,
there's a lot of variance between dot versions of 3, and quite possibly
not all of the changes are documented correctly. In 3.4.3 the usage
might be slightly different, or the code broken.

Any help with this would be hugely appreciated.


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


Re: The hardest problem in computer science...

2017-01-06 Thread Larry Hudson via Python-list

On 01/06/2017 05:03 AM, Steve D'Aprano wrote:

The second hardest problem in computer science is cache invalidation.

The *hardest* problem is naming things.

In a hierarchical tree view widget that displays items like this:


Fiction
├─ Fantasy
│  ├─ Terry Pratchett
│  │  ├─ Discworld

[snip]


but what do I call XXX and YYY?


Seriously-considering-just-hard-coding-them-as-magic-constants-ly y'rs,


I don't know if this is helpful or even relevant, but here is a class for using these 
box-drawing characters that I wrote for my own use.  (I'm just a hobby programmer...)
It's not very elegant and not particularly convenient to use, but it is usable.  And I hesitate 
to post it because it is so long (approx 90 line docstring to explain its use, and ending with 
some test code).  In any case, here it is...



#   boxch.py

"""
BoxChr class to handle box-drawing characters.

The character is selected by a two-character string:
'tl', 'tm', 'tr' -- Top Left, Top Mid, Top Right:  ┌ ┬ ┐
'ml', 'mm', 'mr' -- Mid Left, Mid Mid, Mid Right:  ├ ┼ ┤
'bl', 'bm', 'br' -- Bot Left, Bot Mid, Bot Right:  └ ┴ ┘
'hz', 'vt'   -- Horizontal and Vertical lines: ─ │
Case is ignored.  Invalid selection string returns a dot:  '·'
NOTE:  It is currently disabled, but the code is still
available to handle small and large dots with 'dt' and 'dd'.
These both ignore the style.

The style is selected by a two-character string:
The characters are 's', 'd' and 'b' for single, double and bold.
The first character defines the horizontal components,
the second defines the vertical components.
The valid styles are 'ss', 'sd', 'sb', 'ds', 'dd', 'bs', 'bb'.
The potential styles 'db' and 'bd' are invalid.
The class defaults to 'ss' -- single horizontal, single vertical.
Case is ignored.  Invalid style string raises ValueError.

NOTE:  The following examples assume bc has been set to a BoxChr class.
bc = BoxChr()   #   Style defaults to 'ss'
  or
bc = BoxChr('sd')   #   Style set to single/double, or whatever desired.
(Examples assume 'ss' style.)

Attributes:
style:  set or return the style-code string.
Case is ignored.  Invalid style raises ValueError.
Examples:  bc.style = 'ds' -- sets style to double/single.
st = bc.style -- sets variable st to current style code.

Methods:
[] (__getitem__):  Returns selected box character.
Case is ignored.  Invalid selector returns a dot:  '·'
Example:  bc['tm'] returns '┬'

bxstr():   Returns a string created from a sequence of box character codes
and 'normal' characters.  (in this description 'selector' refers
to the two-character codes as defined above.)

Each element of the given sequence (list or tuple) must be a
string, either a series of selector codes, or a 'normal' string
(one without any box selectors).  The box character selector string
must start with 'BX' followed by the selector codes, separated by
spaces.  The 'BX' must be upper case, but the case of the selector
codes is ignored.  A space between the 'BX' prefix and the first
selector code is optional.  This selector string can only contain
selector codes.  'Normal' characters are simply given as normal
strings, interspersed with the selector strings in the given
sequence.

If the selection is only box characters, it can opionally be passed
as a single string rather than enclosing it in a list.
Example:
seq = ['BX ml hz', ' TEXT ', 'BX hz mr']
bc.bxstr(seq) returns '├─ TEXT ─┤'
Note:
If you need a string beginning with 'BX' it has to be given
as a single-character string 'B' followed by a string containing
the remaining text.  Example 'BX etc' must be given as:
['B', 'X etc'].

boxtext():  Create boxed text, returned as a single string with
embedded newlines.

Parameters:
txt The text to use
tsize   Expand tabs to specified number of spaces,  Default is 4
just'<', '^' or '>' as left/center/right justification.
Default is '<' — left-justified.
tallIf True, inserts a blank line above and below the text.
If False, no extra blank lines are used.
Default is True.

Text can be either a single string with embedded newlines (ie. a
triple-quoted string) or list of strings.  Trailing blank lines
are removed.  Center and right justification will strip whitespace
from both ends of the lines.  Left justification (the default)
only strips trailing whitespace.

Width is based on the length of the longest line, plus two spa

Re: Using sudo with pip3?

2017-01-06 Thread Cameron Simpson

On 06Jan2017 23:03, Clint Moyer  wrote:

Packages supplied by your distribution can be trusted more than packages
from PyPi. Just my two cents.
Most distros offer nearly all the useful Python modules directly from the
repo.


I would agree with this on the whole. And also that it is generally better to 
add modules to your system python via the distro's repo because that bring 
benefit to every user on the system, not just yourself.



Virtual environments are great, but if you want to add libraries to your
system interpreter I'd recommend a simple sync through your repo.


I'm directly advocating _not_ adding PyPI packages to the system interpreter.  
If nothing else, they may differ in behaviour and potentially actually break 
system behaviour.


Having your on virtualenv is good for: adding packages no provided by your 
vendor, adding packages deliberately different from those from your vendor (eg 
newer versions with specific bugfixes or extra features), having an isolated 
environment for packages (you can make more than one virtual environment).


And of course it avoids interfering with your system python install.

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


Re: The hardest problem in computer science...

2017-01-06 Thread Mario R. Osorio
On Friday, January 6, 2017 at 8:45:41 PM UTC-5, Mario R. Osorio wrote:
> On Friday, January 6, 2017 at 10:37:40 AM UTC-5, Ethan Furman wrote:
> > On 01/06/2017 05:03 AM, Steve D'Aprano wrote:
> > 
> > > what do we call the vertical and horizontal line elements? I want to make
> > > them configurable, which means the user has to be able to pass an argument
> > > that specifies them. I have names for the individual components:
> > >
> > > XXX = namedtuple("XXX", "vline tee corner")
> > >
> > > default_YYY = XXX("│  ", "├─ ", "└─ ")
> > > bold_YYY = XXX("┃  ", "┣━ ", "┗━ ")
> > > ascii_YYY = XXX("|  ", "|- ", "+- ")
> > >
> > > def draw_tree(tree, YYY=default_YYY):
> > >  ...
> > >
> > > but what do I call XXX and YYY?
> > 
> > Looks like horizontal, vertical, and corner are as groups -- so I would 
> > call YYY "style" and XXX "default", "bold", and "ascii".
> > 
> > --
> > ~Ethan~
> 
> back in the days of CPM this group was referred to as "box characters", and 
> each of them were called as follows:
> 
> "│": vertical_line, v_line
> 
> "├─": left_intersection, l_intersection, left_tee, l_tee
> 
> "└─": bottom_left_corner, bl_corner
> 
> [...and son on...]
> 
> (the names also apply to the combination of lower ascii characters)



NOW ... in particular this case I'd call them:

"│": vertical_line, v_line
 
"├─": node
 
"└─": last_node, l_node

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


Re: The hardest problem in computer science...

2017-01-06 Thread Mario R. Osorio
On Friday, January 6, 2017 at 10:37:40 AM UTC-5, Ethan Furman wrote:
> On 01/06/2017 05:03 AM, Steve D'Aprano wrote:
> 
> > what do we call the vertical and horizontal line elements? I want to make
> > them configurable, which means the user has to be able to pass an argument
> > that specifies them. I have names for the individual components:
> >
> > XXX = namedtuple("XXX", "vline tee corner")
> >
> > default_YYY = XXX("│  ", "├─ ", "└─ ")
> > bold_YYY = XXX("┃  ", "┣━ ", "┗━ ")
> > ascii_YYY = XXX("|  ", "|- ", "+- ")
> >
> > def draw_tree(tree, YYY=default_YYY):
> >  ...
> >
> > but what do I call XXX and YYY?
> 
> Looks like horizontal, vertical, and corner are as groups -- so I would call 
> YYY "style" and XXX "default", "bold", and "ascii".
> 
> --
> ~Ethan~

back in the days of CPM this group was referred to as "box characters", and 
each of them were called as follows:

"│": vertical_line, v_line

"├─": left_intersection, l_intersection, left_tee, l_tee

"└─": bottom_left_corner, bl_corner

[...and son on...]

(the names also apply to the combination of lower ascii characters)


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


Re: Search a sequence for its minimum and stop as soon as the lowest possible value is found

2017-01-06 Thread Paul Rubin
Peter Otten <__pete...@web.de> writes:
> How would you implement stopmin()?

Use itertools.takewhile
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Using sudo with pip3?

2017-01-06 Thread Clint Moyer
>From Ubuntu, why not try:

sudo apt-get install python-matplotlib

-Clint

On Fri, Jan 6, 2017 at 3:09 PM jim  wrote:

> Setting up a new computer to run Ubuntu 16.04. Started using pip3 to
>
> install all the python stuff I had on the old machine and got this message:
>
>
>
> jfb@jims-1604:~$ sudo pip3 install matplotlib
>
> [sudo] password for jfb:
>
> The directory '/home/jfb/.cache/pip/http' or its parent directory is not
>
> owned by the current user and the cache has been disabled. Please check
>
> the permissions and owner of that directory. If executing pip with sudo,
>
> you may want sudo's -H flag.
>
>
>
> I (jfb) own the directory in question.
>
>
>
> I used sudo because I recall needing to use it on the old machine to get
>
> something to install. So is it necessary or even desirable to use sudo
>
> with pip3?
>
>
>
> Thanks,  Jim
>
>
>
> --
>
> https://mail.python.org/mailman/listinfo/python-list
>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


crosstab output

2017-01-06 Thread Val Krem via Python-list
Hi all,

How do I access the rows and columns of a data frame crosstab output?


Here is code using  a sample data and output.

a= pd.read_csv("cross.dat", skipinitialspace=True)
xc=pd.crosstab(a['nam'],a['x1'],margins=True)

print(xc)

x10  1 
nam 
A13  2 
A21  4

I want to create a variable  by adding 2/(3+2) for the first row(A1)
and 4/(1+4) for the second row (A2)

Final data frame would be
A1 3 2  0.4
A2 1 4  0.8

Thank you in advance
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pexpect

2017-01-06 Thread Cameron Simpson

On 06Jan2017 11:37, Joaquin Alzola  wrote:

Iranna Mathapati  asked:

How to match latter(caps and small) ,numbers and # symbol in python pexpect.


With a .*


Ugh. Please not. Expect() accepts a nongreedy regular expression. ".*" is the 
lazy "match absolutely anything" pattern. Generally overused and imprecise.  
Iranna Mathapati knows what to look for.


See the documentation for the re module, specificly the regular expression 
syntax:


 https://docs.python.org/3/library/re.html#regular-expression-syntax

To match letters, digits and "#", try:

 [0-9a-zA-Z#]*

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


Re: Using sudo with pip3?

2017-01-06 Thread Clint Moyer
Packages supplied by your distribution can be trusted more than packages
from PyPi. Just my two cents.

Most distros offer nearly all the useful Python modules directly from the
repo.

Virtual environments are great, but if you want to add libraries to your
system interpreter I'd recommend a simple sync through your repo.

- Clint

On Fri, Jan 6, 2017 at 3:38 PM  wrote:

> On 06Jan2017 15:44, jim  wrote:
>
> >Setting up a new computer to run Ubuntu 16.04. Started using pip3 to
>
> >install all the python stuff I had on the old machine and got this
>
> >message:
>
> >
>
> >jfb@jims-1604:~$ sudo pip3 install matplotlib
>
> >[sudo] password for jfb:
>
> >The directory '/home/jfb/.cache/pip/http' or its parent directory is
>
> >not owned by the current user and the cache has been disabled. Please
>
> >check the permissions and owner of that directory. If executing pip
>
> >with sudo, you may want sudo's -H flag.
>
> >
>
> >I (jfb) own the directory in question.
>
> >
>
> >I used sudo because I recall needing to use it on the old machine to
>
> >get something to install. So is it necessary or even desirable to use sudo
>
> >with pip3?
>
>
>
> I would not, unless I were specificly trying to install into the system's
>
> python3 libraries. That will inherently fight with any vendor (Unbuntu)
>
> supplied packages that come through apt-get.
>
>
>
> Instead I would make myself a virtualenv _based off the system python3_
> and use
>
> the venv's pip to install extra packages. Not using sudo. They will land in
>
> your virtualenv directory's lib area, be entirely owned and controlled by
> you,
>
> and not have any complications that come with sudo.
>
>
>
> Then just symlink the virtualenv's "python3" into your own $HOME/bin and
>
> whenever you invoke "python3" it will run the virtualenv one, getting all
> the
>
> package goodness you have added.
>
>
>
> An important sysadmin rule of thumb: use apt (or yum etc, depending on
> distro)
>
> as root to install vendor supplied packages. And install your owon
> packages _as
>
> you_ in another area, _not_ in the system managed area. Virtualenv makes
> this
>
> very easy to do for Python.
>
>
>
> Cheers,
>
> Cameron Simpson 
>
> --
>
> https://mail.python.org/mailman/listinfo/python-list
>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Receiving a lot of double messages.

2017-01-06 Thread Deborah Swanson
Grant Edwards wrote, on January 06, 2017 1:56 PM
> 
> On 2017-01-05, Antoon Pardon  wrote:
> 
> > Is there something going on with the mailinglist? Because I have 
> > receive a lot
> > of double messages. One copy is fairly normal and is part 
> of the discussion 
> > thread, the other is completely seperated. -- Antoon Pardon.
> 
> Yep, there are a _lot_ of duplicate messages showing up on 
> gmane's NNTP server.  I would guess around 50-100 of them in 
> the past day. Entire chunks of long threads comprising 20-30 
> posts seem to be duplicated in some cases.  In other cases, 
> they're just individual posts that seem to be detached from 
> their original threads.
> 
> Something is seriously broken somewhere...
> 
> -- 
> Grant Edwards   grant.b.edwardsYow! I 
> want a VEGETARIAN
>   at   BURRITO to 
> go ... with
>   gmail.comEXTRA MSG!!

162 duplicate messages, as of 2:04 PM PST today, to be precise. This
same thing happened when I was on the Exchange team at Microsoft, but
that was on a pre-release dogfood mail server, not even a beta for a
pre-release. Good thing it was only in-house Microsofties who had to
field the thousands of garbage messages when that happened.

The problem then was that they had to flush the mail queue that had
become clogged up with duplicate messages because some bit of code had
looped back on itself. 

Granted, the list mail server probably isn't an enterprise version, with
mail replicating between hundreds of servers, but as Chris mentioned, it
does take a feed from the newsgroup, and there's plenty of room for that
to break. Quite likely the fix for any mail server whose mail queue has
been corrupted is to flush it.

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


Re: Using sudo with pip3?

2017-01-06 Thread cs

On 06Jan2017 15:44, jim  wrote:
Setting up a new computer to run Ubuntu 16.04. Started using pip3 to 
install all the python stuff I had on the old machine and got this 
message:


jfb@jims-1604:~$ sudo pip3 install matplotlib
[sudo] password for jfb:
The directory '/home/jfb/.cache/pip/http' or its parent directory is 
not owned by the current user and the cache has been disabled. Please 
check the permissions and owner of that directory. If executing pip 
with sudo, you may want sudo's -H flag.


I (jfb) own the directory in question.

I used sudo because I recall needing to use it on the old machine to 
get something to install. So is it necessary or even desirable to use sudo 
with pip3?


I would not, unless I were specificly trying to install into the system's 
python3 libraries. That will inherently fight with any vendor (Unbuntu) 
supplied packages that come through apt-get.


Instead I would make myself a virtualenv _based off the system python3_ and use 
the venv's pip to install extra packages. Not using sudo. They will land in 
your virtualenv directory's lib area, be entirely owned and controlled by you, 
and not have any complications that come with sudo.


Then just symlink the virtualenv's "python3" into your own $HOME/bin and 
whenever you invoke "python3" it will run the virtualenv one, getting all the 
package goodness you have added.


An important sysadmin rule of thumb: use apt (or yum etc, depending on distro) 
as root to install vendor supplied packages. And install your owon packages _as 
you_ in another area, _not_ in the system managed area. Virtualenv makes this 
very easy to do for Python.


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


Using sudo with pip3?

2017-01-06 Thread jim
Setting up a new computer to run Ubuntu 16.04. Started using pip3 to 
install all the python stuff I had on the old machine and got this message:


jfb@jims-1604:~$ sudo pip3 install matplotlib
[sudo] password for jfb:
The directory '/home/jfb/.cache/pip/http' or its parent directory is not 
owned by the current user and the cache has been disabled. Please check 
the permissions and owner of that directory. If executing pip with sudo, 
you may want sudo's -H flag.


I (jfb) own the directory in question.

I used sudo because I recall needing to use it on the old machine to get 
something to install. So is it necessary or even desirable to use sudo 
with pip3?


Thanks,  Jim

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


Re: Receiving a lot of double messages.

2017-01-06 Thread Grant Edwards
On 2017-01-05, Antoon Pardon  wrote:

> Is there something going on with the mailinglist? Because I have receive a 
> lot 
> of double messages. One copy is fairly normal and is part of the discussion 
> thread, the other is completely seperated. -- Antoon Pardon.

Yep, there are a _lot_ of duplicate messages showing up on gmane's
NNTP server.  I would guess around 50-100 of them in the past day.
Entire chunks of long threads comprising 20-30 posts seem to be
duplicated in some cases.  In other cases, they're just individual
posts that seem to be detached from their original threads.

Something is seriously broken somewhere...

-- 
Grant Edwards   grant.b.edwardsYow! I want a VEGETARIAN
  at   BURRITO to go ... with
  gmail.comEXTRA MSG!!

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


Re: Choosing a Python IDE. what is your Pythonish recommendation? I do

2017-01-06 Thread Paul Rudin
Tim Johnson  writes:

> * Antonio Caminero Garcia  [170102 20:56]:
>> Guys really thank you for your answers. Basically now I am more
>> emphasizing in learning in depth a tool and get stick to it so I
>> can get a fast workflow. Eventually I will learn Vim and its
>> python developing setup, I know people who have been programming
>> using Vim for almost 20 years and they did not need to change
>> editor (that is really awesome).
>
>  Bye the way, one thing I like about the GUI based vim is that it
>  supports tabs, where emacs does not.

M-x package-install tabbar

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


RE: Receiving a lot of double messages.

2017-01-06 Thread Deborah Swanson
Antoon Pardon wrote, on January 06, 2017 2:11 AM
>
> Is there something going on with the mailinglist? Because I
> have receive a lot of double messages. One copy is fairly
> normal and is part of the discussion thread, the other is
> completely seperated. -- Antoon Pardon.

Looks to me like the mail server got backed up or jammed and they're flushing 
the mail queue. I haven't seen anything older than Jan. 2 and just started 
seeing some current ones, so I think it's almost over with.

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


Re: Forcing prompt to be on newline when embedding Python with

2017-01-06 Thread H Krishnan
Thanks for your help.

>
> >
> > I am working on embedding Python in my application.
>
> You forgot to tell us the version of Python that you're embedding.
>
> I am using Python2.7.


> > I have redirected sys.stdin and sys.stdout to call methods from a Qt
> TextEdit
> > widget. Everything works fine except that the Python prompt does not
> always
> > come in a new line:
> >
>  dir()
> > ['__builtins__', '__doc__', '__name__', '__package__']>>>
> >
> > Why doesn't the prompt appear in a new line as with the default stdout?
>
> Are you using code.InteractiveConsole / code.interact?
>
> I am using code.InteractiveConsole().interact().


> If not, in what mode do you compile, Py_file_input ("exec") or
> Py_single_input ("single")? The latter executes PRINT_EXPR:
>
> >>> dis.dis(compile('1', '', 'single'))
>   1   0 LOAD_CONST   0 (1)
>   3 PRINT_EXPR
>   4 LOAD_CONST   1 (None)
>   7 RETURN_VALUE
>
> PRINT_EXPR in turn calls sys.displayhook on the value it pops from the
> stack. The default hook writes the repr of the value and a newline to
> sys.stdout, and it also references the value as "_" in the builtins
> module (2.x __builtin__).
>

I tried replacing sys.displayhook with a function that does not print newline 
but the newline still got inserted. So, I am not sure where the newline is 
coming from. In any case, I could override sys.displayhook to add a newline at 
the end and that seems to resolve my problem.


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

Thanks,
Krishnan

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


Re: Choosing a Python IDE. what is your Pythonish recommendation? I do

2017-01-06 Thread Steven D'Aprano
On Wednesday 04 January 2017 12:10, Cameron Simpson wrote:

> On 03Jan2017 12:57, Steve D'Aprano  wrote:
>>I dislike the Unix-style Vim/Emacs text editors, I prefer a traditional
>>GUI-based editor. So my "IDE" is:
>>- Firefox, for doing searches and looking up documentation;
>>- an GUI programmer's editor, preferably one with a tab-based
>>  interface, such as geany or kate;
>>- a tab-based terminal.
>
> "traditional GUI-based editor"
>
> For those of us who spent a lot of our earlier time on terminals (actual
> physical terminals) we consider GUIs "new fangled".
>
> Just narking,
> Cameron Simpson 


Heh, GUI editors have been around since at least 1984, if not older, which 
makes them older than half the programmers in the world.

I'm not sure what an *un*traditional GUI-based editor would look like. Maybe 
one that used a ribbon-based interface, like MS Office? Or perhaps Leo?

http://leoeditor.com/

[My resolution for 2017: stop talking about Leo and actually download the damn 
thing and try it out.]



--
Steven
"Ever since I learned about confirmation bias, I've been seeing it everywhere."
- Jon Ronson

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


Re: Python for WEB-page !?

2017-01-06 Thread Michael Torrie
On 01/05/2017 04:53 PM, Victor Porton wrote:
> Ionut Predoiu wrote:
>
>> I am a beginner in programming language.
>> I want to know what version of Python I must to learn to use, beside of
>> basic language, because I want to integrate in my site 1 page in which
>> users to can made calculus based on my formulas already write behind (the
>> users will only complete some field, and after push "Calculate" button
>> will see the results in form of: table, graphic, and so on ...). Please
>> take into account that behind will be more mathematical
>> equations/formulas, so the speed I think must be take into account.
>
> Consider PyPi. I never used it, but they say, it is faster than usual
> CPython interpreter.

With respect, I don't think it's appropriate to direct a python beginner to 
PyPi.  Far better to direct him to the relevant resources (like Django) and 
focus him on the standard Python interpreter, hopefully version 3.

Besides that, there's the old expression. Premature optimization is the root of 
all evil.  Until Python is shown to be too slow for a given task, it's 
premature to think about speedups like Cython or even PyPi.

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


Re: Forcing prompt to be on newline when embedding Python with

2017-01-06 Thread eryk sun
On Fri, Jan 6, 2017 at 1:06 AM, H Krishnan  wrote:
> I tried replacing sys.displayhook with a function that does not print
> newline but the newline still got inserted. So, I am not sure where the
> newline is coming from. In any case, I could override sys.displayhook to add
> a newline at the end and that seems to resolve my problem.

In Python 2 the newline is written depending on the value of 
sys.stdout.softspace. sys.displayhook initially calls Py_FlushLine, which 
resets the file's softspace to 0 via PyFile_SoftSpace and writes a newline if 
the previous value was non-zero. Next displayhook writes the repr, sets the 
softspace to 1 and calls Py_FlushLine again.

The result you're seeing could occur if your filelike object doesn't have a 
dict or a property to allow setting the "softspace" attribute, as the following 
toy example demonstrates:

import sys

class File(object):
def __init__(self, file):
self._file = file
self._sp_enabled = True
self.softspace = 0

def write(self, string):
return self._file.write(string)

def __getattribute__(self, name):
value = object.__getattribute__(self, name)
if name == 'softspace':
if not self._sp_enabled:
raise AttributeError
self._file.write('[get softspace <- %d]\n' % value)
return value

def __setattr__(self, name, value):
if name == 'softspace':
if not self._sp_enabled:
raise AttributeError
self._file.write('[set softspace -> %d]\n' % value)
object.__setattr__(self, name, value)

softspace enabled:

>>> sys.stdout = File(sys.stdout)
[set softspace -> 0]
[get softspace <- 0]
[set softspace -> 0]
>>> 42
[get softspace <- 0]
[set softspace -> 0]
42[get softspace <- 0]
[set softspace -> 1]
[get softspace <- 1]
[set softspace -> 0]

[get softspace <- 0]
[set softspace -> 0]

softspace disabled:

>>> sys.stdout._sp_enabled = False
>>> 42
42>>> 42
42>>>

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


Re: Python for WEB-page !?

2017-01-06 Thread Michael Torrie
On 01/05/2017 05:57 AM, Ionut Predoiu wrote:
> Good afternoon,
>
> I am a beginner in programming language. I want to know what version
> of Python I must to learn to use, beside of basic language, because I
> want to integrate in my site 1 page in which users to can made
> calculus based on my formulas already write behind (the users will
> only complete some field, and after push "Calculate" button will see
> the results in form of: table, graphic, and so on ...). Please take
> into account that behind will be more mathematical
> equations/formulas, so the speed I think must be take into account.

While Python can do that, using a web framework to process HTTP requests and 
generate HTML to display in the browser, I don't believe Python is the 
appropriate language for the task at hand.  Most web sites that do interactive 
formula calculations like you describe do it all in the browser using 
Javascript.  No need to have a web server do all that heavy lifting at all.  A 
simple html file would contain everything you need.

Even if you want to use Python to generate the web page and process events, 
you'll still have to master Javascript at some point to make the webpages more 
interactive.

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


Re: Forcing prompt to be on newline when embedding Python with

2017-01-06 Thread H Krishnan
Hello Mr.Eryk,

Thanks for the detailed explanation. After I added attribute support to my 
extension class for stdio, the problem was resolved.

Regards,
Krishnan


On Fri, Jan 6, 2017 at 9:24 AM, eryk sun  wrote:

> On Fri, Jan 6, 2017 at 1:06 AM, H Krishnan  wrote:
> > I tried replacing sys.displayhook with a function that does not print
> > newline but the newline still got inserted. So, I am not sure where the
> > newline is coming from. In any case, I could override sys.displayhook to
> add
> > a newline at the end and that seems to resolve my problem.
>
> In Python 2 the newline is written depending on the value of
> sys.stdout.softspace. sys.displayhook initially calls Py_FlushLine,
> which resets the file's softspace to 0 via PyFile_SoftSpace and writes
> a newline if the previous value was non-zero. Next displayhook writes
> the repr, sets the softspace to 1 and calls Py_FlushLine again.
>
> The result you're seeing could occur if your filelike object doesn't
> have a dict or a property to allow setting the "softspace" attribute,
> as the following toy example demonstrates:
>
> import sys
>
> class File(object):
> def __init__(self, file):
> self._file = file
> self._sp_enabled = True
> self.softspace = 0
>
> def write(self, string):
> return self._file.write(string)
>
> def __getattribute__(self, name):
> value = object.__getattribute__(self, name)
> if name == 'softspace':
> if not self._sp_enabled:
> raise AttributeError
> self._file.write('[get softspace <- %d]\n' % value)
> return value
>
> def __setattr__(self, name, value):
> if name == 'softspace':
> if not self._sp_enabled:
> raise AttributeError
> self._file.write('[set softspace -> %d]\n' % value)
> object.__setattr__(self, name, value)
>
> softspace enabled:
>
> >>> sys.stdout = File(sys.stdout)
> [set softspace -> 0]
> [get softspace <- 0]
> [set softspace -> 0]
> >>> 42
> [get softspace <- 0]
> [set softspace -> 0]
> 42[get softspace <- 0]
> [set softspace -> 1]
> [get softspace <- 1]
> [set softspace -> 0]
>
> [get softspace <- 0]
> [set softspace -> 0]
>
> softspace disabled:
>
> >>> sys.stdout._sp_enabled = False
> >>> 42
> 42>>> 42
> 42>>>
> --
> https://mail.python.org/mailman/listinfo/python-list
>

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


RE: Python for WEB-page !?

2017-01-06 Thread Deborah Swanson
Ionut Predoiu wrote, on January 05, 2017 11:07 PM
>
> Good morning,
>
> Thanks to all for feedback and advice.
> Because I am a beginner I will read more about versions of
> Python recommended by you.
>
> On the other side I am interested to know if exist some sites
> which have develop platform where can be use for free Python
> from browsers, without have it installed on PC/laptop. As
> beginner I want to practice from everywhere.

There's a website called Python Tutor where you can write Python programs and 
it will show you the structures built in memory as it executes. It's  very 
useful for seeing how recursive functions work, or any function or class you 
call. It will also work for simple programs and it has an output console you 
can print to.  (Well, it's more like a print window, but it works.) Very good 
for beginners, I used it all the time when I was first learning, and I still 
use it for recursive functions, since PyCharm doesn't step through recursion in 
a clear way.

http://pythontutor.com/


> I waiting with higher interest your feedback.
>
> Thanks to all members of community for support and advice.
> Keep in touch.
> Kind regards.
>
>
>
> On Thursday, January 5, 2017 at 2:57:23 PM UTC+2, Ionut Predoiu wrote:
> > Good afternoon,
> >
> > I am a beginner in programming language.
> > I want to know what version of Python I must to learn to
> use, beside of basic language, because I want to integrate in
> my site 1 page in which users to can made calculus based on
> my formulas already write behind (the users will only
> complete some field, and after push "Calculate" button will
> see the results in form of: table, graphic, and so on ...).
> > Please take into account that behind will be more
> mathematical equations/formulas, so the speed I think must be
> take into account.
> >
> > I waiting with higher interest your feedback.
> >
> > Thanks to all members of community for support and advice. Keep in
> > touch. Kind regards.
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>

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


Re: Choosing a Python IDE. what is your Pythonish recommendation? I

2017-01-06 Thread Antonio Caminero Garcia
On Wednesday, January 4, 2017 at 1:10:04 PM UTC-8, Dietmar Schwertberger wrote:
> On 04.01.2017 07:54, Antonio Caminero Garcia wrote:
> > Unfortunately most of the time I am still using print and input functions.
I know that sucks, I did not use the pdb module, I guess that IDE debuggers 
leverage such module.
> pdb is actually quite useful. On my Windows PCs I can invoke python on
> any .py file with the -i command line switch by right clicking in the
> Explorer and selecting "Debug". Now when the script crashes, I can
> inspect variables without launching a full-scale IDE or starting the
> script from the command line. For such quick fixes I have also a context
> menu entry "Edit" for editing with Pythonwin, which is still quite OK as
> editor and has no licensing restrictions or installation requirements.
> This is a nice option when you deploy your installation to many PCs over
> the network.
I am on MacOS but interesting way of debugging, I will take the idea.
>
> For the print functions vs. debugger:
> The most useful application for a debugger like Wing is not for
> bug-fixing, but to set a break point and then interactively develop on
> the debugger console and with the IDE editor's autocompletion using
> introspection on the live objects. This is very helpful for hardware
> interfacing, network protocols or GUI programs. It really boosted my
> productivity in a way I could not believe before. This is something most
> people forget when they evaluate programming languages. It's not the
> language or syntax that counts, but the overall environment. Probably
> the only other really interactive language and environment is Forth.
>
This is exactly part of the capabilities that I am looking for. I loved you 
brought that up. When I think of an ideal IDE (besides the desirable features 
that I already mentioned previously) as a coworker who is telling me the 
values,types and ids that the objects are getting as you are setting 
breakpoints. So why not use the debugger interactively to develop applications. 
As long as one sets the breakpoints in a meaningful way so you can trace your 
code in a very productive way. Is that what you mean by interactive 
environment?

> > If it happens to be Arduino I normally use a sublime plugin called Stino
> > https://github.com/Robot-Will/Stino
> > (1337 people starred that cool number :D)
> Well, it is CodeWarrior which was quite famous at the time of the 68k Macs.
> The company was bought by Motorola and the IDE is still around for
> Freescale/NXP/Qualcomm microcontrollers like the HCS08 8 bit series.
> Around ten years ago the original CodeWarrior IDE was migrated to
> something Eclipse based.
> When I last evaluated HCS08 vs. Arduino, the HCS08 won due to the better
> debug interface and native USB support. HCS08 is still quite cool, but
> when it comes to documentation, learning curve, tools etc. the Arduinos
> win
>
>
> Regards,
>
> Dietmar

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


Receiving a lot of double messages.

2017-01-06 Thread Antoon Pardon
Is there something going on with the mailinglist? Because I have receive a lot 
of double messages. One copy is fairly normal and is part of the discussion 
thread, the other is completely seperated. -- Antoon Pardon.

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


Re: Forcing prompt to be on newline when embedding Python with

2017-01-06 Thread eryk sun
On Thu, Jan 5, 2017 at 7:09 AM, H Krishnan  wrote:
>
> I am working on embedding Python in my application.

You forgot to tell us the version of Python that you're embedding.

> I have redirected sys.stdin and sys.stdout to call methods from a Qt TextEdit
> widget. Everything works fine except that the Python prompt does not always
> come in a new line:
>
 dir()
> ['__builtins__', '__doc__', '__name__', '__package__']>>>
>
> Why doesn't the prompt appear in a new line as with the default stdout?

Are you using code.InteractiveConsole / code.interact?

If not, in what mode do you compile, Py_file_input ("exec") or Py_single_input 
("single")? The latter executes PRINT_EXPR:

>>> dis.dis(compile('1', '', 'single'))
  1   0 LOAD_CONST   0 (1)
  3 PRINT_EXPR
  4 LOAD_CONST   1 (None)
  7 RETURN_VALUE

PRINT_EXPR in turn calls sys.displayhook on the value it pops from the
stack. The default hook writes the repr of the value and a newline to 
sys.stdout, and it also references the value as "_" in the builtins module (2.x 
__builtin__).

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


Re: MySQL schema sync or diff

2017-01-06 Thread Chris Angelico
On Thu, Jan 5, 2017 at 11:02 AM, Charles Heizer  wrote:
> I have a MySQL database that is not managed (yet) and I would like to get an
output or diff against my new model file. I'm using flask-sqlalchemy.
>
> Are there any modules that would help me discover the differences so that I
can script a migration to begin using flask-migrate?

I'm not specifically aware of any such tool per se, but what you may want to 
consider is a tool for generating models from existing tables. Then you could 
diff the generated models against your hand-made ones, and build your 
migrations from that. Expect a ton of noise, though.

ChrisA

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


Re: Choosing a Python IDE. what is your Pythonish recommendation? I

2017-01-06 Thread Antonio Caminero Garcia
On Thursday, January 5, 2017 at 12:32:19 PM UTC-8, fpp wrote:
> > On Thu, Jan 5, 2017 at 12:12 PM, Chris Clark 
> > wrote:
> >> I want an IDE that I can use at work and home, linux and dare I say
> >> windows.
> >> Sublime, had to remove it from my work PC as it is not licensed.
> >> Atom, loved it until it slowed down.
> >> VIM, ok the best if you know vi inside out.
> >> Any JAVA based IDE, just slows up on work PC's due to all the
> >> background stuff that corporates insist they run.
> >> Why can not someone more clever than I fork DrPython and bring it up
> >> to date.
> >> Its is fast, looks great and just does the job ?
>
> I'm suprised no one in this rich thread has even mentioned SciTE :
> http://www.scintilla.org/
>
> Admittedly it's closer to an excellent code editor than a full-blown IDE.
> But it's very lightweight and fast, cross-platform, has superb syntax
> coloring and UTF8 handling, and is highly configurable through its
> configuration file(s) and embedded LUA scripting.
> It's also well maintained : version 1.0 came out in 1999, and the latest
> (3.7.2) is just a week old...
>
> Its IDE side consists mostly of hotkeys to run the interpreter or
> compiler for the language you're editing, with the file in the current
> tab.
> A side pane shows the output (prints, exceptions, errors etc.) of the
> running script.
> A nice touch is that it understands these error messages and makes them
> clickable, taking you to the tab/module/line where the error occurred.
> Also, it can save its current tabs (and their state) to a "session" file
> for later reloading, which is close to the idea of a "project" in most
> IDEs.
> Oh, and it had multi-selection and multi-editing before most of the new
> IDEs out there :-)
>
> Personally that's about all I need for my Python activities, but it can
> be customized much further than I have done : there are "hooks" for other
> external programs than compilers/interpreters, so you can also run a
> linter, debugger or cvs from the editor.
>
> One word of warning: unlike most newer IDEs which tend to be shiny-shiny
> and ful of bells and whistles at first sight, out of the box SciTE is
> *extremely* plain looking (you could even say drab, or ugly :-).
> It is up to you to decide how it should look and what it should do or
> not, through the configuration file.
> Fortunately the documentation is very thorough, and there are a lot of
> examples lying around to be copy/pasted (like a dark theme, LUA scripts
> etc.).
>
> Did I mention it's lightweight ? The archive is about 1.5 MB and it just
> needs unzipping, no installation. May be worth a look if you haven't
> tried it yet...
> fp

Interesting thanks for the link. There are a huge diversity when it comes to 
IDEs/editors. Now I have more than enough options.

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


Re: Python for WEB-page !?

2017-01-06 Thread Victor Porton
Ionut Predoiu wrote:

> I am a beginner in programming language.
> I want to know what version of Python I must to learn to use, beside of
> basic language, because I want to integrate in my site 1 page in which
> users to can made calculus based on my formulas already write behind (the
> users will only complete some field, and after push "Calculate" button
> will see the results in form of: table, graphic, and so on ...). Please
> take into account that behind will be more mathematical
> equations/formulas, so the speed I think must be take into account.

Consider PyPi. I never used it, but they say, it is faster than usual CPython 
interpreter.

> I waiting with higher interest your feedback.
>
> Thanks to all members of community for support and advice.
> Keep in touch.
> Kind regards.

--
Victor Porton - http://portonvictor.org

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


Re: Work between multiple processes

2017-01-06 Thread Irmen de Jong
On 4-1-2017 23:14, zxpat...@gmail.com wrote:
> Hi everyone,
>
> I ran into a case that I need to create a work process of an application
(Jython so has to call using java.exe) which will collect the data based on 
what main process indicates.
>
> (1) I tried multiprocessing package, no luck. Java.exe can't be called from
Process class?
>
> (2) I tried subprocess. subprocess.communicate function will wait for the
work process to terminate so to return.
>
>
> either (1) or (2) doesn't work out well. Please suggest.  Global system
queue?
>
> Thanks,
> Patrick.
>


Is it a requirement that the workdf process is also Jython?

If not: you could spawn a Python subprocess that hosts a Pyro4 daemon. 
Utilizing the Pyrolite java client library you can call methods in it from the 
java/jython side.  (Unfortunately it is not yet possible (due to jython 
incompatibilities) to use the full Pyro4 library on the Jython side as well). 
Not sure if it meets your set of requirements but have a look at 
http://pythonhosted.org/Pyro4/
http://pythonhosted.org/Pyro4/pyrolite.html


Irmen

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


Pexpect

2017-01-06 Thread Iranna Mathapati
Hi Team,

How to match latter(caps and small) ,numbers and # symbol in python pexpect.


Thanks,
Iranna M

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


RE: Clickable hyperlinks

2017-01-06 Thread Deborah Swanson
Rhodri James wrote, on January 05, 2017 3:53 AM
>
> On 05/01/17 04:52, Deborah Swanson wrote:
> > My original question was in fact whether there was a way to make
> > clickable hyperlinks in a console. I was persuaded after about 10
> > replies that the answer was no,
>
> Then you were persuaded wrong; the actual answer was "this isn't a
> meaningful question since it's based on incorrect assumptions."
> Translating that to "No" is just as much a mistake as
> translating it to
> "Yes."
>
> --
> Rhodri James *-* Kynesim Ltd

Actually, your statement "this isn't a meaningful question since it's based on 
incorrect assumptions" is false. PyCharm outputs clickable links to the 
console, but they aren't web links, they simply link to lines of code. I'd seen 
that PyCharm can make links in the console that aren't web enabled, so it 
seemed, and in fact it is, reasonable to assume that it could be done for urls. 
I just wanted to know if anyone knew how to do it.

Granted, the suggestion to use tkinter to enable the links came up much later 
than in the first 10 or so replies, and since tkinter makes clickable links 
possible, that's another reason my question wasn't based on false assumptions. 
It simply appears that the early responders to my question went off on a 
tangent of what is or is not technologically possible, and all of the 
approaches under consideration were in fact dead ends.

But clickable links turns out to be just eye candy, and the real result I 
wanted, which is opening urls in a browser from my IDE, is much more quickly 
and easily done programmatically. Although I didn't see this before I asked my 
question, and only saw it after reading quite a few replies.

Perhaps though, I should have said "I was persuaded after about 10 replies that 
that no one understood what I was asking." But that just seemed plain rude, so 
I went with "the answer was no".

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


Re: Choosing a Python IDE. what is your Pythonish recommendation? I

2017-01-06 Thread Antonio Caminero Garcia
On Thursday, January 5, 2017 at 9:51:17 AM UTC-8, ArnoB wrote:
> On 02-01-17 12:38, Antonio Caminero Garcia wrote:
> > Hello, I am having a hard time deciding what IDE or IDE-like code editor
should I use. This can be overwhelming.
> >
> > So far, I have used Vim, Sublime, Atom, Eclipse with PyDev, Pycharm,
IntelliJ with Python plugin.
> >
> > The thing with the from-the-scratch full featured IDEs (Eclipse, IntelliJ,
Pycharm) is that they look like a space craft dashboard and that unwarranted 
resources consumption and the unnecessary icons. I want my IDE to be 
minimalistic but powerful. My screen should be mostly â £made of codeâ Ø as 
usually happens in Vim, Sublime or Atom. However, Pycharm is really cool and 
python oriented.
> >
> > The problem with Vim is the learning curve, so I know the very basic stuff,
but obviously not enough for coding and I do not have time to learn it, it is a 
pity because there are awesome plugins that turns Vim into a lightweight 
powerful IDE-like. So now it is not an option but I will reconsider it in the 
future, learning little by little. Also, I am not very fan GUI guy if the task 
can be accomplished through the terminal. However, I donâ Öt understand why 
people underrate GUIs, that said I normally use shortcuts for the most frequent 
tasks and when I have to do something that is not that frequent then I do it 
with the mouse, for the latter case in vim you would need to look for that 
specific command every time.
> >
> > Sublime is my current and preferred code editor. I installed Anaconda, Git
integration and a couple of additional plugins that make sublime very powerful. 
Also, what I like about sublime compared to the full featured IDEs, besides the 
minimalism, is how you can perform code navigation back and forth so fast, I 
mean this is something that you can also do with the others but for some 
subjective reason I specifically love how sublime does it. The code completion 
in sublime I do not find it very intelligence, the SublimeCodeIntel is better 
than the one that Anaconda uses but the completions are not as verbose as in 
the IDEs.
> >
> > Now, I am thinking about giving a try to Visual Studio Code Edition (take a
look, it sounds good https://marketplace.visualstudio.com/items?itemName=donjay 
amanne.python). I need an editor for professional software development. What 
would you recommend to me?
>
> Hi Antonio,
>
> Just an extra one in case you'll ever want to create
> a nice GUI, then there's also QT Creator:
> https://wiki.qt.io/QtCreator_and_PySide
>
> A very simple but powerful interface a la XCode...
>
> It integrates nicely with PySide:
> https://wiki.qt.io/QtCreator_and_PySide
>
> gr
> Arno

Thanks!

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


RE: Clickable hyperlinks

2017-01-06 Thread Deborah Swanson
Terry Reedy wrote, on January 04, 2017 10:18 PM
>
> On 1/5/2017 12:11 AM, Deborah Swanson wrote:
> > Terry Reedy wrote, on January 04, 2017 3:58 PM
>
> >> To have a string interpreted as a clickable link, you send the
string to
> >> software capable of creating a clickable link, plus the information

> >> 'this is a clickable link'*.  There are two ways to tag a string as
a
> >> link.  One is to use markup around the url in the string itself.
> >> '' and html are example.  Python provides multiple to make
this
> >> easy. The other is to tag the string with a separate argument.
> >> Python provides tkinter, which wraps tk Text widgets, which have a
> >> powerful tag system.  One can define a Link tag that will a) cause
text
> >> to be displayed, for instance, blue and underlined and b) cause
clicks on
> >> the text to generate a web request.  One could then use
> >> mytext.insert('insert', 'http://www.example.com', Link) Browser
> >> must do something similar when they encounter when they encounter
> >> html link tags.
> >
> > I've actually moved on from my original question to one of opening a

> > url in a browser with python, which seems to be a much more easily
> > achieved goal.
>
> > But someone else mentioned tkinter, and I looked at it awhile ago
but
> > haven't used it for anything. That really could be the way to go if
> > you want to make clickable links, although you still need some kind
of
> > internet engine to open the url in a browser.
>
> IDLE allows a user to add help menu entries that, when clicked on,
open
> either a local file or an internet url.  For instance, adding the pair

> 'Pillow' and "https://pillow.readthedocs.io/en/latest/"; in > the
Settings
> dialog adda "Pillow" to the help menu (after the standard stuff).
> Clicking on Help => Pillow opens
> "https://pillow.readthedocs.io/en/latest/"; in the default browswer.
> IDLE just used the webbrowser module to do this.  No use re-inventing
> the wheel.  If instead "Pillow" were a link in text, the click handler

> should do something similar.

Yes, unless someone suggests something better, the webbrowser module looks like 
the way to go for opening urls in a browser.
>
> > You say, "There are two ways to tag a string as a link. One is to
use
> > markup around the url in the string itself. '' and html are
> > examples.  Python provides multiple ways to make this easy."
> >
> > Can you tell me where I'd begin to look for these? Are they in the
> > core language, or in packages?
>
> I was referring to using either % or .format string formatting.  Both
> are in the core and described somewhere in the Library manual.  '%'
> should be in the Symbols page of the Index and 'format' on
> the 'F' page.
>
> --
> Terry Jan Reedy

I looked up % in the Symbols page, but I didn't see any specifier related to 
urls. It would be nice if there was something like a %u for url format, but it 
isn't in there.

I also tried

print("http//python.org")
^
but got 'SyntaxError: invalid syntax', with the red arrow pointing at the first 
angle bracket. I also tried

print("http//python.org")
^
and got the same syntax error, but I'm not sure if that's how you meant html 
should be used.

I also tried to look up 'format', but there's no such entry in the Index. There 
are a lot of entries that begin with 'format', but none of them mention urls or 
anything link related. 'format_field() (string.Formatter method)' looked like a 
possibility, but again, I didn't see anything to format a link with. Maybe I 
didn't look hard enough, or didn't see something that _would_ work.

As I've said, at this point I've moved on to directly opening a url in a 
browser with the webbrowser module. All I originally wanted to do was be able 
to open a url without leaving my IDE while I was debugging data that has urls 
in it. Clickable links are really just eye candy that I don't need if I can get 
the same result programmatically. But I was curious whether there are any ways 
to tag a string as a link in a print statement. If there are, I didn't find 
any, but thanks for your suggestions!

Deborah

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


Re: Choosing a Python IDE. what is your Pythonish recommendation? I do

2017-01-06 Thread fpp
> On Thu, Jan 5, 2017 at 12:12 PM, Chris Clark 
> wrote:
>> I want an IDE that I can use at work and home, linux and dare I say
>> windows.
>> Sublime, had to remove it from my work PC as it is not licensed.
>> Atom, loved it until it slowed down.
>> VIM, ok the best if you know vi inside out.
>> Any JAVA based IDE, just slows up on work PC's due to all the
>> background stuff that corporates insist they run.
>> Why can not someone more clever than I fork DrPython and bring it up
>> to date.
>> Its is fast, looks great and just does the job ?

I'm suprised no one in this rich thread has even mentioned SciTE : 
http://www.scintilla.org/

Admittedly it's closer to an excellent code editor than a full-blown IDE. But 
it's very lightweight and fast, cross-platform, has superb syntax coloring and 
UTF8 handling, and is highly configurable through its configuration file(s) and 
embedded LUA scripting. It's also well maintained : version 1.0 came out in 
1999, and the latest (3.7.2) is just a week old...

Its IDE side consists mostly of hotkeys to run the interpreter or compiler for 
the language you're editing, with the file in the current tab.
A side pane shows the output (prints, exceptions, errors etc.) of the running 
script.
A nice touch is that it understands these error messages and makes them 
clickable, taking you to the tab/module/line where the error occurred. Also, it 
can save its current tabs (and their state) to a "session" file for later 
reloading, which is close to the idea of a "project" in most IDEs.
Oh, and it had multi-selection and multi-editing before most of the new IDEs 
out there :-)

Personally that's about all I need for my Python activities, but it can be 
customized much further than I have done : there are "hooks" for other external 
programs than compilers/interpreters, so you can also run a linter, debugger or 
cvs from the editor.

One word of warning: unlike most newer IDEs which tend to be shiny-shiny and 
ful of bells and whistles at first sight, out of the box SciTE is
*extremely* plain looking (you could even say drab, or ugly :-).
It is up to you to decide how it should look and what it should do or not, 
through the configuration file. Fortunately the documentation is very thorough, 
and there are a lot of examples lying around to be copy/pasted (like a dark 
theme, LUA scripts etc.).

Did I mention it's lightweight ? The archive is about 1.5 MB and it just needs 
unzipping, no installation. May be worth a look if you haven't tried it yet...
fp

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


Re: Python for WEB-page !?

2017-01-06 Thread Ionut Predoiu
Good morning,

Thanks to all for feedback and advice. Because I am a beginner I will read more 
about versions of Python recommended by you.

On the other side I am interested to know if exist some sites which have 
develop platform where can be use for free Python from browsers, without have 
it installed on PC/laptop. As beginner I want to practice from everywhere.

I waiting with higher interest your feedback.

Thanks to all members of community for support and advice. Keep in touch.
Kind regards.



On Thursday, January 5, 2017 at 2:57:23 PM UTC+2, Ionut Predoiu wrote:
> Good afternoon,
>
> I am a beginner in programming language.
> I want to know what version of Python I must to learn to use, beside of basic
language, because I want to integrate in my site 1 page in which users to can 
made calculus based on my formulas already write behind (the users will only 
complete some field, and after push "Calculate" button will see the results in 
form of: table, graphic, and so on ...).
> Please take into account that behind will be more mathematical
equations/formulas, so the speed I think must be take into account.
>
> I waiting with higher interest your feedback.
>
> Thanks to all members of community for support and advice.
> Keep in touch.
> Kind regards.

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


Re: Search a sequence for its minimum and stop as soon as the lowest possible value is found

2017-01-06 Thread Wolfgang Maier

On 1/6/2017 15:04, Peter Otten wrote:

Example: you are looking for the minimum absolute value in a series of
integers. As soon as you encounter the first 0 it's unnecessary extra work
to check the remaining values, but the builtin min() will continue.

The solution is a minimum function that allows the user to specify a stop
value:


from itertools import count, chain
stopmin(chain(reversed(range(10)), count()), key=abs, stop=0)

0

How would you implement stopmin()?



How about:

def stopmin (iterable, key, stop):
def take_until ():
for e in iterable:
yield e
if key(e) <= stop:
break
return min(take_until(), key=key)

?

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


Re: Search a sequence for its minimum and stop as soon as the lowest possible value is found

2017-01-06 Thread Jussi Piitulainen
Peter Otten writes:

> Example: you are looking for the minimum absolute value in a series of 
> integers. As soon as you encounter the first 0 it's unnecessary extra work 
> to check the remaining values, but the builtin min() will continue.
>
> The solution is a minimum function that allows the user to specify a stop 
> value:
>
 from itertools import count, chain
 stopmin(chain(reversed(range(10)), count()), key=abs, stop=0)
> 0
>
> How would you implement stopmin()?

Only let min see the data up to, but including, the stop value:

from itertools import groupby

def takeuntil(data, pred):
'''Take values from data until and including the first that
satisfies pred (until data is exhausted if none does).'''
for kind, group in groupby(data, pred):
if kind:
yield next(group)
break
else:
yield from group

def stopmin(data, key, stop):
return min(takeuntil(data, lambda o : key(o) == stop),
   key = key)

data = '31415926'
for stop in range(5):
print(stop,
  '=>', repr(''.join(takeuntil(data, lambda o : int(o) == stop))),
  '=>', repr(stopmin(data, int, stop)))

# 0 => '31415926' => '1'
# 1 => '31' => '1'
# 2 => '3141592' => '1'
# 3 => '3' => '3'
# 4 => '314' => '1'

from itertools import count, chain
print(stopmin(chain(reversed(range(10)), count()), key=abs, stop=0))
print(stopmin(chain(reversed(range(10)), count()), key=abs, stop=3))

# 0
# 3
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Work between multiple processes

2017-01-06 Thread Patrick Zhou
On Thursday, January 5, 2017 at 5:49:46 PM UTC-5, Irmen de Jong wrote:
> On 4-1-2017 23:14, zxpat...@gmail.com wrote:
> > Hi everyone,
> > 
> > I ran into a case that I need to create a work process of an application 
> > (Jython so has to call using java.exe) which will collect the data based on 
> > what main process indicates. 
> > 
> > (1) I tried multiprocessing package, no luck. Java.exe can't be called from 
> > Process class?
> > 
> > (2) I tried subprocess. subprocess.communicate function will wait for the 
> > work process to terminate so to return.
> > 
> >  
> > either (1) or (2) doesn't work out well. Please suggest.  Global system 
> > queue?
> > 
> > Thanks,
> > Patrick.
> > 
> 
> 
> Is it a requirement that the workdf process is also Jython?
> 
> If not: you could spawn a Python subprocess that hosts a Pyro4 daemon.
> Utilizing the Pyrolite java client library you can call methods in it from the
> java/jython side.  (Unfortunately it is not yet possible (due to jython
> incompatibilities) to use the full Pyro4 library on the Jython side as well).
> Not sure if it meets your set of requirements but have a look at
> http://pythonhosted.org/Pyro4/
> http://pythonhosted.org/Pyro4/pyrolite.html
> 
> 
> Irmen


Thanks Irmen. I think that could be the solution I am looking for. The main 
process will be native python so it can be used to host a pyro daemon even with 
lock. The jython will be a subprocess that takes the daemon's uri and use the 
pyrolite library to make the communication. The only trouble is that I will 
have to involve two more java libraries but I don't think it is a big of deal. 
Will try it and post the source code if possible.
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Pexpect

2017-01-06 Thread Joaquin Alzola
> How to match latter(caps and small) ,numbers and # symbol in python pexpect.

With a .*

child = pexpect.spawnu("ssh cbpapp@%s"% CBP[cust_cbp_server])
child.setecho(False)
child.logfile = open("/opt/webapi/logs/delete_accountID.log", "w")
child.expect(".*assword:")
child.sendline("\r")
child.expect(".*/onip/app/cbpapp>")
child.sendline("mdsql\r")
child.expect("SQL>")
child.sendline("select * from table; \r")
child.expect("SQL>")
child.expect("SQL>")

-

This email is confidential and may be subject to privilege. If you are not the 
intended recipient, please do not copy or disclose its content but contact the 
sender immediately upon receipt.
-- 
https://mail.python.org/mailman/listinfo/python-list


ANN: Python Events Calendar - Please submit your 2017 events

2017-01-06 Thread M.-A. Lemburg
[Please help spread the word by forwarding to other relevant mailing
lists, user groups, etc. world-wide; thanks :-)]



ANNOUNCING

 Python Events Calendars - Please submit your 2017 events

   maintained by the Python Software Foundation (PSF)
and a group of volunteers



INTRODUCTION

As some of you may know, the PSF has a team of volunteers who are
maintaining a set of central Python event calendars. We currently have
two calendars in place:

 * Python Events Calendar - meant for conferences and larger gatherings
   focusing on Python or a related technology (in whole or in part)

 * Python User Group Calendar - meant for user group events and other
   smaller local events

The calendars are displayed on https://www.python.org/events/ and
http://pycon.org/. There's also a map mashup to show events near
you or get an overview of what currently going in the Python
community:

   http://lmorillas.github.io/python_events/

You can subscribe to the calendars using iCal and RSS feeds and also
embed the calendar widgets on your sites. We have also added a
Twitter feed @PythonEvents to get immediate updates whenever a new
event is added. Please see our wiki page for details:

   https://wiki.python.org/moin/PythonEventsCalendar

The calendars are open to the world-wide Python community, so you
can have local user group events, as well as regional and
international conference events added to the calendars.



NEWS

Looking back, the calendars have proven to be a great tool
for the Python community to connect, with more than 250 conferences
and more than a hundred of user group events listed since 2012.

We would therefore like to encourage everyone to submit their
2017 events, so that the Python community can get a better overview
over what's happening in Python land.



ADDING EVENTS

Please see the instructions at

https://wiki.python.org/moin/PythonEventsCalendar#Submitting_an_Event

for details on how to submit an event. We've made it really easy for
you: just need to send an email to our team address using the email
template we provide for this. Thanks.



MORE INFORMATION

More information on the calendars, the URLs, feed links, IDs, embedding,
etc. is available on the wiki:

https://wiki.python.org/moin/PythonEventsCalendar

Enjoy,
-- 
Marc-Andre Lemburg
Python Software Foundation
http://www.python.org/psf/
http://www.malemburg.com/

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


Re: The hardest problem in computer science...

2017-01-06 Thread Ethan Furman

On 01/06/2017 05:03 AM, Steve D'Aprano wrote:


what do we call the vertical and horizontal line elements? I want to make
them configurable, which means the user has to be able to pass an argument
that specifies them. I have names for the individual components:

XXX = namedtuple("XXX", "vline tee corner")

default_YYY = XXX("│  ", "├─ ", "└─ ")
bold_YYY = XXX("┃  ", "┣━ ", "┗━ ")
ascii_YYY = XXX("|  ", "|- ", "+- ")

def draw_tree(tree, YYY=default_YYY):
 ...

but what do I call XXX and YYY?


Looks like horizontal, vertical, and corner are as groups -- so I would call YYY "style" and XXX 
"default", "bold", and "ascii".

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


How Best to Coerce Python Objects to Integers?

2017-01-06 Thread breamoreboy
Hi all, I'd suggest that this http://blog.pyspoken.com/2017/01/02/how-best-to-c 
oerce-python-objects-to-integers/ is not one of the greatest articles ever 
written about Python exception handling.  Other opinions are welcome.

Kindest regards.

Mark Lawrence.

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


Re: pip install -r requirements.txt fails with Python 3.6 on Windows 10

2017-01-06 Thread breamoreboy
On Tuesday, January 3, 2017 at 8:08:37 PM UTC, Uri Even-Chen wrote:
> Thank you, I'll consider to update our requirements to latest versions of
> all packages. Last time I checked in 22th December 2016 and all our
> requirements were the latest versions. In the meantime we can keep using
> Python 3.5. By the way, Travis CI tests passed with the same requirements
> and Python 3.6 (and 3.5 and 3.4). How did it install the requirements
> there? Does it depend on the operating system?
>
> I see now that Python 3.6.0 was released on 2016-12-23.
>
> By the way we use Ubuntu 16.04 in production with Python 3.5.2, so it's not
> that important to support Python 3.6 right now. What are the reasons to
> upgrade Python to 3.6?
>
> Thanks,
> Uri.
>
>
> *Uri Even-Chen*
> [image: photo] Phone: +972-54-3995700
> Website: http://www.speedysoftware.com/uri/en/
>   
>     
> 


Go here http://www.lfd.uci.edu/~gohlke/pythonlibs/#pillow to get what you need.

In all my years of downloading from this site I've never, ever had a problem.

Kindest regards.

Mark Lawrence.

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


Re: The hardest problem in computer science...

2017-01-06 Thread Skip Montanaro
"VT52 special graphics characters", anyone? Credit where credit is due. Who
hasn't borked their output and wound up with their VT(52|100) in graphics
mode? :-)

https://en.wikipedia.org/wiki/VT52

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


Re: The hardest problem in computer science...

2017-01-06 Thread Alain Ketterlin
Steve D'Aprano  writes:

[...]
> Fiction
> ├─ Fantasy
> │  ├─ Terry Pratchett
> │  │  ├─ Discworld
> │  │  │  ├─ Wyrd Sisters
> │  │  │  └─ Carpe Jugulum
> │  │  └─ Dodger
> │  └─ JK Rowling
[...]
> what do we call the vertical and horizontal line elements?

Box-drawing characters. At least that's how Unicode calls them. Even if
you don't draw boxes...

https://en.wikipedia.org/wiki/Box-drawing_character

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


Search a sequence for its minimum and stop as soon as the lowest possible value is found

2017-01-06 Thread Peter Otten
Example: you are looking for the minimum absolute value in a series of 
integers. As soon as you encounter the first 0 it's unnecessary extra work 
to check the remaining values, but the builtin min() will continue.

The solution is a minimum function that allows the user to specify a stop 
value:

>>> from itertools import count, chain
>>> stopmin(chain(reversed(range(10)), count()), key=abs, stop=0)
0

How would you implement stopmin()?

Currently I raise an exception in the key function:

class Stop(Exception):
pass

def stopmin(items, key, stop):
"""
>>> def g():
... for i in reversed(range(10)):
... print(10*i)
... yield str(i)
>>> stopmin(g(), key=int, stop=5)
90
80
70
60
50
'5'
"""
def key2(value):
result = key(value)
if result <= stop:
raise Stop(value)
return result
try:
return min(items, key=key2)
except Stop as stop:
return stop.args[0]


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


Re: The hardest problem in computer science...

2017-01-06 Thread Tim Chase
On 2017-01-06 13:44, Dan Sommers wrote:
> On Sat, 07 Jan 2017 00:03:37 +1100, Steve D'Aprano wrote:
> > what do we call the vertical and horizontal line elements? I want
> > to make them configurable, which means the user has to be able to
> > pass an argument that specifies them ...
> 
> pstree(1) calls them "line drawing characters,"

I second the use of "drawing characters" as I've seen them described
as "line-drawing characters", "box drawing characters", or "tree
drawing characters" depending on the context.

Wikipedia seems to favor "box drawing characters"

  https://en.wikipedia.org/wiki/Box-drawing_character

Takes me back to my ascii-art days on BBSes. :-)

-tkc





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


Re: The hardest problem in computer science...

2017-01-06 Thread Dan Sommers
On Sat, 07 Jan 2017 00:03:37 +1100, Steve D'Aprano wrote:

> The *hardest* problem is naming things.

> 
> Fiction
> ├─ Fantasy
> │  ├─ Terry Pratchett
> │  │  ├─ Discworld
> │  │  │  ├─ Wyrd Sisters
> │  │  │  └─ Carpe Jugulum

[...]

> what do we call the vertical and horizontal line elements? I want to make
> them configurable, which means the user has to be able to pass an argument
> that specifies them ...

pstree(1) (https://en.wikipedia.org/wiki/Pstree,
http://man7.org/linux/man-pages/man1/pstree.1.html) calls them "line
drawing characters," and took a slightly different approach (I think) to
the command line argument(s):

The default is ASCII, or you can specify -G to specify the VT100 line
drawing characters (G for Graphic, I assume), or you can specify -U for
the UTF-8 line drawing characters.

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


Re: "paperpk" "paper pk" "paperpk.com" "express newspaper" "newspaper classified ads" "dawn jobs ads" "jang newspaper" "dawn jobs" "jang jobs ads" "nawaiwaqt" "classified ads" on www.npjobs.blogspot

2017-01-06 Thread muhammadasad254
this a all of facek you are veiw the latest post today newspaperp on view paperpkads.
-- 
https://mail.python.org/mailman/listinfo/python-list


The hardest problem in computer science...

2017-01-06 Thread Steve D'Aprano
The second hardest problem in computer science is cache invalidation.

The *hardest* problem is naming things.

In a hierarchical tree view widget that displays items like this:


Fiction
├─ Fantasy
│  ├─ Terry Pratchett
│  │  ├─ Discworld
│  │  │  ├─ Wyrd Sisters
│  │  │  └─ Carpe Jugulum
│  │  └─ Dodger
│  └─ JK Rowling
│ └─ Harry Potter And The Philosopher's Stone
├─ Science Fiction
│  ├─ Connie Willis
│  │  └─ To Say Nothing Of The Dog
│  └─ Neal Stephenson
│ └─ Snow Crash
└─ Horror
   └─ Stephen King
  ├─ Salem's Lot
  └─ It


what do we call the vertical and horizontal line elements? I want to make
them configurable, which means the user has to be able to pass an argument
that specifies them. I have names for the individual components:

XXX = namedtuple("XXX", "vline tee corner")

default_YYY = XXX("│  ", "├─ ", "└─ ")
bold_YYY = XXX("┃  ", "┣━ ", "┗━ ")
ascii_YYY = XXX("|  ", "|- ", "+- ")

def draw_tree(tree, YYY=default_YYY):
...


but what do I call XXX and YYY?


Seriously-considering-just-hard-coding-them-as-magic-constants-ly y'rs,


-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

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


Re: Choosing a Python IDE. what is your Pythonish recommendation? I do not know what to choose.

2017-01-06 Thread Dietmar Schwertberger

On 06.01.2017 09:40, Antonio Caminero Garcia wrote:

So why not use the debugger interactively to develop
applications. As long as one sets the breakpoints in a meaningful way so you 
can trace your code in a very productive way. Is that what you mean by 
interactive environment?
Well, not exactly. Maybe have a look at the video "Interactive Debug 
Probe" at

https://wingware.com/wingide/debugger

Regards,

Dietmar

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


Re: Python for WEB-page !?

2017-01-06 Thread Ionut Predoiu
Good afternoon,

Thank you for advice and promptitude in answer.

Keep in touch for further questions.
Kind regards.

On Thursday, January 5, 2017 at 2:57:23 PM UTC+2, Ionut Predoiu wrote:
> Good afternoon,
> 
> I am a beginner in programming language. 
> I want to know what version of Python I must to learn to use, beside of basic 
> language, because I want to integrate in my site 1 page in which users to can 
> made calculus based on my formulas already write behind (the users will only 
> complete some field, and after push "Calculate" button will see the results 
> in form of: table, graphic, and so on ...). 
> Please take into account that behind will be more mathematical 
> equations/formulas, so the speed I think must be take into account.
> 
> I waiting with higher interest your feedback.
> 
> Thanks to all members of community for support and advice.
> Keep in touch.
> Kind regards.

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


RE: Receiving a lot of double messages.

2017-01-06 Thread Deborah Swanson
Antoon Pardon wrote, on January 06, 2017 2:11 AM
> 
> Is there something going on with the mailinglist? Because I 
> have receive a lot of double messages. One copy is fairly 
> normal and is part of the discussion thread, the other is 
> completely seperated. -- Antoon Pardon.

Looks to me like the mail server got backed up or jammed and they're
flushing the mail queue. I haven't seen anything older than Jan. 2 and
just started seeing some current ones, so I think it's almost over with.

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


Re: Choosing a Python IDE. what is your Pythonish recommendation? I do not know what to choose.

2017-01-06 Thread Antonio Caminero Garcia
On Wednesday, January 4, 2017 at 1:10:04 PM UTC-8, Dietmar Schwertberger wrote:
> On 04.01.2017 07:54, Antonio Caminero Garcia wrote:
> > Unfortunately most of the time I am still using print and input functions. 
> > I know that sucks, I did not use the pdb module, I guess that IDE debuggers 
> > leverage such module.
> pdb is actually quite useful. On my Windows PCs I can invoke python on 
> any .py file with the -i command line switch by right clicking in the 
> Explorer and selecting "Debug". Now when the script crashes, I can 
> inspect variables without launching a full-scale IDE or starting the 
> script from the command line. For such quick fixes I have also a context 
> menu entry "Edit" for editing with Pythonwin, which is still quite OK as 
> editor and has no licensing restrictions or installation requirements. 
> This is a nice option when you deploy your installation to many PCs over 
> the network.
I am on MacOS but interesting way of debugging, I will take the idea.
> 
> For the print functions vs. debugger:
> The most useful application for a debugger like Wing is not for 
> bug-fixing, but to set a break point and then interactively develop on 
> the debugger console and with the IDE editor's autocompletion using 
> introspection on the live objects. This is very helpful for hardware 
> interfacing, network protocols or GUI programs. It really boosted my 
> productivity in a way I could not believe before. This is something most 
> people forget when they evaluate programming languages. It's not the 
> language or syntax that counts, but the overall environment. Probably 
> the only other really interactive language and environment is Forth.
> 
This is exactly part of the capabilities that I am looking for. I loved you 
brought that up. When I think of an ideal IDE (besides the desirable features 
that I already mentioned previously) as a coworker who is telling me the 
values,types and ids that the objects are getting as you are setting 
breakpoints. So why not use the debugger interactively to develop
applications. As long as one sets the breakpoints in a meaningful way so you 
can trace your code in a very productive way. Is that what you mean by 
interactive environment?

> > If it happens to be Arduino I normally use a sublime plugin called Stino
> > https://github.com/Robot-Will/Stino
> > (1337 people starred that cool number :D)
> Well, it is CodeWarrior which was quite famous at the time of the 68k Macs.
> The company was bought by Motorola and the IDE is still around for 
> Freescale/NXP/Qualcomm microcontrollers like the HCS08 8 bit series. 
> Around ten years ago the original CodeWarrior IDE was migrated to 
> something Eclipse based.
> When I last evaluated HCS08 vs. Arduino, the HCS08 won due to the better 
> debug interface and native USB support. HCS08 is still quite cool, but 
> when it comes to documentation, learning curve, tools etc. the Arduinos 
> win
> 
> 
> Regards,
> 
> Dietmar
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Choosing a Python IDE. what is your Pythonish recommendation? I do not know what to choose.

2017-01-06 Thread Antonio Caminero Garcia
On Thursday, January 5, 2017 at 9:51:17 AM UTC-8, ArnoB wrote:
> On 02-01-17 12:38, Antonio Caminero Garcia wrote:
> > Hello, I am having a hard time deciding what IDE or IDE-like code editor 
> > should I use. This can be overwhelming.
> >
> > So far, I have used Vim, Sublime, Atom, Eclipse with PyDev, Pycharm, 
> > IntelliJ with Python plugin.
> >
> > The thing with the from-the-scratch full featured IDEs (Eclipse, IntelliJ, 
> > Pycharm) is that they look like a space craft dashboard and that 
> > unwarranted resources consumption and the unnecessary icons. I want my IDE 
> > to be minimalistic but powerful. My screen should be mostly “made of code” 
> > as usually happens in Vim, Sublime or Atom. However, Pycharm is really cool 
> > and python oriented.
> >
> > The problem with Vim is the learning curve, so I know the very basic stuff, 
> > but obviously not enough for coding and I do not have time to learn it, it 
> > is a pity because there are awesome plugins that turns Vim into a 
> > lightweight powerful IDE-like. So now it is not an option but I will 
> > reconsider it in the future, learning little by little. Also, I am not very 
> > fan GUI guy if the task can be accomplished through the terminal. However, 
> > I don’t understand why people underrate GUIs, that said I normally use 
> > shortcuts for the most frequent tasks and when I have to do something that 
> > is not that frequent then I do it with the mouse, for the latter case in 
> > vim you would need to look for that specific command every time.
> >
> > Sublime is my current and preferred code editor. I installed Anaconda, Git 
> > integration and a couple of additional plugins that make sublime very 
> > powerful. Also, what I like about sublime compared to the full featured 
> > IDEs, besides the minimalism, is how you can perform code navigation back 
> > and forth so fast, I mean this is something that you can also do with the 
> > others but for some subjective reason I specifically love how sublime does 
> > it. The code completion in sublime I do not find it very intelligence, the 
> > SublimeCodeIntel is better than the one that Anaconda uses but the 
> > completions are not as verbose as in the IDEs.
> >
> > Now, I am thinking about giving a try to Visual Studio Code Edition (take a 
> > look, it sounds good 
> > https://marketplace.visualstudio.com/items?itemName=donjayamanne.python). I 
> > need an editor for professional software development. What would you 
> > recommend to me?
> 
> Hi Antonio,
> 
> Just an extra one in case you'll ever want to create
> a nice GUI, then there's also QT Creator:
> https://wiki.qt.io/QtCreator_and_PySide
> 
> A very simple but powerful interface a la XCode...
> 
> It integrates nicely with PySide:
> https://wiki.qt.io/QtCreator_and_PySide
> 
> gr
> Arno

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


Re: Receiving a lot of double messages.

2017-01-06 Thread Chris Angelico
On Fri, Jan 6, 2017 at 9:11 PM, Antoon Pardon
 wrote:
> Is there something going on with the mailinglist? Because I have receive
> a lot of double messages. One copy is fairly normal and is part of the
> discussion thread, the other is completely seperated. -- Antoon Pardon.

Yeah, I'm seeing the same. Is the newsgroup gateway feeding back?

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


Pexpect

2017-01-06 Thread Iranna Mathapati
Hi Team,

How to match latter(caps and small) ,numbers and # symbol in python pexpect.


Thanks,
Iranna M
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Python for WEB-page !?

2017-01-06 Thread Deborah Swanson
Ionut Predoiu wrote, on January 05, 2017 11:07 PM
> 
> Good morning,
> 
> Thanks to all for feedback and advice.
> Because I am a beginner I will read more about versions of 
> Python recommended by you.
> 
> On the other side I am interested to know if exist some sites 
> which have develop platform where can be use for free Python 
> from browsers, without have it installed on PC/laptop. As 
> beginner I want to practice from everywhere.

There's a website called Python Tutor where you can write Python
programs and it will show you the structures built in memory as it
executes. It's  very useful for seeing how recursive functions work, or
any function or class you call. It will also work for simple programs
and it has an output console you can print to.  (Well, it's more like a
print window, but it works.) Very good for beginners, I used it all the
time when I was first learning, and I still use it for recursive
functions, since PyCharm doesn't step through recursion in a clear way.

http://pythontutor.com/

 
> I waiting with higher interest your feedback. 
> 
> Thanks to all members of community for support and advice. 
> Keep in touch. 
> Kind regards. 
> 
> 
> 
> On Thursday, January 5, 2017 at 2:57:23 PM UTC+2, Ionut Predoiu wrote:
> > Good afternoon,
> > 
> > I am a beginner in programming language.
> > I want to know what version of Python I must to learn to 
> use, beside of basic language, because I want to integrate in 
> my site 1 page in which users to can made calculus based on 
> my formulas already write behind (the users will only 
> complete some field, and after push "Calculate" button will 
> see the results in form of: table, graphic, and so on ...). 
> > Please take into account that behind will be more 
> mathematical equations/formulas, so the speed I think must be 
> take into account.
> > 
> > I waiting with higher interest your feedback.
> > 
> > Thanks to all members of community for support and advice. Keep in 
> > touch. Kind regards.
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

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


Re: Clickable hyperlinks

2017-01-06 Thread Chris Angelico
On Thu, Jan 5, 2017 at 3:19 PM, Deborah Swanson
 wrote:
> I downloaded the code from the Package Index, but there really wasn't
> much in it. This is the entire .py file:

Ehh, wrong file. Try the one in the standard library:

https://github.com/python/cpython/blob/master/Lib/antigravity.py
https://github.com/python/cpython/blob/master/Lib/webbrowser.py

Or you can look in your installed Python - "import webbrowser; 
print(webbrowser.__file__)" will tell you where.

ChrisA

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


Re: Clickable hyperlinks

2017-01-06 Thread Chris Angelico
On Thu, Jan 5, 2017 at 2:24 PM, D'Arcy Cain  wrote:
> Think of it this way.  You drop a ring down a drain.  You can ask two
> questions, "How do I remove a drain trap?" or "How do I recover a ring that
> I dropped down the drain?"  If you ask the first question you will get lots
> of advice on tools and buckets, etc.  People will assume that the drain is
> blocked.  Ask the second question and someone might mention a magnet and a
> piece of string.

... and then you follow up with "it's a gold ring, magnet won't touch it", and 
we'll go off on a tangent about whether the ring is sufficiently plain that it 
might be the One Ring, and shouldn't you destroy it instead of retrieving 
it because that's what we do here
:D

ChrisA

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


Receiving a lot of double messages.

2017-01-06 Thread Antoon Pardon
Is there something going on with the mailinglist? Because I have receive
a lot of double messages. One copy is fairly normal and is part of the
discussion thread, the other is completely seperated. -- Antoon Pardon.

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


Is there a good process or library for validating changes to XML format

2017-01-06 Thread Sayth Renshaw
Afternoon

Is there a good library or way I could use to check that the author of the XML 
doc I am using doesn't make small changes to structure over releases?

Not fully over this with XML but thought that XSD may be what I need, if I 
search "python XSD" I get a main result for PyXB and generateDS 
(https://pythonhosted.org/generateDS/).

Both seem to be libraries for generating bindings to structures for parsing so 
maybe I am searching the wrong thing. What is the right thing to search?

Cheers

Sayth

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


Re: Clickable hyperlinks

2017-01-06 Thread D'Arcy Cain
On 2017-01-04 07:07 PM, Deborah Swanson wrote:
> D'Arcy Cain wrote, on Wednesday, January 04, 2017 5:03 AM
>> In all the messages in this thread I still don't understand what this
>> "teensy advantage" is supposed to be.  Do you want to be able
>> to do this:
>>
>>make_web_link(http://...)
>>
>> instead of:
>>
>>make_web_link("http://...";)

[...]

> Is make_web_link("http://...";) valid python code? That's exactly the

It's just a made up name.  My point was that the first was syntactically 
incorrect and the second, while not a real method, was at least parseable.

I think I saw someone else mention this but it bears repeating.  When you ask a 
question make sure you are presenting the problem and not your solution to a 
secret problem.  Always tell us the actual problem you are trying to solve.  
You will get much better answers.

Think of it this way.  You drop a ring down a drain.  You can ask two 
questions, "How do I remove a drain trap?" or "How do I recover a ring that I 
dropped down the drain?"  If you ask the first question you will get lots of 
advice on tools and buckets, etc.  People will assume that the drain is 
blocked.  Ask the second question and someone might mention a magnet and a 
piece of string.

--
D'Arcy J.M. Cain
System Administrator, Vex.Net
http://www.Vex.Net/ IM:da...@vex.net VoIP: sip:da...@vex.net

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


Re: Forcing prompt to be on newline when embedding Python with stdin/out redirection

2017-01-06 Thread H Krishnan
Hello Mr.Eryk,

Thanks for the detailed explanation. After I added attribute support to my
extension class for stdio, the problem was resolved.

Regards,
Krishnan


On Fri, Jan 6, 2017 at 9:24 AM, eryk sun  wrote:

> On Fri, Jan 6, 2017 at 1:06 AM, H Krishnan  wrote:
> > I tried replacing sys.displayhook with a function that does not print
> > newline but the newline still got inserted. So, I am not sure where the
> > newline is coming from. In any case, I could override sys.displayhook to
> add
> > a newline at the end and that seems to resolve my problem.
>
> In Python 2 the newline is written depending on the value of
> sys.stdout.softspace. sys.displayhook initially calls Py_FlushLine,
> which resets the file's softspace to 0 via PyFile_SoftSpace and writes
> a newline if the previous value was non-zero. Next displayhook writes
> the repr, sets the softspace to 1 and calls Py_FlushLine again.
>
> The result you're seeing could occur if your filelike object doesn't
> have a dict or a property to allow setting the "softspace" attribute,
> as the following toy example demonstrates:
>
> import sys
>
> class File(object):
> def __init__(self, file):
> self._file = file
> self._sp_enabled = True
> self.softspace = 0
>
> def write(self, string):
> return self._file.write(string)
>
> def __getattribute__(self, name):
> value = object.__getattribute__(self, name)
> if name == 'softspace':
> if not self._sp_enabled:
> raise AttributeError
> self._file.write('[get softspace <- %d]\n' % value)
> return value
>
> def __setattr__(self, name, value):
> if name == 'softspace':
> if not self._sp_enabled:
> raise AttributeError
> self._file.write('[set softspace -> %d]\n' % value)
> object.__setattr__(self, name, value)
>
> softspace enabled:
>
> >>> sys.stdout = File(sys.stdout)
> [set softspace -> 0]
> [get softspace <- 0]
> [set softspace -> 0]
> >>> 42
> [get softspace <- 0]
> [set softspace -> 0]
> 42[get softspace <- 0]
> [set softspace -> 1]
> [get softspace <- 1]
> [set softspace -> 0]
>
> [get softspace <- 0]
> [set softspace -> 0]
>
> softspace disabled:
>
> >>> sys.stdout._sp_enabled = False
> >>> 42
> 42>>> 42
> 42>>>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Clickable hyperlinks

2017-01-06 Thread D'Arcy Cain
On 2017-01-04 05:58 PM, Deborah Swanson wrote:
>> the user to go and authenticate, you can simply
>> webbrowser.open("http://.../";) and it'll DTRT.
>
> Thank you, thank you! Finally, at least one person on this list knows
> about something (anything) in the python world that is internet aware.

Lots of things in Python are Internet aware.  That's not the question you asked 
though.

> It's also occurred to me that Beautifulsoup downloads data from a url,
> so that code must have access to some kind of an internet engine too.

Nope.  You have to feed it HTML.  You either need to generate that or capture 
it from somewhere.

--
D'Arcy J.M. Cain
System Administrator, Vex.Net
http://www.Vex.Net/ IM:da...@vex.net VoIP: sip:da...@vex.net

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


Re: Choosing a Python IDE. what is your Pythonish recommendation? I do not know what to choose.

2017-01-06 Thread Antonio Caminero Garcia
On Thursday, January 5, 2017 at 12:32:19 PM UTC-8, fpp wrote:
> > On Thu, Jan 5, 2017 at 12:12 PM, Chris Clark 
> > wrote: 
> >> I want an IDE that I can use at work and home, linux and dare I say
> >> windows.
> >> Sublime, had to remove it from my work PC as it is not licensed.
> >> Atom, loved it until it slowed down.
> >> VIM, ok the best if you know vi inside out.
> >> Any JAVA based IDE, just slows up on work PC's due to all the
> >> background stuff that corporates insist they run.
> >> Why can not someone more clever than I fork DrPython and bring it up
> >> to date.
> >> Its is fast, looks great and just does the job ?
> 
> I'm suprised no one in this rich thread has even mentioned SciTE :
> http://www.scintilla.org/
> 
> Admittedly it's closer to an excellent code editor than a full-blown IDE.
> But it's very lightweight and fast, cross-platform, has superb syntax 
> coloring and UTF8 handling, and is highly configurable through its 
> configuration file(s) and embedded LUA scripting.
> It's also well maintained : version 1.0 came out in 1999, and the latest 
> (3.7.2) is just a week old...
> 
> Its IDE side consists mostly of hotkeys to run the interpreter or 
> compiler for the language you're editing, with the file in the current 
> tab.
> A side pane shows the output (prints, exceptions, errors etc.) of the 
> running script.
> A nice touch is that it understands these error messages and makes them 
> clickable, taking you to the tab/module/line where the error occurred.
> Also, it can save its current tabs (and their state) to a "session" file 
> for later reloading, which is close to the idea of a "project" in most 
> IDEs.
> Oh, and it had multi-selection and multi-editing before most of the new 
> IDEs out there :-)
> 
> Personally that's about all I need for my Python activities, but it can 
> be customized much further than I have done : there are "hooks" for other 
> external programs than compilers/interpreters, so you can also run a 
> linter, debugger or cvs from the editor.
> 
> One word of warning: unlike most newer IDEs which tend to be shiny-shiny 
> and ful of bells and whistles at first sight, out of the box SciTE is 
> *extremely* plain looking (you could even say drab, or ugly :-).
> It is up to you to decide how it should look and what it should do or 
> not, through the configuration file.
> Fortunately the documentation is very thorough, and there are a lot of 
> examples lying around to be copy/pasted (like a dark theme, LUA scripts 
> etc.).
> 
> Did I mention it's lightweight ? The archive is about 1.5 MB and it just 
> needs unzipping, no installation. May be worth a look if you haven't 
> tried it yet...
> fp

Interesting thanks for the link. There are a huge diversity when it comes to 
IDEs/editors. Now I have more than enough options. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Clickable hyperlinks

2017-01-06 Thread Dennis Lee Bieber
On Wed, 4 Jan 2017 14:58:42 -0800, "Deborah Swanson"
 declaimed the following:

>Thank you, thank you! Finally, at least one person on this list knows
>about something (anything) in the python world that is internet aware.
>It's also occurred to me that Beautifulsoup downloads data from a url,
>so that code must have access to some kind of an internet engine too.
>

Uhm... There is a big difference between "clickable links" and
"internet aware".

Look at the Library reference manual. There is a section on "Internet
Data Handling", and another on "Internet Protocols and Support". For just 
retrieving things identified by a URL, there are both urllib and urllib2; and 
for more specific there is httplib, ftplib, poplib, etc.


Clickable links is a user interface matter -- and as mentioned numerous
times, depends upon the features of the interface, not of Python (unless you 
are writing a full-fledged GUI application in which case you have to tag 
entities as clickable and handle the user clicking on that entity, followed by 
actually using one of the above library routines to fetch the contents at the 
clickable's target)

--
Wulfraed Dennis Lee Bieber AF6VN
wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.com/

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


MySQL schema sync or diff

2017-01-06 Thread Charles Heizer
Hello,
I have a MySQL database that is not managed (yet) and I would like to get an 
output or diff against my new model file. I'm using flask-sqlalchemy.

Are there any modules that would help me discover the differences so that I can 
script a migration to begin using flask-migrate?

Thanks!

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


Re: Python for WEB-page !?

2017-01-06 Thread Ionut Predoiu
Good morning,

Thanks to all for feedback and advice.
Because I am a beginner I will read more about versions of Python recommended 
by you.

On the other side I am interested to know if exist some sites which have 
develop platform where can be use for free Python from browsers, without have 
it installed on PC/laptop. As beginner I want to practice from everywhere.

I waiting with higher interest your feedback. 

Thanks to all members of community for support and advice. 
Keep in touch. 
Kind regards. 



On Thursday, January 5, 2017 at 2:57:23 PM UTC+2, Ionut Predoiu wrote:
> Good afternoon,
> 
> I am a beginner in programming language. 
> I want to know what version of Python I must to learn to use, beside of basic 
> language, because I want to integrate in my site 1 page in which users to can 
> made calculus based on my formulas already write behind (the users will only 
> complete some field, and after push "Calculate" button will see the results 
> in form of: table, graphic, and so on ...). 
> Please take into account that behind will be more mathematical 
> equations/formulas, so the speed I think must be take into account.
> 
> I waiting with higher interest your feedback.
> 
> Thanks to all members of community for support and advice.
> Keep in touch.
> Kind regards.

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


Re: Hey, I'm new to python so don't judge.

2017-01-06 Thread Steven D'Aprano
On Thursday 05 January 2017 10:21, Terry Reedy wrote:

> On 1/3/2017 10:15 PM, Dennis Lee Bieber wrote:
>
>> And that statement tells us you are trying to run from within some
>> IDE/editor which is trapping Python exceptions and producing a dialog
>> box for them.
>
> IDLE does this when one runs code from the editor, because it
> cannot/should not inject error messages into the editor buffer...
> AND it replaces the ^ with red highlighting of the code pointed to.  No
> information is lost.  Apparently, some beginners do not see the
> connection between the SyntaxError box and the red highlighting.

Some people may not even be able to distinguish red from other colours. Those 
with red-green colourblindness will probably see the red as a sort of muddy 
brown that hardly stands out as different from usual black text.

http://wearecolorblind.com/

One should never use colour alone as the only indicator of status.

http://stackoverflow.com/questions/1498669/gui-design-for-color-blindness

http://davemeeker.com/color-blind-considerations-for-ui-design/


> I
> think I should add something to the box.  Maybe 'The error was detected
> at the point of the red highlighting.'


I just tested the REPL in idle for 2.7.4, and I get this:

>>> print Hello World
SyntaxError: invalid syntax


where "print" is green text on a white background, and "World" is black text on 
a red background. That may be unfriendly to the colourblind, and makes coping 
and pasting the error less helpful. I suggest:

- check the colours in a colourblindness simulator, and pay attention to the
contrast; is the text still clear?

- include the ^ caret as the primary status indicator, delegating colour to
secondary; this makes errors in IDLE a little more like the same experience in 
the standard REPL.


If I open a Python file containing:

print Hello World

and choose "Check Module", IDLE highlights the word "World" in red and displays 
a dialog showing:

There's an error in your program:
invalid syntax

Suggestion:

Change the dialog box to display a read-only text field showing the traceback:

  File "idletest.py", line 1
print Hello World
^
SyntaxError: invalid syntax


and add a button "Copy traceback" to allow the user to copy the text of the 
traceback and paste it into an email.

(Strictly speaking, the Copy button is redundant if the user can select the 
text in the field, but beginners may not realise the text can be selected.)



>> Instead, save your script (if you haven't yet) as a file
>> (whatever.py).
>>
>> Open a command line interpreter/shell.
>>
>> Navigate (cd ...) to where you saved the file
>>
>> Type "python whatever.py"
>
> What a nuisance.

*shrug* If you're a Linux user, chances are you already have a shell open and
ready to go. And with tab completion, you don't have to type as much as you 
might think. It just becomes second nature after a while.

I type something like "pypathwhat" and the shell will 
autocomplete directory and filenames.

Anyway, this isn't an argument over which is better, IDLE or the system 
terminal. They both have their advantages and disadvantages, and in practice 
the real answer to "which is better?" is always "whichever one you are used 
to".



--
Steven
"Ever since I learned about confirmation bias, I've been seeing it everywhere." 
- Jon Ronson

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


Re: Clickable hyperlinks

2017-01-06 Thread Michael Torrie
On 01/04/2017 03:58 PM, Deborah Swanson wrote:
> Thank you, thank you! Finally, at least one person on this list knows
> about something (anything) in the python world that is internet aware.
> It's also occurred to me that Beautifulsoup downloads data from a url,
> so that code must have access to some kind of an internet engine too.

Except that you never mentioned anything about this in your posts before. It 
seemed to me you were asking about printing out clickable hyperlinks with 
python.  Calling the OS to launch a browser to view a url is a different beast 
which is why no one mentioned it before.

If you don't tell us what you're actually trying to do (your end goal), things 
are more frustrating for everyone.  If you had said early on you just want to 
be able to send the user to a particular url in a web browser, what Chris 
suggested would have been said a long time ago, rather than focusing on console 
output which is what you were asking about and focusing attention on.

Just so you know, BeautifulSoup does not do any internet access itself; it's 
only an HTML parser. You have to fetch web pages using something like python's 
urllib and then feed the data to BeautifulSoup.  urllib is not a web browser 
though.  It can pretend to be a browser as far as the server is concerned but 
it knows nothing about javascript or rendering. It just retrieves bytes which 
you can then feed to BeautifulSoup or some other parser.

> Yes, I'd gotten as far as figuring out that you don't need a clickable
> link. Code that opens a url in a browse would do the job just fine.

Good! I just wish you would have mentioned this much earlier as your end goal.

> Or the webbrowser.open("http://.../";) in a Linux terminal you suggest.
> (I just have to get my Linux machine up and running again to try it.)

The webbrowser module does not require console or terminal output. It will work 
on Windows or Linux if I'm not mistaken.  It asks the OS to launch the default 
browser and load the indicated url.

> All in all, given that clickable urls in a console is a non-starter,
> this hits the nail on the head. Many thanks again!

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


Re: Choosing a Python IDE. what is your Pythonish recommendation? I

2017-01-06 Thread Dietmar Schwertberger
On 04.01.2017 07:54, Antonio Caminero Garcia wrote:
> Unfortunately most of the time I am still using print and input functions. I
know that sucks, I did not use the pdb module, I guess that IDE debuggers 
leverage such module.
pdb is actually quite useful. On my Windows PCs I can invoke python on any .py 
file with the -i command line switch by right clicking in the Explorer and 
selecting "Debug". Now when the script crashes, I can inspect variables without 
launching a full-scale IDE or starting the script from the command line. For 
such quick fixes I have also a context menu entry "Edit" for editing with 
Pythonwin, which is still quite OK as editor and has no licensing restrictions 
or installation requirements. This is a nice option when you deploy your 
installation to many PCs over the network.

For the print functions vs. debugger: The most useful application for a 
debugger like Wing is not for bug-fixing, but to set a break point and then 
interactively develop on the debugger console and with the IDE editor's 
autocompletion using introspection on the live objects. This is very helpful 
for hardware interfacing, network protocols or GUI programs. It really boosted 
my productivity in a way I could not believe before. This is something most 
people forget when they evaluate programming languages. It's not the language 
or syntax that counts, but the overall environment. Probably the only other 
really interactive language and environment is Forth.

> If it happens to be Arduino I normally use a sublime plugin called Stino
> https://github.com/Robot-Will/Stino
> (1337 people starred that cool number :D)
Well, it is CodeWarrior which was quite famous at the time of the 68k Macs. The 
company was bought by Motorola and the IDE is still around for 
Freescale/NXP/Qualcomm microcontrollers like the HCS08 8 bit series. Around ten 
years ago the original CodeWarrior IDE was migrated to something Eclipse based.
When I last evaluated HCS08 vs. Arduino, the HCS08 won due to the better debug 
interface and native USB support. HCS08 is still quite cool, but when it comes 
to documentation, learning curve, tools etc. the Arduinos win


Regards,

Dietmar

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


RE: Clickable hyperlinks

2017-01-06 Thread Deborah Swanson
Chris Angelico wrote, on January 04, 2017 4:16 AM
>
> Yeah, there's no simple answer; however, you'll find that
> Python on many platforms is entirely capable of popping a URL
> up in the user's default browser. Check this out:
>
> >>> import antigravity

I downloaded the code from the Package Index, but there really wasn't much in 
it. This is the entire .py file:

STRIP_URL = "http://xkcd.com/353/";

def start():
return STRIP_URL

And setup.py is equally disappointing: from distutils.core import setup

setup(
name='antigravity',
version='0.1',
description='A really simple module that allow everyone to do
"import antigravity"',
author='Fabien Schwob',
author_email='antigrav...@x-phuture.com',
url='http://fabien.schwob.org/antigravity/',
packages=['antigravity'],
)

> This uses the 'webbrowser' module, which knows about a number
> of different ways to open a browser, and will attempt them
> all. So if you can figure out the UI part of things, actually
> making the link pop up in a browser isn't too hard; for
> instance, if you're doing OAuth at the command line and need
> the user to go and authenticate, you can simply
> webbrowser.open("http://.../";) and it'll DTRT.
>
> ChrisA

All the action of antigravity must be done by the import statement. When import 
opens a module that immediately returns a url, it must have a mechanism to open 
it in a browser.

It would be very easy to do the same thing with my own .py and import it into 
another .py.

Or, take a look at import's code and figure out how it opens a url in a 
browser. I imagine it's the 'webbrowser' module you mention. If it tries 
several methods, just pick one that will work for you.

Or, take a look at this Index of Packages Matching 'webbrowser' (~50 packages)
https://pypi.python.org/pypi?%3Aaction=search&term=webbrowser&submit=sea
rch

D'Arcy was right, there's lots in python that's internet aware, though that 
wasn't the question I knew to ask.

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


Re: Choosing a Python IDE. what is your Pythonish recommendation? I do

2017-01-06 Thread William Ray Wing

> On Jan 4, 2017, at 3:44 PM, Dietmar Schwertberger 
wrote:
>
> On 04.01.2017 15:41, William Ray Wing wrote:
>> I use Wing, and I think you will like it.  It *is* pythonic, and for what it
is worth, offers remote debugging as one of its more recently added features.
> Obviously, you had no other choice than using Wing ;-)

I should have said something.  First, and to the best of my knowledge, I have 
no relationship with the Wing developers other than being a satisfied customer. 
Second, seven years ago, when I was reading IDE reviews and testing the more 
highly rated products, Wing just bubbled up to the top of the sieve I was using 
(features, ease of use, and the way it fit my idea of â £naturalâ Ø, pretty 
much everyone's standard list).

>
> The remote debugging has been around for some years. I have been using it
quite often to debug on my Raspberry Pi, Nokia N900 and Jolla Phone, all 
running some Linux system. It works well. It is or was a bit complicated to set 
up. I think this has been improved with Wing 6, but I did not need it in the 
last weeks, so I don't know.

They claim it has been, but like you, I havenâ Öt had need to test it on the 
new release.

Thanks,
Bill

>
> Regards,
>
> Dietmar
> --
> https://mail.python.org/mailman/listinfo/python-list

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


Re: Clickable hyperlinks

2017-01-06 Thread Rustom Mody
This thread does lead to the question: Is the Url type in python less 
first-class than it could be?

In scheme I could point to something like this 
https://docs.racket-lang.org/net/url.html

Is there something equivalent in python?

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


Re: Choosing a Python IDE. what is your Pythonish recommendation? I

2017-01-06 Thread Dietmar Schwertberger
On 04.01.2017 15:41, William Ray Wing wrote:
> I use Wing, and I think you will like it.  It *is* pythonic, and for what it
is worth, offers remote debugging as one of its more recently added features. 
Obviously, you had no other choice than using Wing ;-)

The remote debugging has been around for some years. I have been using it quite 
often to debug on my Raspberry Pi, Nokia N900 and Jolla Phone, all running some 
Linux system. It works well. It is or was a bit complicated to set up. I think 
this has been improved with Wing 6, but I did not need it in the last weeks, so 
I don't know.

Regards,

Dietmar

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


Re: Choosing a Python IDE. what is your Pythonish recommendation? I

2017-01-06 Thread Hans-Peter Jansen
On Montag, 2. Januar 2017 03:38:53 Antonio Caminero Garcia wrote:
> Hello, I am having a hard time deciding what IDE or IDE-like code editor
> should I use. This can be overwhelming.
>
> So far, I have used Vim, Sublime, Atom, Eclipse with PyDev, Pycharm,
> IntelliJ with Python plugin.

Well, since nobody mentioned it, yet: eric is doing quite nice here. With on 
the fly error checking, jedi and qscintilla calltips and autocompletion, git 
integration (using a plugin), graphical debugger, it's grown to a capable IDE 
over the years.

Given, it's a fully open source, PyQt based project, it also shows the powers 
of Python3 and PyQt.

Pete

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


Re: Clickable hyperlinks

2017-01-06 Thread Chris Angelico
On Thu, Jan 5, 2017 at 9:58 AM, Deborah Swanson
 wrote:
> Chris Angelico wrote, on January 04, 2017 4:16 AM
>> This uses the 'webbrowser' module, which knows about a number
>> of different ways to open a browser, and will attempt them
>> all. So if you can figure out the UI part of things, actually
>> making the link pop up in a browser isn't too hard; for
>> instance, if you're doing OAuth at the command line and need
>> the user to go and authenticate, you can simply
>> webbrowser.open("http://.../";) and it'll DTRT.
>>
>
> Thank you, thank you! Finally, at least one person on this list knows
> about something (anything) in the python world that is internet aware.
> It's also occurred to me that Beautifulsoup downloads data from a url,
> so that code must have access to some kind of an internet engine too.

We've been all talking at cross purposes a bit in this thread. Most of us 
thought you were talking about the *user interface* of a clickable link, but if 
you're talking about the *mechanics* of HTTP downloads, Python has excellent 
facilities. I'd recommend checking out the third-party 'requests' module on 
PyPI.

> I googled antigravity and found a number of interesting links.
>
> The History of Python: import antigravity
> http://python-history.blogspot.com/2010/06/import-antigravity.html
>
> Among other things, it was added to Python 3 in 2010, so it's been
> around a little while. And a comment mentions that "The antigravity
> module is also included in Python 2.7."
>
> And a reddit poster tells us that "if you type 'import antigravity' into
> a Python command line your default browser opens the XKCD comic 'Python'
> in a tab."
> https://www.reddit.com/r/ProgrammerHumor/comments/1hvb5n/til_if_you_type
> _import_antigravity_into_a_python/
>
> An "import antigravity" video at
> https://www.youtube.com/watch?v=_V0V6Rk6Fp4

Hehe, yeah. It's a big joke that started because XKCD mentioned the language. 
But actually, the source code for antigravity.py itself isn't significant; all 
it does is call on the webbrowser module:

https://docs.python.org/3/library/webbrowser.html

> Yes, I'd gotten as far as figuring out that you don't need a clickable
> link. Code that opens a url in a browse would do the job just fine. Or
> the webbrowser.open("http://.../";) in a Linux terminal you suggest.
> (I just have to get my Linux machine up and running again to try it.)
>
> All in all, given that clickable urls in a console is a non-starter,
> this hits the nail on the head. Many thanks again!

Cool! Glad I could help out a bit. There are a few different things you can 
consider:

1) Open up a browser tab and let the user see the result 2) Make the request 
programmatically and access the text of the page for further processing
3) Invoke a hidden web browser, browse to a URL, submit form data, etc, as a 
means of testing a web server.

All three are possible. Take your pick!

ChrisA

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


Work between multiple processes

2017-01-06 Thread zxpatric
Hi everyone,

I ran into a case that I need to create a work process of an application 
(Jython so has to call using java.exe) which will collect the data based on 
what main process indicates.

(1) I tried multiprocessing package, no luck. Java.exe can't be called from 
Process class?

(2) I tried subprocess. subprocess.communicate function will wait for the work 
process to terminate so to return.


either (1) or (2) doesn't work out well. Please suggest.  Global system queue?

Thanks,
Patrick.

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


Re: Clickable hyperlinks

2017-01-06 Thread Terry Reedy
On 1/4/2017 4:32 AM, Deborah Swanson wrote:

> My original question was whether python had anything to provide this
> functionality, and the answer appears to be a resounding NO!!!

I would say 'Yes, but with user effort'.

To have a string interpreted as a clickable link, you send the string to 
software capable of creating a clickable link, plus the information
'this is a clickable link'*.  There are two ways to tag a string as a
link.  One is to use markup around the url in the string itself.
'' and html are example.  Python provides multiple to make this
easy. The other is to tag the string with a separate argument.  Python provides 
tkinter, which wraps tk Text widgets, which have a powerful tag system.  One 
can define a Link tag that will a) cause text to be displayed, for instance, 
blue and underlined and b) cause clicks on the text to generate a web request.  
One could then use
   mytext.insert('insert', 'http://www.example.com', Link)
Browser must do something similar when they encounter when they encounter html 
link tags.

* If the software directly recognizes a bare url such as
'http://www.example.com' as a link, without further indication, then it
should have a way to disable conversion to a clickable link.

--
Terry Jan Reedy

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


Re: Clickable hyperlinks

2017-01-06 Thread Grant Edwards
On 2017-01-04, Michael Torrie  wrote:

> On my Linux machine, the terminal emulators I've used all make a regular
> url printed out into a clickable link (or at least a right-clickable
> link).  This is just something they try to do with all things that look
> like urls.  Sometimes it's helpful, often it's annoying.

What I have done is defined a window manager root menu entry that opens a web 
browser on the current text selection.  That lets me "click" on a link in any 
application that suport the standard X11 text-selection mechanism (which is 
almost all of them).

>> I was hoping there was some functionality in python to make clickable
>> links. Could be a package, if the core language doesn't have it.
>
> No, there is not.  If you made a full GUI app using a toolkit like
> GTK or Qt, you can indeed place hyperlinks on your forms and the
> operating system will automatically connect them to the web browser.
> But not in text-mode terminal apps.

For me it's double-click to select the url in the terminal window or PDF viewer 
or whaterver, then right-click on the root window and pick
the menu entry that says 'Firefox [sel]' or 'Chrome [sel]'.  It's a few extra 
steps, but it works for almostly any application that displays text.

--
Grant Edwards   grant.b.edwardsYow! Where do your SOCKS
  at   go when you lose them in
  gmail.comth' WASHER?

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


Re: Clickable hyperlinks

2017-01-06 Thread Grant Edwards
On 2017-01-03, Deborah Swanson  wrote:
> Grant Edwards wrote, on January 03, 2017 3:13 PM
>>
>> On 2017-01-03, Deborah Swanson  wrote:
>>
>> > I'm sorry, I should have said a GUI console because I
>> wouldn't expect
>> > a text-based console to produce clickable links.
>>
>> What's a "GUI console"?

> The GUI consoles I have are in Pycharm, the IDLE that comes with
> Anaconda, and Spyder. PyCharm and IDLE both ask for internet access when
> I open them, so they're capable of opening links, but whether that means
> their output space is capable of handling clickable links I don't know.

Thanks, that's a bit clearer.  For those of us from the Unix world "console" 
means something else.

> I do know printing a full url with the %s specifier or entering a url
> and clicking enter just gives you the plain text url. Obviously, not all
> GUI consoles are enabled recognize and make clickable links from
> correctly formatted urls.
>
> I was hoping there was some functionality in python to make clickable
> links. Could be a package, if the core language doesn't have it.

There is no definition for what a "clickable link" is unless you're sending 
HTML to a web browser.  That means there's no way to create funcationality to 
make one.

--
Grant Edwards   grant.b.edwardsYow! I'm not an Iranian!!
  at   I voted for Dianne
  gmail.comFeinstein!!

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


RE: Clickable hyperlinks

2017-01-06 Thread Deborah Swanson
Chris Angelico wrote, on January 04, 2017 4:16 AM
>
> On Wed, Jan 4, 2017 at 10:43 PM, Deborah Swanson
>  wrote:
> > I'm quite well aware by now that there is no one-sentence
> answer to my
> > original question, if there's any coherent answer at all.
> Them's the
> > breaks. Live with it or live without it, it doesn't care.
>
> Yeah, there's no simple answer; however, you'll find that
> Python on many platforms is entirely capable of popping a URL
> up in the user's default browser. Check this out:
>
> >>> import antigravity
>
> This uses the 'webbrowser' module, which knows about a number
> of different ways to open a browser, and will attempt them
> all. So if you can figure out the UI part of things, actually
> making the link pop up in a browser isn't too hard; for
> instance, if you're doing OAuth at the command line and need
> the user to go and authenticate, you can simply
> webbrowser.open("http://.../";) and it'll DTRT.
>

Thank you, thank you! Finally, at least one person on this list knows about 
something (anything) in the python world that is internet aware. It's also 
occurred to me that Beautifulsoup downloads data from a url, so that code must 
have access to some kind of an internet engine too.

I googled antigravity and found a number of interesting links.

The History of Python: import antigravity 
http://python-history.blogspot.com/2010/06/import-antigravity.html

Among other things, it was added to Python 3 in 2010, so it's been around a 
little while. And a comment mentions that "The antigravity module is also 
included in Python 2.7."

And a reddit poster tells us that "if you type 'import antigravity' into a 
Python command line your default browser opens the XKCD comic 'Python' in a 
tab."
https://www.reddit.com/r/ProgrammerHumor/comments/1hvb5n/til_if_you_type
_import_antigravity_into_a_python/

An "import antigravity" video at
https://www.youtube.com/watch?v=_V0V6Rk6Fp4

And its page in the Package Index:
https://pypi.python.org/pypi/antigravity/0.1, with a Page Not Found Error for 
the Home Page. So it doesn't look like there's any alternative but to download 
it and look at the code.

Yes, I'd gotten as far as figuring out that you don't need a clickable link. 
Code that opens a url in a browse would do the job just fine. Or the 
webbrowser.open("http://.../";) in a Linux terminal you suggest. (I just 
have to get my Linux machine up and running again to try it.)

All in all, given that clickable urls in a console is a non-starter, this hits 
the nail on the head. Many thanks again!

Deborah

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


Re: Clickable hyperlinks

2017-01-06 Thread D'Arcy Cain
Deborah - please trim your quoted text.

On 2017-01-04 04:32 AM, Deborah Swanson wrote:
> Thanks, Steven. Yes, of course if you want to print strings you must
> enclose them in quotes. I think you learn that in Week 1 of any
> introductory course on Python.

Closer to minute one.  When I investigated Python years ago the first thing I 
learned was;

  print "Hello, world"

> But we aren't trying to print strings here, the point is to produce
> clickable links. I didn't enclose them with quotes because I didn't see
> any point in printing plain text when I wanted clickable links. I

I'm not sure what your links are composed of but mine all look like sequences 
of characters or "strings."  It sounds like you are trying to make URL a first 
class type like strings. integers, floats, etc.  I can't think of any language 
that treats URLs as first class objects. Even HTML needs quotes:

   http://...";>Go here

> actually didn't understand why you thought I should print them, but it

You want to output them to something.  That often involves printing them to a 
particular handler.

> never would have occurred to me that you wanted me to print out a bunch
> of silly plain text strings, apparently just for the heck of it.

Is that really what you got from his message?

> At this point, if I pursue this any farther, it will be to look into how
> Firefox takes webpage titles and urls out of its sqlite database and
> makes objects you can click on to open the webpages. That's the basic
> technology I'd need to find a way to talk (write) python into doing.

I can assure you that FF prints the string at some point.  It may wrap it in 
HTML tags first but printing is what it does.  Also, the URLs are stored as 
strings.  SQLite has no URL type.  If it did then it would still store it as a 
string somewhere.  PostGreSQL would let you create a URL type if you wanted but 
you would still need to wrap it in quotes
(single in this case) when you created the entry.

> If it's even worth it. On a practical level it's not worth it, way too
> much work for the teensy advantage of having it to use. It might be some
> giggles to figure out how to do it and maybe I will sometime just for
> funsies.

In all the messages in this thread I still don't understand what this "teensy 
advantage" is supposed to be.  Do you want to be able to do this:

   make_web_link(http://...)

instead of:

   make_web_link("http://...";)

--
D'Arcy J.M. Cain
System Administrator, Vex.Net
http://www.Vex.Net/ IM:da...@vex.net VoIP: sip:da...@vex.net

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


Re: Hey, I'm new to python so don't judge.

2017-01-06 Thread Terry Reedy
On 1/3/2017 10:15 PM, Dennis Lee Bieber wrote:

> And that statement tells us you are trying to run from within some
> IDE/editor which is trapping Python exceptions and producing a dialog
> box for them.

IDLE does this when one runs code from the editor, because it
cannot/should not inject error messages into the editor buffer... AND it 
replaces the ^ with red highlighting of the code pointed to.  No
information is lost.  Apparently, some beginners do not see the connection 
between the SyntaxError box and the red highlighting.  I think I should add 
something to the box.  Maybe 'The error was detected at the point of the red 
highlighting.'

> Instead, save your script (if you haven't yet) as a file
> (whatever.py).
>
> Open a command line interpreter/shell.
>
> Navigate (cd ...) to where you saved the file
>
> Type "python whatever.py"

What a nuisance.

> Copy and paste the results of the CLI/Shell window.

Or one can hit F5 to run the code or Alt-X to just check the syntax. A beginner 
should do this every few lines, and it should be as easy as possible to check.  
If one needs to ask about a syntax error, one can copy the code up and 
including the highlighted part. Example:

"When I run this code in IDLE

def is_same(target, number:
 if

I get a SyntaxError at 'if'."

If the OP had known to do this, the error might have been seen without posting.

--
Terry Jan Reedy

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


Re: Clickable hyperlinks

2017-01-06 Thread Chris Angelico
On Wed, Jan 4, 2017 at 10:43 PM, Deborah Swanson
 wrote:
> I'm quite well aware by now that there is no one-sentence answer to my
> original question, if there's any coherent answer at all. Them's the
> breaks. Live with it or live without it, it doesn't care.

Yeah, there's no simple answer; however, you'll find that Python on many 
platforms is entirely capable of popping a URL up in the user's default 
browser. Check this out:

>>> import antigravity

This uses the 'webbrowser' module, which knows about a number of different ways 
to open a browser, and will attempt them all. So if you can figure out the UI 
part of things, actually making the link pop up in a browser isn't too hard; 
for instance, if you're doing OAuth at the command line and need the user to go 
and authenticate, you can simply webbrowser.open("http://.../";) and it'll 
DTRT.

ChrisA

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


RE: Clickable hyperlinks

2017-01-06 Thread Deborah Swanson
D'Arcy Cain wrote, on Wednesday, January 04, 2017 5:03 AM
>
> Deborah - please trim your quoted text.

Yes, I will. Some lists want to have it all to review in one message, some want 
it trimmed to just the lines you are responding to. I was just waiting to see 
what this list wants.

> On 2017-01-04 04:32 AM, Deborah Swanson wrote:


> > But we aren't trying to print strings here, the point is to produce
> > clickable links. I didn't enclose them with quotes because I didn't
> > see any point in printing plain text when I wanted
> clickable links. I
>
> I'm not sure what your links are composed of but mine all look like
> sequences of characters or "strings."  It sounds like you are
> trying to
> make URL a first class type like strings. integers, floats, etc.  I
> can't think of any language that treats URLs as first class objects.
> Even HTML needs quotes:
>
>http://...";>Go here

It seemed reasonable that you might be able to print urls, which is why I tried 
the experiment with all of Steven's suggested formats. But I was highly 
skeptical that any would work without some kind of modifiers to a bare print 
statement.

> > actually didn't understand why you thought I should print
> them, but it
>
> You want to output them to something.  That often involves
> printing them
> to a particular handler.

Yes, that's one of the things I would expect if we could print them.

> > never would have occurred to me that you wanted me to print out a
> > bunch of silly plain text strings, apparently just for the
> heck of it.
>
> Is that really what you got from his message?

Please forgive me, and I hope Steven forgives me too, but I was sick to death 
of all the beating on a dead horse (using Python to make clickable links in a 
console, any console). I'd taken heart when he first suggested his print 
experiment, because it was a plausible approach. But I lost my temper when he 
upbraided me in this message for failing to enclose my strings in quotes, in a 
most patronizing kind of way, when printing out plain text was absolutely 
nowhere on the progress toward a solution scale. I've been quite impressed with 
Steven's knowledge and talent, and after fending off the throng of unseeing 
naysayers all afternoon, it was just a little too much. I really should have 
closed my email reader hours before I read and replied to this message. 
Shoulda, coulda, woulda.



> I can assure you that FF prints the string at some point.  It
> may wrap
> it in HTML tags first but printing is what it does.  Also,
> the URLs are
> stored as strings.  SQLite has no URL type.  If it did then it would
> still store it as a string somewhere.  PostGreSQL would let
> you create a
> URL type if you wanted but you would still need to wrap it in quotes
> (single in this case) when you created the entry.

I have no doubt that some variant of printing is involved. Transporting urls to 
the internet is an output process. FF's sqlite implementation does store urls 
as a text field in at least 2 tables. I would be interested in how FF takes 
those text urls and opens web pages with them, although I've learned and 
figured out just today some ways that Python can also do it. Turns out 
clickable links were a red herring.

If Steven's original suggestion included anything but a bare print statement, 
like the use of a special specifier or linking the print statement to some 
module, the use of quoted strings would have at least been worthy of 
consideration. But we all know what print("http://www.wherever.com";) would 
print, and it would be utterly worthless for the purpose at hand. Trying the 
print statement without the quotes was a least a possibility, if there was any 
awareness in the print code of urls and what to do with them. That was the 
whole point of this fishing expedition, as I saw it. To see if there was any 
undocumented or narrowly known-of features in the print code.


> In all the messages in this thread I still don't understand what this
> "teensy advantage" is supposed to be.  Do you want to be able
> to do this:
>
>make_web_link(http://...)
>
> instead of:
>
>make_web_link("http://...";)
>
> --
> D'Arcy J.M. Cain
> System Administrator, Vex.Net
> http://www.Vex.Net/ IM:da...@vex.net
> VoIP: sip:da...@vex.net

You probably didn't see my oneliner on the "why do it" part in the swarm of 
messages on this thread yesterday. In it I mentioned that the use would be to 
open urls in the data I'm working with while I'm debugging the code that uses 
them. I want to see what pages they open, without having to leave my IDE. 
(Obviously I'd have to open another .py file, but that would be easier and 
quicker than the alternatives.) I never intended my original question to be any 
more than a frivolous toss out into the sea, to see if anyone knew an answer. I 
was flat out astonished when it blew up into the mini-monster that it did.

Is make_web_link("http://...";) valid python code? That's exactly the kind of 
answer I was loo

RE: Clickable hyperlinks

2017-01-06 Thread Deborah Swanson
Steve D'Aprano wrote, on January 04, 2017 2:39 AM
>
> On Wed, 4 Jan 2017 08:32 pm, Deborah Swanson wrote:
>
> > Thanks, Steven. Yes, of course if you want to print strings
> you must
> > enclose them in quotes. I think you learn that in Week 1 of any
> > introductory course on Python.
> >
> > But we aren't trying to print strings here, the point is to produce
> > clickable links. I didn't enclose them with quotes because I didn't
> > see any point in printing plain text when I wanted
> clickable links. I
> > actually didn't understand why you thought I should print
> them, but it
> > never would have occurred to me that you wanted me to print out a
> > bunch of silly plain text strings, apparently just for the
> heck of it.
>
> What we have here is a failure to communicate :-)
>
> I apologise for ruffling your feathers, but its difficult to
> judge another person's level of knowledge. In someways you're
> obviously quite knowledgeable about Python, but in other ways
> you're still learning (as we all are!) and I'm afraid I may
> have misjudged exactly what your level of knowledge was.
> Sorry about that.
>
> I'm not suggesting that you print "silly plain text strings"
> just for the heck of it. You've asked how to get a clickable
> link using Python. There is only one way I know of to get a
> clickable link using Python:
>
> Write out a link as plain text to another application which
> then interprets the plain text as a clickable link.
>
> You *might* be able to get clickable links in Python by
> writing an entire GUI application, using (say) the tkinter
> library, or one of the third-party GUI libraries like
> wxPython, kivy, pyqt, or others, but I haven't a clue how.
> But even there, your links will start off as text, which
> means you will still need to surround them with quotes to
> make them strings.
>
>
> Aside: you've actually raised a fascinating question. I
> wonder whether there are any programming languages that
> understand URLs as native data types, so that *source code*
> starting with http:// etc is understood in the same way that
> source code starting with [ is seen as a list or { as a dict?
>
>
> But back to your problem: short of writing you own GUI
> application, in which case you can do *anything you like*, you can:
>
> - write out a HTML file containing the URLs you want, in  href= ...  tags, then open the HTML file in a web browser
> and let the web browser interpret the HTML tags as clickable links;
>
>
> - write out an Excel spreadsheet, using whatever format Excel
> expects, open the spreadsheet in Excel, and let Excel
> interpret the mystery format as a clickable link;
>
> - print the URL to the console, and see if the console is
> smart enough to interpret it as a clickable link.
>
>
> I'm sorry that I can't give you a one-sentence answer "just
> use such-and-such a function, that does exactly what you want
> in a platform-independent manner" :-(
>
>
>
>
> --
> Steve
> "Cheer up," they said, "things could be worse." So I cheered
> up, and sure enough, things got worse.

Well, well. People mix and people misunderstand and misjudge each other. It's 
the way of things with people. I just needed to tell you how it all looked from 
my side.  So are we done with that?  I certainly hope so.

I'm quite well aware by now that there is no one-sentence answer to my original 
question, if there's any coherent answer at all. Them's the breaks. Live with 
it or live without it, it doesn't care.

I do appreciate the education I've gotten on this thread about the issues 
involved. But I rather imagine that near term anyway, I'll only be pondering it 
now and then, and maybe poking around a bit. Who knows, maybe I'll eventually 
invent the solution and make my first million dollars from it.  haha, yeah 
right.

So it goes.


Deborah

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


Re: Screwing Up looping in Generator

2017-01-06 Thread Sayth Renshaw
For completeness I was close this is the working code.

def get_list_of_names(generator_arg):
name_set = set()
for name in generator_arg:
base = os.path.basename(name.name)
filename = os.path.splitext(base)[0]
name_set.add(filename)
return name_set


def data_attr(roots):
"""Get the root object and iter items."""
for name in names:
directory = "output"
write_name = name + ".csv"
with open(os.path.join(directory, write_name), 'w', newline='') as
csvf:
race_writer = csv.writer(csvf, delimiter=','
)


thanks for your time and assistance. It's much appreciated

Sayth

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


Re: Clickable hyperlinks

2017-01-06 Thread Gilmeh Serda
On Tue, 03 Jan 2017 11:46:16 -0800, Deborah Swanson wrote:

> Does python have an equivalent function? Probably the most common use
> for it would be output to the console, similar to a print statement, but
> clickable.

Write it as HTML code save to temp file and call the browser which loads the 
file.

--
Gilmeh

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


RE: Clickable hyperlinks

2017-01-06 Thread Deborah Swanson
Steve D'Aprano wrote, on January 04, 2017 2:20 AM
>
> On Wed, 4 Jan 2017 03:46 pm, Deborah Swanson wrote:
>
> > As I've mentioned in other posts on this thread, I'm now
> thinking that
> > I need to write a class to do this, and find out how
> Firefox and url
> > aware terminals in Linux do it. There must be a way.
>
>
> A GUI application can interpret text any way it chooses.
> Firefox takes a HTML file and renders it, using whatever GUI
> library it chooses. That GUI library understands that text like:
>
> Hello World!
>
> should be shown in bold face, and text like:
>
> http://www.example.com";>Example
>
> should be shown as the word "Example" underlined and in some
> colour, and when you click on it the browser will navigate to
> the URL given. Firefox can do this because it controls the
> environment it runs in.
>
> Same for Excel, which also controls the environment it runs in.
>
> That's *not* the case for Python, which is at the mercy of
> whatever console or terminal application it is running in.
>
> However, you can use Python to write GUI applications. Then it becomes
> *your* responsibility to create the window, populate it with
> any buttons or text or scroll bars you want, and you can
> choose to interpret text any way you like -- including as
> clickable Hyperlinks.
>
> The bottom line is, there is no "a way" to do this. There are
> a thousand, ten thousand, ways to do it. Every web browser,
> every terminal, every URL-aware application, can choose its
> own way to do it. There's no one single way that works
> everywhere, but if you are working in a console or terminal,
> just printing the URL is likely to be interpreted by the
> console as a clickable link:
>
> print("http://www.example.com";)
>
>
>
>
> --
> Steve
> "Cheer up," they said, "things could be worse." So I cheered
> up, and sure enough, things got worse.

I can appreciate all that and pretty much knew most of it already. At this 
point I'm not so much concerned with how to put characters on a white space 
that are clickable, we've pretty much established at least a couple dozen 
messages ago that there's nothing for python to get hold of there because of 
the vast number of places people might want to put clickable links. (I actually 
read every message on a thread that interests me enough to participate.)

I think the entry point to this problem is to find out how to connect to the 
internet when you click that link. Then I think the nuts and bolts of what 
symbols to put where for a particular target would fall into place.

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


RE: Clickable hyperlinks

2017-01-06 Thread Steve D'Aprano
On Wed, 4 Jan 2017 03:46 pm, Deborah Swanson wrote:

> As I've mentioned in other posts on this thread, I'm now thinking that I
> need to write a class to do this, and find out how Firefox and url aware
> terminals in Linux do it. There must be a way.


A GUI application can interpret text any way it chooses. Firefox takes a HTML 
file and renders it, using whatever GUI library it chooses. That GUI
library understands that text like:

Hello World!

should be shown in bold face, and text like:

http://www.example.com";>Example

should be shown as the word "Example" underlined and in some colour, and when 
you click on it the browser will navigate to the URL given. Firefox can do this 
because it controls the environment it runs in.

Same for Excel, which also controls the environment it runs in.

That's *not* the case for Python, which is at the mercy of whatever console or 
terminal application it is running in.

However, you can use Python to write GUI applications. Then it becomes
*your* responsibility to create the window, populate it with any buttons or
text or scroll bars you want, and you can choose to interpret text any way you 
like -- including as clickable Hyperlinks.

The bottom line is, there is no "a way" to do this. There are a thousand, ten 
thousand, ways to do it. Every web browser, every terminal, every URL-aware 
application, can choose its own way to do it. There's no one
single way that works everywhere, but if you are working in a console or 
terminal, just printing the URL is likely to be interpreted by the console as a 
clickable link:

print("http://www.example.com";)




--
Steve
â £Cheer up,â Ø they said, â £things could be worse.â Ø So I cheered up, and
sure
enough, things got worse.

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


  1   2   >