Re: Using namedtuples field names for column indices in a list of lists

2017-01-12 Thread Antoon Pardon
Op 11-01-17 om 23:57 schreef Deborah Swanson:
>
>> What are we supposed to do when somebody asks a question based on an
>> obvious mistake? Assume that they're a quick learner who has probably 
>> already worked out their mistake and doesn't need an answer? That 
>> would certainly make our life easier: we can just ignore everybody's 
>> questions.
> No, of course not. My advice to people who want to help is to not assume
> that you know what the question asker does and doesn't know, and just
> answer the questions without obsessing about what they know.

With all respect, such an answer betrays not much experience on this
list. Half the time answering in this way would mean making very little
progress in actually helping the person. There is an important difference
in trying to help someone and just answering his questions. And your
advice may be the best way to help someone like you but not everyone
is like you. A lot of people have been helped by a remark that didn't
answer the question.

>  If that's
> impossible because they have something so wrong that you don't know what
> they're asking, that would be a good time to point it out and give them
> a chance to correct it.

It is rarely a question of impossibility. It often enough is a sense
that the person asking the question is approaching the problem from
the wrong side. Often enough that sense is correct, often enough that
sense is wrong. All the participants can do is take a clue from the
question and then guess what respons would help this person best.

Nobody can expect that this list will treat their questions in a way
that suits their personal style.

-- 
Antoon Pardon


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


RE: Using namedtuples field names for column indices in a list of lists

2017-01-12 Thread Deborah Swanson
Antoon Pardon wrote, on January 12, 2017 12:49 AM
> 
> Op 11-01-17 om 23:57 schreef Deborah Swanson:
> >
> >> What are we supposed to do when somebody asks a question based on
an 
> >> obvious mistake? Assume that they're a quick learner who has
probably 
> >> already worked out their mistake and doesn't need an answer? That 
> >> would certainly make our life easier: we can just ignore
everybody's 
> >> questions.
> > No, of course not. My advice to people who want to help is to not 
> > assume that you know what the question asker does and doesn't know, 
> > and just answer the questions without obsessing about what 
> they know.
> 
> With all respect, such an answer betrays not much experience 
> on this list. Half the time answering in this way would mean 
> making very little progress in actually helping the person. 
> There is an important difference in trying to help someone 
> and just answering his questions. And your advice may be the 
> best way to help someone like you but not everyone is like 
> you. A lot of people have been helped by a remark that didn't 
> answer the question.

It's true, I've only been on this list a few weeks, although I've seen
and been on the receiving end of the kind of "help" that feels more like
being sneered at than help. Not on this list, but on Linux and similar
lists. There does seem to be a "tough love" approach to "helping"
people, and I haven't seen that it really helped that much, in other
places that I've seen it in action over a period of time.  I'm willing
though to just see how it works on this list. Since I've been here, I
haven't seen people come back who get that kind of approach, but a few
weeks is too short a time to draw conclusions. Still, when people who
need help don't come right back, that should be a first clue that they
didn't get it.
 
> >  If that's
> > impossible because they have something so wrong that you don't know 
> > what they're asking, that would be a good time to point it out and 
> > give them a chance to correct it.
> 
> It is rarely a question of impossibility. It often enough is 
> a sense that the person asking the question is approaching 
> the problem from the wrong side. Often enough that sense is 
> correct, often enough that sense is wrong. All the 
> participants can do is take a clue from the question and then 
> guess what respons would help this person best.

This sounds right to me. Any list or forum that fields questions has the
problem of understanding the questioner who's writing in. Any strategy
that briges that gap seems like a good one to me.

> Nobody can expect that this list will treat their questions 
> in a way that suits their personal style.
> 
> -- 
> Antoon Pardon
> 
> 
Oh, I'm sure that's true, though I do think more direct question asking
and answering is always helpful. Communication in lists and forums is
somewhat in the dark, because there's so little context in many of the
conversations. Questions (and waiting for the answers before responding)
are an excellent way to fill in some of the dark spaces.

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


need help getting error when trying selenium with python

2017-01-12 Thread Ansuman Suryaprakash
pyhton version 3.5
selenium version 3.0.2
firefox version 50.1.0


pyhton code:

from selenium import webdriver

browser = webdriver.Firefox()
browser.get('http://127.0.0.1:8000')

assert 'Django' in browser.title

Error:

D:\django_learning_TDD>py functional_tests.py
Traceback (most recent call last):
  File "functional_tests.py", line 3, in 
browser = webdriver.Firefox()
  File "C:\Users\Subhasish\AppData\Local\Programs\Python\Python35-32\lib\site-pa
ckages\selenium\webdriver\firefox\webdriver.py", line 140, in __init__
self.service.start()
  File 
"C:\Users\Subhasish\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\common\service.py",
 line 102, in start
raise WebDriverException("Can not connect to the Service %s" % self.path)
selenium.common.exceptions.WebDriverException: Message: Can not connect to the 
Service geckodriver


Can someonr help me with getting rid of the above error
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Using namedtuples field names for column indices in a list of lists

2017-01-12 Thread Marko Rauhamaa
"Deborah Swanson" :

> I've only been on this list a few weeks, although I've seen and been
> on the receiving end of the kind of "help" that feels more like being
> sneered at than help. Not on this list, but on Linux and similar
> lists. There does seem to be a "tough love" approach to "helping"
> people,

An instructive anecdote: somebody I know told me he once needed the
definitive list of some websites. He posted a question on the relevant
online forum, but it fell on deaf ears. After some days, he replied to
his own posting saying he had found the list and included the list in
his reply. He knew the list was probably not current, but it served its
purpose: right away he got an angry response pointing out his list was
completely wrong with a link to the up-to-date list.


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


timers in threaded application

2017-01-12 Thread Skip Montanaro
I know signals and threads are a bad mix, but I only discovered I was
playing with fire a few minutes ago. I've been using the websocket-client
library (https://pypi.python.org/pypi/websocket-client/) to interact with
another system at work. It implements its own event loop, but doesn't seem
to play nice with others. I used gtk/gobject for years. It implemented
timeouts for you, you could integrate it with other event loops, etc.

As far as I could tell, websocket-client implements none of that. I needed
some timer functionality, so not thinking about it too carefully, I
implemented it using signal.alarm. This worked pretty well, but I was
experiencing mysterious hangs. This morning, looking through the
websocket-client code to see if I'd missed something, I saw that it uses
threads. So, that might be my problem.

I still need timers, and for the moment I'm stuck with this package's event
loop. What options do I have? I'm certainly willing to switch to another
websocket client library if that will make all my problems go away. This is
my first ws experience though, and I inherited some code which used
websocket-client, so just went with what I had.

Thx,

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


Re: Using namedtuples field names for column indices in a list of lists

2017-01-12 Thread Chris Angelico
On Thu, Jan 12, 2017 at 9:27 PM, Marko Rauhamaa  wrote:
> An instructive anecdote: somebody I know told me he once needed the
> definitive list of some websites. He posted a question on the relevant
> online forum, but it fell on deaf ears. After some days, he replied to
> his own posting saying he had found the list and included the list in
> his reply. He knew the list was probably not current, but it served its
> purpose: right away he got an angry response pointing out his list was
> completely wrong with a link to the up-to-date list.

There's a reason for that. Inaccurate information is worse than none
at all, because it's indistinguishable from accurate information
without deep analysis. Also, often someone won't know the correct
answer, but will recognize a wrong answer. In correcting the record,
you come a bit closer to the truth. Sometimes all it takes is one
wrong answer, and the discussion kicks off.

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


ANN: Wing IDE 6.0.1 released

2017-01-12 Thread Wingware

Hi,

We've just released Wing IDE 6.0.1 which improves remote host 
configuration, adds remote development support for 32-bit Linux and 
older 64-bit Linux systems, fixes stability problems affecting some 
users, and makes many other improvements.  For details on this release, 
see the change log at http://wingware.com/pub/wingide/6.0.1/CHANGELOG.txt


Wing IDE 6 is the latest major release of Wingware's Python IDE that 
adds many new features, introduces a new annual license option, and 
makes some changes to the product line.


New Features

 * Improved Multiple Selections:  Quickly add selections and edit them
   all at once
 * Easy Remote Development:  Work seamlessly on remote Linux, OS X, and
   Raspberry Pi systems
 * Debugging in the Python Shell:  Reach breakpoints and exceptions in
   (and from) the Python Shell
 * Recursive Debugging:  Debug code invoked in the context of stack
   frames that are already being debugged
 * PEP 484 and PEP 526 Type Hinting:  Inform Wing's static analysis
   engine of types it cannot infer
 * Support for Python 3.6 and Stackless 3.4:  Use async and other new
   language features
 * Optimized debugger:  Run faster, particularly in multi-process and
   multi-threaded code
 * Support for OS X full screen mode:  Zoom to a virtual screen, with
   auto-hiding menu bar
 * Added a new One Dark color palette:  Enjoy the best dark display
   style yet
 * Updated French and German localizations:  Thanks to Jean Sanchez,
   Laurent Fasnacht, and Christoph Heitkamp

For a much more detailed overview of new features see the release notice 
at http://wingware.com/news/2017-01-10


Annual Use License Option

Wing 6 adds the option of purchasing a lower-cost expiring annual 
license for Wing IDE Pro.  An annual license includes access to all 
available Wing IDE versions while it is valid, and then ceases to 
function if it is now renewed.  Pricing for annual licenses is US$ 
179/user for Commercial Use and US$ 69/user for Non-Commercial Use.


Perpetual licenses for Wing IDE will continue to be available at the 
same pricing.


The cost of extending Support+Upgrades subscriptions on Non-Commercial 
Use perpetual licenses for Wing IDE Pro has also been dropped from US$ 
89 to US$ 39 per user.


For details, see https://wingware.com/store/purchase

Wing Personal is Free

Wing IDE Personal is now free and no longer requires a license to run. 
 It now also includes the Source Browser, PyLint, and OS Commands 
tools, and supports the scripting API and Perspectives.


However, Wing Personal does not include Wing Pro's advanced editing, 
debugging, testing and code management features, such as remote host 
access, refactoring, find uses, version control, unit testing, 
interactive debug probe, multi-process and child process debugging, move 
program counter, conditional breakpoints, debug watch, 
framework-specific support (for matplotlib, Django, and others), find 
symbol in project, and other features.


Links

Release notice: http://wingware.com/news/2017-01-10
Free trial: http://wingware.com/wingide/trial
Downloads: http://wingware.com/downloads
Feature list: http://wingware.com/wingide/features
Buy: http://wingware.com/store/purchase
Upgrade: https://wingware.com/store/upgrade

Questions?  Don't hesitate to email us at supp...@wingware.com.

Thanks,

--

Stephan Deibel
Wingware | Python IDE

The Intelligent Development Environment for Python Programmers

wingware.com


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


Find and append file path

2017-01-12 Thread Iranna Mathapati
Hi Team,

How to append file path and find the latest folder according to the latest
date:

CLI input :"/root/user/branches/xyz"

i want to find latest file within CLI input path and append to given CLI
path

Example:
CLI Input: /root/user/branches/xyz

find latest file and append to CLI path:
"/root/user/branches/xyz/Apple"
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Find and append file path

2017-01-12 Thread Rhodri James

On 12/01/17 13:58, Iranna Mathapati wrote:

Hi Team,

How to append file path and find the latest folder according to the latest
date:

CLI input :"/root/user/branches/xyz"

i want to find latest file within CLI input path and append to given CLI
path

Example:
CLI Input: /root/user/branches/xyz

find latest file and append to CLI path:
"/root/user/branches/xyz/Apple"



Use os.scandir() to list whatever is in the directory, DirEntry.is_dir() 
will tell you if an entry is itself a directory, and DirEntry.stat() 
will let you get at the directory's various time stats.  Which attribute 
you want depends on exactly what you mean by "the latest folder 
according to the latest date".  Then just use your favourite means to 
join the directory name you selected to the original path.


--
Rhodri James *-* Kynesim Ltd
--
https://mail.python.org/mailman/listinfo/python-list


Doubt with matrix

2017-01-12 Thread José Manuel Suárez Sierra
Hello, I want to  go over matrix indexs with this code:
def comparador2(a, b):
c3 = ["0"]  # variables
x = -1  # contador de letras aniadidas a c3
i = 0  # contador bucle secuencia a
j = 0  # contador bucle secuencia b
l1 = len(a)
l2 = len(b)
cont = []  # contador de ciclos poner primer termino a 0
k = -1  # contador de 0 y 1 aniadidos a cont

if l1 > l2:  # metodo de la burbuja que elige la secuencia mas larga 
REVISAR puede ser alreves
aux = a
a = b
b = aux

for a[i] in a:  # en la secuencia1 recorro los elementos

for b[j] in b :

if a[i] == b[j] and i <= l1 and j <= l2:  # Si el elemento i de 
la seq1 es igual que el elemento j de la seq2, y el numero de elementos en i y 
j es menor o igual que la longitud de las secuencias 1 y 2
c3.append(a[i])  # se aniade el elemento comun a la lista c3
x = x + 1
k = k + 1
j = j + 1  # se pasa el elemento siguiente de la seq2
i = i + 1  # se pasa el elemento siguiente de la seq1
cont.append(1)



elif a[i] != b[
j] and i <= l1 and j <= l2:  # si no coinciden estos 
elementos se pasa al siguiente elemento de la lista 2
j = j + 1
k = k + 1
cont.append(0)
if cont[k] == 0 and cont[k - 1] == 1 and cont[k - 2] == 0 
and k >= 2:
i = i - 1
j = j - 1
else:
k = k + 1
cont.append(0)
if i == l2:
i = i + 1
j = 0


return c3

and this issue is prompted:
IndexError: list assignment index out of range

How could I fix it?

Thank you for your assistance
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Doubt with matrix

2017-01-12 Thread Bob Gailer
Always Post the entire traceback. That will show us the line of code that
raised the error, as well as the sequence of function calls involved.

On Jan 12, 2017 11:10 AM, "José Manuel Suárez Sierra" <
josemsuarezsie...@gmail.com> wrote:

> Hello, I want to  go over matrix indexs with this code:
> def comparador2(a, b):
> c3 = ["0"]  # variables
> x = -1  # contador de letras aniadidas a c3
> i = 0  # contador bucle secuencia a
> j = 0  # contador bucle secuencia b
> l1 = len(a)
> l2 = len(b)
> cont = []  # contador de ciclos poner primer termino a 0
> k = -1  # contador de 0 y 1 aniadidos a cont
>
> if l1 > l2:  # metodo de la burbuja que elige la secuencia mas larga
> REVISAR puede ser alreves
> aux = a
> a = b
> b = aux
>
> for a[i] in a:  # en la secuencia1 recorro los elementos
>
> for b[j] in b :
>
> if a[i] == b[j] and i <= l1 and j <= l2:  # Si el elemento
> i de la seq1 es igual que el elemento j de la seq2, y el numero de
> elementos en i y j es menor o igual que la longitud de las secuencias 1 y 2
> c3.append(a[i])  # se aniade el elemento comun a la
> lista c3
> x = x + 1
> k = k + 1
> j = j + 1  # se pasa el elemento siguiente de la seq2
> i = i + 1  # se pasa el elemento siguiente de la seq1
> cont.append(1)
>
>
>
> elif a[i] != b[
> j] and i <= l1 and j <= l2:  # si no coinciden estos
> elementos se pasa al siguiente elemento de la lista 2
> j = j + 1
> k = k + 1
> cont.append(0)
> if cont[k] == 0 and cont[k - 1] == 1 and cont[k - 2]
> == 0 and k >= 2:
> i = i - 1
> j = j - 1
> else:
> k = k + 1
> cont.append(0)
> if i == l2:
> i = i + 1
> j = 0
>
>
> return c3
>
> and this issue is prompted:
> IndexError: list assignment index out of range
>
> How could I fix it?
>
> Thank you for your assistance
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Find and append file path

2017-01-12 Thread Tim Chase
On 2017-01-12 19:28, Iranna Mathapati wrote:
> Example:
> CLI Input: /root/user/branches/xyz
> 
> find latest file and append to CLI path:
> "/root/user/branches/xyz/Apple"


I've used something like the below to find the most recent file in a
directory tree (it also works for pulling other attributes like the
file-size from os.stat() results).

-tkc


import os
from operator import attrgetter

def dir_iter(root):
for fullpath in (
os.path.join(path, dir_)
for path, dirs, files in os.walk(root)
for dir_ in dirs
):
if os.path.isdir(fullpath):
yield fullpath

def find_latest(root,
which_time=attrgetter("st_mtime")
):
return max(dir_iter(root),
key=lambda fullpath: which_time(os.stat(fullpath))
)

if __name__ == "__main__":
from sys import argv
if len(argv) > 1:
root = argv[1]
else:
root = '.'
print(find_latest(root))
print(find_latest(root, which_time=attrgetter("st_ctime")))
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Doubt with matrix

2017-01-12 Thread Peter Otten
José Manuel Suárez Sierra wrote:

> Hello, I want to  go over matrix indexs with this code:
> def comparador2(a, b):
> c3 = ["0"]  # variables
> x = -1  # contador de letras aniadidas a c3
> i = 0  # contador bucle secuencia a
> j = 0  # contador bucle secuencia b
> l1 = len(a)
> l2 = len(b)
> cont = []  # contador de ciclos poner primer termino a 0
> k = -1  # contador de 0 y 1 aniadidos a cont
> 
> if l1 > l2:  # metodo de la burbuja que elige la secuencia mas larga
> REVISAR puede ser alreves

In Python there's a cool way to swap values without an explicit helper 
variable:

  a, b = b, a

> aux = a
> a = b
> b = aux

OK, now you have swapped a and b, but not their respective lengths l1 and 
l2...
 
> for a[i] in a:  # en la secuencia1 recorro los elementos

Do you really want to modify a[i] on every iteration? Most certainly not. 
Try to use the normal way with just a name, e. g.

  for entry_a in a:
  ...

Then use entry_a instead of a[i] for your comparison in the body of the for-
loop. With that approach it's impossible to get an IndexError.
If you still need the index to alter an entry in the list -- enumerate() is 
your friend:

for index_a, entry_a in enumerate(a):
...

Again it's unlikely that you will get an IndexError.
 
> for b[j] in b :
> 
> if a[i] == b[j] and i <= l1 and j <= l2:  # Si el elemento
> i de la seq1 es igual que el elemento j de la seq2, y el
> numero de elementos en i y j es menor o igual que la
> longitud de las secuencias 1 y 2
> c3.append(a[i])  # se aniade el elemento comun a la
> lista c3 x = x + 1
> k = k + 1
> j = j + 1  # se pasa el elemento siguiente de la seq2
> i = i + 1  # se pasa el elemento siguiente de la seq1
> cont.append(1)
> 
> 
> 
> elif a[i] != b[
> j] and i <= l1 and j <= l2:  # si no coinciden estos
> elementos se pasa al siguiente elemento de la lista 2
> j = j + 1 k = k + 1
> cont.append(0)
> if cont[k] == 0 and cont[k - 1] == 1 and cont[k - 2]
> == 0 and k >= 2:
> i = i - 1
> j = j - 1
> else:
> k = k + 1
> cont.append(0)
> if i == l2:
> i = i + 1
> j = 0
> 
> 
> return c3
> 
> and this issue is prompted:
> IndexError: list assignment index out of range
> 
> How could I fix it?
> 
> Thank you for your assistance


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


Re: Find and append file path

2017-01-12 Thread Peter Otten
Tim Chase wrote:

> def dir_iter(root):
> for fullpath in (
> os.path.join(path, dir_)
> for path, dirs, files in os.walk(root)
> for dir_ in dirs
> ):
> if os.path.isdir(fullpath):
> yield fullpath

Why did you add an explicit isdir() check? My understanding is that the 
names in dirs are known to be directories.


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


Re: Find and append file path

2017-01-12 Thread Tim Chase
On 2017-01-12 18:32, Peter Otten wrote:
> Why did you add an explicit isdir() check? My understanding is that
> the names in dirs are known to be directories.

Ah, right.  The code I had laying around that did something similar
but processes both the dirs and the files, so when the OP asked for
just dirs, I ended up with both belt-and-suspenders changes to it.

So that isdir() check could readily be removed.

-tkc


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


Automatically restore virtualenv in Terminal.app on macOS (zsh, bash)

2017-01-12 Thread Ilya Kulakov
Today I discovered that one can customize session restoration in Terminal.app
by defining the shell_session_save_user_state function.

Here is a script that restores active virtualenv, e.g. after you reboot your 
machine:

https://gist.github.com/Kentzo/185e4eab382bbcf1f0a9738a28128dce

It's written for ZSH, but it's fairly simple to port it to bash: you don't even 
need plugin,
since session management is supported out of the box.

Here is a plugin for oh-my-zsh:

https://github.com/Kentzo/oh-my-zsh/tree/master/plugins/session
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Using namedtuples field names for column indices in a list of lists

2017-01-12 Thread Michael Torrie
On 01/12/2017 02:26 AM, Deborah Swanson wrote:
> It's true, I've only been on this list a few weeks, although I've seen
> and been on the receiving end of the kind of "help" that feels more like
> being sneered at than help. Not on this list, but on Linux and similar
> lists. There does seem to be a "tough love" approach to "helping"
> people, and I haven't seen that it really helped that much, in other
> places that I've seen it in action over a period of time.  

If you go down a wrong path, people are going to try to warn you.  For
example, you were told several times, no that object really is a list,
yet you argued with them on that point for several posts.  Tough love or
sneering? No, absolutely not.  Communication difficulties?  Yes!  But
not even close to wholly the fault of those who were trying to assist
you. If you haven't been helped, it's not for lack of their trying.

> I'm willing
> though to just see how it works on this list. Since I've been here, I
> haven't seen people come back who get that kind of approach, but a few
> weeks is too short a time to draw conclusions. Still, when people who
> need help don't come right back, that should be a first clue that they
> didn't get it.

Fortunately this list is pretty friendly and open to newbies.  And
long-time posters have no problem telling other long-time posters when
they do cross the line into bullying or trolling territory.

Fortunately I've seen nothing but people wanting to help you with your
ventures in Python programming responding to your queries, which I'm
gratified to see.  And many many newbies have been helped in their
explorations of Python land.
-- 
https://mail.python.org/mailman/listinfo/python-list