Re: static variables

2015-12-02 Thread Antoon Pardon
Op 02-12-15 om 02:24 schreef Steven D'Aprano:
> Python has three not-entirely-awful solutions to the problem of static
> locals, but no really great or obvious one.

I think python is unsuited for an obvious solution for static locals.
Because you need to initialise your static variable somewhere. If you
initialise whithin the body of your function, you will have a statement
that is essentialy a declaration instead of an executable statement.
Which goes totally against the dynamic nature op python.

-- 
Antoon

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


Re: Is vars() the most useless Python built-in ever?

2015-12-02 Thread Serhiy Storchaka

On 01.12.15 03:00, Steven D'Aprano wrote:

I'm trying to understand why vars() exists. Does anyone use it?


I use vars() exclusively for introspection in interactive environment. 
As well as dir() and help(). Sad that it doesn't work with __slots__.



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


Re: static variables

2015-12-02 Thread Antoon Pardon
Op 02-12-15 om 02:24 schreef Steven D'Aprano:
> Heh, I agree, and as I suggested, it might be good to have an actual
> mechanism for static locals. But using a class is no better: your "static
> storage" is exposed as an instance attribute, and even if you flag it
> private, *somebody* is going to mess with it.

Why don't you invoke the consenting adults now? People have come here
arguing for all kind of extra features, which would somehow defend
against messing with certain variable or attributes the author wants
protected. The general respons has always been, that we are consenting
adults here.

Static variables, are just a feature to protect what is essentially
a global variable against messing from somewhere else. So why is
this feature worthy of discussion and others are not?

-- 
Antoon.

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


Re: Is Microsoft Windows secretly downloading childporn to your computer ?!

2015-12-02 Thread Juha Nieminen
In comp.lang.c++ Steve Hayes  wrote:
> You download things FROM a computer, you upload them TO a computer.

It's a matter of perspective. If a hacker breaks into your computer and
starts a download from somewhere else into your computer, isn't the hacker
"downloading" things to your computer?

--- news://freenews.netfront.net/ - complaints: [email protected] ---
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: 4D arrays

2015-12-02 Thread Manolo Martínez
On 12/01/15 at 06:47pm, Peter Otten wrote:
> Extract 2D arrays:
> 
> >>> a[:,2,3]
> array([[ 55,  56,  57,  58,  59],
>[115, 116, 117, 118, 119]])
> >>> a[1,:,2]
> array([[ 70,  71,  72,  73,  74],
>[ 90,  91,  92,  93,  94],
>[110, 111, 112, 113, 114]])

The first one is equivalent to a[:, 2, 3, :], which is perhaps clearer
in this context: you are singling out row 2 in axis 1, and row 3 in axis
2, and taking everything from axes 0 and 3.

Mutatis mutandis with the second example and a[1, :, 2, :], which is
different from a[1, :, :, 2], etc.

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


Installation of Python troubles

2015-12-02 Thread bezan deme via Python-list
Dear supporters,
I tried several times to install the Python 3.5.0 (windows x86 executable 
installer) in my PC then in my LT and in both cases I failed. Last time, few 
hours ago, I tried it again, then it opened a window with a sole "cancel" 
button on it. I waited for 10-15 min without anything to seem to happen, then I 
tried to click on the open parts of the window just above the "cancel" button. 
Then it started a procedure of "uninstalling the Python" and after 5-10 minutes 
it delivered the message of "successfully uninstalling" a program which was 
neven installed, with a "close" button!I have downloaded the .exe Python 
version for 32-bit machine of 27,950KB size, for more than 3 times, in case 
s/th went wrong with the connection, from your main website.I tried it in 2 
PC's and 3 laptops, with similar results (the installation process failed - 
unspecified error, etc.). Could you suggest something? Thanks,Demetris
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Is vars() the most useless Python built-in ever?

2015-12-02 Thread Manolo Martínez
Dear Peter, and Steven, thanks again for engaging with my script. I'm
fully aware that this is not the tutor mailing list :)

Peter Otten wrote:
> As far as I can see in a correctly written script the AttributeError cannot 
> be triggered by the user as argparse handles this case automatically by 
> showing the help. 

This... is true. I could have sworn that's not the way argparse behaved
when I wrote that snippet, but I've been very wrong before about similar
things. Anyway my main() function looks much better now :)

> By the way, I recommend coverage.py to find dead code. I have not used
> it for too long, and I regret it ;)

I blush to confess I would first need to write a test suite. But yeah,
will do both, thanks for the recommendation.

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


regarding download issues from sharepoint site

2015-12-02 Thread Arpit Arya
hi,

i am facing problem downloading files from sharepoint site and to display
it on my web portal. i have used requests_ntlm module which gives
successful authorisation but i am stuck in next step i.e. to download data
from sharepoint site and dispaly on portal. please help me out

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


Re: static variables

2015-12-02 Thread Chris Angelico
On Wed, Dec 2, 2015 at 7:21 PM, Antoon Pardon
 wrote:
> I think python is unsuited for an obvious solution for static locals.
> Because you need to initialise your static variable somewhere. If you
> initialise whithin the body of your function, you will have a statement
> that is essentialy a declaration instead of an executable statement.
> Which goes totally against the dynamic nature op python.

It ought to be initialized at the same time the function is defined -
just like argument defaults, only without them being visible as
arguments. If Python had a keyword that meant
"currently-executing-function", that would work out well for
attributes (and might also make recursion more optimizable);
otherwise, default args are probably the cleanest way we have.

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


Re: Is vars() the most useless Python built-in ever?

2015-12-02 Thread Chris Angelico
On Wed, Dec 2, 2015 at 7:22 PM, Serhiy Storchaka  wrote:
> On 01.12.15 03:00, Steven D'Aprano wrote:
>>
>> I'm trying to understand why vars() exists. Does anyone use it?
>
>
> I use vars() exclusively for introspection in interactive environment. As
> well as dir() and help(). Sad that it doesn't work with __slots__.

Maybe the upshot of all this is a post to python-ideas recommending
that vars() grow support for __slots__ types? If it's most often used
interactively, this would make it more useful there, and it wouldn't
break backward compatibility unless there's some way that people are
depending on it raising an exception.

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


Re: Installation of Python troubles

2015-12-02 Thread Chris Angelico
On Wed, Dec 2, 2015 at 2:11 PM, bezan deme via Python-list
 wrote:
> I tried several times to install the Python 3.5.0 (windows x86 executable 
> installer) in my PC then in my LT and in both cases I failed. Last time, few 
> hours ago, I tried it again, then it opened a window with a sole "cancel" 
> button on it.

Is this Windows XP? If so, you'll need to get a better operating
system - either a newer version of Windows (7, 8, 10), or something
Unix-based (Linux, *BSD, Mac OS). Windows XP doesn't support Python
3.5, and vice versa.

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


Re: Is vars() the most useless Python built-in ever?

2015-12-02 Thread Chris Angelico
On Wed, Dec 2, 2015 at 8:09 PM, Manolo Martínez
 wrote:
> Peter Otten wrote:
>> As far as I can see in a correctly written script the AttributeError cannot
>> be triggered by the user as argparse handles this case automatically by
>> showing the help.
>
> This... is true. I could have sworn that's not the way argparse behaved
> when I wrote that snippet, but I've been very wrong before about similar
> things. Anyway my main() function looks much better now :)

I would recommend not using argparse directly. Pick up a wrapper like
clize, and then define everything through docstrings.

Clize usage example:
https://github.com/Rosuav/LetMeKnow/blob/master/letmeknow.py

https://pypi.python.org/pypi/clize

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


Re: Is Microsoft Windows secretly downloading childporn to your computer ?!

2015-12-02 Thread Richard Heathfield

On 02/12/15 08:57, Juha Nieminen wrote:

In comp.lang.c++ Steve Hayes  wrote:

You download things FROM a computer, you upload them TO a computer.


It's a matter of perspective. If a hacker breaks into your computer and
starts a download from somewhere else into your computer, isn't the hacker
"downloading" things to your computer?


My understanding of the term has always been that you upload from a 
smaller device to a larger, and download from a larger device to a 
smaller. Thus, from your laptop you might *up*load data to a Web server 
or a mainframe, but you would *down*load data to your phone or tablet.


If the devices are of comparable size and power, you aren't upping or 
downing anything - you're just transferring data from one computer to 
another. I suppose we could say "crossloading"?


--
Richard Heathfield
Email: rjh at cpax dot org dot uk
"Usenet is a strange place" - dmr 29 July 1999
Sig line 4 vacant - apply within
--
https://mail.python.org/mailman/listinfo/python-list


Re: static variables

2015-12-02 Thread Antoon Pardon
Op 02-12-15 om 10:23 schreef Chris Angelico:
> On Wed, Dec 2, 2015 at 7:21 PM, Antoon Pardon
>  wrote:
>> I think python is unsuited for an obvious solution for static locals.
>> Because you need to initialise your static variable somewhere. If you
>> initialise whithin the body of your function, you will have a statement
>> that is essentialy a declaration instead of an executable statement.
>> Which goes totally against the dynamic nature op python.
> It ought to be initialized at the same time the function is defined -
> just like argument defaults, only without them being visible as
> arguments.

I am not talking about the time. That could be done with something
declarative too. I am talking about where to put in the code.

>  If Python had a keyword that meant
> "currently-executing-function", that would work out well for
> attributes (and might also make recursion more optimizable);
> otherwise, default args are probably the cleanest way we have.

No it wouldn't. Lets call that keyword cef. The fact that you
can write:

def foo():
   cef.attr

instead of

def foo()
   foo.attr

changes nothing about foo.attr being globally accessible.

-- 
Antoon. 


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


Re: Is vars() the most useless Python built-in ever?

2015-12-02 Thread Manolo Martínez
On 12/02/15 at 08:33pm, Chris Angelico wrote:
> On Wed, Dec 2, 2015 at 8:09 PM, Manolo Martínez
> > This... is true. I could have sworn that's not the way argparse behaved
> > when I wrote that snippet, but I've been very wrong before about similar
> > things. Anyway my main() function looks much better now :)
> 
> I would recommend not using argparse directly. Pick up a wrapper like
> clize, and then define everything through docstrings.
> 
> Clize usage example:
> https://github.com/Rosuav/LetMeKnow/blob/master/letmeknow.py
> 
> https://pypi.python.org/pypi/clize

I try to do as much as I can with standard library tools. As a user, I
find it somewhat off-putting when a tiny project asks you to install any
number of seemingly unrelated libraries. But clize does look like a good
idea, thanks for the pointer.

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


Re: Is Microsoft Windows secretly downloading childporn to your computer ?!

2015-12-02 Thread Les Cargill

Juha Nieminen wrote:

In comp.lang.c++ Steve Hayes  wrote:

You download things FROM a computer, you upload them TO a computer.


It's a matter of perspective. If a hacker breaks into your computer and
starts a download from somewhere else into your computer, isn't the hacker
"downloading" things to your computer?

--- news://freenews.netfront.net/ - complaints: [email protected] ---



Down is towards an end node; up is towards the backbone. Servers
live closer to the backbone. Usually. Or rather did when the
nomenclature was forged.

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


Re: static variables

2015-12-02 Thread Marko Rauhamaa
Antoon Pardon :

> def foo()
>foo.attr
>
> changes nothing about foo.attr being globally accessible.

I don't know why global accessibility is such a problem.

Anyway, in practice I handle such "static" variables as module globals.
If you want a more puristic solution, you could do:

   def _make_f():
   x = 0
   def f():
   nonlocal x
   x += 1
   return x
   return f

   f = _make_f()

   print(f())
   => 1
   print(f())
   => 2
   print(f())
   => 3


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


Re: static variables

2015-12-02 Thread Steven D'Aprano
On Wed, 2 Dec 2015 07:34 pm, Antoon Pardon wrote:

> Op 02-12-15 om 02:24 schreef Steven D'Aprano:
>> Heh, I agree, and as I suggested, it might be good to have an actual
>> mechanism for static locals. But using a class is no better: your "static
>> storage" is exposed as an instance attribute, and even if you flag it
>> private, *somebody* is going to mess with it.
> 
> Why don't you invoke the consenting adults now? 

Because I don't wish to.

I can invoke consenting adults to defend people drinking soft drinks and
eating chocolate, doesn't mean I have to invoke consenting adults to defend
the practice of middle-class film-makers goading homeless people into
fighting and other dangerous acts for trivial amounts of money.

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


> People have come here 
> arguing for all kind of extra features, which would somehow defend
> against messing with certain variable or attributes the author wants
> protected. The general respons has always been, that we are consenting
> adults here.

Yes, and that's fine. Consider the word *judgement* -- in our (the
collective community) judgement, certain things are acceptable for
consenting adults and others are not. 

But if it makes you feel better, if I were to champion this feature, I would
suggest that the initialised static variable be stored in a writable dunder
attribute of the function, just like default values are today. If you
wanted to inspect, or even modify, the static variables, you could access
function.__static__[x].


> Static variables, are just a feature to protect what is essentially
> a global variable against messing from somewhere else.

No, that's not the reason for static variables. The primary reasons for
static variables are efficiency and encapsulation.

Efficiency: consider a function that requires a considerable amount of
initialisation, which only needs to be done once. In older languages like
Pascal which lack static variables, you might perform that initialisation
every time you call the function. Or, you might break encapsulation by
storing something that belongs with the function outside the function.
Static variables let you have your cake and eat it too: you can keep the
variable with the function, avoiding namespace pollution, which still
allowing the efficiency of having that variable calculated once only.


> So why is 
> this feature worthy of discussion and others are not?

Because I say so. Since it's my suggestion, that's the only reason I need.

 

-- 
Steven

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


Re: Is vars() the most useless Python built-in ever?

2015-12-02 Thread Peter Otten
Manolo Martínez wrote:

> On 12/02/15 at 08:33pm, Chris Angelico wrote:
>> On Wed, Dec 2, 2015 at 8:09 PM, Manolo Martínez
>> > This... is true. I could have sworn that's not the way argparse behaved
>> > when I wrote that snippet, but I've been very wrong before about
>> > similar things. Anyway my main() function looks much better now :)
>> 
>> I would recommend not using argparse directly. Pick up a wrapper like
>> clize, and then define everything through docstrings.
>> 
>> Clize usage example:
>> https://github.com/Rosuav/LetMeKnow/blob/master/letmeknow.py
>> 
>> https://pypi.python.org/pypi/clize
> 
> I try to do as much as I can with standard library tools. As a user, I
> find it somewhat off-putting when a tiny project asks you to install any
> number of seemingly unrelated libraries. But clize does look like a good
> idea, thanks for the pointer.

Same here ;)

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


Re: static variables

2015-12-02 Thread Antoon Pardon
Op 02-12-15 om 11:18 schreef Marko Rauhamaa:
> Antoon Pardon :
>
>> def foo()
>>foo.attr
>>
>> changes nothing about foo.attr being globally accessible.
> I don't know why global accessibility is such a problem.

Some people seem to have a problem with global variables.

-- 
Antoon.

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


Re: Is vars() the most useless Python built-in ever?

2015-12-02 Thread Chris Angelico
On Wed, Dec 2, 2015 at 9:48 PM, Peter Otten <[email protected]> wrote:
>> I try to do as much as I can with standard library tools. As a user, I
>> find it somewhat off-putting when a tiny project asks you to install any
>> number of seemingly unrelated libraries. But clize does look like a good
>> idea, thanks for the pointer.
>
> Same here ;)

I found out about clize by developing my own module that did the same
job - and then found that, by compromising VERY slightly on some
specifics, I could turn my usage directly to clize :)

One thing I didn't want to compromise on was the simplicity of setup
that I'd had - just slap a decorator onto every function that you want
to make into a callable. So I made my own decorator that collects up
the functions. Total cost: Three lines at the top, two at the bottom
(if name is main, clize.run), and one line per function, plus the
encoded docstring. That's a LOT cheaper than argparse normally is.

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


Re: static variables

2015-12-02 Thread Antoon Pardon
Op 02-12-15 om 11:22 schreef Steven D'Aprano:
> On Wed, 2 Dec 2015 07:34 pm, Antoon Pardon wrote:
>
>> Op 02-12-15 om 02:24 schreef Steven D'Aprano:
>>> Heh, I agree, and as I suggested, it might be good to have an actual
>>> mechanism for static locals. But using a class is no better: your "static
>>> storage" is exposed as an instance attribute, and even if you flag it
>>> private, *somebody* is going to mess with it.
>> Why don't you invoke the consenting adults now? 
> Because I don't wish to.
>
> I can invoke consenting adults to defend people drinking soft drinks and
> eating chocolate, doesn't mean I have to invoke consenting adults to defend
> the practice of middle-class film-makers goading homeless people into
> fighting and other dangerous acts for trivial amounts of money.
>
> https://en.wikipedia.org/wiki/Bumfights

If you want your arguments to be taken seriously, then you better should.
If you use an argument when it suits you and ignore it when it doesn't
you are showing you don't really have an argument. You are just showing
your preference and making it sound like an argument.

>> People have come here 
>> arguing for all kind of extra features, which would somehow defend
>> against messing with certain variable or attributes the author wants
>> protected. The general respons has always been, that we are consenting
>> adults here.
> Yes, and that's fine. Consider the word *judgement* -- in our (the
> collective community) judgement, certain things are acceptable for
> consenting adults and others are not.

Which makes "consenting adults" just empty posturing that means nothing
more than /we like it that way/ or /we don't have a problem with that./

> But if it makes you feel better, if I were to champion this feature, I would
> suggest that the initialised static variable be stored in a writable dunder
> attribute of the function, just like default values are today. If you
> wanted to inspect, or even modify, the static variables, you could access
> function.__static__[x].
>
>
>> Static variables, are just a feature to protect what is essentially
>> a global variable against messing from somewhere else.
> No, that's not the reason for static variables. The primary reasons for
> static variables are efficiency and encapsulation.

No it isn't. Global variables are just as efficient and encapsulation
is just one means to protect a variable against messing.

Efficiency: consider a function that requires a considerable amount of
initialisation, which only needs to be done once. In older languages like
Pascal which lack static variables, you might perform that initialisation
every time you call the function. Or, you might break encapsulation by
storing something that belongs with the function outside the function.
Static variables let you have your cake and eat it too: you can keep the
variable with the function, avoiding namespace pollution, which still
allowing the efficiency of having that variable calculated once only.


>> So why is 
>> this feature worthy of discussion and others are not?
> Because I say so. Since it's my suggestion, that's the only reason I need.
>
>  
>

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


Re: static variables

2015-12-02 Thread Marko Rauhamaa
Antoon Pardon :

> Op 02-12-15 om 11:18 schreef Marko Rauhamaa:
>> I don't know why global accessibility is such a problem.
>
> Some people seem to have a problem with global variables.

Well, *I* don't go around defining global variables, but there are times
when they are the way to go. For example, if a module function uses a
regular expression, the regular expression should be compiled into a
(module) global variable.

Module functions and classes are global variables as well:

>>> import math
>>> def f(x): return -1
...
>>> math.sqrt = f
>>> math.sqrt(3)
-1


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


Re: Is vars() the most useless Python built-in ever?

2015-12-02 Thread eryk sun
On Wed, Dec 2, 2015 at 3:28 AM, Chris Angelico  wrote:
> On Wed, Dec 2, 2015 at 7:22 PM, Serhiy Storchaka  wrote:
>>
>> I use vars() exclusively for introspection in interactive environment. As
>> well as dir() and help(). Sad that it doesn't work with __slots__.
>
> Maybe the upshot of all this is a post to python-ideas recommending
> that vars() grow support for __slots__ types? If it's most often used
> interactively, this would make it more useful there, and it wouldn't
> break backward compatibility unless there's some way that people are
> depending on it raising an exception.

Let vars() continue in its antediluvian ways. Maybe the standard
library could add an inspect.getdata function that returns a union of
an object's __dict__ items and data-descriptor attributes.
-- 
https://mail.python.org/mailman/listinfo/python-list


how to make the below code look better

2015-12-02 Thread Ganesh Pal
Hello team,

I need suggestion to improve the below code , Iam on Linux and python 2.7

if not os.path.ismount("/tmp"):
   sys.exit("/tmp not mounted.")
else:
 if  create_dataset() and check_permission():
 try:
  run_full_back_up()
  run_partial_back_up()
except Exception, e:
logging.error(e)
sys.exit("Running backup failed")
if not validation_errors():
sys.exit("Validation failed")
else:
try:
compare_results()
except Exception, e:
   logging.error(e)
   sys.exit("Comparing result failed")

Question 1:

1.  if  create_dataset() and check_permission():
Iam assuming that if statement will be executed only if both the
functions are true ?

2. Can I have a if statement within  if else ? , some how I feel its messy

3.  Any other suggestion ? please
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how to make the below code look better

2015-12-02 Thread BartC

On 02/12/2015 12:11, Ganesh Pal wrote:


if not os.path.ismount("/tmp"):
sys.exit("/tmp not mounted.")
else:
  if  create_dataset() and check_permission():
  try:
   run_full_back_up()
   run_partial_back_up()
 except Exception, e:
 logging.error(e)
 sys.exit("Running backup failed")
 if not validation_errors():
 sys.exit("Validation failed")
 else:
 try:
 compare_results()
 except Exception, e:
logging.error(e)
sys.exit("Comparing result failed")



3.  Any other suggestion ? please



You could make the indentation more consistent. Example:

if not os.path.ismount("/tmp"):
sys.exit("/tmp not mounted.")
else:
if create_dataset() and check_permission():
try:
run_full_back_up()
run_partial_back_up()
except Exception, e:
logging.error(e)
sys.exit("Running backup failed")
if not validation_errors():
sys.exit("Validation failed")
else:
try:
compare_results()
except Exception, e:
logging.error(e)
sys.exit("Comparing result failed")



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


Re: how to make the below code look better

2015-12-02 Thread Chris Angelico
On Wed, Dec 2, 2015 at 11:11 PM, Ganesh Pal  wrote:
> I need suggestion to improve the below code , Iam on Linux and python 2.7
>
> if not os.path.ismount("/tmp"):
>sys.exit("/tmp not mounted.")
> else:
>  if  create_dataset() and check_permission():
>  try:
>   run_full_back_up()
>   run_partial_back_up()
> except Exception, e:
> logging.error(e)
> sys.exit("Running backup failed")
> if not validation_errors():
> sys.exit("Validation failed")
> else:
> try:
> compare_results()
> except Exception, e:
>logging.error(e)
>sys.exit("Comparing result failed")
>
> Question 1:
>
> 1.  if  create_dataset() and check_permission():
> Iam assuming that if statement will be executed only if both the
> functions are true ?

If both the functions return true values, yes. You have an indentation
error there, but I'm assuming you meant to have the try/except
indented further.

> 2. Can I have a if statement within  if else ? , some how I feel its messy

Certainly you can! However, most (maybe all) of your 'if' statements
are checking for error conditions, so the easiest solution is to
simply exit right away (either with sys.exit or by raising an
exception).

> 3.  Any other suggestion ? please

The first suggestion I'd make is to avoid the comma syntax for
exception handling. Replace "except Exception, e:" with "except
Exception as e:". That's a trivial change of syntax that shouldn't
affect your code at all; consider it low-hanging fruit.

The second thing to look at is the way you're 'handling' those errors.
All you do is log the error and exit. So you can skip the except
clauses altogether, and just do this:

if not os.path.ismount("/tmp"):
 sys.exit("/tmp not mounted.")
if create_dataset() and check_permission():
run_full_back_up()
run_partial_back_up()
if not validation_errors(): # CHECK ME
sys.exit("Validation failed")
compare_results()


Check the logic of validation_errors, though. If it returns something
True, does that mean there were errors or there weren't? If it means
there were errors, then the 'not' seems to me to be wrong; but if it
means there weren't, then I would rename it "validation_successful"
rather than "validation_errors".

Also worth checking: If you can't create the data set or the
permission check fails, what should it do? Should it terminate with an
error? Currently, it carries on and does the validation, which is
probably not right. If it ought to terminate straight away, you can
write the whole program in "fail and bail" style:

if not create_dataset():
sys.exit("Data set creation failed")
if not check_permission():
sys.exit("Permission check failed")

Even better: Make those functions raise exceptions on failure, instead
of returning False. They can give extra information that way, and all
your main routine needs to do is:

create_dataset()
check_permission()

To advise further, we'd need to see what those functions are doing.
The main routine you have here is pretty simple, and anything you do
is probably going to be fine.

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


Re: how to make the below code look better

2015-12-02 Thread Chris Angelico
On Wed, Dec 2, 2015 at 11:20 PM, BartC  wrote:
> You could make the indentation more consistent. Example:

You fixed one indentation error...

> if create_dataset() and check_permission():
> try:
> run_full_back_up()
> run_partial_back_up()
> except Exception, e:
> logging.error(e)
> sys.exit("Running backup failed")

... but introduced another :)

> try:
> compare_results()
> except Exception, e:
> logging.error(e)
> sys.exit("Comparing result failed")

These last three lines need to be unindented one level. Otherwise,
Bart's recommendation is a good one.

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


RE: Installation Problem

2015-12-02 Thread Packie Kelly
Hi my name is Patrick,

I have a problem regarding the installation of the latest version of
python, everytime I install the program I keep getting the message modify,
repair, uninstall. I've tried different versions but with no luck. Before
you ask I have already completely removed the program.

Looking forward to your reply
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Installation Problem

2015-12-02 Thread Chris Angelico
On Wed, Dec 2, 2015 at 11:08 PM, Packie Kelly  wrote:
> Hi my name is Patrick,
>
> I have a problem regarding the installation of the latest version of
> python, everytime I install the program I keep getting the message modify,
> repair, uninstall. I've tried different versions but with no luck. Before
> you ask I have already completely removed the program.
>
> Looking forward to your reply

My crystal ball says you're using Windows XP. Your options, if that is
the case, are:

1) Downgrade to Python 3.4
2) Upgrade to Windows 7/8/10
3) Install a better operating system, like Linux, *BSD, or Mac OS

Otherwise, tell us some more about your system - what kind of computer
are you running, what OS are you using, etc, etc - and where you got
Python from, etc. We'll then be better able to advise.

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


Re: static variables

2015-12-02 Thread Steven D'Aprano
On Wed, 2 Dec 2015 10:09 pm, Antoon Pardon wrote:

> If you want your arguments to be taken seriously, then you better should.
> If you use an argument when it suits you and ignore it when it doesn't
> you are showing you don't really have an argument. You are just showing
> your preference and making it sound like an argument.

"A foolish consistency is the hobgoblin of little minds."

Thank you for your feedback. If you ever decide to post here to make
constructive comments or to help others, instead of just flaunting your
imagined superiority and whinging and moaning about the rest of us, then
I'll start to take your arguments seriously too.



-- 
Steven

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


Re: static variables

2015-12-02 Thread Steven D'Aprano
On Wed, 2 Dec 2015 10:30 pm, Marko Rauhamaa wrote:

> Antoon Pardon :
> 
>> Op 02-12-15 om 11:18 schreef Marko Rauhamaa:
>>> I don't know why global accessibility is such a problem.
>>
>> Some people seem to have a problem with global variables.
> 
> Well, *I* don't go around defining global variables, but there are times
> when they are the way to go. For example, if a module function uses a
> regular expression, the regular expression should be compiled into a
> (module) global variable.
> 
> Module functions and classes are global variables as well:

Actually, those examples are more usually global *constants* (or at least
the closest thing that Python has to constants). While we can rebind
math.sqrt, as in your example, treating it as a variable, we normally would
not do so. We would normally treat such module level objects as constants.



-- 
Steven

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


Re: how to make the below code look better

2015-12-02 Thread Steven D'Aprano
On Wed, 2 Dec 2015 11:11 pm, Ganesh Pal wrote:

> Hello team,
> 
> I need suggestion to improve the below code , Iam on Linux and python 2.7
> 
> if not os.path.ismount("/tmp"):
>sys.exit("/tmp not mounted.")

This is good enough for quick and dirty scripts, but this is vulnerable to a
race condition. It may be that /tmp is mounted *now*, but a millisecond
later (before you can use it) another process unmounts it.

This is called a "time of check to time of use" bug:

https://cwe.mitre.org/data/definitions/367.html

https://www.owasp.org/index.php/Time_of_check,_time_of_use_race_condition

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

and can be a serious software vulnerability.

If this code is only being used under trusted conditions, then it is
probably okay, otherwise you should reconsider your strategy.

(Besides, how often do you unmount /tmp?)




> else:
>  if  create_dataset() and check_permission():

this with:

elif create_dataset() and check_permission():

but again be mindful of the risk of race conditions.



>  try:
>   run_full_back_up()
>   run_partial_back_up()
> except Exception, e:
> logging.error(e)
> sys.exit("Running backup failed")
> if not validation_errors():
> sys.exit("Validation failed")

I would swap the sense of validation_errors(). Currently, it looks like it
returns True if there are *no* errors, and False if there are errors. That
seems confusing and easy to get wrong. 

if validation_errors():
sys.exit("Validation failed")

reads better and is easier to understand. Now validation_errors() returns
true if there are errors, and false if there are no errors.


> else:
> try:
> compare_results()
> except Exception, e:
>logging.error(e)
>sys.exit("Comparing result failed")
> 
> Question 1:
> 
> 1.  if  create_dataset() and check_permission():
> Iam assuming that if statement will be executed only if both the
> functions are true ?

Correct.


> 2. Can I have a if statement within  if else ? , some how I feel its messy

Yes you can, but elif is usually nicer, and saves a level of indentation.



-- 
Steven

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


Re: Installation Problem

2015-12-02 Thread Mark Lawrence

On 02/12/2015 13:12, Chris Angelico wrote:

On Wed, Dec 2, 2015 at 11:08 PM, Packie Kelly  wrote:

Hi my name is Patrick,

I have a problem regarding the installation of the latest version of
python, everytime I install the program I keep getting the message modify,
repair, uninstall. I've tried different versions but with no luck. Before
you ask I have already completely removed the program.

Looking forward to your reply


My crystal ball says you're using Windows XP. Your options, if that is
the case, are:

1) Downgrade to Python 3.4
2) Upgrade to Windows 7/8/10
3) Install a better operating system, like Linux, *BSD, or Mac OS

Otherwise, tell us some more about your system - what kind of computer
are you running, what OS are you using, etc, etc - and where you got
Python from, etc. We'll then be better able to advise.

ChrisA



0) before asking search for "python installation problem" just in case 
you're not the first person to have this issue.


--
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: Installation Problem

2015-12-02 Thread Laura Creighton
In a message of Wed, 02 Dec 2015 12:08:02 +, Packie Kelly writes:
>Hi my name is Patrick,
>
>I have a problem regarding the installation of the latest version of
>python, everytime I install the program I keep getting the message modify,
>repair, uninstall. I've tried different versions but with no luck. Before
>you ask I have already completely removed the program.
>
>Looking forward to your reply

What Operating System?  If it is Windows XP, that is your problem.
Python 3.5 is not supported on Windows XP.  Either stick with 3.4 or
upgrade your OS to something more recent.

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


Re: static variables

2015-12-02 Thread Antoon Pardon
Op 02-12-15 om 14:11 schreef Steven D'Aprano:
> On Wed, 2 Dec 2015 10:09 pm, Antoon Pardon wrote:
>
>> If you want your arguments to be taken seriously, then you better should.
>> If you use an argument when it suits you and ignore it when it doesn't
>> you are showing you don't really have an argument. You are just showing
>> your preference and making it sound like an argument.
> "A foolish consistency is the hobgoblin of little minds."

So? That doesn't show that we are talking about a foolish consistency here.

This pseudo kind of arguing happens a lot on this list. A lot of the times
one just throws out some proverb as if it is at all clear that the proverb
applies.

Somebody points out an inconsistency and out comes the above proverb, without
much arguments that this inconsisty has advantages over a more consistent
approach.

> Thank you for your feedback. If you ever decide to post here to make
> constructive comments or to help others, instead of just flaunting your
> imagined superiority and whinging and moaning about the rest of us, then
> I'll start to take your arguments seriously too.

Oh come of your high horse. If people use arguments in a selective way,
I can point that out. If you selectively apply an argument so you ignore
the counter arguments when it suits you, that is not a constructive comment
either and you can expect people to point out when that first argument can
be used against you in the same way.

Then going on to complain about non constructive comments seems a bit
disingenous.

-- 
Antoon.

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


Re: how to make the below code look better

2015-12-02 Thread Chris Angelico
On Thu, Dec 3, 2015 at 12:28 AM, Steven D'Aprano  wrote:
>> if not os.path.ismount("/tmp"):
>>sys.exit("/tmp not mounted.")
>
> This is good enough for quick and dirty scripts, but this is vulnerable to a
> race condition. It may be that /tmp is mounted *now*, but a millisecond
> later (before you can use it) another process unmounts it.
>
> This is called a "time of check to time of use" bug:
>
> https://cwe.mitre.org/data/definitions/367.html
>
> https://www.owasp.org/index.php/Time_of_check,_time_of_use_race_condition
>
> https://en.wikipedia.org/wiki/Time_of_check_to_time_of_use
>
> and can be a serious software vulnerability.
>
> If this code is only being used under trusted conditions, then it is
> probably okay, otherwise you should reconsider your strategy.
>
> (Besides, how often do you unmount /tmp?)
>

Possibly it's not worried about *un*mounting of /tmp, but about being
run prior to /tmp being mounted for the first time. If that's the
case, the check/use difference won't matter - worst case, the program
errors out even though the mount was almost completed.

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


Re: static variables

2015-12-02 Thread Mark Lawrence

On 02/12/2015 13:41, Antoon Pardon wrote:

Op 02-12-15 om 14:11 schreef Steven D'Aprano:

On Wed, 2 Dec 2015 10:09 pm, Antoon Pardon wrote:


If you want your arguments to be taken seriously, then you better should.
If you use an argument when it suits you and ignore it when it doesn't
you are showing you don't really have an argument. You are just showing
your preference and making it sound like an argument.

"A foolish consistency is the hobgoblin of little minds."


So? That doesn't show that we are talking about a foolish consistency here.

This pseudo kind of arguing happens a lot on this list. A lot of the times
one just throws out some proverb as if it is at all clear that the proverb
applies.

Somebody points out an inconsistency and out comes the above proverb, without
much arguments that this inconsisty has advantages over a more consistent
approach.


Thank you for your feedback. If you ever decide to post here to make
constructive comments or to help others, instead of just flaunting your
imagined superiority and whinging and moaning about the rest of us, then
I'll start to take your arguments seriously too.


Oh come of your high horse. If people use arguments in a selective way,
I can point that out. If you selectively apply an argument so you ignore
the counter arguments when it suits you, that is not a constructive comment
either and you can expect people to point out when that first argument can
be used against you in the same way.

Then going on to complain about non constructive comments seems a bit
disingenous.



Would the pair of you, Antoon and Steven, be kind enough to take your 
bickering offline, thanks.


--
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: Installation Problem

2015-12-02 Thread Laura Creighton
In a message of Wed, 02 Dec 2015 13:30:38 +, Mark Lawrence writes:
>0) before asking search for "python installation problem" just in case 
>you're not the first person to have this issue.

That is not a good idea, there are so many different hits for that.
The first one I get is this:
http://superuser.com/questions/613820/error-installing-python-on-windows-7-x64

which is unlikely to be the OP's problem.

I'd like it if people would stop mentioning crystal balls and the like
around here, which was funny once, but which has gotten extremely stale
since.  And if people whose first take on others is 'does this give me
an opportunity to be sarcastic' took it someplace else.  I get very
tired of hanging around people who think that sarcastic is clever.

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


Re: static variables

2015-12-02 Thread Antoon Pardon
Op 02-12-15 om 14:48 schreef Mark Lawrence:
>
> Would the pair of you, Antoon and Steven, be kind enough to take your
> bickering offline, thanks.
>
Mark, you are in no position to make such a request of others.

-- 
Antoon.

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


Re: static variables

2015-12-02 Thread Ian Kelly
On Wed, Dec 2, 2015 at 7:41 AM, Antoon Pardon
 wrote:
> Op 02-12-15 om 14:11 schreef Steven D'Aprano:
>> On Wed, 2 Dec 2015 10:09 pm, Antoon Pardon wrote:
>>
>>> If you want your arguments to be taken seriously, then you better should.
>>> If you use an argument when it suits you and ignore it when it doesn't
>>> you are showing you don't really have an argument. You are just showing
>>> your preference and making it sound like an argument.
>> "A foolish consistency is the hobgoblin of little minds."
>
> So? That doesn't show that we are talking about a foolish consistency here.

It's actually the truest use of the quote that I've yet seen on this
list. Emerson was complaining about those who adhere to opinions that
they've expressed in the past solely for the sake of appearing
consistent in their values, which is basically what you're accusing
Steven of not doing.

If you haven't previously read Self-Reliance, I would recommend it as
a good (and short) read.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: static variables

2015-12-02 Thread Mark Lawrence

On 02/12/2015 14:07, Antoon Pardon wrote:

Op 02-12-15 om 14:48 schreef Mark Lawrence:


Would the pair of you, Antoon and Steven, be kind enough to take your
bickering offline, thanks.


Mark, you are in no position to make such a request of others.



I am, I'm sat perfectly comfortably thank you.

--
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: Installation Problem

2015-12-02 Thread Mark Lawrence

On 02/12/2015 13:59, Laura Creighton wrote:

In a message of Wed, 02 Dec 2015 13:30:38 +, Mark Lawrence writes:

0) before asking search for "python installation problem" just in case
you're not the first person to have this issue.


That is not a good idea, there are so many different hits for that.
The first one I get is this:
http://superuser.com/questions/613820/error-installing-python-on-windows-7-x64

which is unlikely to be the OP's problem.


So you are advocating that people keep on asking the same question, even 
if it has been asked twice a day for the last month?  Wouldn't it be 
better to advise people to restrict their search to maybe the last month 
or even week, or do a site specific search, or even check the mailing 
list archives?




I'd like it if people would stop mentioning crystal balls and the like
around here, which was funny once, but which has gotten extremely stale
since.  And if people whose first take on others is 'does this give me
an opportunity to be sarcastic' took it someplace else.  I get very
tired of hanging around people who think that sarcastic is clever.


It's not funny, but it does show the number of times that the question 
asked is often less than useless.  Personally I'm tired of the fit bib, 
spoon feed, change nappy brigade, who IMHO are doing far more harm than 
good.




Laura




--
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: Installation Problem

2015-12-02 Thread Laura Creighton
In a message of Wed, 02 Dec 2015 14:42:48 +, Mark Lawrence writes:
>On 02/12/2015 13:59, Laura Creighton wrote:
>> In a message of Wed, 02 Dec 2015 13:30:38 +, Mark Lawrence writes:
>>> 0) before asking search for "python installation problem" just in case
>>> you're not the first person to have this issue.
>>
>> That is not a good idea, there are so many different hits for that.
>> The first one I get is this:
>> http://superuser.com/questions/613820/error-installing-python-on-windows-7-x64
>>
>> which is unlikely to be the OP's problem.
>
>So you are advocating that people keep on asking the same question, even 
>if it has been asked twice a day for the last month?

Yes.  It is old for us, but nobody should be giving 2 hoots about 
our feelings.  Since we can just ignore such things.  The problem 
is always fresh and new for the poster.

>  Wouldn't it be 
>better to advise people to restrict their search to maybe the last month 
>or even week, or do a site specific search, or even check the mailing 
>list archives?

They are already getting the advice to ask the question on python-list.
This is the preferred way to get such problems solved.  We even have
automated mailer responses telling people to ask such questions here.
We don't warn them that they are about to meet anti-social and egotistical
people who think that they should take every opportunity to be 
sarcastic that presents itself.

You also have a woefully inadequate understanding of ignorance.
See Kruger Dunnign effect:
https://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect
People in the bottom quartile of comprehension of anything -- i.e.
the most ignorant -- lack the metacognative skills to recognise
the solutions to their problems even when they are presented in
a clear and logical fashion.  Thus the most ignorant can not be expected 
to just google up an answer, because even if they got one, they wouldn't 
be able to recognise it.

It's bad enough when they miss solutions out there.  It's worse when
they try to do things that work for one OS on another, or one version
of an OS on another, and so on and so forth.  

Much, much better that these people come and ask quesitons.

>It's not funny, but it does show the number of times that the question 
>asked is often less than useless.  Personally I'm tired of the fit bib, 
>spoon feed, change nappy brigade, who IMHO are doing far more harm than 
>good.

I think you should stay away from python-list, then, until your sense
of humour returns and your ability to deal with the abysmally ignorant
matures.  Because this is where we actually want to get a hold of 
such people so we can teach them things, and the active and vocal
presence of people who resent them for being ignorant makes the job
a whole lot harder.

Laura

>Mark Lawrence

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


Re: "Downloading"

2015-12-02 Thread Grant Edwards
On 2015-12-01, Chris Angelico  wrote:
> On Wed, Dec 2, 2015 at 6:05 AM, Random832  wrote:
>> On 2015-12-01, Steve Hayes  wrote:
>>> You download things FROM a computer, you upload them TO a computer.
>>
>> I'm a little bit confused as to what kinds of file transfers
>> you think don't have at least two endpoints.
>
>>From some other computer to the one you're controlling it from. A

> download is initiated by the recipient; an upload is initiated by the
> sender.

Nope.  It doesn't depend on who initiated the transfer, up/down is a
direction. I upload things to the Host on the Internet, and I download
things to the circuit board on my bench.  In both cases I initiate the
transaction


   [ Host on The Internet ]
 |
[my computer]
 |
[circuit board I'm working on]  


-- 
Grant Edwards   grant.b.edwardsYow! I invented skydiving
  at   in 1989!
  gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Is Microsoft Windows secretly downloading childporn to your computer ?!

2015-12-02 Thread Grant Edwards
On 2015-12-02, Les Cargill  wrote:
> Juha Nieminen wrote:
>> In comp.lang.c++ Steve Hayes  wrote:
>>> You download things FROM a computer, you upload them TO a computer.
>>
>> It's a matter of perspective. If a hacker breaks into your computer and
>> starts a download from somewhere else into your computer, isn't the hacker
>> "downloading" things to your computer?
>>
>> --- news://freenews.netfront.net/ - complaints: [email protected] ---
>>
>
> Down is towards an end node; up is towards the backbone. Servers live
> closer to the backbone. Usually. Or rather did when the nomenclature
> was forged.

Exactly!  Thats the usage I've been used to for the past 30 years.

-- 
Grant Edwards   grant.b.edwardsYow! I'm pretending that
  at   we're all watching PHIL
  gmail.comSILVERS instead of RICARDO
   MONTALBAN!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Is Microsoft Windows secretly downloading childporn to your computer ?!

2015-12-02 Thread Grant Edwards
On 2015-12-02, Richard Heathfield  wrote:
> On 02/12/15 08:57, Juha Nieminen wrote:
>> In comp.lang.c++ Steve Hayes  wrote:
>>> You download things FROM a computer, you upload them TO a computer.
>>
>> It's a matter of perspective. If a hacker breaks into your computer and
>> starts a download from somewhere else into your computer, isn't the hacker
>> "downloading" things to your computer?
>
> My understanding of the term has always been that you upload from a 
> smaller device to a larger, and download from a larger device to a 
> smaller. Thus, from your laptop you might *up*load data to a Web server 
> or a mainframe, but you would *down*load data to your phone or tablet.

That's sort of the usage I'm used to, but it probably has more to do
with network topology than CPU power.  Servers on the internet are at
the top of the diagram, and embedded devices that can't access the
internet directly are at the bottom with my PC somewhere in the
middle.

-- 
Grant Edwards   grant.b.edwardsYow! Are you still an
  at   ALCOHOLIC?
  gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how to make the below code look better

2015-12-02 Thread me
On 2015-12-02, Ganesh Pal  wrote:
> if not os.path.ismount("/tmp"):
>sys.exit("/tmp not mounted.")
> else:
>  if  create_dataset() and check_permission():
>  try:
>   run_full_back_up()
>   run_partial_back_up()
> except Exception, e:
> logging.error(e)
> sys.exit("Running backup failed")
> if not validation_errors():
> sys.exit("Validation failed")
> else:
> try:
> compare_results()
> except Exception, e:
>logging.error(e)
>sys.exit("Comparing result failed")

Apart from what already mentioned (indentation, assumptions on
environment):

> 1.  if  create_dataset() and check_permission():
> Iam assuming that if statement will be executed only if both the
> functions are true ?

Yes, this is the meaning of 'and'.
Notice how functions are always true, but the result of the function call
might not be.

- create_dataset is a function.
- create_dataset() is a function call.

> 2. Can I have a if statement within  if else ? , some how I feel its messy

You are searching for `elif`.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: regarding download issues from sharepoint site

2015-12-02 Thread me
On 2015-12-02, Arpit Arya  wrote:
> please help me out

http://catb.org/~esr/faqs/smart-questions.html#beprecise
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: static variables

2015-12-02 Thread Antoon Pardon
Op 02-12-15 om 15:15 schreef Ian Kelly:
> On Wed, Dec 2, 2015 at 7:41 AM, Antoon Pardon
>  wrote:
>> Op 02-12-15 om 14:11 schreef Steven D'Aprano:
>>> On Wed, 2 Dec 2015 10:09 pm, Antoon Pardon wrote:
>>>
 If you want your arguments to be taken seriously, then you better should.
 If you use an argument when it suits you and ignore it when it doesn't
 you are showing you don't really have an argument. You are just showing
 your preference and making it sound like an argument.
>>> "A foolish consistency is the hobgoblin of little minds."
>> So? That doesn't show that we are talking about a foolish consistency here.
> It's actually the truest use of the quote that I've yet seen on this
> list. Emerson was complaining about those who adhere to opinions that
> they've expressed in the past solely for the sake of appearing
> consistent in their values, which is basically what you're accusing
> Steven of not doing.

That is not true. I expect that the next time someone will try to
argue for private attributes or some such, Steven will be among
those that will support the "consenting adults" line. This view
of his, is not in the past, it is for all i know still in the
present. That his latest expression was in the past, doesn't make
his view something of the past.

If there was a reason to think he had changed his mind, you would
have been right. But I see no reason for that.

There is a difference between changing your mind and thus change
your arguments and using an argument selectively.

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


Re: Is Microsoft Windows secretly downloading childporn to your computer ?!

2015-12-02 Thread Keith Thompson
Juha Nieminen  writes:
> In comp.lang.c++ Steve Hayes  wrote:
>> You download things FROM a computer, you upload them TO a computer.
>
> It's a matter of perspective. If a hacker breaks into your computer and
> starts a download from somewhere else into your computer, isn't the hacker
> "downloading" things to your computer?

My understanding of the word "downloading" has always been STOP FEEDING
THE TROLL!

-- 
Keith Thompson (The_Other_Keith) [email protected]  
Working, but not speaking, for JetHead Development, Inc.
"We must do something.  This is something.  Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: "Downloading"

2015-12-02 Thread Marko Rauhamaa
Grant Edwards :

> On 2015-12-01, Chris Angelico  wrote:
>> download is initiated by the recipient; an upload is initiated by the
>> sender.
>
> Nope.  It doesn't depend on who initiated the transfer, up/down is a
> direction. I upload things to the Host on the Internet, and I download
> things to the circuit board on my bench.  In both cases I initiate the
> transaction

Forget the ups and downs and just load the file.


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


Re: Is Microsoft Windows secretly downloading childporn to your computer ?!

2015-12-02 Thread Laura Creighton
In a message of Wed, 02 Dec 2015 08:36:24 -0800, Keith Thompson writes:

>"We must do something.  This is something.  Therefore, we must do this."
>-- Antony Jay and Jonathan Lynn, "Yes Minister"

This is one of my favourite quotes of all time.  Unfortunately, you
have it slightly wrong.  The quote is:
Something must be done.  This is something.  Therefore we must do it.

cheers!
Laura

https://www.google.se/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&cad=rja&uact=8&ved=0ahUKEwjZvrXl0L3JAhVmJHIKHTBjCugQtwIIIjAB&url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dtrw1PbQt_Yo&usg=AFQjCNHEKrgju4vVOH_hmwnbn0zAWU0aEg&sig2=VwmILBUKi-vz7YCA5k_0ew

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


Re: Is secretly downloading to your computer ?!

2015-12-02 Thread Rob Hills
On 03/12/15 00:53, Laura Creighton wrote:

> This is one of my favourite quotes of all time.  Unfortunately, you
> have it slightly wrong.  The quote is:
> Something must be done.  This is something.  Therefore we must do it.

I wish people would check their email subjects before replying to this
thread.  I suspect part of the OP's intent is to have his assertion
generate lots of traffic, all repeating the assertion via their subject
heading...

Unless of course you actually agree with his assertion!

Cheers,

-- 
Rob Hills
Waikiki, Western Australia

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


Q4 Quant Coding Competition in Python

2015-12-02 Thread quantiacsllc
$2.25M for the best three trading algos. You pocket 10% of the profits with no 
downside risk. The winner of one of our last competitions made $4,000 in the 
past five weeks with an initial investment of $1M. We provide a free and 
open-source toolbox in Python. It comes with 25 years of financial data. 

Join the Q4: https://quantiacs.com/q4 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Is Microsoft Windows secretly downloading childporn to your computer ?!

2015-12-02 Thread Ian Kelly
On Wed, Dec 2, 2015 at 10:36 AM, Keith Thompson  wrote:
> Juha Nieminen  writes:
>> In comp.lang.c++ Steve Hayes  wrote:
>>> You download things FROM a computer, you upload them TO a computer.
>>
>> It's a matter of perspective. If a hacker breaks into your computer and
>> starts a download from somewhere else into your computer, isn't the hacker
>> "downloading" things to your computer?
>
> My understanding of the word "downloading" has always been STOP FEEDING
> THE TROLL!

In what way is discussion of a tangential topic feeding the troll?
Said troll is not even participating in the discussion.
-- 
https://mail.python.org/mailman/listinfo/python-list


python message

2015-12-02 Thread jorge . conrado



Hi,


I'm a new user of Pyhton and I run my code lenetcdf1.py and I plot the 
figure but I had this message:



/usr/lib64/python2.7/site-packages/matplotlib/collections.py:590: 
FutureWarning: elementwise comparison failed; returning scalar instead, 
but in the future will perform elementwise comparison

  if self._edgecolors == str('face'):

I do not understand this message. Atached it my code.


What can I do to solve this message.

Thanks in advance.


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


Re: Is vars() the most useless Python built-in ever?

2015-12-02 Thread Albert Visser
On Tue, 01 Dec 2015 22:15:08 +0100, Rick Johnson  
 wrote:



On Tuesday, December 1, 2015 at 10:56:27 AM UTC-6, John Gordon wrote:

Rick Johnson writes:
> Your lament does remind me of a pet peeve i have concerning Python,  
and

> that is, the lie about: "THERE SHOULD BE ONE (AND PREFERABLY ONLY ONE)
> WAY TO DO IT!". In fact, in python there is almost always *MANY* ways  
to

> achieve the same output.=20

The koan reads:

There should be one-- and preferably only one --obvious way to do  
it.


You left out the rather important word "obvious".


Indeed you are correct about the wording, but your interpretation is  
wrong.


Mm, not so much. What you're describing is a statement like "There should  
be one way and it should be obvious".


--
Vriendelijke groeten / Kind regards,

Albert Visser

Using Opera's mail client: http://www.opera.com/mail/
--
https://mail.python.org/mailman/listinfo/python-list


Re: python message

2015-12-02 Thread Laura Creighton
In a message of Wed, 02 Dec 2015 15:53:08 -0200, [email protected] wr
ites:
>
>
>
>Hi,
>
>
>I'm a new user of Pyhton and I run my code lenetcdf1.py and I plot the 
>figure but I had this message:
>
>
>/usr/lib64/python2.7/site-packages/matplotlib/collections.py:590: 
>FutureWarning: elementwise comparison failed; returning scalar instead, 
>but in the future will perform elementwise comparison
>   if self._edgecolors == str('face'):
>
>I do not understand this message. Atached it my code.
>
>
>What can I do to solve this message.
>
>Thanks in advance.
>
>
>Conrado

Your code did not get attached, but no matter.
Just ignore this one.
https://github.com/matplotlib/matplotlib/issues/5209

next release of matplotlib should fix it.

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


HELP PLEASE printing single characters!

2015-12-02 Thread Dylan Riley
hi all,
I have been trying to figure out all day why my code is printing single 
characters from my list when i print random elements using random.choice the 
elements in the list are not single characters for example when i print, 
print(LIST[random.choice]) i get:
["e", "x", "a", "m", "p", "l", "e"] when i should get ["example"].

my code is:
#Create a program that prints a list of words in random order.
#The program should print all the words and not repeat any.

import random

LIST = ["blue ", "red ", "yellow ", "green ", "orange "]
order = []

print("This game will print a random order of colours")
print("The list is", LIST)
input("press enter to start")



while LIST != []:
choice = random.choice(LIST)
order += choice
while choice in LIST:
LIST.remove(choice)
print(order)



input("press enter to exit")

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


Re: HELP PLEASE printing single characters!

2015-12-02 Thread Ian Kelly
On Wed, Dec 2, 2015 at 12:58 PM, Dylan Riley  wrote:
> hi all,
> I have been trying to figure out all day why my code is printing single 
> characters from my list when i print random elements using random.choice the 
> elements in the list are not single characters for example when i print, 
> print(LIST[random.choice]) i get:
> ["e", "x", "a", "m", "p", "l", "e"] when i should get ["example"].

Remember that strings are iterable, and that iterating over strings
results in individual characters. That should give you a clue as to
what's going on.

> my code is:
> #Create a program that prints a list of words in random order.
> #The program should print all the words and not repeat any.
>
> import random
>
> LIST = ["blue ", "red ", "yellow ", "green ", "orange "]
> order = []
>
> print("This game will print a random order of colours")
> print("The list is", LIST)
> input("press enter to start")
>
>
>
> while LIST != []:
> choice = random.choice(LIST)
> order += choice

Addition on a list does concatenation, not appending. So this takes
each element from choice and adds them individually to order.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: HELP PLEASE printing single characters!

2015-12-02 Thread Dylan Riley
On Wednesday, December 2, 2015 at 7:09:23 PM UTC, Ian wrote:
> On Wed, Dec 2, 2015 at 12:58 PM, Dylan Riley  wrote:
> > hi all,
> > I have been trying to figure out all day why my code is printing single 
> > characters from my list when i print random elements using random.choice 
> > the elements in the list are not single characters for example when i 
> > print, print(LIST[random.choice]) i get:
> > ["e", "x", "a", "m", "p", "l", "e"] when i should get ["example"].
> 
> Remember that strings are iterable, and that iterating over strings
> results in individual characters. That should give you a clue as to
> what's going on.
> 
> > my code is:
> > #Create a program that prints a list of words in random order.
> > #The program should print all the words and not repeat any.
> >
> > import random
> >
> > LIST = ["blue ", "red ", "yellow ", "green ", "orange "]
> > order = []
> >
> > print("This game will print a random order of colours")
> > print("The list is", LIST)
> > input("press enter to start")
> >
> >
> >
> > while LIST != []:
> > choice = random.choice(LIST)
> > order += choice
> 
> Addition on a list does concatenation, not appending. So this takes
> each element from choice and adds them individually to order.

hi ian what would be the correct code to use in this situation then because as 
far as i am aware the elements of my list should be printed as whole elements 
and not just characters of the elements.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: "Downloading"

2015-12-02 Thread Emile van Sebille

On 12/2/2015 8:37 AM, Marko Rauhamaa wrote:

Grant Edwards :


On 2015-12-01, Chris Angelico  wrote:

download is initiated by the recipient; an upload is initiated by the
sender.


Nope.  It doesn't depend on who initiated the transfer, up/down is a
direction. I upload things to the Host on the Internet, and I download
things to the circuit board on my bench.  In both cases I initiate the
transaction


Forget the ups and downs and just load the file.



Nowadays I suspect push and pull are better terms.

Emile



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


Re: HELP PLEASE printing single characters!

2015-12-02 Thread Ian Kelly
On Wed, Dec 2, 2015 at 1:44 PM, Dylan Riley  wrote:
> hi ian what would be the correct code to use in this situation then because 
> as far as i am aware the elements of my list should be printed as whole 
> elements and not just characters of the elements.

order.append(choice)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: static variables

2015-12-02 Thread Ian Kelly
On Wed, Dec 2, 2015 at 9:30 AM, Antoon Pardon
 wrote:
> Op 02-12-15 om 15:15 schreef Ian Kelly:
>> On Wed, Dec 2, 2015 at 7:41 AM, Antoon Pardon
>>  wrote:
>>> Op 02-12-15 om 14:11 schreef Steven D'Aprano:
 On Wed, 2 Dec 2015 10:09 pm, Antoon Pardon wrote:

> If you want your arguments to be taken seriously, then you better should.
> If you use an argument when it suits you and ignore it when it doesn't
> you are showing you don't really have an argument. You are just showing
> your preference and making it sound like an argument.
 "A foolish consistency is the hobgoblin of little minds."
>>> So? That doesn't show that we are talking about a foolish consistency here.
>> It's actually the truest use of the quote that I've yet seen on this
>> list. Emerson was complaining about those who adhere to opinions that
>> they've expressed in the past solely for the sake of appearing
>> consistent in their values, which is basically what you're accusing
>> Steven of not doing.
>
> That is not true. I expect that the next time someone will try to
> argue for private attributes or some such, Steven will be among
> those that will support the "consenting adults" line. This view
> of his, is not in the past, it is for all i know still in the
> present. That his latest expression was in the past, doesn't make
> his view something of the past.
>
> If there was a reason to think he had changed his mind, you would
> have been right. But I see no reason for that.
>
> There is a difference between changing your mind and thus change
> your arguments and using an argument selectively.

A person can hold one opinion in some contexts and an opposing opinion
in others.

"Speak what you think now in hard words, and to-morrow speak what
to-morrow thinks in hard words again, though it contradict every thing
you said to-day."

"There will be an agreement in whatever variety of actions, so they be
each honest and natural in their hour. For of one will, the actions
will be harmonious, however unlike they seem. These varieties are lost
sight of at a little distance, at a little height of thought. One
tendency unites them all. The voyage of the best ship is a zigzag line
of a hundred tacks. See the line from a sufficient distance, and it
straightens itself to the average tendency. Your genuine action will
explain itself, and will explain your other genuine actions. Your
conformity explains nothing. Act singly, and what you have already
done singly will justify you now."
-- 
https://mail.python.org/mailman/listinfo/python-list


Question about split method

2015-12-02 Thread Robert
Hi,

I learn split method online. When I try to run the line with ss1 beginning,
I don't understand why its output of ss1 and ss2. I have check the help
about split. It looks like that it is a numpy method.
What is the split method parameter (within "  ") for?


Thanks,



...
ss0="1, 2, 4, 8, 16".split(", ")

ss0
Out[2]: ['1', '2', '4', '8', '16']

ss1="1, 2, 4, 8, 16".split(", ")

ss1
Out[4]: ['1, 2, 4, 8, 16']

ss2="1, 2, 4, 8, 16".split(",   ")

ss2
Out[9]: ['1, 2, 4, 8, 16']

help(split)
Help on function split in module numpy.lib.shape_base:
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question about split method

2015-12-02 Thread Ian Kelly
On Wed, Dec 2, 2015 at 2:37 PM, Robert  wrote:
> Hi,
>
> I learn split method online. When I try to run the line with ss1 beginning,
> I don't understand why its output of ss1 and ss2. I have check the help
> about split. It looks like that it is a numpy method.
> What is the split method parameter (within "  ") for?
>
>
> Thanks,
>
>
>
> ...
> ss0="1, 2, 4, 8, 16".split(", ")
>
> ss0
> Out[2]: ['1', '2', '4', '8', '16']
>
> ss1="1, 2, 4, 8, 16".split(", ")
>
> ss1
> Out[4]: ['1, 2, 4, 8, 16']
>
> ss2="1, 2, 4, 8, 16".split(",   ")
>
> ss2
> Out[9]: ['1, 2, 4, 8, 16']
>
> help(split)
> Help on function split in module numpy.lib.shape_base:

That's just some random function that you've imported into globals by
doing "from numpy import *" or some such. What you're calling in these
examples is a string method, not a global function.

Try help(str.split)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question about split method

2015-12-02 Thread Robert
On Wednesday, December 2, 2015 at 3:45:34 PM UTC-5, Ian wrote:
> On Wed, Dec 2, 2015 at 2:37 PM, Robert  wrote:
> > Hi,
> >
> > I learn split method online. When I try to run the line with ss1 beginning,
> > I don't understand why its output of ss1 and ss2. I have check the help
> > about split. It looks like that it is a numpy method.
> > What is the split method parameter (within "  ") for?
> >
> >
> > Thanks,
> >
> >
> >
> > ...
> > ss0="1, 2, 4, 8, 16".split(", ")
> >
> > ss0
> > Out[2]: ['1', '2', '4', '8', '16']
> >
> > ss1="1, 2, 4, 8, 16".split(", ")
> >
> > ss1
> > Out[4]: ['1, 2, 4, 8, 16']
> >
> > ss2="1, 2, 4, 8, 16".split(",   ")
> >
> > ss2
> > Out[9]: ['1, 2, 4, 8, 16']
> >
> > help(split)
> > Help on function split in module numpy.lib.shape_base:
> 
> That's just some random function that you've imported into globals by
> doing "from numpy import *" or some such. What you're calling in these
> examples is a string method, not a global function.
> 
> Try help(str.split)

Thanks. I didn't know numpy has been automatically imported, not by me.
And your demo line code is helpful.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: stuff and nonsense

2015-12-02 Thread Denis McMahon
On Wed, 02 Dec 2015 11:32:25 -0600, Ian Kelly wrote:

> In what way is discussion of a tangential topic feeding the troll? Said
> troll is not even participating in the discussion.

Reposting / responding / following up with the original subject boosts 
the visibility of the subject to internet search engines because of the 
way newsgroups get gated to websites.

-- 
Denis McMahon, [email protected]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3.5.0: python.exe is not a valid Windows 32 application

2015-12-02 Thread blackwingcat2000
Hi.

https://mail.python.org/pipermail/python-dev/2015-July/140823.html
Python 3.5 was dropped the support Windows XP and 2003.



It's just an aside, but Python 3.5.1 works on my customized Windows 2000 :P
http://blog.livedoor.jp/blackwingcat/archives/1917281.html
-- 
https://mail.python.org/mailman/listinfo/python-list


Subclassing tuple and introspection

2015-12-02 Thread Joseph L. Casale
I need to return a collection of various types, since python doesn't
have the terse facility of extension methods like C#, subclassing tuple
and adding a method seems like a terse way to accommodate this.

However, if the method returns one element of the collection, how can
one enable introspection for users of IDE's that the resulting reference
is of type A, and therefor has A's fields?

For example:
col = (Class(..), Class(...))
item = col[0]

Introspection will now enumerate item as an instance of Class, providing
its fields. The subclass of tuple breaks this. 

Is there a better way to do this?

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


Re: Python 3.5.0: python.exe is not a valid Windows 32 application

2015-12-02 Thread Ian Kelly
On Wed, Dec 2, 2015 at 4:09 PM,   wrote:
> Hi.
>
> https://mail.python.org/pipermail/python-dev/2015-July/140823.html
> Python 3.5 was dropped the support Windows XP and 2003.
>
>
>
> It's just an aside, but Python 3.5.1 works on my customized Windows 2000 :P
> http://blog.livedoor.jp/blackwingcat/archives/1917281.html

You may be able to get it to run, but as it is unsupported there may
be features that are broken but not immediately obviously so and will
not be fixed if they are.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Subclassing tuple and introspection

2015-12-02 Thread Ian Kelly
On Wed, Dec 2, 2015 at 4:32 PM, Joseph L. Casale
 wrote:
> I need to return a collection of various types, since python doesn't
> have the terse facility of extension methods like C#, subclassing tuple
> and adding a method seems like a terse way to accommodate this.

If you're not already familiar with collections.namedtuple, have a
look at it, as it sounds like just naming the fields may be all that
you need. You can also subclass it further to add methods if desired.

> However, if the method returns one element of the collection, how can
> one enable introspection for users of IDE's that the resulting reference
> is of type A, and therefor has A's fields?
>
> For example:
> col = (Class(..), Class(...))
> item = col[0]
>
> Introspection will now enumerate item as an instance of Class, providing
> its fields. The subclass of tuple breaks this.
>
> Is there a better way to do this?

I think that's going to depend heavily on the specific IDE being used,
but for general usage you might consider using PEP 484 type
annotations; I know that at least PyCharm supports their use for type
hinting.
-- 
https://mail.python.org/mailman/listinfo/python-list


Does Python 2.7 do Open Office

2015-12-02 Thread Seymore4Head
I have a text file I would like to search through but I have tried it
before.  I don't remember why they are not compatible together, but I
wanted to ask to make sure.

I know I can convert the file to plain text but it would be nice not
to have to do that.

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


Re: Subclassing tuple and introspection

2015-12-02 Thread Joseph L. Casale
> If you're not already familiar with collections.namedtuple, have a
> look at it, as it sounds like just naming the fields may be all that
> you need. You can also subclass it further to add methods if desired.

Yeah, all the types in these collections are named tuples... The collection
itself isn't applicable, think of a simple list/tuple.

> I think that's going to depend heavily on the specific IDE being used,
> but for general usage you might consider using PEP 484 type
> annotations; I know that at least PyCharm supports their use for type
> hinting.

The guys here use PyCharm, where it becomes less than describable is
I have to make a distinct instance of the subclass for each use by each
namedtuple instance and generate doc strings that return those types
for the helper methods.

This is auto XSLT auto generated code, so I am not worried about the
overhead maintaining it, I just didn't want to have to do that if there
was a way to prime the type hinting by "properly" subclassing tuple
for example.

Thanks for the feedback.
jlc
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: HELP PLEASE printing single characters!

2015-12-02 Thread John Strick
On Wednesday, December 2, 2015 at 12:58:30 PM UTC-6, Dylan Riley wrote:
> hi all,
> I have been trying to figure out all day why my code is printing single 
> characters from my list when i print random elements using random.choice the 
> elements in the list are not single characters for example when i print, 
> print(LIST[random.choice]) i get:
> ["e", "x", "a", "m", "p", "l", "e"] when i should get ["example"].
> 
> my code is:
> #Create a program that prints a list of words in random order.
> #The program should print all the words and not repeat any.
> 
> import random
> 
> LIST = ["blue ", "red ", "yellow ", "green ", "orange "]
> order = []
> 
> print("This game will print a random order of colours")
> print("The list is", LIST)
> input("press enter to start")
> 
> 
> 
> while LIST != []:
> choice = random.choice(LIST)
> order += choice
> while choice in LIST:
> LIST.remove(choice)
> print(order)
> 
> 
> 
> input("press enter to exit")
> 
> thanks in advance guys

You could just shuffle the list first, then loop through it. This will 
guarantee that each color is only used once. 

import random
LIST = ["blue ", "red ", "yellow ", "green ", "orange "]
random.shuffle(LIST)
for color in LIST:
print(color)
# or add to order or whatever you need to

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


Re: stuff and nonsense

2015-12-02 Thread Laura Creighton
In a message of Wed, 02 Dec 2015 22:51:13 +, Denis McMahon writes:
>On Wed, 02 Dec 2015 11:32:25 -0600, Ian Kelly wrote:
>
>> In what way is discussion of a tangential topic feeding the troll? Said
>> troll is not even participating in the discussion.
>
>Reposting / responding / following up with the original subject boosts 
>the visibility of the subject to internet search engines because of the 
>way newsgroups get gated to websites.
>
>-- 
>Denis McMahon, [email protected]

That is not what I was told.  I was told that these days it is all
done by References: lines.  Thus changing the Subject no longer has
this effect.  Wrong?

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


Re: Does Python 2.7 do Open Office

2015-12-02 Thread MRAB

On 2015-12-02 23:50, Seymore4Head wrote:

I have a text file I would like to search through but I have tried it
before.  I don't remember why they are not compatible together, but I
wanted to ask to make sure.

I know I can convert the file to plain text but it would be nice not
to have to do that.


A quick search found this:

https://wiki.openoffice.org/wiki/Python

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


Re: Does Python 2.7 do Open Office

2015-12-02 Thread Laura Creighton
In a message of Wed, 02 Dec 2015 18:50:34 -0500, Seymore4Head writes:
>I have a text file I would like to search through but I have tried it
>before.  I don't remember why they are not compatible together, but I
>wanted to ask to make sure.
>
>I know I can convert the file to plain text but it would be nice not
>to have to do that.
>
>-- 
>https://mail.python.org/mailman/listinfo/python-list

You are looking for PyUNO.Unfortuntately it is not well
documented, but I have heard good things about this as documentation.
https://documenthacker.wordpress.com/2013/03/05/first-draft-released/

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


Re: stuff and nonsense

2015-12-02 Thread Denis McMahon
On Thu, 03 Dec 2015 01:46:44 +0100, Laura Creighton wrote:

> In a message of Wed, 02 Dec 2015 22:51:13 +, Denis McMahon writes:
>>On Wed, 02 Dec 2015 11:32:25 -0600, Ian Kelly wrote:
>>
>>> In what way is discussion of a tangential topic feeding the troll?
>>> Said troll is not even participating in the discussion.
>>
>>Reposting / responding / following up with the original subject boosts
>>the visibility of the subject to internet search engines because of the
>>way newsgroups get gated to websites.

> That is not what I was told.  I was told that these days it is all done
> by References: lines.  Thus changing the Subject no longer has this
> effect.  Wrong?

Hmm, not sure on that bone, I heard that more instances of a phrase being 
found (eg in forums where a web page includes the subject in each 
message) helped increase the visibility of the phrase in some way, but I 
don't profess to understand how search engines score stuff, and I'm 
fairly sure few people do to be honest.

And what I heard might no longer be true if it ever was to be honest.

-- 
Denis McMahon, [email protected]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Is Microsoft Windows secretly downloading childporn to your computer ?!

2015-12-02 Thread Steve Hayes
On Wed, 2 Dec 2015 15:20:13 + (UTC), Grant Edwards
 wrote:

>On 2015-12-02, Richard Heathfield  wrote:
>> On 02/12/15 08:57, Juha Nieminen wrote:
>>> In comp.lang.c++ Steve Hayes  wrote:
 You download things FROM a computer, you upload them TO a computer.
>>>
>>> It's a matter of perspective. If a hacker breaks into your computer and
>>> starts a download from somewhere else into your computer, isn't the hacker
>>> "downloading" things to your computer?
>>
>> My understanding of the term has always been that you upload from a 
>> smaller device to a larger, and download from a larger device to a 
>> smaller. Thus, from your laptop you might *up*load data to a Web server 
>> or a mainframe, but you would *down*load data to your phone or tablet.
>
>That's sort of the usage I'm used to, but it probably has more to do
>with network topology than CPU power.  Servers on the internet are at
>the top of the diagram, and embedded devices that can't access the
>internet directly are at the bottom with my PC somewhere in the
>middle.

In my usage it all has to do with sending and receiving, like
immigration and emigration. 

I UPload photos from my cell phone to Facebook. 

I DOWNload photos from my cell phone to my desktop computer. 


-- 
Steve Hayes from Tshwane, South Africa
Web:  http://www.khanya.org.za/stevesig.htm
Blog: http://khanya.wordpress.com
E-mail - see web page, or parse: shayes at dunelm full stop org full stop uk
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Is Microsoft Windows secretly downloading childporn to your computer ?!

2015-12-02 Thread Steve Hayes
On Thu, 03 Dec 2015 06:21:45 +0200, Steve Hayes
 wrote:

>On Wed, 2 Dec 2015 15:20:13 + (UTC), Grant Edwards
> wrote:
>
>>On 2015-12-02, Richard Heathfield  wrote:
>>> On 02/12/15 08:57, Juha Nieminen wrote:
 In comp.lang.c++ Steve Hayes  wrote:
> You download things FROM a computer, you upload them TO a computer.

 It's a matter of perspective. If a hacker breaks into your computer and
 starts a download from somewhere else into your computer, isn't the hacker
 "downloading" things to your computer?
>>>
>>> My understanding of the term has always been that you upload from a 
>>> smaller device to a larger, and download from a larger device to a 
>>> smaller. Thus, from your laptop you might *up*load data to a Web server 
>>> or a mainframe, but you would *down*load data to your phone or tablet.
>>
>>That's sort of the usage I'm used to, but it probably has more to do
>>with network topology than CPU power.  Servers on the internet are at
>>the top of the diagram, and embedded devices that can't access the
>>internet directly are at the bottom with my PC somewhere in the
>>middle.
>
>In my usage it all has to do with sending and receiving, like
>immigration and emigration. 
>
>I UPload photos from my cell phone to Facebook. 
>
>I DOWNload photos from my cell phone to my desktop computer. 

To which I will add that uploading is sending, and downloading is
fetching.

So saying that Microsoft downloaded something to my computer is like
saying that someone fetched me a ltter when they actually sent it. 


-- 
Steve Hayes from Tshwane, South Africa
Web:  http://www.khanya.org.za/stevesig.htm
Blog: http://khanya.wordpress.com
E-mail - see web page, or parse: shayes at dunelm full stop org full stop uk
-- 
https://mail.python.org/mailman/listinfo/python-list


filter a list of strings

2015-12-02 Thread c.buhtz
I would like to know how this could be done more elegant/pythonic.

I have a big list (over 10.000 items) with strings (each 100 to 300
chars long) and want to filter them.

list = .

for item in list[:]:
  if 'Banana' in item:
 list.remove(item)
  if 'Car' in item:
 list.remove(item)

There are a lot of more conditions of course. This is just example code.
It doesn't look nice to me. To much redundance.

btw: Is it correct to iterate over a copy (list[:]) of that string list
and not the original one?
-- 
GnuPGP-Key ID 0751A8EC
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how to make the below code look better

2015-12-02 Thread Ganesh Pal
On Wed, Dec 2, 2015 at 6:00 PM, Chris Angelico  wrote:
> If both the functions return true values, yes. You have an indentation
> error there, but I'm assuming you meant to have the try/except
> indented further.
>

Correct I had meant to have try/except indented further.

>> 2. Can I have a if statement within  if else ? , some how I feel its messy
>
> Certainly you can! However, most (maybe all) of your 'if' statements
> are checking for error conditions, so the easiest solution is to
> simply exit right away (either with sys.exit or by raising an
> exception).

Yes agreed , have included the suggestion

>> 3.  Any other suggestion ? please
>
> The first suggestion I'd make is to avoid the comma syntax for
> exception handling. Replace "except Exception, e:" with "except
> Exception as e:". That's a trivial change of syntax that shouldn't
> affect your code at all; consider it low-hanging fruit.
>
,Are we avoiding  comma syntax because it's a bad convention  or  will
it have any side effects? In fact I have used this comma syntax in
most of my code . I will clean the code latter as it seems working
fine

> The second thing to look at is the way you're 'handling' those errors.
> All you do is log the error and exit. So you can skip the except
> clauses altogether, and just do this:
>
> if not os.path.ismount("/tmp"):
>  sys.exit("/tmp not mounted.")
> if create_dataset() and check_permission():
> run_full_back_up()
> run_partial_back_up()
> if not validation_errors(): # CHECK ME
> sys.exit("Validation failed")
> compare_results()
>
>

Agreed.

> Check the logic of validation_errors, though. If it returns something
> True, does that mean there were errors or there weren't? If it means
> there were errors, then the 'not' seems to me to be wrong; but if it
> means there weren't, then I would rename it "validation_successful"
> rather than "validation_errors".
>
> Also worth checking: If you can't create the data set or the
> permission check fails, what should it do? Should it terminate with an
> error? Currently, it carries on and does the validation, which is
> probably not right. If it ought to terminate straight away, you can
> write the whole program in "fail and bail" style:
>
> if not create_dataset():
> sys.exit("Data set creation failed")
> if not check_permission():
> sys.exit("Permission check failed")
>

Thanks for other suggestions also
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how to make the below code look better

2015-12-02 Thread Chris Angelico
On Thu, Dec 3, 2015 at 5:20 PM, Ganesh Pal  wrote:
>> The first suggestion I'd make is to avoid the comma syntax for
>> exception handling. Replace "except Exception, e:" with "except
>> Exception as e:". That's a trivial change of syntax that shouldn't
>> affect your code at all; consider it low-hanging fruit.
>>
> ,Are we avoiding  comma syntax because it's a bad convention  or  will
> it have any side effects? In fact I have used this comma syntax in
> most of my code . I will clean the code latter as it seems working
> fine
>

The comma syntax isn't supported in Python 3, so it'll be a barrier to
migration. It's also a bit less clear if you catch multiple exception
types in a single handler, which also uses a comma (to make a tuple).
Also, the 'as' syntax matches up with similar syntax for 'with' and
'import' statements.

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


Re: Is Microsoft Windows secretly downloading childporn to your computer ?!

2015-12-02 Thread Chris in Makati
On Wed, 2 Dec 2015 08:57:44 + (UTC), Juha Nieminen
 wrote:

>In comp.lang.c++ Steve Hayes  wrote:
>> You download things FROM a computer, you upload them TO a computer.
>
>It's a matter of perspective. If a hacker breaks into your computer and
>starts a download from somewhere else into your computer, isn't the hacker
>"downloading" things to your computer?

Does it matter? As far as the law is concerned, it is possession of
child porn that's illegal. How it got there is irrelevant.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: filter a list of strings

2015-12-02 Thread Jussi Piitulainen
 writes:

> I would like to know how this could be done more elegant/pythonic.
>
> I have a big list (over 10.000 items) with strings (each 100 to 300
> chars long) and want to filter them.
>
> list = .
>
> for item in list[:]:
>   if 'Banana' in item:
>  list.remove(item)
>   if 'Car' in item:
>  list.remove(item)
>
> There are a lot of more conditions of course. This is just example
> code.  It doesn't look nice to me. To much redundance.

Yes. The initial copy is redundant and the repeated .remove calls are
not only expensive (quadratic time loop that could have been linear),
they are also incorrect if there are duplicates in the list. You want to
copy and filter in one go:

list = ...
list = [ item for item in list
 if ( 'Banana' not in item and
  'Car' not in item ) ]

It's better to use another name, since "list" is the name of a built-in
function. It may be a good idea to define a complex condition as a
separate function:

def isbad(item):
return ( 'Banana' in item or
 'Car' in item )

def isgood(item)
return not isbad(item)

items = ...
items = [ item for item in items if isgood(item) ]

Then there's also filter, which is easy to use now that the condition is
already a named function:

items = list(filter(isgood, items))

> btw: Is it correct to iterate over a copy (list[:]) of that string
> list and not the original one?

I think it's a good idea to iterate over a copy if you are modifying the
original during the iteration, but the above suggestions are better for
other reasons.
-- 
https://mail.python.org/mailman/listinfo/python-list


storing test logs under /var/log/

2015-12-02 Thread Ganesh Pal
Hi Team ,


I would need few tips  from your past  experiences on  how  to store
the test logs


My requirement is to capture log under /var/log/  directory every time
the test is run .  The test will create one small log files  which are
around 1KB in size .


Here is how I plan to approach this , create directory based on
current timesamp and store the logs in it .


Sample code :

time_now = datetime.datetime.now().strftime('%Y-%m-%d_%H-%M-%S') + "/"
LOG_DIR = ""  +  time_now

 try:
 retcode = os.makedirs(LOG_DIR)
 if retcode:
 raise Exception(
 "Faild to create log directory. mkdir %s failed !!!"
 % LOG_DIR)
except Exception, e:
sys.exit("Failed to create log directory...Exiting !!!")


1.  Do  I need to add the cleanup code  to remove the  log directory
say  /var/log/test_log/2015-11-25_04-07-48/   , because we might have
many more directories like this when test are run multiple times , Iam
avoiding because  the test will be  run

 2/3 times max and file sizes are also very small

2. Any better suggestion for my use case.


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


'string.join' is wrong in my Python console

2015-12-02 Thread Robert
Hi,

I read the tutorial on "Why is join() a string method instead of a list
 or tuple method?"
at link:
https://docs.python.org/2/faq/design.html#why-must-self-be-used-explicitly-in-method-definitions-and-calls

I have a problem on running the last line:
---
If none of these arguments persuade you, then for the moment you can
 continue to use the join() function from the string module, which allows
 you to write

string.join(['1', '2', '4', '8', '16'], ", ")
---

My Python console is 2.7. It should be no problem because I see the tutorial
is 2.7 too.

The console has these display:

string.join(['1', '2', '4', '8', '16'], ", ")
---
NameError Traceback (most recent call last)
 in ()
> 1 string.join(['1', '2', '4', '8', '16'], ", ")

NameError: name 'string' is not defined 


>From the context, I don't see string should be replaced by something else.

Could you tell me why I have such an error?


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


Re: regarding download issues from sharepoint site

2015-12-02 Thread dieter
Arpit Arya  writes:

> i am facing problem downloading files from sharepoint site and to display
> it on my web portal.

Your sentence above mentions to processes "downloading" and "displaying".
Which of the two gives you problems?

For the one with the problems, you must describe it in detail:
how the problem manisfests itself; which components (if possible, which
versions thereof) are involved; what you tried in detail; ...

>i have used requests_ntlm module which gives
> successful authorisation but i am stuck in next step i.e. to download data
> from sharepoint site and dispaly on portal. please help me out

Again the "and". Where is the problem: in the "downloading" or in the
"displaying" (likely the "downloading").

How does it fail (for the "downloading": which response code do you get
for the downloading)?

How did you try it (for downloading: with a browser or from the portal
backend)?

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


Re: 'string.join' is wrong in my Python console

2015-12-02 Thread dieter
Robert  writes:

> I read the tutorial on "Why is join() a string method instead of a list
>  or tuple method?"
> at link:
> https://docs.python.org/2/faq/design.html#why-must-self-be-used-explicitly-in-method-definitions-and-calls
>
> I have a problem on running the last line:
> ---
> If none of these arguments persuade you, then for the moment you can
>  continue to use the join() function from the string module, which allows
>  you to write
>
> string.join(['1', '2', '4', '8', '16'], ", ")
> ---
>
> My Python console is 2.7. It should be no problem because I see the tutorial
> is 2.7 too.
>
> The console has these display:
>
> string.join(['1', '2', '4', '8', '16'], ", ")
> ---
> NameError Traceback (most recent call last)
>  in ()
> > 1 string.join(['1', '2', '4', '8', '16'], ", ")
>
> NameError: name 'string' is not defined 

You need to import the "string" module before you can use it.

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