Re: compiling matplotlib in virtual env

2015-10-01 Thread Miki Tebeka
> I been trying to compile matplotlib in a python3.4 virtual env using 
> pip version 1.7 on Fedora 22. I am in about 3 weeks learning python 
> and Django so I am not clear on the error response to:
> ...
>   File "/usr/lib64/python3.4/distutils/version.py", line 343, in _cmp
> if self.version < other.version:
> TypeError: unorderable types: str() < int()
Looks like a bug in distuils (which is a package used by pip). Maybe you can 
upgrade to a newer version of distutils? (pip3 install -U distutils) and try 
again?

As a side note, I find using conda to install scipy related packages a much 
easier way.
-- 
https://mail.python.org/mailman/listinfo/python-list


compiling matplotlib in virtual env

2015-10-01 Thread Rolston Jeremiah
Hello everyone,

I been trying to compile matplotlib in a python3.4 virtual env using 
pip version 1.7 on Fedora 22. I am in about 3 weeks learning python 
and Django so I am not clear on the error response to:


commmand
=

pip3 install matplotlib


error message
=


Traceback (most recent call last):
  File "", line 20, in 
  File "/tmp/pip-build-b_yuukm4/matplotlib/setup.py", line 155, in 
result = package.check()
  File "/tmp/pip-build-b_yuukm4/matplotlib/setupext.py", line 961, in check
min_version='2.3', version=version)
  File "/tmp/pip-build-b_yuukm4/matplotlib/setupext.py", line 445, in 
_check_for_pkg_config
if (not is_min_version(version, min_version)):
  File "/tmp/pip-build-b_yuukm4/matplotlib/setupext.py", line 173, in 
is_min_version
return found_version >= expected_version
  File "/usr/lib64/python3.4/distutils/version.py", line 76, in __ge__
c = self._cmp(other)
  File "/usr/lib64/python3.4/distutils/version.py", line 343, in _cmp
if self.version < other.version:
TypeError: unorderable types: str() < int()


Command "python setup.py egg_info" failed with error code 1 in 
/tmp/pip-build-b_yuukm4/matplotlib


Appreciate  your help
thanks

rjae



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


Re: Generating a vector from successive multiplications of another vector from an initial value

2015-10-01 Thread Paulo da Silva
Às 23:36 de 01-10-2015, Oscar Benjamin escreveu:
> 
> On Thu, 1 Oct 2015 21:51 Paulo da Silva  > wrote:
...

> 
> V * np.cumprod(vec)
> 

Thank you very much Oscar and Duncan.

I googled a lot for such a function. Unfortunately the word "cumulative"
didn't come to my mind!

Paulo


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


Re: The Nikola project is deprecating Python 2.7 (+2.x/3.x user survey results)

2015-10-01 Thread Terry Reedy

On 10/1/2015 12:26 PM, Chris Warrick wrote:

The Nikola developers decided to deprecate Python 2.7 support.
Starting with v7.7.2, Nikola will display a warning if Python 2.7 is
used (but it will still be fully supported). In early 2016, Nikola
v8.0.0 will come out, and that release will not support Python 2.7
officially.


How sane ;-)


The decision was made on the basis of a user survey, with 138
participants. The vast majority of them claimed that they either use
Python 3 already, or can switch really easily.


From the survey and description below, 'using Python 3' means having 
Python 3 installed, not writing Python 3 code.  Correct?


I must admit that I am surprised that even 7% of those who bothered to 
answer would claim that they would refuse to even install Py 3.


> The main reason for the

switch was the fact that supporting both requires a lot of extra
effort, especially because Python 2.7’s Unicode support is abysmal.


2.7 unicode bug-fixing pretty much ended a couple of years ago or so. 
Remaining bugs either have or eventually will be closed as fixed in 3.x.



Full results: 
https://getnikola.com/blog/env-survey-results-and-the-future-of-python-27.html

What is Nikola?
===

Nikola is a static site and blog generator, written in Python.
It can use Mako and Jinja2 templates, and input in many popular markup
formats, such as reStructuredText and Markdown — and can even turn
Jupyter (IPython) Notebooks into blog posts! It also supports image
galleries, and is multilingual. Nikola is flexible, and page builds
are extremely fast, courtesy of doit (which is rebuilding only what
has been changed).

Find out more at the website: https://getnikola.com/


--
Terry Jan Reedy


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


Re: Pandas Left Merge with xlsx with CSV producing null value columns in output

2015-10-01 Thread Mark Lawrence

On 01/10/2015 16:03, kbtyo wrote:

I would appreciate any feedback on the following question that I have raised 
here:

http://stackoverflow.com/questions/32889129/pandas-left-merge-with-xlsx-with-csv-producing-null-value-columns-in-output

Thank you for your feedback and support.



I was going to suggest that you ask on the pandas mailing list/google 
group, but as you've all ready done so, is there anywhere that you 
haven't asked?  Is there a subreddit for pandas you could also try just 
in case?


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: Generating a vector from successive multiplications of another vector from an initial value

2015-10-01 Thread duncan smith
On 01/10/15 21:45, Paulo da Silva wrote:
> Hi all.
> 
> What is the fastest way to do the following:
> 
> I have an initial value V and a vector vec of (financial) indexes.
> I want to generate a new vector nvec as
> 
> V, V*vec[0], V*vec[0]*vec[1], V*vec[0]*vec[1]*vec[2], ...
> 
> A numpy vectorized solution would be better.
> 
> Thanks
> 

Maybe,

http://docs.scipy.org/doc/numpy/reference/generated/numpy.cumprod.html

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


Re: Check if a given value is out of certain range

2015-10-01 Thread Chris Kaynor
On Thu, Oct 1, 2015 at 3:03 PM, Ian Kelly  wrote:
> On Thu, Oct 1, 2015 at 3:45 PM, John Gordon  wrote:
> > In <87r3le1ht3@elektro.pacujo.net> Marko Rauhamaa  
> > writes:
> >> Wouldn't
> >
> >>x < 0 or 10 < x
> >
> >> be even more visual?
> >
> > [SNIP]
> >
> > Another strike is that the code isn't consistent with itself; it puts the
> > variable on the left in the first comparison, then swaps to the right for
> > the second comparison.
>
> And on the other hand, it consistently uses the < operator rather
> than swapping to > for the second comparison.

I would argue that the former consistency is more important than the
second, mostly because my mode of thought is along the lines of:
- Do I have more than 10 apples? (x > 10) or
- Do I have fewer than 10 apples? (x < 10)
rather than
- Is 10 fewer apples than I have? (10 < x) or
- Is 10 more apples than I have? (10 > x)

Because the former set is how I think, the former set is the easier to
understand. By no means does it mean I cannot understand the later
set, but it takes more thought to parse the meaning.

If a bunch of code consistently used the second, my mind would adapt
to more easily parse it, but it would take a while to transition
between the sets, especially compared to transitioning within a set.

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


Re: Check if a given value is out of certain range

2015-10-01 Thread Mark Lawrence

On 01/10/2015 19:18, Steven D'Aprano wrote:

On Thu, 1 Oct 2015 08:31 am, Mark Lawrence wrote:


What is so "yuck" about that?  What would you do instead?  It seems like
the best solution to me.  Easy to read, fast to execute.



I have to parse those damn brackets and then figure out the inverted
logic. Give me x < 0 or x > 10 any day of the week.  When you're an old,
senile git like me, readability counts :-)


With the greatest of respect Mark, I don't believe that for a second. Your
sig line, which you have used without fail for more years than I can
remember includes the phrase "ask not what our language can do for you". If
you can understand that, I don't believe that you cannot figure out how to
go from this:

# x is within the range a to b
a <= x < = b

to this:

# x is NOT within the range a to b
not a <= x < = b

You're certainly a senile old git if you think we're falling for that
one :-)


Why do you think I never gamble at anything, it's a mug's game.



P.S. in case you missed it, you don't actually need the params, since the
precedence of not is lower than the other operators.


I confess that I did not bother to check.



Did-I-include-sufficient-smileys-ly y'rs,



Not bad.  However after the big match coming up on Saturday evening UK 
time one of us will possibly be putting up ginormous quantities of 
smileys, matched by the ginormous quantity of grimaces from the other :)


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: Only getting the first 6 lines

2015-10-01 Thread Cameron Simpson

On 01Oct2015 23:58, Cecil Westerhof  wrote:

I want to get the first 6 lines of ps output. For this I use:

from subprocess import check_output

ps_command = ('ps', '-eo', 'user,pid,pcpu,pmem,stat,start,time,cmd', '--sort')
message = '\n'.join(check_output(ps_command + 
('-%cpu',)).decode("utf-8").splitlines()[0:6])


It works, but does not look very efficient. Is there a better way to
do this?


It depends what you mean by inefficient. I'm presuming you mean that this:

 - sucks in all the output of ps instead of just the first 6 lines

 - sucks all the output into memory instead of just some of it

 - does more in-memory work in splitlines()

 - needs ps to run to completion instead of just long enough to print 6 lines

You could just read six lines of output from ps. Something like this 
(untested):



 lines = []
 for lineno, line in \
   enumerate(Popen(ps_command + ('-%cpu',),
   stdin=NULL, stdout=PIPE).stdout,
 1):
   lines.append(line.decode("utf-8"))
   if lineno >= 6:
 break

This works because in a miracle of foresight you can split binary data streams 
(the stdout) on line breaks, so you can fetch "binary" lines and decode them 
individually.


This approach is important if the output of your command is large or slow, as 
it does not need to suck the whole thing into memory or to wait for it to 
finish a long procedure. With "ps" these issues are pretty minor; with some 
other programs it can be significant, especially if the other program _doesn't_ 
terminate (consider "tail -f" of an active log file).


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


Re: Only getting the first 6 lines

2015-10-01 Thread Ian Kelly
On Thu, Oct 1, 2015 at 3:58 PM, Cecil Westerhof  wrote:
> I want to get the first 6 lines of ps output. For this I use:
> 
> from subprocess import check_output
>
> ps_command = ('ps', '-eo', 'user,pid,pcpu,pmem,stat,start,time,cmd', '--sort')
> message = '\n'.join(check_output(ps_command + 
> ('-%cpu',)).decode("utf-8").splitlines()[0:6])
> 
>
> It works, but does not look very efficient. Is there a better way to
> do this?

Instead of using check_output which reads the entire output, you could
create a Popen with stdin=None, stdout=PIPE, stderr=None, and then
read just the first six lines. Don't forget to clean up the subprocess
afterward.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: ConnectionError handling problem

2015-10-01 Thread Cameron Simpson

On 30Sep2015 23:56, Laura Creighton  wrote:

In a message of Thu, 01 Oct 2015 07:30:59 +1000, Cameron Simpson writes:

Most likely the Ctrl-C interrupts whatever system call is hanging, causing it
to return (failed, probably with errno EINTR). And the python program resumes
because the OS system call has returned.


Shiva Upreti needs to post the current code, but last time I read it
the problem was that control-C is a KeyboardInterrupt, which the
program was catching, and then continuing the loop.


Indeed.

Cheers,
Cameron Simpson 

C makes it easy for you to shoot yourself in the foot.  C++ makes that
harder, but when you do, it blows away your whole leg.
- Bjarne Stroustrup
--
https://mail.python.org/mailman/listinfo/python-list


Re: Generating a vector from successive multiplications of another vector from an initial value

2015-10-01 Thread Oscar Benjamin
On Thu, 1 Oct 2015 21:51 Paulo da Silva 
wrote:

Hi all.

What is the fastest way to do the following:

I have an initial value V and a vector vec of (financial) indexes.
I want to generate a new vector nvec as

V, V*vec[0], V*vec[0]*vec[1], V*vec[0]*vec[1]*vec[2], ...

A numpy vectorized solution would be better.



V * np.cumprod(vec)

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


Re: Check if a given value is out of certain range

2015-10-01 Thread Ian Kelly
On Thu, Oct 1, 2015 at 3:45 PM, John Gordon  wrote:
> In <87r3le1ht3@elektro.pacujo.net> Marko Rauhamaa  
> writes:
>> Wouldn't
>
>>x < 0 or 10 < x
>
>> be even more visual?
>
> [SNIP]
>
> Another strike is that the code isn't consistent with itself; it puts the
> variable on the left in the first comparison, then swaps to the right for
> the second comparison.

And on the other hand, it consistently uses the < operator rather
than swapping to > for the second comparison.
-- 
https://mail.python.org/mailman/listinfo/python-list


Only getting the first 6 lines

2015-10-01 Thread Cecil Westerhof
I want to get the first 6 lines of ps output. For this I use:

from subprocess import check_output

ps_command = ('ps', '-eo', 'user,pid,pcpu,pmem,stat,start,time,cmd', '--sort')
message = '\n'.join(check_output(ps_command + 
('-%cpu',)).decode("utf-8").splitlines()[0:6])


It works, but does not look very efficient. Is there a better way to
do this?

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question about regular expression

2015-10-01 Thread gal kauffman
On Oct 2, 2015 12:35 AM, "Denis McMahon"  wrote:
>
> On Thu, 01 Oct 2015 01:48:03 -0700, gal kauffman wrote:
>
> > items = s.replace(' (', '(').replace(', ',',').split()
> >
> > items_dict = dict()
> > for item in items:
> > if '(' not in item:
> > item += '(0,0)'
> > if ',' not in item:
> > item = item.replace(')', ',0)')
> >
> > name, raw_data = item.split('(') data_tuple = tuple((int(v) for v in
> > raw_data.replace(')','').split(',')))
> >
> > items_dict[name] = data_tuple
>
> Please don't top post.
Sorry  :(
>
> What happens if there's more whitespace than you allow for preceding a
> '(' or following a ',', or if there's whitespace following '('?
My code won't work. Even worse then that, it will return a dict as if
everything is OK, but the dict will have weird keys and values.
But I didn't try to make it work for every possible input. It works for the
conventions defined.

If I wanted to accept a wider range of values, I would write another
program that applies the conventions on the input, and chain it with the
current code.
>
> --
> Denis McMahon, denismfmcma...@gmail.com
> --
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Check if a given value is out of certain range

2015-10-01 Thread John Gordon
In <87r3le1ht3@elektro.pacujo.net> Marko Rauhamaa  writes:

> > I wasn't commenting directly to the "ask not..." quote; I was
> > referring upthread to the choice between
> >
> > not 0 <= x <= 10
> >
> > and
> >
> > x < 0 or x > 10
> >
> > Both are of course understandable, but in my opinion, the latter one
> > takes slightly less effort to grok.

> Wouldn't

>x < 0 or 10 < x

> be even more visual?

I don't know what you mean by "more visual".

In my opinion, when comparing a variable to a constant, it's more natural
to have the variable on the left and the constant on the right, so that's
one strike against this code.

Another strike is that the code isn't consistent with itself; it puts the
variable on the left in the first comparison, then swaps to the right for
the second comparison.

-- 
John Gordon   A is for Amy, who fell down the stairs
gor...@panix.com  B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"

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


Re: Question about regular expression

2015-10-01 Thread Denis McMahon
On Thu, 01 Oct 2015 15:53:38 +, Rob Gaddi wrote:

> There's a quote for this.  'Some people, when confronted with a problem,
> think “I know, I'll use regular expressions.”  Now they have two
> problems.'

I actually used 2 regexes:

wordpatt = re.compile('[a-zA-Z]+')

numpatt = re.compile('[0-9]+')

replace all '(', ',' and ')' in the string with spaces

split the string on space

create an empty dict d

process each thing in the split list setting d[word]=[0,0] for each word 
element (wordpatt.match(thing)) (a list because I want to be able to 
modify it)

setting d[word][n] = int(num) for each num element (numpatt.match(thing)) 
with n depending on whether it was the first or second num following the 
previous word

then:

d = {x:tuple(d[x]) for x in d}

to convert the lists in the new dic to tuples

-- 
Denis McMahon, denismfmcma...@gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question about regular expression

2015-10-01 Thread Denis McMahon
On Thu, 01 Oct 2015 01:48:03 -0700, gal kauffman wrote:

> items = s.replace(' (', '(').replace(', ',',').split()
> 
> items_dict = dict()
> for item in items:
> if '(' not in item:
> item += '(0,0)'
> if ',' not in item:
> item = item.replace(')', ',0)')
> 
> name, raw_data = item.split('(') data_tuple = tuple((int(v) for v in
> raw_data.replace(')','').split(',')))
> 
> items_dict[name] = data_tuple

Please don't top post.

What happens if there's more whitespace than you allow for preceding a 
'(' or following a ',', or if there's whitespace following '('?

-- 
Denis McMahon, denismfmcma...@gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Generating a vector from successive multiplications of another vector from an initial value

2015-10-01 Thread Ian Kelly
On Thu, Oct 1, 2015 at 2:45 PM, Paulo da Silva
 wrote:
> Hi all.
>
> What is the fastest way to do the following:
>
> I have an initial value V and a vector vec of (financial) indexes.
> I want to generate a new vector nvec as
>
> V, V*vec[0], V*vec[0]*vec[1], V*vec[0]*vec[1]*vec[2], ...
>
> A numpy vectorized solution would be better.

That looks hard to vectorize since each calculation depends on the
previous. You might be stuck with something like:

result = [V]
for x in vec:
result.append(result[-1] * x)
-- 
https://mail.python.org/mailman/listinfo/python-list


Generating a vector from successive multiplications of another vector from an initial value

2015-10-01 Thread Paulo da Silva
Hi all.

What is the fastest way to do the following:

I have an initial value V and a vector vec of (financial) indexes.
I want to generate a new vector nvec as

V, V*vec[0], V*vec[0]*vec[1], V*vec[0]*vec[1]*vec[2], ...

A numpy vectorized solution would be better.

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


Re: Check if a given value is out of certain range

2015-10-01 Thread Emile van Sebille

On 10/1/2015 12:59 PM, Marko Rauhamaa wrote:

John Gordon :


I wasn't commenting directly to the "ask not..." quote; I was
referring upthread to the choice between

 not 0 <= x <= 10

and

 x < 0 or x > 10

Both are of course understandable, but in my opinion, the latter one
takes slightly less effort to grok.


Wouldn't

x < 0 or 10 < x

be even more visual?


Well, I had to parse that one twice to grok it.

Emile



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


Re: matplotlib timer

2015-10-01 Thread Laura Creighton
In a message of Thu, 01 Oct 2015 20:47:10 +0100, Dave Farrance writes:
>Laura Creighton  wrote:
>
>>In a message of Thu, 01 Oct 2015 20:03:26 +0100, Dave Farrance writes:
>>>Laura Creighton  wrote:
>>>
In a message of Thu, 01 Oct 2015 18:45:06 +0100, Dave Farrance writes:
>Yet the documentation says that it's mandatory for the GUI backend base
>to implement stop() but that single_shot is optional. Ho hum.

report as a bug.  its a doc bug at least, but I think its a real bug,
and your code should have worked.

https://github.com/matplotlib/matplotlib/issues
>>>
>>>OK, done.
>>>
>>
>>Thank you.
>>
>>Can you add how you got it to work, and the doc you read
>>that seems wrong?
>
>OK.

You, sir, are a champion.

Thank you again.

Laura

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


Re: Check if a given value is out of certain range

2015-10-01 Thread Marko Rauhamaa
John Gordon :

> I wasn't commenting directly to the "ask not..." quote; I was
> referring upthread to the choice between
>
> not 0 <= x <= 10
>
> and
>
> x < 0 or x > 10
>
> Both are of course understandable, but in my opinion, the latter one
> takes slightly less effort to grok.

Wouldn't

   x < 0 or 10 < x

be even more visual?


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


Re: matplotlib timer

2015-10-01 Thread Dave Farrance
Laura Creighton  wrote:

>In a message of Thu, 01 Oct 2015 20:03:26 +0100, Dave Farrance writes:
>>Laura Creighton  wrote:
>>
>>>In a message of Thu, 01 Oct 2015 18:45:06 +0100, Dave Farrance writes:
Yet the documentation says that it's mandatory for the GUI backend base
to implement stop() but that single_shot is optional. Ho hum.
>>>
>>>report as a bug.  its a doc bug at least, but I think its a real bug,
>>>and your code should have worked.
>>>
>>>https://github.com/matplotlib/matplotlib/issues
>>
>>OK, done.
>>
>
>Thank you.
>
>Can you add how you got it to work, and the doc you read
>that seems wrong?

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


Re: Check if a given value is out of certain range

2015-10-01 Thread John Gordon
In <560d8726$0$1602$c3e8da3$54964...@news.astraweb.com> Steven D'Aprano 
 writes:

> > But it takes ever-so-slightly more effort to do so.

> Slightly more effort than what alternative? How would you communicate the
> idea of *not* asking for X without using the concept of "not"?

I wasn't commenting directly to the "ask not..." quote; I was referring
upthread to the choice between

not 0 <= x <= 10

and

x < 0 or x > 10

Both are of course understandable, but in my opinion, the latter one takes
slightly less effort to grok.

-- 
John Gordon   A is for Amy, who fell down the stairs
gor...@panix.com  B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"

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


Re: Check if a given value is out of certain range

2015-10-01 Thread Steven D'Aprano
On Fri, 2 Oct 2015 04:20 am, John Gordon wrote:

> In <560d78e2$0$1618$c3e8da3$54964...@news.astraweb.com> Steven D'Aprano
>  writes:
> 
>> > I have to parse those damn brackets and then figure out the inverted
>> > logic. Give me x < 0 or x > 10 any day of the week.  When you're an
>> > old, senile git like me, readability counts :-)
> 
>> With the greatest of respect Mark, I don't believe that for a second.
>> Your sig line, which you have used without fail for more years than I can
>> remember includes the phrase "ask not what our language can do for you".
>> If you can understand that, I don't believe that you cannot figure out
>> how to
> 
> Certainly we can understand it.

Unless every single one of you (the "we" you refer to) are called Mark, I
don't believe I was talking to you :-P


> But it takes ever-so-slightly more effort 
> to do so.

Slightly more effort than what alternative? How would you communicate the
idea of *not* asking for X without using the concept of "not"?



-- 
Steven

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


Re: matplotlib timer

2015-10-01 Thread Laura Creighton
In a message of Thu, 01 Oct 2015 20:03:26 +0100, Dave Farrance writes:
>Laura Creighton  wrote:
>
>>In a message of Thu, 01 Oct 2015 18:45:06 +0100, Dave Farrance writes:
>>>Yet the documentation says that it's mandatory for the GUI backend base
>>>to implement stop() but that single_shot is optional. Ho hum.
>>
>>report as a bug.  its a doc bug at least, but I think its a real bug,
>>and your code should have worked.
>>
>>https://github.com/matplotlib/matplotlib/issues
>
>OK, done.
>

Thank you.

Can you add how you got it to work, and the doc you read
that seems wrong?

Laura

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


Re: Create a .lua fle from Python

2015-10-01 Thread Steven D'Aprano
On Wed, 30 Sep 2015 07:21 pm, jmp wrote:

>> Is Ariel's xml file user-supplied? If so, how does your suggestion
>> prevent the resulting lua script from executing arbitrary code?
> 
> It does not. Like it doesn't fulfill the millions of possible
> requirements the OP could have written but did not. What if the OP want
> a thread safe, super fast, multi core solution distributed on multiple
> remote hosts ?

Then he should have said so.

We are not *required* to guess every last requirement that somebody might
have but didn't mention. But we do have a professional[1] duty of care to
warn an *obvious beginner* that he may be introducing a serious security
vulnerability into his code.




[1] In the sense of a job well done, not in the sense of "I got paid money
to write this shit". Think master craftsman, not interchangeable code
monkey.


-- 
Steven

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


Re: matplotlib timer

2015-10-01 Thread Dave Farrance
Laura Creighton  wrote:

>In a message of Thu, 01 Oct 2015 18:45:06 +0100, Dave Farrance writes:
>>Yet the documentation says that it's mandatory for the GUI backend base
>>to implement stop() but that single_shot is optional. Ho hum.
>
>report as a bug.  its a doc bug at least, but I think its a real bug,
>and your code should have worked.
>
>https://github.com/matplotlib/matplotlib/issues

OK, done.

https://github.com/matplotlib/matplotlib/issues/5163
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Check if a given value is out of certain range

2015-10-01 Thread Steven D'Aprano
On Thu, 1 Oct 2015 06:46 am, Ian Kelly wrote:

> On Wed, Sep 30, 2015 at 2:19 PM, alister
>  wrote:

[...]
>> the problem with 1 is the human brain is not particularity good with
>> negatives*.
>> to do not (some function) you first of all have to work out some function
>> & then invert it, a computer does this without difficulty the human brain
>> gets confused which is why I personally consider ii is  more readable
>> (YMMV especially if you are working with Boolean maths regularly) this
>> example is relatively simple as things get more complex they become more
>> error prone error.

In other words, "more complex things are more error prone". Well, sure. That
doesn't tell us much about simple things though.

You are right that there are certain constructs which, when written in terms
of negatives, are harder for people to parse and understand than if written
in more straight-forward positive forms. But others are simpler when
written in the negative:

"No entry to under 18s" versus "Entry to over 18s only"


Ian:
> To me, the negative of one condition (is x in this range) is more
> easily processable than the disjunction of two conditions that
> together compose the real, more easily understood condition (is x
> outside this range). I find it preferable to avoid nested conditions,
> not negated conditions, and (II) has more nesting than (I).
> 
> Thought mirrors language. In English, we typically would say "x is not
> between 0 and 10", not "x is either less than 0 or greater than 10".

I agree with Ian here.


>> *as an example you brain cannot correctly process the following.
>>
>> Not (think of your left toe)
>>
>> you are now thinking about it aren't you?

Actually I'm not, I'm too busy trying to think of a witty reply :-)


> No, it made me think about thinking. I barely even registered the
> phrase "left toe", much less thought about that.

It's a nice trick, but that's all it is -- it's a trick. The problem isn't
that we can't parse and understand the "not", but that few people have
either the mental discipline or the short attention span to not think about
about something once the thought is planted in the mind.

The classic formulation of this idea is the instruction:

Don't think of an elephant!

Sometimes people will use rhinoceros instead.

The more you try to think about *not* thinking of an elephant, the more the
idea of one comes to your consciousness. It takes great discipline, or a
level of flightiness and empty-headedness that is rare even in the post-MTV
and Twitter generation, to consciously think about something else without
going back to the elephant.

Of course, there is a loop-hole. There is always a loop-hole.[1]

In one of Terry Pratchett's Discworld novels, a young witch mentions the
phrase "Don't think of a rhinoceros", and states that it is impossible to
not think of a rhinoceros. The elderly and curmudgeonly, but extremely
powerful, witch Granny Weatherwax confidently dismisses this, and says that
it doesn't work on her, she's not thinking of a rhinoceros. Such is
Granny's reputation for strength of will, and a self-confidence that you
could bend horseshoes on, that her claim is accepted without question.

It's not until quite late in the book that her secret is revealed. Being an
rural witch who has never really travelled much and doesn't hold with book
learning, she has no idea what a rhinoceros is.


> In any case, that's more an issue of being unable to control what
> you're thinking about. If I instruct you, "don't raise your right
> hand", do you then automatically raise your right hand?

I could be wrong, but I seem to recall reading that this is *exactly* what
happens -- the muscles used to raise the right arm trigger
ever-so-slightly. You don't even notice it, but sensitive electrodes can
detect the change in electrical potential in the muscles.




[1] Except when there isn't.



-- 
Steven

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


Re: Check if a given value is out of certain range

2015-10-01 Thread John Gordon
In <560d78e2$0$1618$c3e8da3$54964...@news.astraweb.com> Steven D'Aprano 
 writes:

> > I have to parse those damn brackets and then figure out the inverted
> > logic. Give me x < 0 or x > 10 any day of the week.  When you're an old,
> > senile git like me, readability counts :-)

> With the greatest of respect Mark, I don't believe that for a second. Your
> sig line, which you have used without fail for more years than I can
> remember includes the phrase "ask not what our language can do for you". If
> you can understand that, I don't believe that you cannot figure out how to

Certainly we can understand it.  But it takes ever-so-slightly more effort
to do so.

-- 
John Gordon   A is for Amy, who fell down the stairs
gor...@panix.com  B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"

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


Re: Check if a given value is out of certain range

2015-10-01 Thread Steven D'Aprano
On Thu, 1 Oct 2015 08:31 am, Mark Lawrence wrote:

>> What is so "yuck" about that?  What would you do instead?  It seems like
>> the best solution to me.  Easy to read, fast to execute.
>>
> 
> I have to parse those damn brackets and then figure out the inverted
> logic. Give me x < 0 or x > 10 any day of the week.  When you're an old,
> senile git like me, readability counts :-)

With the greatest of respect Mark, I don't believe that for a second. Your
sig line, which you have used without fail for more years than I can
remember includes the phrase "ask not what our language can do for you". If
you can understand that, I don't believe that you cannot figure out how to
go from this:

# x is within the range a to b
a <= x < = b

to this:

# x is NOT within the range a to b
not a <= x < = b


You're certainly a senile old git if you think we're falling for that
one :-)



P.S. in case you missed it, you don't actually need the params, since the
precedence of not is lower than the other operators.



Did-I-include-sufficient-smileys-ly y'rs,


-- 
Steven

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


Re: matplotlib timer

2015-10-01 Thread Laura Creighton
In a message of Thu, 01 Oct 2015 18:45:06 +0100, Dave Farrance writes:
>Yet the documentation says that it's mandatory for the GUI backend base
>to implement stop() but that single_shot is optional. Ho hum.

report as a bug.  its a doc bug at least, but I think its a real bug,
and your code should have worked.

https://github.com/matplotlib/matplotlib/issues

Laura

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


Re: matplotlib timer

2015-10-01 Thread Dave Farrance
Laura Creighton  wrote:

>In a message of Thu, 01 Oct 2015 17:36:50 +0100, Dave Farrance writes:
>>I'm trying to set up the basics of a timer-scheduled function in
>>matplotlib and I can't figure out how to stop the timer. Maybe the
>>stop() method is dysfunctional in Ubuntu 14.04 or maybe I'm getting the
>>syntax wrong.
>>
>>If anybody's got matplotlib installed, can you try this code and tell me
>>if it stops after one tick as it should -- or does it continue printing
>>every second without stopping as mine does?
>>
>>#!/usr/bin/env python
>>import matplotlib.pyplot as P
>>def fn():
>>  timer.stop()
>>  print("tick")
>>fig, ax = P.subplots()
>>timer = fig.canvas.new_timer(interval=1000)
>>timer.add_callback(fn)
>>timer.start()
>>P.show()
>> 
>
>debian unstable
>Python 3.4.3+ (default, Jul 28 2015, 13:17:50)
>
>mine ticks forever, too.

Thanks. I've just figured out how to stop the timer.

replace "timer.stop()" with
timer.single_shot = True

Yet the documentation says that it's mandatory for the GUI backend base
to implement stop() but that single_shot is optional. Ho hum.

http://matplotlib.org/api/backend_bases_api.html#matplotlib.backend_bases.TimerBase
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: The Nikola project is deprecating Python 2.7 (+2.x/3.x user survey results)

2015-10-01 Thread Laura Creighton
In a message of Thu, 01 Oct 2015 10:43:58 -0600, paul.hermeneu...@gmail.com wri
tes:
>Python 3 has venv in the kit. Is there a reason users should get the
>virtualenv add-on?

Yes.  It is known to work.
Debian packager doko (Matthias Klose) thinks that venv is not debian
compatible. Thus when you try to use it, on a debian system, it doesn't
work unless you have installed Barry Warsaw's package fix, because you
don't have an ensure-pip.

This should only affect debian and their downstream, though not
ubuntu as Barry fixed things.  See my bug report, here, after a
frustrating morning trying to see why venv didn't work -- 'debian
broke my python' was not the first tree I climbed in trying to
understand this.

https://bugs.python.org/issue25151

Actually, search there for venv and pyenv and read all about it.
... pyenv is going away, use python -m instead ...

So unless you want to help your debian users get a working venv,
I would stick with telling everybody to use virtualenv for now.

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


Re: matplotlib timer

2015-10-01 Thread Laura Creighton
In a message of Thu, 01 Oct 2015 17:36:50 +0100, Dave Farrance writes:
>I'm trying to set up the basics of a timer-scheduled function in
>matplotlib and I can't figure out how to stop the timer. Maybe the
>stop() method is dysfunctional in Ubuntu 14.04 or maybe I'm getting the
>syntax wrong.
>
>If anybody's got matplotlib installed, can you try this code and tell me
>if it stops after one tick as it should -- or does it continue printing
>every second without stopping as mine does?
>
>#!/usr/bin/env python
>import matplotlib.pyplot as P
>def fn():
>  timer.stop()
>  print("tick")
>fig, ax = P.subplots()
>timer = fig.canvas.new_timer(interval=1000)
>timer.add_callback(fn)
>timer.start()
>P.show()
> 

debian unstable
Python 3.4.3+ (default, Jul 28 2015, 13:17:50)

mine ticks forever, too.

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


Re: The Nikola project is deprecating Python 2.7 (+2.x/3.x user survey results)

2015-10-01 Thread Chris Warrick
On 1 October 2015 at 18:43,   wrote:
> Python 3 has venv in the kit. Is there a reason users should get the
> virtualenv add-on?

Both can be used; I wrote about virtualenv because it’s the
tried-and-true solution (and is it guaranteed in all Linux distros
anyway?)

On 1 October 2015 at 19:02, Stefan Behnel  wrote:
> Chris Warrick schrieb am 01.10.2015 um 18:26:
>> The Nikola developers decided to deprecate Python 2.7 support.
>
> I wonder why it took the Nikola project so long to take that decision.
> Python 3.3 came out almost exactly three(!) years ago and seems to have all
> major features that they would require. Nikola's PyPI page claims support
> of Python 3.3 for just about as long, since version 5.4 or so, which means
> that all of their dependencies were already available back then.
>
> It's a different thing for *libraries* that Python 2.x users still depend
> on, but for an *application* that has all its (necessary) dependencies
> available in Python 3.x, I can't see a general reason to keep supporting
> both language versions.
>
> Stefan

We did it now because it all started with frustration with 2.7 [0].
Also, doing it back in 2012/2013 would be problematic, because back
then not all Linux distros had an easily installable Python 3 stack
(and RHEL 7 still doesn’t have one in the default repos)

[0]: http://ralsina.me/weblog/posts/floss-decision-making-in-action.html

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


Re: The Nikola project is deprecating Python 2.7 (+2.x/3.x user survey results)

2015-10-01 Thread Stefan Behnel
Chris Warrick schrieb am 01.10.2015 um 18:26:
> The Nikola developers decided to deprecate Python 2.7 support.

I wonder why it took the Nikola project so long to take that decision.
Python 3.3 came out almost exactly three(!) years ago and seems to have all
major features that they would require. Nikola's PyPI page claims support
of Python 3.3 for just about as long, since version 5.4 or so, which means
that all of their dependencies were already available back then.

It's a different thing for *libraries* that Python 2.x users still depend
on, but for an *application* that has all its (necessary) dependencies
available in Python 3.x, I can't see a general reason to keep supporting
both language versions.

Stefan


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


Re: The Nikola project is deprecating Python 2.7 (+2.x/3.x user survey results)

2015-10-01 Thread paul.hermeneutic
Python 3 has venv in the kit. Is there a reason users should get the
virtualenv add-on?
On Oct 1, 2015 10:28 AM, "Chris Warrick"  wrote:

> The Nikola developers decided to deprecate Python 2.7 support.
> Starting with v7.7.2, Nikola will display a warning if Python 2.7 is
> used (but it will still be fully supported). In early 2016, Nikola
> v8.0.0 will come out, and that release will not support Python 2.7
> officially.
>
> The decision was made on the basis of a user survey, with 138
> participants. The vast majority of them claimed that they either use
> Python 3 already, or can switch really easily. The main reason for the
> switch was the fact that supporting both requires a lot of extra
> effort, especially because Python 2.7’s Unicode support is abysmal.
>
> Full results:
> https://getnikola.com/blog/env-survey-results-and-the-future-of-python-27.html
>
> What is Nikola?
> ===
>
> Nikola is a static site and blog generator, written in Python.
> It can use Mako and Jinja2 templates, and input in many popular markup
> formats, such as reStructuredText and Markdown — and can even turn
> Jupyter (IPython) Notebooks into blog posts! It also supports image
> galleries, and is multilingual. Nikola is flexible, and page builds
> are extremely fast, courtesy of doit (which is rebuilding only what
> has been changed).
>
> Find out more at the website: https://getnikola.com/
>
> --
> Chris Warrick 
> PGP: 5EAAEA16
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


matplotlib timer

2015-10-01 Thread Dave Farrance
I'm trying to set up the basics of a timer-scheduled function in
matplotlib and I can't figure out how to stop the timer. Maybe the
stop() method is dysfunctional in Ubuntu 14.04 or maybe I'm getting the
syntax wrong.

If anybody's got matplotlib installed, can you try this code and tell me
if it stops after one tick as it should -- or does it continue printing
every second without stopping as mine does?

#!/usr/bin/env python
import matplotlib.pyplot as P
def fn():
  timer.stop()
  print("tick")
fig, ax = P.subplots()
timer = fig.canvas.new_timer(interval=1000)
timer.add_callback(fn)
timer.start()
P.show()
 
-- 
https://mail.python.org/mailman/listinfo/python-list


The Nikola project is deprecating Python 2.7 (+2.x/3.x user survey results)

2015-10-01 Thread Chris Warrick
The Nikola developers decided to deprecate Python 2.7 support.
Starting with v7.7.2, Nikola will display a warning if Python 2.7 is
used (but it will still be fully supported). In early 2016, Nikola
v8.0.0 will come out, and that release will not support Python 2.7
officially.

The decision was made on the basis of a user survey, with 138
participants. The vast majority of them claimed that they either use
Python 3 already, or can switch really easily. The main reason for the
switch was the fact that supporting both requires a lot of extra
effort, especially because Python 2.7’s Unicode support is abysmal.

Full results: 
https://getnikola.com/blog/env-survey-results-and-the-future-of-python-27.html

What is Nikola?
===

Nikola is a static site and blog generator, written in Python.
It can use Mako and Jinja2 templates, and input in many popular markup
formats, such as reStructuredText and Markdown — and can even turn
Jupyter (IPython) Notebooks into blog posts! It also supports image
galleries, and is multilingual. Nikola is flexible, and page builds
are extremely fast, courtesy of doit (which is rebuilding only what
has been changed).

Find out more at the website: https://getnikola.com/

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


Re: PySide window does not resize to fit screen

2015-10-01 Thread Laura Creighton
In a message of Thu, 01 Oct 2015 06:44:25 -0700, Hedieh Ebrahimi writes:
>Dear all, 
>
>I am using Pyside to create a user interface for my app. 
>The app works fine on my computer with big screen, but when I take it to my 
>laptop with smaller screen size, it does not resize to match the screen size. 
>
>How can I make my main widget get some information about the screen size and 
>resize automatically? 
>
>Thanks in Advance for your answers.

screenGeometry = QApplication.instance().desktop().screenGeometry()
to find out your desktop size in pixels.
availGeometry = QApplication.instance().desktop().availableGeometry()
is the same thing minus the space for the task bar, so maybe more
useful.

width, height = availGeometry.width(), availGeometry.height()

Finding out what pyside thinks the size is can be useful for debugging
problems, but this stuff should already be happening automatically.  There is
something not quite right with your layout, and brutally resizing things
by hand is treating the symptom, not the cause.

Laura

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


Re: Question about regular expression

2015-10-01 Thread Rob Gaddi
On Wed, 30 Sep 2015 11:34:04 -0700, massi_srb wrote:

> Hi everyone,
> 
> firstly the description of my problem. I have a string in the following
> form:
> 
> s = "name1 name2(1) name3 name4 (1, 4) name5(2) ..."
> 
> that is a string made up of groups in the form 'name' (letters only)
> plus possibly a tuple containing 1 or 2 integer values. Blanks can be
> placed between names and tuples or not, but they surely are placed
> beween two groups. I would like to process this string in order to get a
> dictionary like this:
> 
> d = {
> "name1":(0, 0),
> "name2":(1, 0),
> "name3":(0, 0),
> "name4":(1, 4),
> "name5":(2, 0),
> }
> 
> I guess this problem can be tackled with regular expressions, but I have
> no idea bout how to use them in this case (I'm not a regexp guy). Can
> anyone give me a hint? any possible different approach is absolutely
> welcome.
> 
> Thanks in advance!

There's a quote for this.  'Some people, when confronted with a problem, 
think “I know, I'll use regular expressions.”  Now they have two 
problems.'  

That one's not always true, but any time you're debating a regex solution 
it should at least come to mind.  Lots of people have posted lots of pure 
Python solutions.  I will simply comment that using any of them will make 
you fundamentally happier as time goes on than trying to shoehorn a regex 
in.

-- 
Rob Gaddi, Highland Technology -- www.highlandtechnology.com
Email address domain is currently out of order.  See above to fix.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PySide window does not resize to fit screen

2015-10-01 Thread Chris Warrick
On 1 October 2015 at 15:44, Hedieh Ebrahimi  wrote:
> Dear all,
>
> I am using Pyside to create a user interface for my app.
> The app works fine on my computer with big screen, but when I take it to my 
> laptop with smaller screen size, it does not resize to match the screen size.
>
> How can I make my main widget get some information about the screen size and 
> resize automatically?
>
> Thanks in Advance for your answers.
> --
> https://mail.python.org/mailman/listinfo/python-list

The correct way to do this is to lay your application out using a
layout.  The available layouts are:

* QHBoxLayout
* QVBoxLayout
* QGridLayout
* QFormLayout

The exact layout to use depends on your needs.

What are you using to create your Qt code? Are you using Qt Designer
or are you writing the code by hand?  If you are using Qt Designer,
use the “Lay Out…” buttons in the Form menu or on the tool bar.  If
you are writing Qt code by hand, it looks roughly like this (for a
VBox; Grid and Form are more complicated as they involve positioning):

lay = QtGui.QVBoxLayout(self)  # your central widget, dialog, main
window — whichever one exists
btn = QtGui.QButton("Hello", lay)
lay.addWidget(btn)

Please check with Qt documentation for more details

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


Pandas Left Merge with xlsx with CSV producing null value columns in output

2015-10-01 Thread kbtyo
I would appreciate any feedback on the following question that I have raised 
here:

http://stackoverflow.com/questions/32889129/pandas-left-merge-with-xlsx-with-csv-producing-null-value-columns-in-output

Thank you for your feedback and support. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Check if a given value is out of certain range

2015-10-01 Thread Ian Kelly
On Thu, Oct 1, 2015 at 2:33 AM, alister
 wrote:
> Why is it that the Phrase "Don't Panic" is strongly discouraged in
> emergency situations?
>
> answer because the brain parses the statement as follows and focuses on
> Panic instead of calm.
>
> Don't : I must not do somthing what must i not do
> Panic:  what is there to panic about?
> Holly shit the buildings onfire, Raise Panic
>
>
> The recommended phase is Stay calm
>
> Stay:   ok dont change anything, whats next
> Calm
> ok I am calm that's alright then
>
>
> I may not have raised my right hand but I though about it (& decided no
> thanks)

Again though this is not due to any failure in processing the "not",
but because the phrase "don't panic" suggests that there may be reason
to panic, which leads to panic (assuming for the sake of argument that
this phenomenon is real and not just anecdotal).
-- 
https://mail.python.org/mailman/listinfo/python-list


ANN: eGenix PyRun - One file Python Runtime 2.1.1

2015-10-01 Thread eGenix Team: M.-A. Lemburg


ANNOUNCING

 eGenix PyRun - One file Python Runtime

Version 2.1.1


 An easy-to-use single file relocatable Python run-time -
   available for Linux, Mac OS X and Unix platforms,
 with support for Python 2.6, 2.7 and
 **now also for Python 3.4**.


This announcement is also available on our web-site for online reading:
http://www.egenix.com/company/news/eGenix-PyRun-2.1.1-GA.html



INTRODUCTION

eGenix PyRun is our open source, one file, no installation version of
Python, making the distribution of a Python interpreter to run based
scripts and applications to Unix based systems as simple as copying a
single file.

eGenix PyRun's executable only needs 11MB for Python 2 and 13MB for
Python 3, but still supports most Python application and scripts - and
it can be compressed to just 3-4MB using upx, if needed.

Compared to a regular Python installation of typically 100MB on disk,
eGenix PyRun is ideal for applications and scripts that need to be
distributed to several target machines, client installations or
customers.

It makes "installing" Python on a Unix based system as simple as
copying a single file.

eGenix has been using eGenix PyRun internally in the mxODBC Connect
Server product since 2008 with great success and decided to make it
available as a stand-alone open-source product.

We provide both the source archive to build your own eGenix PyRun, as
well as pre-compiled binaries for Linux, FreeBSD and Mac OS X, as 32-
and 64-bit versions. The binaries can be downloaded manually, or you
can let our automatic install script install-pyrun take care of the
installation: ./install-pyrun dir and you're done.

Please see the product page for more details:

http://www.egenix.com/products/python/PyRun/



NEWS

This patch level release of eGenix PyRun 2.1 comes with the following
enhancements:

Enhancements / Changes
--

 * Upgraded eGenix PyRun to work with and use Python 2.7.10 per
   default.

 * eGenix PyRun will now adjust sys.base_prefix and
   sys.base_exec_prefix in the same way it does for sys.prefix and
   sys.exec_prefix. This is needed for Python 3.4 in order to have
   distutils find the Python.h include file when compiling C
   extensions.

 * PyRun for Python 3.4 will now show the correct file name of scripts
   in tracebacks when running them directly, instead of just
   ''.

 * The new internal _sysconfigdata module used by the sysconfig module
   is now patched with the eGenix PyRun config data as well, to make
   sure that PyRun doesn't ship with two sets of build config
   variables.

install-pyrun Quick Install Enhancements
-

eGenix PyRun includes a shell script called install-pyrun, which
greatly simplifies installation of PyRun. It works much like the
virtualenv shell script used for creating new virtual environments
(except that there's nothing virtual about PyRun environments).

https://downloads.egenix.com/python/install-pyrun

With the script, an eGenix PyRun installation is as simple as running:

./install-pyrun targetdir

This will automatically detect the platform, download and install the
right pyrun version into targetdir.

We have updated this script since the last release:

 * Updated install-pyrun to default to eGenix PyRun 2.1.1 and its
   feature set.

For a complete list of changes, please see the eGenix PyRun Changelog:

http://www.egenix.com/products/python/PyRun/changelog.html



LICENSE

eGenix PyRun is distributed under the eGenix.com Public License 1.1.0
which is an Open Source license similar to the Python license. You can
use eGenix PyRun in both commercial and non-commercial settings
without fee or charge.

Please see our license page for more details:

http://www.egenix.com/products/python/PyRun/license.html

The package comes with full source code.



DOWNLOADS

The download archives and instructions for installing eGenix PyRun can
be found at:

http://www.egenix.com/products/python/PyRun/

As always, we are providing pre-built binaries for all common
platforms: Windows 32/64-bit, Linux 32/64-bit, FreeBSD 32/64-bit, Mac
OS X 32/64-bit. Source code archives are available for installation on
other platforms, such as Solaris, AIX, HP-UX, etc.

___

SUPPORT

Commercial support for this product is available from eGenix.com.
Please see

http://www.egenix.com/services/support/

for details about our support offerings.

__

PySide window does not resize to fit screen

2015-10-01 Thread Hedieh Ebrahimi
Dear all, 

I am using Pyside to create a user interface for my app. 
The app works fine on my computer with big screen, but when I take it to my 
laptop with smaller screen size, it does not resize to match the screen size. 

How can I make my main widget get some information about the screen size and 
resize automatically? 

Thanks in Advance for your answers.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: reg multiple login python

2015-10-01 Thread paul.hermeneutic
On Oct 1, 2015 1:06 AM,  wrote:
>
> Hi All,
>
> Is there anyway i can login to remote servers at once and do the
activity, i can do one by one using for loop..
>
If you want to start them all at the same time, look into subprocess and
popen.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question about regular expression

2015-10-01 Thread gal kauffman
My example will give false positive if there is a space before a comma. Or
anything else by the conventions in the original string.
I tried to keep it as simple as I could.
If you want to catch a wider range of values you can use *simple* regular
expression to catch as much spaces as you want.
On Oct 1, 2015 3:48 PM, "Tim Chase"  wrote:

> On 2015-10-01 01:48, gal kauffman wrote:
> > items = s.replace(' (', '(').replace(', ',',').split()
>
> s = "name1  (1)"
>
> Your suggestion doesn't catch cases where more than one space can
> occur before the paren.
>
> -tkc
>
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question about regular expression

2015-10-01 Thread Tim Chase
On 2015-10-01 01:48, gal kauffman wrote:
> items = s.replace(' (', '(').replace(', ',',').split()

s = "name1  (1)"

Your suggestion doesn't catch cases where more than one space can
occur before the paren.

-tkc



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


Re: reg multiple login python

2015-10-01 Thread Laura Creighton
In a message of Thu, 01 Oct 2015 03:07:14 -0700, harirammanohar...@gmail.com wr
ites:
>On Thursday, 1 October 2015 12:35:01 UTC+5:30, hariramm...@gmail.com  wrote:
>> Hi All,
>> 
>> Is there anyway i can login to remote servers at once and do the activity, i 
>> can do one by one using for loop..
>> 
>> Thanks in advance.
>
>Hi Laura,
>
>at the same time means...
>i have an activity say on two servers serverA and serverB, my aim is to do the 
>activity using script by logging in to both servers serverA and serverB at the 
>same time and not one by one. hope this time i am able to convey :)
>
>in earlier post the way you suggested will work only as one by one..
>
>Thanks.

I am still not understanding.

Is your problem that you don't want to wait for the script to be done
on machine A before you go to machine B?

fork a separate process for each machine.

You could even do this in, for instance, a bash shell.
Given a script called myscript.py that takes a machine name as an argument.

for machine in `cat list_of_machines`
do
python --machine $machine myscript.py &
done

if you need to do this inside python see
os.fork https://docs.python.org/3.4/library/os.html
and make sure you read about the problems with ssl if
you care.  https://docs.python.org/3.4/library/ssl.html#module-ssl

Most people don't need any more 'at the same time' than this.
Do you?

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


Re: reg multiple login python

2015-10-01 Thread harirammanohar159
On Thursday, 1 October 2015 12:35:01 UTC+5:30, hariramm...@gmail.com  wrote:
> Hi All,
> 
> Is there anyway i can login to remote servers at once and do the activity, i 
> can do one by one using for loop..
> 
> Thanks in advance.

Hi Laura,

at the same time means...
i have an activity say on two servers serverA and serverB, my aim is to do the 
activity using script by logging in to both servers serverA and serverB at the 
same time and not one by one. hope this time i am able to convey :)

in earlier post the way you suggested will work only as one by one..

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


Re: reg multiple login python

2015-10-01 Thread harirammanohar159
On Thursday, 1 October 2015 12:35:01 UTC+5:30, hariramm...@gmail.com  wrote:
> Hi All,
> 
> Is there anyway i can login to remote servers at once and do the activity, i 
> can do one by one using for loop..
> 
> Thanks in advance.

Hi Michael,

please see earlier post to know the exact requirement :) and suggest if you 
have any solutions... :)

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


Re: reg multiple login python

2015-10-01 Thread Michael Ströder
harirammanohar...@gmail.com wrote:
> I have checked fabric tutorial and examples, it didn't sound that using fab
> we can do/push the thing at same time in all servers.

What does that mean?

Since the posting's subject contains "login" are you trying to minimize the
number of authentications needed? I had this discussion in project using OTP.

Ciao, Michael.

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


Re: reg multiple login python

2015-10-01 Thread Laura Creighton
In a message of Thu, 01 Oct 2015 01:25:47 -0700, harirammanohar...@gmail.com wr
ites:
>On Thursday, 1 October 2015 12:35:01 UTC+5:30, hariramm...@gmail.com  wrote:
>> Hi All,
>> 
>> Is there anyway i can login to remote servers at once and do the activity, i 
>> can do one by one using for loop..
>> 
>> Thanks in advance.
>
>Hi Laura,
>
>I have checked fabric tutorial and examples, it didn't sound that using fab we 
>can do/push the thing at same time in all servers.
>Are you saying that using fab we can login to all servers at same time and do 
>the activity and come out... if so, can you just give me some example..
>
>meanwhile i will try getting fab with py3.3 to machine...
>-- 
>https://mail.python.org/mailman/listinfo/python-list

I still don't know what you mean by 'at the same time'.

But see:
http://www.pythonforbeginners.com/systems-programming/how-to-use-fabric-in-a-development-environment/

change env.hosts to be a list of all the places that you want the things
you put in your fabfile.py to run.

I don't know if this is going to help you, or be any better than just
using a loop.  It depends on what your problem is.  Fabric is designed
to solve a certain set of problems, but I don't know if they are
the sort you have.

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


Re: Check if a given value is out of certain range

2015-10-01 Thread alister
On Thu, 01 Oct 2015 18:37:50 +1000, Chris Angelico wrote:

> On Thu, Oct 1, 2015 at 6:33 PM, alister
>  wrote:
>> The recommended phase is Stay calm
>>
>> Stay:   ok dont change anything, whats next
>> Calm ok I am calm that's alright then
> 
> Yes, because that always works.
> 
> Okay. Alright. I'm calm.
> *throws snowball*
> See? Now you made him mad!
> 
> :)
> 
> ChrisA

No it doesn't always work, but it does have a higher success rate than 
doing a "Corporal Jones"

Apologies to no UK residents who might not get the "Dads Army" reference.


-- 
One small step for man, one giant stumble for mankind.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question about regular expression

2015-10-01 Thread gal kauffman
items = s.replace(' (', '(').replace(', ',',').split()

items_dict = dict()
for item in items:
if '(' not in item:
item += '(0,0)'
if ',' not in item:
item = item.replace(')', ',0)')

name, raw_data = item.split('(')
data_tuple = tuple((int(v) for v in
raw_data.replace(')','').split(',')))

items_dict[name] = data_tuple

2015-09-30 20:58 GMT-07:00 Emile van Sebille :

> On 9/30/2015 12:20 PM, Tim Chase wrote:
>
>> On 2015-09-30 11:34, massi_...@msn.com wrote:
>>
> 
>
>> I guess this problem can be tackled with regular expressions, b
>>>
>> ... However, if you *want* to do it with
>>
>> regular expressions, you can.  It's ugly and might be fragile, but
>>
>> #
>> import re
>> s = "name1 name2(1) name3 name4 (1, 4) name5(2) ..."
>> r = re.compile(r"""
>>  \b   # start at a word boundary
>>  (\w+)# capture the word
>>  \s*  # optional whitespace
>>  (?:  # start an optional grouping for things in the parens
>>   \(  # a literal open-paren
>>\s*# optional whitespace
>>(\d+)  # capture the number in those parens
>>(?:# start a second optional grouping for the stuff after a
>> comma
>> \s*   # optional whitespace
>> , # a literal comma
>> \s*   # optional whitespace
>> (\d+) # the second number
>>)? # make the command and following number optional
>>   \)  # a literal close-paren
>>  )?   # make that stuff in parens optional
>>  """, re.X)
>> d = {}
>> for m in r.finditer(s):
>>  a, b, c  = m.groups()
>>  d[a] = (int(b or 0), int(c or 0))
>>
>> from pprint import pprint
>> pprint(d)
>> #
>>
>
> :)
>
>
>> I'd stick with the commented version of the regexp if you were to use
>> this anywhere so that others can follow what you're doing.
>>
>
> ... and this is why I use python.  That looks too much like a hex sector
> disk dump rot /x20.  :)
>
> No-really-that's-sick-ly yr's,
>
> Emile
>
>
>
>
> --
> 
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Check if a given value is out of certain range

2015-10-01 Thread Chris Angelico
On Thu, Oct 1, 2015 at 6:33 PM, alister
 wrote:
> The recommended phase is Stay calm
>
> Stay:   ok dont change anything, whats next
> Calm
> ok I am calm that's alright then

Yes, because that always works.

Okay. Alright. I'm calm.
*throws snowball*
See? Now you made him mad!

:)

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


Re: Check if a given value is out of certain range

2015-10-01 Thread alister
On Wed, 30 Sep 2015 14:46:48 -0600, Ian Kelly wrote:

> On Wed, Sep 30, 2015 at 2:19 PM, alister
>  wrote:
>> On Wed, 30 Sep 2015 21:06:02 +0300, Marko Rauhamaa wrote:
>>
>>> Grant Edwards :
>>>
   not (0 <= x <= 10) (I)
 [...]
(x < 0) or (x > 10)   (II)
 [...]
 IMO, (I) is _more_ readable than (II)
>>>
>>> IMO, they're equally readable (except that you should drop the
>>> redundant parentheses from (II)).
>>>
>>>
>>> Marko
>>
>> both are correct the problem with 1 is the human brain is not
>> particularity good with negatives*.
>> to do not (some function) you first of all have to work out some
>> function & then invert it, a computer does this without difficulty the
>> human brain gets confused which is why I personally consider ii is 
>> more readable (YMMV especially if you are working with Boolean maths
>> regularly) this example is relatively simple as things get more complex
>> they become more error prone error.
> 
> To me, the negative of one condition (is x in this range) is more easily
> processable than the disjunction of two conditions that together compose
> the real, more easily understood condition (is x outside this range). I
> find it preferable to avoid nested conditions, not negated conditions,
> and (II) has more nesting than (I).
> 
> Thought mirrors language. In English, we typically would say "x is not
> between 0 and 10", not "x is either less than 0 or greater than 10".
> 
>> *as an example you brain cannot correctly process the following.
>>
>> Not (think of your left toe)
>>
>> you are now thinking about it aren't you?
> 
> No, it made me think about thinking. I barely even registered the phrase
> "left toe", much less thought about that.
clearly it did, & you are now consciously aware of you left toe even if 
you try to deny it.
> 
> In any case, that's more an issue of being unable to control what you're
> thinking about. If I instruct you, "don't raise your right hand", do you
> then automatically raise your right hand?

Why is it that the Phrase "Don't Panic" is strongly discouraged in 
emergency situations?

answer because the brain parses the statement as follows and focuses on 
Panic instead of calm.

Don't : I must not do somthing what must i not do
Panic:  what is there to panic about?
Holly shit the buildings onfire, Raise Panic


The recommended phase is Stay calm

Stay:   ok dont change anything, whats next
Calm 
ok I am calm that's alright then


I may not have raised my right hand but I though about it (& decided no 
thanks)

getting closer to topic, i work on PBX systems where the VM is capable of 
combining multiple conditions into one super condition using Boolean 
Operators.
Invariably this does not happen & engineers are encoraged to check each 
condition separately because:

1) They are less likely to make a mistake
2) It is more obvious to subsequent engineers exactly what is happening
3) it is a lot easier to amend if req.

on the other hand if i was designing an electronic circuit using discreet 
electronics I would use all available techniques to manipulate the 
equation to make best use of components available
the may be reducing the total gate  count, it may actually increase the 
component count so that I could use only Nand gates, or it may get 
strangely complex so that I could make use of spare gates on existing ic's

Although I would have no difficulty reading the final equation it may not 
be obvious at 1st glance  .





-- 
Blue paint today.
[Funny to Jack Slingwine, Guy Harris and Hal Pierson.  
Ed.]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: reg multiple login python

2015-10-01 Thread harirammanohar159
On Thursday, 1 October 2015 12:35:01 UTC+5:30, hariramm...@gmail.com  wrote:
> Hi All,
> 
> Is there anyway i can login to remote servers at once and do the activity, i 
> can do one by one using for loop..
> 
> Thanks in advance.

Hi Laura,

I have checked fabric tutorial and examples, it didn't sound that using fab we 
can do/push the thing at same time in all servers.
Are you saying that using fab we can login to all servers at same time and do 
the activity and come out... if so, can you just give me some example..

meanwhile i will try getting fab with py3.3 to machine...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Check if a given value is out of certain range

2015-10-01 Thread Laura Creighton
In a message of Thu, 01 Oct 2015 09:40:58 +0200, Laura Creighton writes:
>'Either' doesn't get used much unless you are heading for
>'either x or y but not both'.

I don't think I was clear in expressing things this way.  What I meant
was, around here at any rate, 'either' is more often used for
emphasis that you can have x or y (but not both).  If there is no
particular emphasis, the 'either' usually gets dropped.

But it would not surprise me to find out that this is regional.

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


Re: Check if a given value is out of certain range

2015-10-01 Thread Laura Creighton
In a message of Wed, 30 Sep 2015 14:46:48 -0600, Ian Kelly writes:
>Thought mirrors language. In English, we typically would say "x is not
>between 0 and 10", not "x is either less than 0 or greater than 10".

I wonder if that is regional.

I think you may have stacked things with the 'either' and the 'greater
than'.  'Either' doesn't get used much unless you are heading for
'either x or y but not both'.  And everybody says 'more' even when
'greater than' is arguably more precise.

Around here, I would expect
"x is less than 0 or more than 10"

more often than either of your proposed forms.

But yesterday I hit up the students with the 'what do you find
more readable' question.

There was broad consensus that:

if 0 < x < 10 :
   do_something()
else:
   do_something_else()

was plenty more readable than anything using 'not'

so that the class favourite for readability was:

if 0 < x < 10:
   pass
else:
  complain_out_of_range()

though refactoring the whole lot so that you could have an
out_of_range Exception instead of an if had a large number of
supporters.

Laura


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


Re: reg multiple login python

2015-10-01 Thread Laura Creighton
In a message of Thu, 01 Oct 2015 00:04:16 -0700, harirammanohar...@gmail.com wr
ites:
>Hi All,
>
>Is there anyway i can login to remote servers at once and do the activity, i 
>can do one by one using for loop..
>
>Thanks in advance.
>-- 
>https://mail.python.org/mailman/listinfo/python-list

I am not sure that what you said 'do at once' is what you meant.  Actually
making sure that 2 things happen at the same time on different machines
is a rather hard problem.

But you probably don't care.  'Do this thing all these places, asap'
and 'Do this thing, sometime just after 03:00' is what we most of
the time want, and the best you are going to get with your for loop.

How much 'at once' do you need?

Note, if your real problem is 'I have a lot of machines to admininster,
and I need to push changes to all of them, and sometimes some of them
are down, and keeping track of which ones still need the update vs
which ones already have it is a real pain', you may find that
admin tools such as fabric
http://www.fabfile.org/

make your life easier.

Laura

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


Re: Check if a given value is out of certain range

2015-10-01 Thread Ian Kelly
On Wed, Sep 30, 2015 at 2:19 PM, alister
 wrote:
> On Wed, 30 Sep 2015 21:06:02 +0300, Marko Rauhamaa wrote:
>
>> Grant Edwards :
>>
>>>   not (0 <= x <= 10) (I)
>>> [...]
>>>(x < 0) or (x > 10)   (II)
>>> [...]
>>> IMO, (I) is _more_ readable than (II)
>>
>> IMO, they're equally readable (except that you should drop the redundant
>> parentheses from (II)).
>>
>>
>> Marko
>
> both are correct
> the problem with 1 is the human brain is not particularity good with
> negatives*.
> to do not (some function) you first of all have to work out some function
> & then invert it, a computer does this without difficulty the human brain
> gets confused which is why I personally consider ii is  more readable
> (YMMV especially if you are working with Boolean maths regularly) this
> example is relatively simple as things get more complex they become more
> error prone error.

To me, the negative of one condition (is x in this range) is more
easily processable than the disjunction of two conditions that
together compose the real, more easily understood condition (is x
outside this range). I find it preferable to avoid nested conditions,
not negated conditions, and (II) has more nesting than (I).

Thought mirrors language. In English, we typically would say "x is not
between 0 and 10", not "x is either less than 0 or greater than 10".

> *as an example you brain cannot correctly process the following.
>
> Not (think of your left toe)
>
> you are now thinking about it aren't you?

No, it made me think about thinking. I barely even registered the
phrase "left toe", much less thought about that.

In any case, that's more an issue of being unable to control what
you're thinking about. If I instruct you, "don't raise your right
hand", do you then automatically raise your right hand?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: execute commands as su on remote server

2015-10-01 Thread harirammanohar159
On Tuesday, 18 August 2015 08:27:33 UTC+5:30, hariramm...@gmail.com  wrote:
> execute commands as su on remote server
> 
> Postby hariram » Mon Aug 17, 2015 4:02 am
> Needed:
> I need to execute commands after doing su to other user on remote server(not 
> sudo which doesn't require password) how i can achieve this using python?
> I googled and came to know that its not possible, so just for confirmation 
> asking again, is it possible ?
> 
> Already Tried:
> Tried paramiko that's too not working.

Thanks laura, i am able to acheive it using pxssh...
-- 
https://mail.python.org/mailman/listinfo/python-list


reg multiple login python

2015-10-01 Thread harirammanohar159
Hi All,

Is there anyway i can login to remote servers at once and do the activity, i 
can do one by one using for loop..

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