Re: datetime question

2013-11-10 Thread Gene Heskett
On Saturday 09 November 2013 19:52:52 Chris Angelico did opine:

> On Sun, Nov 10, 2013 at 2:39 AM, Gene Heskett  wrote:
> > Ya know, folks like Nick would have me signing off.  Fortunately there
> > are kill files. But the backscatter he creates I am still forced to
> > read, or more usually skip.
> > 
> > Then one of you frustrated standup comics comes along, and gives me a
> > VBG, and its suddenly all worth it.  Thank You Chris.
> :
> :) Don't just thank me, Grant and Roy were key to it too - and the
> 
> whole "there's no shortage of newlines" thing started with Steven
> D'Aprano (I think), and it's a ripe field for harvest :)

And likely not fully gleaned yet. :)  To all of you, thats some of the 
better creative writing I've read in my 79 years.  ;-)
 
> But hey. If you're going to have to read backscatter, may as well make
> it funny...

Precisely.
 
> ChrisA


Cheers, Gene
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)

A Difficulty for Every Solution.
-- Motto of the Federal Civil Service
A pen in the hand of this president is far more
dangerous than 200 million guns in the hands of
 law-abiding citizens.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-10 Thread ishish

Am 09.11.2013 15:07, schrieb Steven D'Aprano:
...

Nikos, you have annoyed and alienated enough people here...


Sorry, I DO NOT AGREE! These threads keep my entire office entertained. 
I would even go so far to suggest, that we should set up an entirely new 
mailing list for Nikos only, maybe something called like 
acropolis-list(at)python.org.


Mea culpa, I am entirely aware that this is an IT list, but hey, when 
you have done 2x65ish hrs per week in a row - standing in for our Ops 
Guy, holidaying - you really start to appreciating little interruptions 
like this...


Greekings ...oops, meant greetings from Tartan-Land,

Sas&Co
--
https://mail.python.org/mailman/listinfo/python-list


Re: chunking a long string?

2013-11-10 Thread Chris Angelico
On Sun, Nov 10, 2013 at 5:39 PM, Steven D'Aprano
 wrote:
> On Sun, 10 Nov 2013 09:14:28 +1100, Chris Angelico wrote:
>
>> And
>> as is typical of python-list, it's this extremely minor point that
>> became the new course of the thread -
>
> You say that as if it were a bad thing :-P

More a curiosity than a bad thing.

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


Re: datetime question

2013-11-10 Thread Chris Angelico
On Sun, Nov 10, 2013 at 11:55 AM, Gene Heskett  wrote:
> On Saturday 09 November 2013 19:52:52 Chris Angelico did opine:
>> :) Don't just thank me, Grant and Roy were key to it too - and the
>> whole "there's no shortage of newlines" thing started with Steven
>> D'Aprano (I think), and it's a ripe field for harvest :)
>
> And likely not fully gleaned yet. :)  To all of you, thats some of the
> better creative writing I've read in my 79 years.  ;-)

Are you going to have a newyear after next year and start over with
Year 1 again?

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


Re: New user's initial thoughts / criticisms of Python

2013-11-10 Thread Jorgen Grahn
On Sat, 2013-11-09, Chris Angelico wrote:
> On Sun, Nov 10, 2013 at 12:08 AM, John von Horn  wrote:
...
>> * Why not allow floater=float(int1/int2) - rather than floater=float
>> (int1)/float(int2)?
>>
>> Give me a float (or an error message) from evaluating everything in the
>> brackets. Don't make me explicitly convert everything myself (unless I
>> want to)
>
> As others have said, what you're asking for is actually magic. One of
> the rules of Python - one for which I'm not aware of any exceptions -
> is that you can always take a subexpression out and give it a new
> name:

And it's not just Python: programming languages have been designed
that way since at least the 1960s.  People are used to analysing
expressions inside and out according to rules common for almost all
languages.

/Jorgen

-- 
  // Jorgen GrahnO  o   .
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Languages for different purposes (was Re: New user's initial thoughts / criticisms of Python)

2013-11-10 Thread Jorgen Grahn
On Sun, 2013-11-10, Chris Angelico wrote:
> On Sun, Nov 10, 2013 at 11:41 AM, Roy Smith  wrote:
>> On 09/11/2013 22:58, Chris Angelico wrote:
>>> >
>>> > * Some languages are just fundamentally bad. I do not recommend ever
>>> > writing production code in Whitespace, Ook, or Piet.
>>
>> One of the worst coding experiences I ever had was trying to build an
>> app for a Roku media player.  They have a home-grown language called
>> BrightScript.  Barf.
>
> And this is exactly why I was so strongly against the notion of
> developing an in-house scripting language. It may be a lot of work to
> evaluate Lua, Python, JavaScript, and whatever others we wanted to
> try, but it's a *lot* less work than making a new language that
> actually is worth using.

Yes.  I am baffled that people insist on doing the latter. Designing a
limited /data/ language is often a good idea; designing something
which eventually will need to become Turing-complete is not.

/Jorgen

-- 
  // Jorgen GrahnO  o   .
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: my favorite line of py code so far

2013-11-10 Thread Peter Cacioppi
Chris said :

"I think map is fine if you can use a named function, but if you can't
come up with a descriptive name for what you're doing, a comprehension
is probably better (as it'll have the code right there). Mapping _
across everything tells you nothing about what it's actually doing"

OK, this makes a lot of sense. (Any my apologies to Peter Otten if my previous 
post was overly snarky).

How about this? I put the following in my catchall_utility.py module

  # the oneArg combinator takes a multi-argument calleable
  # and returns the equivalent single argument calleable
  oneArg = lambda c: lambda x : c(*x)


With example code

  map(oneArg(P), zip([1,2,3], [6, 5, 4]))

To my mind the idea that oneArg(P) is a calleble that behaves exactly like P, 
with the only difference being oneArg(P) accepts P's arguments packed into a 
single iterable, is very intuitive.

I actually find the oneArg version more readable than the comprehension that 
unpacks explicitly using *. At this point I probably have equal experience 
coding Lisp and Py, with the latter more recent, so I don't think this bias can 
be chalked up to "experienced functional programmer, beginner py programmer".

To be clear, I was never really intending to keep the

  _ = lambda c : lambda x : c(*x)
  map(oneArg(P), zip([1,2,3], [6, 5, 4]))

code snippets in my final work product. The purpose of this thread was too fish 
around for ideas on what to replace it with when I execute the "use the unit 
tests to facilitate refactoring for better names and more professional idioms" 
step.

(We never, ever, skip that step, right?)

Although it is unlikely you will convince me to use the comprehension in this 
sort of situation, it's possible someone could convince me to use starmap with 
P instead of map with oneArg(P). Those two techniques are fully equivalent. 
But, to my mind, the latter just feels right, and I find that I write fewer 
bugs when I use idioms that resonate.

Thanks again, good thread for me
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: my favorite line of py code so far

2013-11-10 Thread Peter Cacioppi
Sorry, typo, meant to say

To be clear, I was never really intending to keep the

  _ = lambda c : lambda x : c(*x)
  map(_(P), zip([1,2,3], [6, 5, 4]))

code snippets in my final work product. The purpose of this thread was too fish 
around for ideas on what to replace it with... 
 

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


Re: New user's initial thoughts / criticisms of Python

2013-11-10 Thread Chris Angelico
On Sun, Nov 10, 2013 at 7:47 PM, Jorgen Grahn  wrote:
> On Sat, 2013-11-09, Chris Angelico wrote:
>> On Sun, Nov 10, 2013 at 12:08 AM, John von Horn  wrote:
> ...
>>> * Why not allow floater=float(int1/int2) - rather than floater=float
>>> (int1)/float(int2)?
>>>
>>> Give me a float (or an error message) from evaluating everything in the
>>> brackets. Don't make me explicitly convert everything myself (unless I
>>> want to)
>>
>> As others have said, what you're asking for is actually magic. One of
>> the rules of Python - one for which I'm not aware of any exceptions -
>> is that you can always take a subexpression out and give it a new
>> name:
>
> And it's not just Python: programming languages have been designed
> that way since at least the 1960s.  People are used to analysing
> expressions inside and out according to rules common for almost all
> languages.

That's true to at least some extent, but quite a few languages have
differences here and there. In C, there's no such thing as an array
literal, only an initializer list, so:

/* This works: */
int month_days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int this_month_days = month_days[this_month];

/* This doesn't: */
int three = {1, 2, 3, 4, 5}[2];

PHP had similar issues up until a *very* recent version (5.3 or 5.4 or
something), where you couldn't dereference an array returned by a
function:

//Works:
$arr = func();
$val = $arr[5];

//Didn't work until recently, and therefore can't be trusted for
//deployment to random systems across the internet:
$val = func()[5];

JavaScript has magic around the dot and function-call operators, as I
mentioned earlier. Lots of other languages have some little quirk
somewhere that breaks this rule; some have a LOT of quirks that break
this rule. Does Python have any? Aside from parsing oddities like
attribute access on a literal integer[1], are there any cases where
two expressions yielding the same object are in any way different?

ChrisA
[1] You can write "(1234).to_bytes(2,'big')" but omitting the parens
gives a SyntaxError because it looks like the start of a float
literal.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: datetime question

2013-11-10 Thread Gene Heskett
On Sunday 10 November 2013 04:06:06 Chris Angelico did opine:

> On Sun, Nov 10, 2013 at 11:55 AM, Gene Heskett  wrote:
> > On Saturday 09 November 2013 19:52:52 Chris Angelico did opine:
> >> :) Don't just thank me, Grant and Roy were key to it too - and the
> >> 
> >> whole "there's no shortage of newlines" thing started with Steven
> >> D'Aprano (I think), and it's a ripe field for harvest :)
> > 
> > And likely not fully gleaned yet. :)  To all of you, thats some of the
> > better creative writing I've read in my 79 years.  ;-)
> 
> Are you going to have a newyear after next year and start over with
> Year 1 again?
> 
Nah.  I tried to put it off as long as I could, but times arrow, dammit, 
only points forward.  I might as well get used to it.  From that famous 
line about death and taxes, taxes will of course outlive me. Being a DM-II, 
I of course haven't a shred of warranty left.  Just up to pee and check on 
that falling satellite, I could fall over walking the 20 feet back to bed, 
but I'm going to do it anyway... ;-)

> ChrisA


Cheers, Gene
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)

$100 invested at 7% interest for 100 years will become $100,000, at
which time it will be worth absolutely nothing.
-- Lazarus Long, "Time Enough for Love"
A pen in the hand of this president is far more
dangerous than 200 million guns in the hands of
 law-abiding citizens.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: my favorite line of py code so far

2013-11-10 Thread Chris Angelico
On Sun, Nov 10, 2013 at 7:57 PM, Peter Cacioppi
 wrote:
> Chris said :
>
> "I think map is fine if you can use a named function, but if you can't
> come up with a descriptive name for what you're doing, a comprehension
> is probably better (as it'll have the code right there). Mapping _
> across everything tells you nothing about what it's actually doing"
>
> How about this? I put the following in my catchall_utility.py module
>
>   # the oneArg combinator takes a multi-argument calleable
>   # and returns the equivalent single argument calleable
>   oneArg = lambda c: lambda x : c(*x)

Now it has a name, so I could imagine you importing it into modules
and using it usefully. I'd be inclined to call it something along the
lines of "unpacked" but that's just bikeshedding.

> ... I find that I write fewer bugs when I use idioms that resonate.

Absolutely! The unfortunate truth, though, is that idioms that
resonate with you _and nobody else_ are just as big a problem as bugs,
because they're unmaintainable. So hopefully what you're doing will
make sense to other people too!

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


Re: To whoever hacked into my Database

2013-11-10 Thread Νίκος Αλεξόπουλος

Στις 10/11/2013 12:20 πμ, ο/η Chris Angelico έγραψε:

On Sun, Nov 10, 2013 at 2:32 AM, Antoon Pardon
 wrote:

And i had until i made some new changes last night, which i think i have 
corrected now as we speak.


Continuing the arrogance.


Just to put that in perspective, by the way: *EVERYONE* writes
vulnerable code. Even Python itself has been found to have had
significant exploits (hash randomization had to get backported a long
way). There's nothing wrong with fixing security bugs; there's not
even a lot wrong with the iterative process of "find bug, fix bug,
find another bug, fix another bug". There are two major problems with
what you did here, Nikos, and they are:

1) Starting with a hopelessly insecure system and then trying to
band-aid patch it one vulnerability at a time, which is folly; and

2) Boasting that your system was now secure.

The main issue is the boasting, which is utterly unwarranted
arrogance. All you have to do is look at how, after boasting
previously, you were provably vulnerable - which means that you
clearly still had problems while you were boasting. A more humble
attitude of "Oops, well, that's fixed now" without saying "Ha ha, now
try to break THAT, I'm oh so perfect now" would suit you far better,
based on your history.

ChrisA




Ha, ha ha!
I'm safe now!!

No breaks in this time!
--
https://mail.python.org/mailman/listinfo/python-list


Re: python operational semantics paper

2013-11-10 Thread Terry Reedy

On 11/9/2013 1:35 PM, Paul Rubin wrote:

This looks kind of interesting.

http://cs.brown.edu/~sk/Publications/Papers/Published/pmmwplck-python-full-monty/

Abstract

We present a small-step operational semantics for the Python programming
language. We present both a core language for Python, suitable for tools
and proofs, and a translation process for converting Python source to
this core. We have tested the composition of translation and evaluation
of the core for conformance with the primary Python implementa- tion,
thereby giving confidence in the fidelity of the seman- tics. We briefly
report on the engineering of these compo- nents. Finally, we examine
subtle aspects of the language, identifying scope as a pervasive concern
that even impacts features that might be considered orthogonal.


Thanks for posting this. I found it very interesting but will need more 
time to digest it. I plan to open a separate thread based on one item in 
the paper.


--
Terry Jan Reedy

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


Re: New user's initial thoughts / criticisms of Python

2013-11-10 Thread Ian Kelly
On Sun, Nov 10, 2013 at 2:22 AM, Chris Angelico  wrote:
> JavaScript has magic around the dot and function-call operators, as I
> mentioned earlier. Lots of other languages have some little quirk
> somewhere that breaks this rule; some have a LOT of quirks that break
> this rule. Does Python have any? Aside from parsing oddities like
> attribute access on a literal integer[1], are there any cases where
> two expressions yielding the same object are in any way different?

I can think of one:

class Spam:
def __init__(self):
super().__init__()  # This works.

sup = super

class Eggs:
def __init__(self):
sup().__init__()  # This doesn't.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: New user's initial thoughts / criticisms of Python

2013-11-10 Thread Chris Angelico
On Sun, Nov 10, 2013 at 10:39 PM, Ian Kelly  wrote:
> On Sun, Nov 10, 2013 at 2:22 AM, Chris Angelico  wrote:
>> JavaScript has magic around the dot and function-call operators, as I
>> mentioned earlier. Lots of other languages have some little quirk
>> somewhere that breaks this rule; some have a LOT of quirks that break
>> this rule. Does Python have any? Aside from parsing oddities like
>> attribute access on a literal integer[1], are there any cases where
>> two expressions yielding the same object are in any way different?
>
> I can think of one:
>
> class Spam:
> def __init__(self):
> super().__init__()  # This works.
>
> sup = super
>
> class Eggs:
> def __init__(self):
> sup().__init__()  # This doesn't.

Ah, yes, super() is magical. In that particular instance, I think the
magic is better than the alternative, but let's face it: Multiple
inheritance is an inherently hard problem, so a solution that has so
little magic and manages to achieve the goal is doing well. The only
thing that would have been better than this would be making it a piece
of special syntax rather than something that looks like a function
call, but it's too late to change now.

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


Re: New user's initial thoughts / criticisms of Python

2013-11-10 Thread Thomas Rachel

Am 09.11.2013 14:27 schrieb Joshua Landau:


`select` is quite an odd statement, in that in most cases it's just a
weaker variant of `if`. By the time you're at the point where a
`select` is actually more readable you're also at the point where a
different control flow is probably a better idea. Things like
dictionaries or a variables pointing to functions are really useful
and can be encapsulated in a class quite well. This is a bit more
advanced but largely more rigorous.


class Switch(object):
def __init__(self, value):
self.value = value
self.called = False
def case(self, other):
def wr(func):
if not self.called and self.value == other:
self.called = True
return func(self.value)
return wr
def default(self, func):
if not self.called:
self.called = True
return func(self.value)


if __name__ == '__main__':
import random

while 1:
n = random.randrange(0, 5)
sw = Switch (n)
@sw.case(1)
def _(n): print n, "is one"

@sw.case(2)
def _(n): print n, "is two"

@sw.default
def _(n): print n, "is something else"

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


Re: pywin32 programming error on Win7 with shell.SHGetDesktopFolder, desktop.BindToObject, desktop.GetDisplayNameOf

2013-11-10 Thread iMath
I solved it like the following

from win32com.shell import shell, shellcon
import os
def launch_file_explorer(path, files):
'''
Given a absolute base path and names of its children (no path), open
up one File Explorer window with all the child files selected
'''
folder_pidl = shell.SHILCreateFromPath(path,0)[0]
desktop = shell.SHGetDesktopFolder()
shell_folder = desktop.BindToObject(folder_pidl, 
None,shell.IID_IShellFolder)
name_to_item_mapping = dict([(desktop.GetDisplayNameOf(item, 
shellcon.SHGDN_FORPARSING|shellcon.SHGDN_INFOLDER), item) for item in 
shell_folder])
print(name_to_item_mapping)
to_show = []
for file in files:
if file in name_to_item_mapping:
to_show.append(name_to_item_mapping[file])
# else:
# raise Exception('File: "%s" not found in "%s"' % (file, path))

shell.SHOpenFolderAndSelectItems(folder_pidl, to_show, 0)



p=r'E:\aa'
print(os.listdir(p))
launch_file_explorer(p, os.listdir(p))
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pywin32 programming error on Win7 with shell.SHGetDesktopFolder, desktop.BindToObject, desktop.GetDisplayNameOf

2013-11-10 Thread iMath
I solved it like the following

from win32com.shell import shell, shellcon
import os
def launch_file_explorer(path, files):
'''
Given a absolute base path and names of its children (no path), open
up one File Explorer window with all the child files selected
'''
folder_pidl = shell.SHILCreateFromPath(path,0)[0]
desktop = shell.SHGetDesktopFolder()
shell_folder = desktop.BindToObject(folder_pidl, 
None,shell.IID_IShellFolder)
name_to_item_mapping = dict([(desktop.GetDisplayNameOf(item, 
shellcon.SHGDN_FORPARSING|shellcon.SHGDN_INFOLDER), item) for item in 
shell_folder])
print(name_to_item_mapping)
to_show = []
for file in files:
if file in name_to_item_mapping:
to_show.append(name_to_item_mapping[file])
# else:
# raise Exception('File: "%s" not found in "%s"' % (file, path))

shell.SHOpenFolderAndSelectItems(folder_pidl, to_show, 0)



p=r'E:\aa'
print(os.listdir(p))
launch_file_explorer(p, os.listdir(p))
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-10 Thread Alister
On Sun, 10 Nov 2013 01:44:17 +, ishish wrote:

> Am 09.11.2013 15:07, schrieb Steven D'Aprano:
> ...
>> Nikos, you have annoyed and alienated enough people here...
> 
> Sorry, I DO NOT AGREE! These threads keep my entire office entertained.
> I would even go so far to suggest, that we should set up an entirely new
> mailing list for Nikos only, maybe something called like
> acropolis-list(at)python.org.
> 
> Mea culpa, I am entirely aware that this is an IT list, but hey, when
> you have done 2x65ish hrs per week in a row - standing in for our Ops
> Guy, holidaying - you really start to appreciating little interruptions
> like this...
> 
> Greekings ...oops, meant greetings from Tartan-Land,
> 
> Sas&Co

I too am leaning plenty from watching Nicos' tales of woe, thank you 
Nicos.

To repay the favour one instant lesson i can see that you need to apply 
is how you are using the page variable to select pages.

Do not use the value provided as the direct source of the page name 
instead us it as a key to look up the page in a white-list, no where do i 
store that white list? I know how about another database table.
I know you don't seem to like using more than one table Nicos but that is 
daft. they are not rationed & cost nothing.

Also when you fail to find a page in the white-list return nothing, there 
is no point in giving potential hackers any more clues than necessary.

I also suggest you check your firewall you seem to have far more ports 
open to the public internet than should ever be necessary. to follow on 
from one of the other security analogy's posted here you would not put 
the door to your house safe on the outside wall even if you think it has 
a stronger lock than your front door.





-- 
He who despises himself nevertheless esteems himself as a self-despiser.
-- Friedrich Nietzsche
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: datetime question

2013-11-10 Thread unknown
On Sat, 09 Nov 2013 15:43:53 +0200, Νίκος Αλεξόπουλος wrote:

> Στις 9/11/2013 2:45 μμ, ο/η Mark Lawrence έγραψε:
>> On 08/11/2013 23:02, Νίκος Αλεξόπουλος wrote:
>>> Στις 9/11/2013 12:49 πμ, ο/η Denis McMahon έγραψε:
 On Sat, 09 Nov 2013 00:01:37 +0200, Νίκος Αλεξόπουλος wrote:

> I saw the link and i'm wondering if it can be written in 1-liner.

 Yes, but you have to rewrite all your code in perl to do this.


>>>
>>> Please tell me and as a git i will provide you with 2 good pdfs i just
>>> found:
>>>
>>> You can see them at my website if you click the blue download button.
>>>
>>> The 1st is a Linux Bile and the 2nd is WebHosting for Dummies.
>>
>> Why is Web Security for Dummies missing?
>>
>>
> 
> It's not missing.
> Its there, check again.
> Just click on the Blue download button and select it from the list of
> buttons.

Try Reading IT!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-10 Thread Antoon Pardon
Op 10-11-13 11:32, Νίκος Αλεξόπουλος schreef:
> Στις 10/11/2013 12:20 πμ, ο/η Chris Angelico έγραψε:

>> There are two major problems with
>> what you did here, Nikos, and they are:
>>
>> 1) Starting with a hopelessly insecure system and then trying to
>> band-aid patch it one vulnerability at a time, which is folly; and
>>
>> 2) Boasting that your system was now secure.
>>
>> The main issue is the boasting, which is utterly unwarranted
>> arrogance. 
,,,

> Ha, ha ha!
> I'm safe now!!
> 
> No breaks in this time!

You just can't help yourself, can you? I predict your database will
be broken in, within a week, after which you will plug one leak
and after an other day boast again about how secure your system is,
because you hadn't had a break in after your latest "fix".

-- 
Antoon Pardon

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


Re: Basic Python Questions - Oct. 31, 2013

2013-11-10 Thread sigtool
On Q4, you could try Waterloo Graphics . Its 
LGPLv3 and, although Java-based, runs in Python via Py4J. It has built-in mouse 
interactivity/GUI editors etc that will all be active when used from Python.

It is Java Swing-based, so e.g. data points can be drawn as standard clickable 
Swing components (see http://waterloo.sourceforge.net/R/scatter.html for an 
example using R [N.B. not interactive on the web site which just shows a 
bit-map]).

For Python examples see http://waterloo.sourceforge.net/python/grid.html







On Thursday, October 31, 2013 9:31:11 AM UTC, E.D.G. wrote:
> Posted by E.D.G. on October 31, 2013
> 
> 
> 
>The following are several relatively basic questions regarding 
> Python's 
> 
> capabilities.  I am not presently using it myself.  At the moment a number 
> 
> of people including myself are comparing it with other programs such as 
> 
> XBasic for possible use.
> 
> 
> 
> 1.  How fast can Python do math calculations compared with other languages 
> 
> such as Fortran and fast versions of Basic.  I would have to believe that it 
> 
> is much faster than Perl for doing math calculations.
> 
> 
> 
> 2.  Can Python be used to create CGI programs?  These are the ones that run 
> 
> on Internet server computers and process data submitted through Web site 
> 
> data entry screens etc.  I know that Perl CGI programs will do that.
> 
> 
> 
> 3.  If Python can be used for CGI programming, can it draw charts such as 
> 
> .png files that will then display on Web pages at a Web site?
> 
> 
> 
> 4.  How well does Python work for interactive programming.  For example, if 
> 
> a Python program is running on a PC and is drawing a chart, can that chart 
> 
> be modified by simply pressing a key while the Python program is running.  I 
> 
> have Perl and Gnuplot program combinations that can do that.  Their 
> 
> interactive speed is not that great.  But it is adequate for my own uses.
> 
> 
> 
> 5.  Can a running Python program send information to the Windows operating 
> 
> system as if it were typed in from the keyboard?  Perl can do that and I 
> 
> would imagine that Python probably has that same capability.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-10 Thread Mark Lawrence

On 10/11/2013 10:32, Νίκος Αλεξόπουλος wrote:



Ha, ha ha!
I'm safe now!!

No breaks in this time!


She's just biding her time again.  Or was it the little fingers of my 
team?  Clearly you haven't the faintest idea.


I've now come to the conclusion that someone is going to make a fortune 
from these hacking incidents, as the film industry is always looking for 
new material, and this would make one of the greatest comedies ever. 
You could play yourself, you wouldn't need a script, and you could 
certainly help with the screenplay!!!


--
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

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


Re: To whoever hacked into my Database

2013-11-10 Thread Νίκος Αλεξόπουλος

Στις 10/11/2013 3:49 μμ, ο/η Antoon Pardon έγραψε:

Op 10-11-13 11:32, Νίκος Αλεξόπουλος schreef:

Στις 10/11/2013 12:20 πμ, ο/η Chris Angelico έγραψε:



There are two major problems with
what you did here, Nikos, and they are:

1) Starting with a hopelessly insecure system and then trying to
band-aid patch it one vulnerability at a time, which is folly; and

2) Boasting that your system was now secure.

The main issue is the boasting, which is utterly unwarranted
arrogance.

,,,


Ha, ha ha!
I'm safe now!!

No breaks in this time!


You just can't help yourself, can you? I predict your database will
be broken in, within a week, after which you will plug one leak
and after an other day boast again about how secure your system is,
because you hadn't had a break in after your latest "fix".




It won't break again. 'page' variable cannot be manipulated by arbitrary 
url strings no more.


This time is fixed for good.

Your predictions are wrong.

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


Re: To whoever hacked into my Database

2013-11-10 Thread Mark Lawrence

On 10/11/2013 15:01, Νίκος Αλεξόπουλος wrote:

Στις 10/11/2013 3:49 μμ, ο/η Antoon Pardon έγραψε:

Op 10-11-13 11:32, Νίκος Αλεξόπουλος schreef:

Στις 10/11/2013 12:20 πμ, ο/η Chris Angelico έγραψε:



There are two major problems with
what you did here, Nikos, and they are:

1) Starting with a hopelessly insecure system and then trying to
band-aid patch it one vulnerability at a time, which is folly; and

2) Boasting that your system was now secure.

The main issue is the boasting, which is utterly unwarranted
arrogance.

,,,


Ha, ha ha!
I'm safe now!!

No breaks in this time!


You just can't help yourself, can you? I predict your database will
be broken in, within a week, after which you will plug one leak
and after an other day boast again about how secure your system is,
because you hadn't had a break in after your latest "fix".




It won't break again. 'page' variable cannot be manipulated by arbitrary
url strings no more.

This time is fixed for good.

Your predictions are wrong.



I'm not a gambling man, but I'd put my house on the fact that your site 
is so insecure that even the little fingers of my team can get in.



--
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

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


Re: To whoever hacked into my Database

2013-11-10 Thread Νίκος Αλεξόπουλος

Στις 10/11/2013 4:45 μμ, ο/η Mark Lawrence έγραψε:

On 10/11/2013 10:32, Νίκος Αλεξόπουλος wrote:



Ha, ha ha!
I'm safe now!!

No breaks in this time!


She's just biding her time again.  Or was it the little fingers of my
team?



Tell your female friend to polish her nails or do her hair instead as 
she will not be successful any more to mess with any of my 3 scripts.


If it was little fingers tell him to stick those fingers you know where
--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-10 Thread Mark Lawrence

On 10/11/2013 15:12, Νίκος Αλεξόπουλος wrote:

Στις 10/11/2013 4:45 μμ, ο/η Mark Lawrence έγραψε:

On 10/11/2013 10:32, Νίκος Αλεξόπουλος wrote:



Ha, ha ha!
I'm safe now!!

No breaks in this time!


She's just biding her time again.  Or was it the little fingers of my
team?



Tell your female friend to polish her nails or do her hair instead as
she will not be successful any more to mess with any of my 3 scripts.


Congratulations, you've just let the cat in amongst the pigeons.  I 
suggest you take cover before the brickbats quite rightly start flying.




If it was little fingers tell him to stick those fingers you know where


I hope you're not suggesting what I think you're suggesting, I couldn't 
possibly make such a statement to a group of four year olds, how dare you.


--
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

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


Re: To whoever hacked into my Database

2013-11-10 Thread Antoon Pardon
Op 10-11-13 16:01, Νίκος Αλεξόπουλος schreef:
> Στις 10/11/2013 3:49 μμ, ο/η Antoon Pardon έγραψε:
>> Op 10-11-13 11:32, Νίκος Αλεξόπουλος schreef:
>>> Ha, ha ha!
>>> I'm safe now!!
>>>
>>> No breaks in this time!
>>
>> You just can't help yourself, can you? I predict your database will
>> be broken in, within a week, after which you will plug one leak
>> and after an other day boast again about how secure your system is,
>> because you hadn't had a break in after your latest "fix".
>>
> 
> It won't break again. 'page' variable cannot be manipulated by
> arbitrary url strings no more.

So you fixed one specific leak and you think that is enough to
declare yourself safe?!

> This time is fixed for good.

The fact that you said this before and were wrong didn't teach
you anything?

> Your predictions are wrong.

And you wonder why people think you are arrogant. You are a perfect
example of the arrogance of the ignorant.

-- 
Antoon Pardon.

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


Re: To whoever hacked into my Database

2013-11-10 Thread Ned Batchelder
On Sunday, November 10, 2013 10:28:46 AM UTC-5, Antoon Pardon wrote:
> Op 10-11-13 16:01, Νίκος Αλεξόπουλος schreef:
> > Στις 10/11/2013 3:49 μμ, ο/η Antoon Pardon έγραψε:
> >> Op 10-11-13 11:32, Νίκος Αλεξόπουλος schreef:
> >>> Ha, ha ha!
> >>> I'm safe now!!
> >>>
> >>> No breaks in this time!
> >>
> >> You just can't help yourself, can you? I predict your database will
> >> be broken in, within a week, after which you will plug one leak
> >> and after an other day boast again about how secure your system is,
> >> because you hadn't had a break in after your latest "fix".
> >>
> > 
> > It won't break again. 'page' variable cannot be manipulated by
> > arbitrary url strings no more.
> 
> So you fixed one specific leak and you think that is enough to
> declare yourself safe?!
> 
> > This time is fixed for good.
> 
> The fact that you said this before and were wrong didn't teach
> you anything?
> 
> > Your predictions are wrong.
> 
> And you wonder why people think you are arrogant. You are a perfect
> example of the arrogance of the ignorant.
> 
> -- 
> Antoon Pardon.


Can we please just ignore Nikos' boasts?  The only way to end a Nikos thread is 
to ignore Nikos.  At this point, Mark and Antoon are as much of a problem as 
Nikos is.  Continuing to insult and bait Nikos just prolongs the noise.  Yes, 
we know he is wrong.  But no amount of "nyah-nyah" posts is going to convince 
him.  We have to settle for an end to the thread.

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


Re: Py 3.3.2, MacBookPro, segmentation fault, GCC issue?

2013-11-10 Thread Laurent Pointal
John Ladasky wrote:

> I am trying to help a student of mine install Python 3 on his MacBook Pro.

> Follow-up questions: if I need a more current GCC for my student's Mac,
> how do I obtain it?  And are there any backwards-compatibility issues I
> might need to worry about if I do upgrade?  From my Linux experience,
> upgrading GCC has never caused problems.  But I want to be cautious, since
> this isn't my computer I'll be playing with, but someone else's.

AFAIK Apple stop delivering new gcc when it goes to GPL3 licence. 
In place, they use llvm compiler tool.

See discussions and links in
http://stackoverflow.com/questions/9353444/how-to-use-install-gcc-on-mac-os-x-10-8-xcode-4-4

There may be other solutions, but you should prefer ask in a specific MacOS
usenet group.

A+

> 
> Thanks for any advice you may have.
-- 
Laurent POINTAL - [email protected]

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


Re: To whoever hacked into my Database

2013-11-10 Thread Νίκος Αλεξόπουλος

Στις 10/11/2013 5:28 μμ, ο/η Antoon Pardon έγραψε:

Op 10-11-13 16:01, Νίκος Αλεξόπουλος schreef:

Στις 10/11/2013 3:49 μμ, ο/η Antoon Pardon έγραψε:

Op 10-11-13 11:32, Νίκος Αλεξόπουλος schreef:

Ha, ha ha!
I'm safe now!!

No breaks in this time!


You just can't help yourself, can you? I predict your database will
be broken in, within a week, after which you will plug one leak
and after an other day boast again about how secure your system is,
because you hadn't had a break in after your latest "fix".



It won't break again. 'page' variable cannot be manipulated by
arbitrary url strings no more.


So you fixed one specific leak and you think that is enough to
declare yourself safe?!


This time is fixed for good.


The fact that you said this before and were wrong didn't teach
you anything?


Your predictions are wrong.


And you wonder why people think you are arrogant. You are a perfect
example of the arrogance of the ignorant.


Really?

I have even pasted the code as i used to had it and the new correction i 
have made.


Since my code is so crappy try to mess with the script and databases 
since you re so competent and smart

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


Re: To whoever hacked into my Database

2013-11-10 Thread Petite Abeille

On Nov 10, 2013, at 4:28 PM, Antoon Pardon  wrote:

> You are a perfect example of the arrogance of the ignorant.

Finally! The Dunning–Kruger effect proven beyond a doubt.


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


Re: To whoever hacked into my Database

2013-11-10 Thread Νίκος Αλεξόπουλος

Στις 10/11/2013 7:57 μμ, ο/η Petite Abeille έγραψε:


On Nov 10, 2013, at 4:28 PM, Antoon Pardon  wrote:


You are a perfect example of the arrogance of the ignorant.


Finally! The Dunning–Kruger effect proven beyond a doubt.





You are a moron, no doubt! Freddy Kruger Effect!
--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-10 Thread Petite Abeille

On Nov 10, 2013, at 7:46 PM, Νίκος Αλεξόπουλος  wrote:

> You are a moron

Rumor has it you are the head of ELSTAT, the Hellenic Statistical Authority. 
Any truth to that?

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


Re: To whoever hacked into my Database

2013-11-10 Thread Νίκος Αλεξόπουλος

Στις 10/11/2013 9:16 μμ, ο/η Petite Abeille έγραψε:


On Nov 10, 2013, at 7:46 PM, Νίκος Αλεξόπουλος  wrote:


You are a moron


Rumor has it you are the head of ELSTAT, the Hellenic Statistical Authority. 
Any truth to that?




Perhaps i'm working for NSA too and i was assigned to keep an eye on 
what's happening on Python News Lists.

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


[RELEASE] Python 2.7.6

2013-11-10 Thread Benjamin Peterson
Python 2.7.6 is now available.

This release resolves crashes of the interactive interpreter on OS X 10.9. The
final release also fixes several issues identified in the release
candidate. Importantly, a security bug in CGIHTTPServer was fixed [1]. Thank you
to those who tested the 2.7.6 release candidate and reported these bugs!

All the changes in Python 2.7.6 are described in full detail in the Misc/NEWS
file of the source tarball. You can also view online at

http://hg.python.org/cpython/raw-file/99d03261c1ba/Misc/NEWS

Downloads are at

http://python.org/download/releases/2.7.6/

As always, report bugs to

http://bugs.python.org/

Have a nice November,
Benjamin Peterson
2.7 Release Manager

[1] http://bugs.python.org/issue19435
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-10 Thread Petite Abeille

On Nov 10, 2013, at 8:21 PM, Νίκος Αλεξόπουλος  wrote:

> Perhaps

You're in a desert, walking along in the sand, when all of a sudden you look 
down and see a tortoise. It's crawling toward you. You reach down and you flip 
the tortoise over on its back. The tortoise lays on its back, its belly baking 
in the hot sun, beating its legs trying to turn itself over, but it can't. Not 
without your help. But you're not helping. Why is that?

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


Re: To whoever hacked into my Database

2013-11-10 Thread Rod Person
On Sun, 10 Nov 2013 20:32:11 +0100
Petite Abeille  wrote:
> 
> On Nov 10, 2013, at 8:21 PM, Νίκος Αλεξόπουλος
>  wrote:
> 
> > Perhaps
> 
> You're in a desert, walking along in the sand, when all of a sudden
> you look down and see a tortoise. It's crawling toward you. You reach
> down and you flip the tortoise over on its back. The tortoise lays on
> its back, its belly baking in the hot sun, beating its legs trying to
> turn itself over, but it can't. Not without your help. But you're not
> helping. Why is that?
> 

Tortoise? What's a tortoise?


LOL!  Officially now the best thread every on the internet.

From a lurker that has been watching the slow train wreck.

-- 
Rod

http://www.rodperson.com

He who knows himself to be one way and pretends it is another way is a
thief who robs his own soul.

  The Mahabharata
 Sakuntala 25
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-10 Thread Antoon Pardon
Op 10-11-13 17:15, Ned Batchelder schreef:
> On Sunday, November 10, 2013 10:28:46 AM UTC-5, Antoon Pardon wrote:
>> Op 10-11-13 16:01, Νίκος Αλεξόπουλος schreef:
>>> Στις 10/11/2013 3:49 μμ, ο/η Antoon Pardon έγραψε:
 Op 10-11-13 11:32, Νίκος Αλεξόπουλος schreef:
> Ha, ha ha!
> I'm safe now!!
>
> No breaks in this time!

 You just can't help yourself, can you? I predict your database will
 be broken in, within a week, after which you will plug one leak
 and after an other day boast again about how secure your system is,
 because you hadn't had a break in after your latest "fix".

>>>
>>> It won't break again. 'page' variable cannot be manipulated by
>>> arbitrary url strings no more.
>>
>> So you fixed one specific leak and you think that is enough to
>> declare yourself safe?!
>>
>>> This time is fixed for good.
>>
>> The fact that you said this before and were wrong didn't teach
>> you anything?
>>
>>> Your predictions are wrong.
>>
>> And you wonder why people think you are arrogant. You are a perfect
>> example of the arrogance of the ignorant.
>>
>> -- 
>> Antoon Pardon.
> 
> 
> Can we please just ignore Nikos' boasts? 

When I'm bored with them. I don't understand why you suddenly complain.
This whole thread started with what amounts to a boast. So why wait
four days before you ask for them to be ignored.

> The only way to end a Nikos thread is to ignore Nikos.  At this point,
> Mark and Antoon are as much of a problem as Nikos is. Continuing to
> insult and bait Nikos just prolongs the noise.  Yes, we know he is wrong.
> But no amount of "nyah-nyah" posts is going to convince him.  We have to
> settle for an end to the thread.

This much we new when the thread started. Thus IMO all those that reacted
and blew life into this thread are to blame that it could flourish. But
it seemed they were having their fun. So why shouldn't I have my fun now?
They were a problem then, I am a problem now, that seems perfectly fair.

-- 
Antoon Pardon

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


Re: To whoever hacked into my Database

2013-11-10 Thread Chris “Kwpolska” Warrick
On Nov 10, 2013 9:01 PM, "Rod Person"  wrote:
> Tortoise? What's a tortoise?
Is that a real question? If yes, then it's an animal, similar to a turtle.
Ask Google or Wikipedia for more details.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-10 Thread Rod Person
On Sun, 10 Nov 2013 21:41:54 +0100
Chris “Kwpolska” Warrick  wrote:

> On Nov 10, 2013 9:01 PM, "Rod Person"  wrote:
> > Tortoise? What's a tortoise?
> Is that a real question? If yes, then it's an animal, similar to a
> turtle. Ask Google or Wikipedia for more details.

Check the movie Blade Runner.

-- 
Rod

http://www.rodperson.com

He who knows himself to be one way and pretends it is another way is a
thief who robs his own soul.

  The Mahabharata
 Sakuntala 25
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-10 Thread Rod Person
On Sun, 10 Nov 2013 21:41:54 +0100
Chris “Kwpolska” Warrick  wrote:

> On Nov 10, 2013 9:01 PM, "Rod Person"  wrote:
> > Tortoise? What's a tortoise?
> Is that a real question? If yes, then it's an animal, similar to a
> turtle. Ask Google or Wikipedia for more details.

http://youtu.be/Umc9ezAyJv0?t=1m10s

-- 
Rod

http://www.rodperson.com

He who knows himself to be one way and pretends it is another way is a
thief who robs his own soul.

  The Mahabharata
 Sakuntala 25
-- 
https://mail.python.org/mailman/listinfo/python-list


Help - Exercise Decision

2013-11-10 Thread kennedysalvino . ks
I'm trying to make a ranking of 3 numbers and say which the greatest and 
consider whether there is a tie between them, I am not able to make the 
conditions of draws.  

Code in PT-BR: http://pastebin.com/18pYJjPC
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: New user's initial thoughts / criticisms of Python

2013-11-10 Thread Chris Angelico
On Mon, Nov 11, 2013 at 4:12 AM, Dennis Lee Bieber
 wrote:
 -123 .bit_length()
> -7
>
> No parens needed if a space precedes the .

Heh! I would call that an inferior alternative to the parentheses
though; it's so unusual to put a space before the dot that I wouldn't
consider it something to do in normal code. Anyone coming through and
editing would see it as a mistake to be fixed.

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


Re: To whoever hacked into my Database

2013-11-10 Thread Chris Angelico
On Mon, Nov 11, 2013 at 7:41 AM, Chris “Kwpolska” Warrick
 wrote:
> On Nov 10, 2013 9:01 PM, "Rod Person"  wrote:
>> Tortoise? What's a tortoise?
> Is that a real question? If yes, then it's an animal, similar to a turtle.
> Ask Google or Wikipedia for more details.

The Master was an old Turtle. We called him Tortoise...

Why did you call him Tortoise if he wasn't one?

We called him Tortoise because he taught us! Really, you are very dull.

-- the Mock Turtle explaining his lessons to Alice (they lessened
every day, and I still have no idea how they managed on the twelfth
day).

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


Re: my favorite line of py code so far

2013-11-10 Thread Peter Cacioppi
Chris said :

"Absolutely! The unfortunate truth, though, is that idioms that
resonate with you _and nobody else_ are just as big a problem as bugs,
because they're unmaintainable. So hopefully what you're doing will
make sense to other people too! "

There is some truth in what you say ...  but in this case we're talking about 
an algorithmically trivial portion of a project for which I am basically BDFL. 
So as long as I'm not totally in left field, I'm going with what feels truthy 
to me.

Also, 

  lambda c : lambda x : c(*x)

would make a sweet tattoo. Much better than some Kanji that might as well 
translate into "dumb white guy" for all I know ;)
 



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


Re: New user's initial thoughts / criticisms of Python

2013-11-10 Thread Terry Reedy

On 11/10/2013 6:29 PM, Chris Angelico wrote:

On Mon, Nov 11, 2013 at 4:12 AM, Dennis Lee Bieber
 wrote:

-123 .bit_length()

-7

 No parens needed if a space precedes the .


Heh! I would call that an inferior alternative to the parentheses
though; it's so unusual to put a space before the dot that I wouldn't
consider it something to do in normal code. Anyone coming through and
editing would see it as a mistake to be fixed.


I have only used int methods in interactive exploration, and have always 
used space. I have never used (), but agree that they are better for 
permanent code. The -7 is really nasty (unless one were to actually want 
that).


--
Terry Jan Reedy

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


Re: python operational semantics paper

2013-11-10 Thread Gregory Ewing

Paul Rubin wrote:


http://cs.brown.edu/~sk/Publications/Papers/Published/pmmwplck-python-full-monty/

Abstract

We present a small-step operational semantics for the Python programming
language.


I noticed one thing they seem to have missed. They
assume that

   a + b

is equivalent to

   a.__add__(b)

when, as many of us know, it's considerably more
complicated than that.

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


Re: Help - Exercise Decision

2013-11-10 Thread Gary Herron

On 11/10/2013 02:56 PM, [email protected] wrote:

I'm trying to make a ranking of 3 numbers and say which the greatest and 
consider whether there is a tie between them, I am not able to make the 
conditions of draws.

Code in PT-BR: http://pastebin.com/18pYJjPC


Please post the code directly in this message.  As a matter of 
safe-browsing practices, I won't follow that link.


One tests for equality (draws as you call them) with the == operator.
In what way does that not work for you?  Your question is so terse, that 
I'm not sure what you want.  Provide some examples please.


Gary Herron

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


Re: Help - Exercise Decision

2013-11-10 Thread Kennedy Salvino
Em domingo, 10 de novembro de 2013 21h34min39s UTC-3, Gary Herron  escreveu:
> On 11/10/2013 02:56 PM, [email protected] wrote:
> 
> > I'm trying to make a ranking of 3 numbers and say which the greatest and 
> > consider whether there is a tie between them, I am not able to make the 
> > conditions of draws.
> 
> >
> 
> > Code in PT-BR: http://pastebin.com/18pYJjPC
> 
> 
> 
> Please post the code directly in this message.  As a matter of 
> 
> safe-browsing practices, I won't follow that link.
> 
> 
> 
> One tests for equality (draws as you call them) with the == operator.
> 
> In what way does that not work for you?  Your question is so terse, that 
> 
> I'm not sure what you want.  Provide some examples please.
> 
> 
> 
> Gary Herron


Using only if elif else, here is the code

primeira_pontuacao = int(input("Digite a primeira pontuação: "))
segunda_pontuacao = int(input("Digite a segunda pontuação: "))
terceira_pontuacao = int(input("Digite a terceira pontuação: "))
'''
empate = primeira_pontuacao == segunda_pontuacao or terceira_pontuacao
empate2 = segunda_pontuacao == primeira_pontuacao or terceira_pontuacao
empate3 = terceira_pontuacao == primeira_pontuacao or segunda_pontuacao
empate4 = primeira_pontuacao == terceira_pontuacao != segunda_pontuacao
empate5 = segunda_pontuacao == terceira_pontuacao != primeira_pontuacao
empate6 = terceira_pontuacao == segunda_pontuacao != primeira_pontuacao
empate7 = primeira_pontuacao == segunda_pontuacao == terceira_pontuacao
'''
colocacao1 = 0
colocacao2 = 0
colocacao3 = 0

if (primeira_pontuacao > segunda_pontuacao):
if(segunda_pontuacao > terceira_pontuacao):
colocacao1 = primeira_pontuacao
colocacao2 = segunda_pontuacao
colocacao3 = terceira_pontuacao 
else:
colocacao1 = primeira_pontuacao
colocacao2 = terceira_pontuacao
colocacao3 = segunda_pontuacao
elif (segunda_pontuacao > terceira_pontuacao):
if(terceira_pontuacao > primeira_pontuacao):
colocacao1 = segunda_pontuacao  
colocacao2 = terceira_pontuacao
colocacao3 = primeira_pontuacao
else:
colocacao1 = segunda_pontuacao
colocacao2 = primeira_pontuacao
colocacao3 = terceira_pontuacao
elif (terceira_pontuacao > segunda_pontuacao):
if(segunda_pontuacao > primeira_pontuacao):
colocacao1 = terceira_pontuacao
colocacao2 = segunda_pontuacao 
colocacao3 = primeira_pontuacao
else:
colocacao1 = terceira_pontuacao
colocacao2 = primeira_pontuacao 
colocacao3 = segunda_pontuacao
elif (primeira_pontuacao > terceira_pontuacao):
if(terceira_pontuacao > segunda_pontuacao):
colocacao1 = primeira_pontuacao
colocacao2 = terceira_pontuacao
colocacao3 = segunda_pontuacao
else:
colocacao1 = primeira_pontuacao
colocacao2 = segunda_pontuacao
colocacao3 = terceira_pontuacao
elif (segunda_pontuacao > primeira_pontuacao):
if (primeira_pontuacao > terceira_pontuacao):
colocacao1 = segunda_pontuacao
colocacao2 = primeira_pontuacao
colocacao3 = terceira_pontuacao
else:
colocacao2 = segunda_pontuacao
colocacao3 = terceira_pontuacao
colocacao1 = primeira_pontuacao
elif (terceira_pontuacao > primeira_pontuacao):
if(primeira_pontuacao > segunda_pontuacao):
colocacao1 = terceira_pontuacao
colocacao2 = primeira_pontuacao
colocacao3 = segunda_pontuacao
else:
colocacao1 = terceira_pontuacao
colocacao2 = segunda_pontuacao
colocacao3 = primeira_pontuacao

print("O primeiro: " , colocacao1)
print("O segundo: ", colocacao2)
print("O terceiro: ", colocacao3)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Code with random module faster on the vm than the vm host...

2013-11-10 Thread alex23

On 9/11/2013 3:48 AM, Pascal Bit wrote:

from random import random

> [...]


Running on win7 python 2.7 32 bit it uses around 30 seconds avg.
Running on xubuntu, 32 bit, on vmware on windows 7: 20 seconds!
The code runs faster on vm, than the computer itself...
The python version in this case is 1.5 times faster...
I don't understand.

What causes this?


The random module uses os.urandom, which relies on OS implementations of 
randomness functionality:


"On a UNIX-like system this will query /dev/urandom, and on Windows it 
will use CryptGenRandom()."


http://docs.python.org/2/library/os.html#miscellaneous-functions

The linux implementation appears to be faster.
--
https://mail.python.org/mailman/listinfo/python-list


Re: Code with random module faster on the vm than the vm host...

2013-11-10 Thread Robert Kern

On 2013-11-11 00:49, alex23 wrote:

On 9/11/2013 3:48 AM, Pascal Bit wrote:

from random import random

 > [...]


Running on win7 python 2.7 32 bit it uses around 30 seconds avg.
Running on xubuntu, 32 bit, on vmware on windows 7: 20 seconds!
The code runs faster on vm, than the computer itself...
The python version in this case is 1.5 times faster...
I don't understand.

What causes this?


The random module uses os.urandom,


No, it doesn't. random.random() is an alias to the random() method on the 
random.Random class, which uses the Mersenne Twister to generate values. 
os.urandom() gets called in the initial default seeding, but not for each value.


--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

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


Re: Code with random module faster on the vm than the vm host...

2013-11-10 Thread Ned Batchelder
On Friday, November 8, 2013 12:48:04 PM UTC-5, Pascal Bit wrote:
> Here's the code:
> 
> from random import random
> from time import clock
> 
> s = clock()
> 
> for i in (1, 2, 3, 6, 8):
>  M = 0
>  N = 10**i
> 
>  for n in xrange(N):
>  r = random()
>  if 0.5 < r < 0.6:
>  M += 1
> 
>  k = (N, float(M)/N)
> 
> print (clock()-s)
> 
> Running on win7 python 2.7 32 bit it uses around 30 seconds avg.
> Running on xubuntu, 32 bit, on vmware on windows 7: 20 seconds!
> The code runs faster on vm, than the computer itself...
> The python version in this case is 1.5 times faster...
> I don't understand.
> 
> What causes this?

The docs for time.clock() make clear that the meaning on Windows and Unix are 
different:

"On Unix, return the current processor time as a floating point number 
expressed in seconds."

"On Windows, this function returns wall-clock seconds elapsed since the first 
call to this function..."

Try the experiment again with time.time() instead.

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


Re: Code with random module faster on the vm than the vm host...

2013-11-10 Thread Mark Lawrence

On 11/11/2013 01:15, Ned Batchelder wrote:

On Friday, November 8, 2013 12:48:04 PM UTC-5, Pascal Bit wrote:

Here's the code:

from random import random
from time import clock

s = clock()

for i in (1, 2, 3, 6, 8):
  M = 0
  N = 10**i

  for n in xrange(N):
  r = random()
  if 0.5 < r < 0.6:
  M += 1

  k = (N, float(M)/N)

print (clock()-s)

Running on win7 python 2.7 32 bit it uses around 30 seconds avg.
Running on xubuntu, 32 bit, on vmware on windows 7: 20 seconds!
The code runs faster on vm, than the computer itself...
The python version in this case is 1.5 times faster...
I don't understand.

What causes this?


The docs for time.clock() make clear that the meaning on Windows and Unix are 
different:

"On Unix, return the current processor time as a floating point number expressed in 
seconds."

"On Windows, this function returns wall-clock seconds elapsed since the first call 
to this function..."

Try the experiment again with time.time() instead.

--Ned.



http://www.python.org/dev/peps/pep-0418/ for some related reading about 
Python time functions.


--
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

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


Re: [Python-Dev] [RELEASE] Python 2.7.6

2013-11-10 Thread Victor Stinner
2013/11/10 Benjamin Peterson :
> All the changes in Python 2.7.6 are described in full detail in the Misc/NEWS
> file of the source tarball. You can also view online at
>
> http://hg.python.org/cpython/raw-file/99d03261c1ba/Misc/NEWS

- Issue #18747: Re-seed OpenSSL's pseudo-random number generator after fork.
  A pthread_atfork() parent handler is used to seed the PRNG with pid, time
  and some stack data.

Is this changeset in Python 2.7.6 or not?

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


Re: [Python-Dev] [RELEASE] Python 2.7.6

2013-11-10 Thread Benjamin Peterson
2013/11/10 Victor Stinner :
> 2013/11/10 Benjamin Peterson :
>> All the changes in Python 2.7.6 are described in full detail in the Misc/NEWS
>> file of the source tarball. You can also view online at
>>
>> http://hg.python.org/cpython/raw-file/99d03261c1ba/Misc/NEWS
>
> - Issue #18747: Re-seed OpenSSL's pseudo-random number generator after fork.
>   A pthread_atfork() parent handler is used to seed the PRNG with pid, time
>   and some stack data.
>
> Is this changeset in Python 2.7.6 or not?

It was backed out, but evidently the news entry wasn't removed.


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


Re: Code with random module faster on the vm than the vm host...

2013-11-10 Thread alex23

On 11/11/2013 11:19 AM, Robert Kern wrote:

On 2013-11-11 00:49, alex23 wrote:

The random module uses os.urandom,


No, it doesn't. random.random() is an alias to the random() method on
the random.Random class, which uses the Mersenne Twister to generate
values. os.urandom() gets called in the initial default seeding, but not
for each value.


That's what I get for rapidly skimming the module rather than looking at 
it carefully.


Cheers.

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



Re: Help - Exercise Decision

2013-11-10 Thread Gary Herron

On 11/10/2013 04:48 PM, Kennedy Salvino wrote:

Em domingo, 10 de novembro de 2013 21h34min39s UTC-3, Gary Herron  escreveu:

On 11/10/2013 02:56 PM, [email protected] wrote:


I'm trying to make a ranking of 3 numbers and say which the greatest and 
consider whether there is a tie between them, I am not able to make the 
conditions of draws.
Code in PT-BR: http://pastebin.com/18pYJjPC



Please post the code directly in this message.  As a matter of

safe-browsing practices, I won't follow that link.



One tests for equality (draws as you call them) with the == operator.

In what way does that not work for you?  Your question is so terse, that

I'm not sure what you want.  Provide some examples please.



Gary Herron


Using only if elif else, here is the code




Holy HELL man, that's a lot of code for such a simple problem. But 
perhaps your assignment requires you to do it this way. (In which case 
I'd have a word with your teacher.)


But assuming you've got the sorting part correct, (which you don't quite 
-- the three numbers 2 1 3 entered in that order don't sort correctly), 
I'll guess the problem is in the 8 lines you have triple-quoted out, true?


The first of those lines won't do what I think you are trying to do. Try 
this instead (I'm using a, b, and c instead of your variables):

empate = a==b or a==c
Each == test produces a True/False value and the "or" combines the two 
into a single True/False. Your code

empata = a == b or c
does something much different.

That being said, I have to question what you are going to do with 8 such 
computations. A single test like

if a==b or b==c or a==c:
would tell you if any two of the three values are equal. Do you need 
more information than that?


And then I feel compelled to add one more comment: Your method of 
sorting three numbers is extremely wordy and inefficient. What part of 
that did you invent, and what part is forced on you by your teacher? Are 
you allowed to be “smarter” about it, and would you like some advice on 
that part?


Gary Herron





primeira_pontuacao = int(input("Digite a primeira pontuação: "))
segunda_pontuacao = int(input("Digite a segunda pontuação: "))
terceira_pontuacao = int(input("Digite a terceira pontuação: "))
'''
empate = primeira_pontuacao == segunda_pontuacao or terceira_pontuacao
empate2 = segunda_pontuacao == primeira_pontuacao or terceira_pontuacao
empate3 = terceira_pontuacao == primeira_pontuacao or segunda_pontuacao
empate4 = primeira_pontuacao == terceira_pontuacao != segunda_pontuacao
empate5 = segunda_pontuacao == terceira_pontuacao != primeira_pontuacao
empate6 = terceira_pontuacao == segunda_pontuacao != primeira_pontuacao
empate7 = primeira_pontuacao == segunda_pontuacao == terceira_pontuacao
'''
colocacao1 = 0
colocacao2 = 0
colocacao3 = 0

if (primeira_pontuacao > segunda_pontuacao):
 if(segunda_pontuacao > terceira_pontuacao):
 colocacao1 = primeira_pontuacao
 colocacao2 = segunda_pontuacao
 colocacao3 = terceira_pontuacao
 else:
 colocacao1 = primeira_pontuacao
 colocacao2 = terceira_pontuacao
 colocacao3 = segunda_pontuacao
elif (segunda_pontuacao > terceira_pontuacao):
 if(terceira_pontuacao > primeira_pontuacao):
 colocacao1 = segunda_pontuacao
 colocacao2 = terceira_pontuacao
 colocacao3 = primeira_pontuacao
 else:
 colocacao1 = segunda_pontuacao
 colocacao2 = primeira_pontuacao
 colocacao3 = terceira_pontuacao
elif (terceira_pontuacao > segunda_pontuacao):
 if(segunda_pontuacao > primeira_pontuacao):
 colocacao1 = terceira_pontuacao
 colocacao2 = segunda_pontuacao
 colocacao3 = primeira_pontuacao
 else:
 colocacao1 = terceira_pontuacao
 colocacao2 = primeira_pontuacao
 colocacao3 = segunda_pontuacao
elif (primeira_pontuacao > terceira_pontuacao):
 if(terceira_pontuacao > segunda_pontuacao):
 colocacao1 = primeira_pontuacao
 colocacao2 = terceira_pontuacao
 colocacao3 = segunda_pontuacao
 else:
 colocacao1 = primeira_pontuacao
 colocacao2 = segunda_pontuacao
 colocacao3 = terceira_pontuacao
elif (segunda_pontuacao > primeira_pontuacao):
 if (primeira_pontuacao > terceira_pontuacao):
 colocacao1 = segunda_pontuacao
 colocacao2 = primeira_pontuacao
 colocacao3 = terceira_pontuacao
 else:
 colocacao2 = segunda_pontuacao
 colocacao3 = terceira_pontuacao
 colocacao1 = primeira_pontuacao
elif (terceira_pontuacao > primeira_pontuacao):
 if(primeira_pontuacao > segunda_pontuacao):
 colocacao1 = terceira_pontuacao
 colocacao2 = primeira_pontuacao
 colocacao3 = segunda_pontuacao
 else:
 colocacao1 = terceira_pontuacao
 colocacao2 = segunda_pontuacao
 colocacao3 = primeira_pontuacao

print("O primeiro: " , colocacao1)
print("O segundo: ", colocacao2)
print("O 

Re: Help - Exercise Decision

2013-11-10 Thread Mark Lawrence

On 11/11/2013 02:26, Gary Herron wrote:

On 11/10/2013 04:48 PM, Kennedy Salvino wrote:

Em domingo, 10 de novembro de 2013 21h34min39s UTC-3, Gary Herron
escreveu:

On 11/10/2013 02:56 PM, [email protected] wrote:


I'm trying to make a ranking of 3 numbers and say which the greatest
and consider whether there is a tie between them, I am not able to
make the conditions of draws.
Code in PT-BR: http://pastebin.com/18pYJjPC



Please post the code directly in this message.  As a matter of

safe-browsing practices, I won't follow that link.



One tests for equality (draws as you call them) with the == operator.

In what way does that not work for you?  Your question is so terse, that

I'm not sure what you want.  Provide some examples please.



Gary Herron


Using only if elif else, here is the code




Holy HELL man, that's a lot of code for such a simple problem. But
perhaps your assignment requires you to do it this way. (In which case
I'd have a word with your teacher.)

But assuming you've got the sorting part correct, (which you don't quite
-- the three numbers 2 1 3 entered in that order don't sort correctly),
I'll guess the problem is in the 8 lines you have triple-quoted out, true?

The first of those lines won't do what I think you are trying to do. Try
this instead (I'm using a, b, and c instead of your variables):
empate = a==b or a==c
Each == test produces a True/False value and the "or" combines the two
into a single True/False. Your code
empata = a == b or c
does something much different.

That being said, I have to question what you are going to do with 8 such
computations. A single test like
if a==b or b==c or a==c:
would tell you if any two of the three values are equal. Do you need
more information than that?

And then I feel compelled to add one more comment: Your method of
sorting three numbers is extremely wordy and inefficient. What part of
that did you invent, and what part is forced on you by your teacher? Are
you allowed to be “smarter” about it, and would you like some advice on
that part?

Gary Herron




Regardless of the way the OP goes about it the use of print functions or 
a debugger wouldn't go amiss.


--
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

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


PyWart: Packages (oh how thou art lacking!)

2013-11-10 Thread Rick Johnson


 The Pros of Python Packages:


  Python packages require no special syntax to declare which
  modules are members of the package. Instead, Python simply
  allows the programmer to utilize the hierarchy of his file
  system to decide *which* modules are in *which* packages.

  Sure you've got to create a "__init__.py" file under the
  directory which will become the package, which is just one
  operation to preform, as opposed to writing "uses package
  blah" in every damn source file!

  But the real genius is in the consistency!

  By utilizing such a novel approach to packaging, the
  implementation of Python packages remains consistent with
  Python modules. Let's face it people, packaging by any
  other means is just re-inventing the wheel!


 The Cons of Python Packages:


  1. No ability to EASILY share state between package
  members. Sure you can import and inject symbols until
  you're fingers bleed, but all you've done is create an
  unmaintainable spaghetti mess!

  2. Attempting to use packages to create a hierarchy of
  library modules is even more difficult and opens a
  Pandora's box of confusion, circular imports, name errors,
  unintended side effects, etc, etc...


 What should a package be anyway?


  Whilst python packages can be useful, their design is so
  woefully inadequate as to render them almost useless. To
  describe the disparities using an example:

Imagine if classes were nothing more than an
encapsulation of N functions that share information via
a global variable "self" -- no inheritance, no
polymorphism, no overloading, no blah blah blah...

  Sure, i could find a use for such a type, but the usage
  would be painfully limited.

  So now we find ourselves faced with the reality of the
  glaring question --> What the hell should a python package
  be exactly?

  A package SHOULD be an extrapolation of the namespace
  methodology, in the purest form. You start with local
  scope, then you proceed to module level scope, then
  package level scope (well, that's my wish anyway!), and
  finally, global scope[*]

  Just as class members can share information easily via
  "self", package members should have this ability also.


 Some food for thought...


  "Namespaces are one honking great idea -- let's do more of
  those!"


 REFERENCES:

  [*] Even though Python does not "officially" support
  global variables, you can emulate such functionality by
  injecting objects into __builtins__, since __builtins__ is
  available in every module namespace.
-- 
https://mail.python.org/mailman/listinfo/python-list


PyWart: Python modules are not so "modular" after all!

2013-11-10 Thread Rick Johnson


 The Pros of Python Modules:


  Python modules require no special syntax to create, nor do
  they induce extra indentation in your source code to
  maintain readability. Simply write some Python code in an
  editor, save it with a py|pyw extension, throw in a
  directory that python can find, and WHAMO, you've got
  yourself an importable module namespace!

  Of all the package implementations i've seen, Python's use
  of the source file as a module is absolutely my favorite

  But don't pucker up your benevolent anus just yet!


 The Cons of Python Modules:


  1. Modules cannot be extended or manipulated by the
  programmer. Basically the PyGods have handed us modules,
  but they failed to give us any tools to manipulate them --
  heck, they might as well have blessed us an unlimited
  supply of high carbon steel but cursed us with an
  atmosphere that does not support combustion.

  What good is ANY namespace when you cannot override it's
  fundamental interface? And interfaces are the key to OOP!

  Is __setattr__/__getattr__ ringing a bell people?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: New user's initial thoughts / criticisms of Python

2013-11-10 Thread Rick Johnson
On Saturday, November 9, 2013 10:30:26 AM UTC-6, rusi wrote:
> [...]
> Well
>
> print ( {"mon":"mondays suck",
>  "tue":"at least it's not monday",
>  "wed":"humpday"
> }.get(day_of_week,"its some other day")
>   )
> may be dense
> Separate into named dictionary and its ok (I think!)

Proper code formatting can do WONDERS for readability!

## START CODE ##
d = {
"mon":"mondays suck",
"tue":"at least it's not monday",
"wed":"humpday"
}
default = "some other day"
target = "tue"
print d.get(target, default)
target = "blah"
print d.get(target, default)
## END CODE ##

Of course you could create something "reusable" and "interface-ee".

## START CODE ##
class UsageError(Exception):
pass

class Case(object):
def __init__(self, defaultDict=None, defaultValue=None):
self.d = defaultDict or {}
self.defaultValue = defaultValue

def __str__(self):
return "Case({0})".format(self.d)

def __call__(self, key):
try:
v = self.d[key]
except KeyError:
v = self.defaultValue
return v

def __getitem__(self, k):
raise UsageError("RTFS MAN!!!")

if __name__ == '__main__':
import calendar
d = {
"mon":"mondays suck",
"tue":"at least it's not monday",
"wed":"humpday"
}
case = Case(d, "some other day")
try:
case["tue"]
except UsageError:
print 'Stopped improper useage.'
print case
lst = [s.lower() for s in calendar.weekheader(3).split(' ')]
for dayName in lst:
print "Case.__call__({0!r}) -> {1!r}".format(dayName, case(dayName))
## END CODE ##

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


Re: The narcissism of small code differences

2013-11-10 Thread Rick Johnson
On Saturday, November 9, 2013 6:42:04 AM UTC-6, Steven
D'Aprano wrote: 
> Uses an example written in Ruby, but don't
> let that put you off:

Why would it? I write Ruby code all the time. Ruby code in
and of itself does not bother me, what bothers me about Ruby
is the ease at which a programmer can write inconsistent and
convoluted code -- evidenced by the poor examples in your
linked article. Case in point.

To save anyone else from reading this long-winded "blab
fest" chalk full the driest humor and "cyclic illogical
meandering" that could make a ferris-wheel blush with
jealousy...

  In a nutshell the author attempts to plead for the
  "longevity" of "old code bases" simply on the basis of his
  assertion that "old code bases" are "less buggy" and
  contain more "wisdom" than their new brethren -- both of
  which are absurd conclusions!
  
Now, whilst he is correct regarding the narcissism of
programmers (i must admit we are all guilty of this deadly
sin), his attempts to draw parallels between "Freudian
pathologies" and "software development idiosyncrasies" is,
in fact, the very HEIGHT of sophistry!

Has the author considered that new functionality often
renders old code bases useless, or at the very least,
antiquated? Even code bases that are in fact "bug free" (for
*some* definition of "bug free"!)

Has the author consider that changes in external
dependencies can render a code base useless? Py3000 ring
a bell folks?

Is the author also unaware of evolution? 

Doth he falsely believe that even the BEST programmer can
look back on code he wrote a few years ago and not think of
some way it could be improved? GvR had such a realization
not so long ago -- and then there was Py3000!!!

>From something as simple as code restructuring for
readabilities sake; to choosing better naming conventions;
to improving consistency; reformulating algorithms to
eliminate bottlenecks; taking advantage of new functionality
in external libraries; or implementing new design patterns,
and on and on -- the list is limitless man!

The fact is, no code base will ever be perfect. Code will
constantly need updating and upgrading. The challenge is to
remove the old crusty bits and inject consistency everywhere
we can. That's not narcissism, that's altruism.








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


Re: PyWart: Python modules are not so "modular" after all!

2013-11-10 Thread Steven D'Aprano
On Sun, 10 Nov 2013 20:13:45 -0800, Rick Johnson wrote:

>   What good is ANY namespace when you cannot override it's fundamental
>   interface? And interfaces are the key to OOP!
> 
>   Is __setattr__/__getattr__ ringing a bell people?


import sys
sys.modules["mymodule"] = any_object_you_like()


Want a module with __setattr__ and __getattr__? Make a class, instantiate 
it, and shove it in sys.modules.


This has worked since Python 2.1:

http://code.activestate.com/recipes/65207-constants-in-python/



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