Re: To whoever hacked into my Database

2013-11-13 Thread Antoon Pardon
Op 13-11-13 01:41, Steven D'Aprano schreef:
> On Tue, 12 Nov 2013 17:27:08 +0100, Antoon Pardon wrote:
> 
>>> Somebody has to
>>> accept the responsibility to walk away and break the positive feedback
>>> loop, or it will never end.  And I can't see Nikos being the one to do
>>> that.
>>
>> Not my problem.
> 
> It might not be a problem for you, since you are obviously getting far 
> more pleasure out of arguing with others then you do about discussing 
> Python. But you are a problem for the rest of us.

So? Spoon feeders and others who seem unwilling or unable to ignore
Nikos's cravings for attention are a problem for me and others who
get frustrated by it. I don't see much people care about that. So
why should I care about other people's problem? I always get requests
to care about the problem of others but I don't see much consideration
for the problems I and those like me experience.

>> Why do you come to me? I didn't contribute to this
>> thread for about two days.
> 
> And now you are keeping it alive, just because "they started it".

So? if it was all right for others to blow life into this thread,
then why is it wrong if I would keep it alive?

And for your information, IMO I'm not keeping it alive for now.
At this moment all those who are eager to argue me into behaving
as they would prefer seem more responsible for keeping it alive
than me.

> Antoon, I don't remember the last time I've seen you contribute anything 
> productive to a Python thread.

I'm not responsible for your memory Steven.

> Chris and Mark have a regrettable tendency 
> to tease or bait Nikos, or at least run off on tangents mocking him, but 
> they at least are also productive members of the community who contribute 
> to discussing Python and helping solve Python problems. You don't, not as 
> far as I can see. Since you are now in my opinion almost as big a problem 
> here as Nikos, I'm adding you back to my kill-file.

That is your perogative.

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


Re: Please help with this

2013-11-13 Thread mkharper
On Wednesday, November 13, 2013 4:18:58 AM UTC, saad imran wrote:
> Could you point out any errors in my code:
> 
> 
> 
>  #This is a game where you have to escape a dragon.
> 
> # By Saad Imran
> 
> 
> 
> import random
> 
> import pygame
> 
> 
> 
> 
> 
> 
> 
> # Define questions and answers.
> 
> que1 = "4481 *2"
> 
> ans1 = "8962"
> 
> que2 = "457 * 21"
> 
> ans2 =  "9597"
> 
> que3 = "2345*23"
> 
> ans3 =  "53935"
> 
> que4 = "Who plays against the USA in golf's Walker Cup?"  
>  
> 
> ans4 = "britain"
> 
> que5 = "Which game is played in autumn using the fruit of the horse chestnut 
> tree?"
> 
> ans5 = "conkers"
> 
> que6 = "From what country does Lego come?"
> 
> ans6 = "denmark"
> 
> que7 = "What term is used in cricket for the two men on the field who decide 
> on whether batsmen are out, and signal for extras and boundaries?"
> 
> ans7 =  "umpire"
> 
> que8 = "What date was D-Day?"
> 
> ans8 = "06,06,1944"
> 
> que9 ="Who is called the 'Great One' in hockey history?"
> 
> ans9 = "wayne gretzky"
> 
> 
> 
> 
> 
> # intro
> 
> print("Welcome!")
> 
> print("")
> 
> name = input("What is your name? ")
> 
> print("")
> 
> print("You are in a cave and hear a dragon!",name)
> 
> print("")
> 
> print("Thinking you are doomed, you panic and run")
> 
> print("")
> 
> 
> 
> # Ask whether user wants to play or not
> 
> print("You run into a wizard who tells you that he will teleport you out of 
> the cave if you solve his questions!")
> 
> print("")
> 
> game = input("Do you trust him?(y/n) ")
> 
> print("")
> 
> 
> 
> #if he doesn't game is ended
> 
> if game == "N" or game == "n":
> 
> print("The dragon catches you and you are doomed!")
> 
> gameloop = False
> 
> loop = False
> 
> # if he does, game starts
> 
> 
> 
> else:
> 
> gameLoop = True
> 
> 
> 
> while gameLoop ==True:
> 
> 
> 
> # Tell user how to write answers
> 
> 
> 
> print("Please use all lower case letters. date format is dd,mm,")
> 
> print("dragon is red, You are green!")
> 
> 
> 
> 
> 
> 
> 
> # The following code intialises a pygame window where user can track 
> progress of self and dragon
> 
> # Needed to initialize pygame
> 
> pygame.init()
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> # define variable for user position
> 
> userX =75
> 
> userY =450
> 
> 
> 
> 
> 
> 
> 
> # define variable for dragon position.
> 
> dragonX = 0
> 
> dragonY = 450
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> # Define some Constants(colours and screen size)
> 
> BLACK = (0, 0, 0)
> 
> WHITE = (255, 255, 255)
> 
> GREEN = (0, 255, 0)
> 
> RED = (255, 0, 0)
> 
> 
> 
> SCREEN_WIDTH = 700
> 
> SCREEN_HEIGHT = 500
> 
> 
> 
> # Create a screen 
> 
> size = [SCREEN_WIDTH,SCREEN_HEIGHT]
> 
> screen = pygame.display.set_mode(size)
> 
> 
> 
> pygame.display.set_caption("dragonEscape Game")
> 
> 
> 
> # Used to manage how fast the screen updates
> 
> clock = pygame.time.Clock()
> 
> 
> 
> #Loop until the user clicks the close button.
> 
> loop = True
> 
> 
> 
> #  Main Program Loop ---
> 
> while loop == True:
> 
> # EVENT PROCESSING
> 
> for event in pygame.event.get():
> 
> if event.type == pygame.QUIT:   
> 
> loop = False 
> 
> 
> 
> #if user is caught
> 
> 
> 
> if userX <= dragonX:
> 
> print("The dragon ate you for dinner!")
> 
> loop = False
> 
> gameLoop = False
> 
> 
> 
> 
> 
> #if user wins
> 
> if userX >= 680:
> 
> 
> 
> print("You win!")
> 
> loop = False
> 
> gameLoop = False
> 
> 
> 
> 
> 
>  
> 
> # DRAW COMMANDS
> 
> screen.fill(WHITE)
> 
> 
> 
> 
> 
> pygame.draw.rect(screen, GREEN, [userX,userY,50,50])
> 
> pygame.draw.rect(screen, RED, [dragonX,dragonY,50,50])
> 
> pygame.draw.line(screen, BLACK, [680,0],[680,500],40)
> 
> 
> 
> 
> 
> #Code to generate random number
> 
> 
> 
> questionSelection = random.randrange(1,10)
> 
> 
> 
> 
> 
> # if statements that select question randomly based on random 
> number generated and collects user answer
> 
> print("")
> 
> print("")
> 
> print("")
> 
> print("")
> 
> print("")
> 
> print("")
> 
> if questionSelection == 1:
> 
> print(que1)
> 
> playerAnswer = input("What do you think the answer is?")
> 
> if playerAnswe

Re: Please help with this

2013-11-13 Thread mkharper
On Wednesday, November 13, 2013 4:18:58 AM UTC, saad imran wrote:
> Could you point out any errors in my code:
> 
> 
> 
>  #This is a game where you have to escape a dragon.
> 
> # By Saad Imran
> 
> 
> 
> import random
> 
> import pygame
> 
> 
> 
> 
> 
> 
> 
> # Define questions and answers.
> 
> que1 = "4481 *2"
> 
> ans1 = "8962"
> 
> que2 = "457 * 21"
> 
> ans2 =  "9597"
> 
> que3 = "2345*23"
> 
> ans3 =  "53935"
> 
> que4 = "Who plays against the USA in golf's Walker Cup?"  
>  
> 
> ans4 = "britain"
> 
> que5 = "Which game is played in autumn using the fruit of the horse chestnut 
> tree?"
> 
> ans5 = "conkers"
> 
> que6 = "From what country does Lego come?"
> 
> ans6 = "denmark"
> 
> que7 = "What term is used in cricket for the two men on the field who decide 
> on whether batsmen are out, and signal for extras and boundaries?"
> 
> ans7 =  "umpire"
> 
> que8 = "What date was D-Day?"
> 
> ans8 = "06,06,1944"
> 
> que9 ="Who is called the 'Great One' in hockey history?"
> 
> ans9 = "wayne gretzky"
> 
> 
> 
> 
> 
> # intro
> 
> print("Welcome!")
> 
> print("")
> 
> name = input("What is your name? ")
> 
> print("")
> 
> print("You are in a cave and hear a dragon!",name)
> 
> print("")
> 
> print("Thinking you are doomed, you panic and run")
> 
> print("")
> 
> 
> 
> # Ask whether user wants to play or not
> 
> print("You run into a wizard who tells you that he will teleport you out of 
> the cave if you solve his questions!")
> 
> print("")
> 
> game = input("Do you trust him?(y/n) ")
> 
> print("")
> 
> 
> 
> #if he doesn't game is ended
> 
> if game == "N" or game == "n":
> 
> print("The dragon catches you and you are doomed!")
> 
> gameloop = False
> 
> loop = False
> 
> # if he does, game starts
> 
> 
> 
> else:
> 
> gameLoop = True
> 
> 
> 
> while gameLoop ==True:
> 
> 
> 
> # Tell user how to write answers
> 
> 
> 
> print("Please use all lower case letters. date format is dd,mm,")
> 
> print("dragon is red, You are green!")
> 
> 
> 
> 
> 
> 
> 
> # The following code intialises a pygame window where user can track 
> progress of self and dragon
> 
> # Needed to initialize pygame
> 
> pygame.init()
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> # define variable for user position
> 
> userX =75
> 
> userY =450
> 
> 
> 
> 
> 
> 
> 
> # define variable for dragon position.
> 
> dragonX = 0
> 
> dragonY = 450
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> # Define some Constants(colours and screen size)
> 
> BLACK = (0, 0, 0)
> 
> WHITE = (255, 255, 255)
> 
> GREEN = (0, 255, 0)
> 
> RED = (255, 0, 0)
> 
> 
> 
> SCREEN_WIDTH = 700
> 
> SCREEN_HEIGHT = 500
> 
> 
> 
> # Create a screen 
> 
> size = [SCREEN_WIDTH,SCREEN_HEIGHT]
> 
> screen = pygame.display.set_mode(size)
> 
> 
> 
> pygame.display.set_caption("dragonEscape Game")
> 
> 
> 
> # Used to manage how fast the screen updates
> 
> clock = pygame.time.Clock()
> 
> 
> 
> #Loop until the user clicks the close button.
> 
> loop = True
> 
> 
> 
> #  Main Program Loop ---
> 
> while loop == True:
> 
> # EVENT PROCESSING
> 
> for event in pygame.event.get():
> 
> if event.type == pygame.QUIT:   
> 
> loop = False 
> 
> 
> 
> #if user is caught
> 
> 
> 
> if userX <= dragonX:
> 
> print("The dragon ate you for dinner!")
> 
> loop = False
> 
> gameLoop = False
> 
> 
> 
> 
> 
> #if user wins
> 
> if userX >= 680:
> 
> 
> 
> print("You win!")
> 
> loop = False
> 
> gameLoop = False
> 
> 
> 
> 
> 
>  
> 
> # DRAW COMMANDS
> 
> screen.fill(WHITE)
> 
> 
> 
> 
> 
> pygame.draw.rect(screen, GREEN, [userX,userY,50,50])
> 
> pygame.draw.rect(screen, RED, [dragonX,dragonY,50,50])
> 
> pygame.draw.line(screen, BLACK, [680,0],[680,500],40)
> 
> 
> 
> 
> 
> #Code to generate random number
> 
> 
> 
> questionSelection = random.randrange(1,10)
> 
> 
> 
> 
> 
> # if statements that select question randomly based on random 
> number generated and collects user answer
> 
> print("")
> 
> print("")
> 
> print("")
> 
> print("")
> 
> print("")
> 
> print("")
> 
> if questionSelection == 1:
> 
> print(que1)
> 
> playerAnswer = input("What do you think the answer is?")
> 
> if playerAnswe

Re: To whoever hacked into my Database

2013-11-13 Thread Antoon Pardon
Op 12-11-13 22:26, Ian Kelly schreef:
> On Tue, Nov 12, 2013 at 9:27 AM, Antoon Pardon
>  wrote:
>> Op 12-11-13 14:02, Ian Kelly schreef:
>>> On Tue, Nov 12, 2013 at 2:09 AM, Antoon Pardon
>>>  wrote:
 So you are complaining about people being human. Yes that is
 how people tend to react when they continualy are frustrated
 by someone who refuses to show the slightest cooperation.
 So no rejecting such responses, particullarly by the person
 who caused them is not right. It is defelecting the blame from
 the primal cause.
>>>
>>> As you say you're a human, not a sheep, so stop pointing at the
>>> behavior of others to justify your own.
>>
>> No, because often enough what is justifiable and what is not
>> depends on the context and what happened before. Morals are
>> generally not absolute so that a particular action would be
>> either right or wrong no matter what the circumstances.
> 
> I never claimed that they are.

What you said suggested it strongly enough to treat it as such.

> That doesn't mean that when somebody
> misbehaves, you can do whatever you want in retaliation without regard
> for others who might be involved.

But I didn't do whatever. What I did was similar in what others
had been doing before. And while those others were doing it
they received very little reaction. So why the reaction now?

>>> "But he started it" wasn't an
>>> excuse in kindergarten, and it still isn't one now.
>>
>> Then that kindergarten teacher was lousy at her job and would
>> probably let the bullies maninupulate her in punishing their
>> victems. That is what you get if you unconditionally tell
>> people that "he started it" can't be an excuse.
> 
> Yes, when one kid is yelling at another kid because the second kid
> pulled the first kid's hair, the teacher should just ignore the
> yelling because, after all, "he started it."  I'm sure that won't
> cause any disruption in the classroom at all, and having one kid
> yelling probably isn't going to set any of the others off, is it?

Thank you for making my point. You are concentrating completely
on the yelling and ignoring that somebody pulled the yellers hair.
So you have no problem with the teacher telling the yeller to stop
it, while ignoring that the hair puller is largely ignored in this.

> As for letting the "bullies" (which I'll take as a metaphor for
> trolls, since I've not once seen Nikos act like a bully) get away with
> things, none of these threads have been about pursuing any sort of
> justice, so don't try to frame the discussion as if they are.

No I'm just pointing out, that "he started it", can at times be
important enough to at least create some understanding for why someone
behaved in the way he did.

>> Not my problem. Why do you come to me? I didn't contribute to this
>> thread for about two days. That is two days of various contributors
>> that didn't accept their responsibility and whom you left alone.
>> If it wasn't a problem then that the positive feedback loop was
>> maintained, then why is it a problem now? I'll start taking you
>> seriously when I see you tackling the specific behaviour in a
>> consistent manner instead of you tackling specific contributors.
> 
> My apologies then for implying that you have been actively feeding the
> troll; I have not been paying attention to who is or isn't doing that.
>  I replied to you because you've been very vocal on the topic, and
> because you wrote things that I wanted to respond to, not to single
> you out as the problem.  I'm not going to individually address every
> single person who I think is contributing to the problem, because
> that's not my job and I don't have time for it.  If you think that's
> not being fair, then that's tough, but this mailing list is not a
> kindergarten.  We're all adults here, and I expect that others who are
> feeding the troll will have the maturity and self-awareness to
> recognize that what I wrote applies to them without me having to
> repeat myself a dozen times.

Well you can expect all you want. It is not going to happen. Your
expectations are completely unrealistic and the way you react will
be perceived by a number of people as just an attempt to getting those
that are frustrated silenced without much care about what caused those
frustrations.

>> If you leave a thread alone for four days while various contributors
>> maintain a positive feedback loop then you are implicitly saying
>> that such behaviour is not a big problem. So don't come complaining
>> now.
> 
> I've spoken up on this issue before.  I'm not going to repetitively
> respond to every single post or even every single thread that I think
> is problematic.  If I did that, then I would be part of the problem.
> As I said above, I chose to speak up now because you wrote things that
> I specifically wanted to respond to.  For the most part however I
> prefer silence in the knowledge that making noise just invites more
> noise.  For that reason you can expect that I 

Re: Please help with this

2013-11-13 Thread mkharper
On Wednesday, November 13, 2013 4:18:58 AM UTC, saad imran wrote:
> Could you point out any errors in my code:
> 
> 
> 
>  #This is a game where you have to escape a dragon.
> 
> # By Saad Imran
> 
> 
> 
> import random
> 
> import pygame
> 
> 
> 
> 
> 
> 
> 
> # Define questions and answers.
> 
> que1 = "4481 *2"
> 
> ans1 = "8962"
> 
> que2 = "457 * 21"
> 
> ans2 =  "9597"
> 
> que3 = "2345*23"
> 
> ans3 =  "53935"
> 
> que4 = "Who plays against the USA in golf's Walker Cup?"  
>  
> 
> ans4 = "britain"
> 
> que5 = "Which game is played in autumn using the fruit of the horse chestnut 
> tree?"
> 
> ans5 = "conkers"
> 
> que6 = "From what country does Lego come?"
> 
> ans6 = "denmark"
> 
> que7 = "What term is used in cricket for the two men on the field who decide 
> on whether batsmen are out, and signal for extras and boundaries?"
> 
> ans7 =  "umpire"
> 
> que8 = "What date was D-Day?"
> 
> ans8 = "06,06,1944"
> 
> que9 ="Who is called the 'Great One' in hockey history?"
> 
> ans9 = "wayne gretzky"
> 
> 
> 
> 
> 
> # intro
> 
> print("Welcome!")
> 
> print("")
> 
> name = input("What is your name? ")
> 
> print("")
> 
> print("You are in a cave and hear a dragon!",name)
> 
> print("")
> 
> print("Thinking you are doomed, you panic and run")
> 
> print("")
> 
> 
> 
> # Ask whether user wants to play or not
> 
> print("You run into a wizard who tells you that he will teleport you out of 
> the cave if you solve his questions!")
> 
> print("")
> 
> game = input("Do you trust him?(y/n) ")
> 
> print("")
> 
> 
> 
> #if he doesn't game is ended
> 
> if game == "N" or game == "n":
> 
> print("The dragon catches you and you are doomed!")
> 
> gameloop = False
> 
> loop = False
> 
> # if he does, game starts
> 
> 
> 
> else:
> 
> gameLoop = True
> 
> 
> 
> while gameLoop ==True:
> 
> 
> 
> # Tell user how to write answers
> 
> 
> 
> print("Please use all lower case letters. date format is dd,mm,")
> 
> print("dragon is red, You are green!")
> 
> 
> 
> 
> 
> 
> 
> # The following code intialises a pygame window where user can track 
> progress of self and dragon
> 
> # Needed to initialize pygame
> 
> pygame.init()
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> # define variable for user position
> 
> userX =75
> 
> userY =450
> 
> 
> 
> 
> 
> 
> 
> # define variable for dragon position.
> 
> dragonX = 0
> 
> dragonY = 450
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> # Define some Constants(colours and screen size)
> 
> BLACK = (0, 0, 0)
> 
> WHITE = (255, 255, 255)
> 
> GREEN = (0, 255, 0)
> 
> RED = (255, 0, 0)
> 
> 
> 
> SCREEN_WIDTH = 700
> 
> SCREEN_HEIGHT = 500
> 
> 
> 
> # Create a screen 
> 
> size = [SCREEN_WIDTH,SCREEN_HEIGHT]
> 
> screen = pygame.display.set_mode(size)
> 
> 
> 
> pygame.display.set_caption("dragonEscape Game")
> 
> 
> 
> # Used to manage how fast the screen updates
> 
> clock = pygame.time.Clock()
> 
> 
> 
> #Loop until the user clicks the close button.
> 
> loop = True
> 
> 
> 
> #  Main Program Loop ---
> 
> while loop == True:
> 
> # EVENT PROCESSING
> 
> for event in pygame.event.get():
> 
> if event.type == pygame.QUIT:   
> 
> loop = False 
> 
> 
> 
> #if user is caught
> 
> 
> 
> if userX <= dragonX:
> 
> print("The dragon ate you for dinner!")
> 
> loop = False
> 
> gameLoop = False
> 
> 
> 
> 
> 
> #if user wins
> 
> if userX >= 680:
> 
> 
> 
> print("You win!")
> 
> loop = False
> 
> gameLoop = False
> 
> 
> 
> 
> 
>  
> 
> # DRAW COMMANDS
> 
> screen.fill(WHITE)
> 
> 
> 
> 
> 
> pygame.draw.rect(screen, GREEN, [userX,userY,50,50])
> 
> pygame.draw.rect(screen, RED, [dragonX,dragonY,50,50])
> 
> pygame.draw.line(screen, BLACK, [680,0],[680,500],40)
> 
> 
> 
> 
> 
> #Code to generate random number
> 
> 
> 
> questionSelection = random.randrange(1,10)
> 
> 
> 
> 
> 
> # if statements that select question randomly based on random 
> number generated and collects user answer
> 
> print("")
> 
> print("")
> 
> print("")
> 
> print("")
> 
> print("")
> 
> print("")
> 
> if questionSelection == 1:
> 
> print(que1)
> 
> playerAnswer = input("What do you think the answer is?")
> 
> if playerAnswe

Re: To whoever hacked into my Database

2013-11-13 Thread Ferrous Cranus

Στις 13/11/2013 1:38 πμ, ο/η Mark Lawrence έγραψε:

On 12/11/2013 23:27, Ian Kelly wrote:

On Tue, Nov 12, 2013 at 2:59 PM, Ethan Furman  wrote:

Every time he uses foul language against somebody he's acting like a
bully.

Every time he reposts questions and ignores answers he's acting like a
bully.

Every time he declares that what he wants is the most important and
so he is
going to ignore our culture and the topic of this forum/ml/ng he is
acting
like a bully.

If you haven't seen those posts, I have.  Now you know.


Per Wikipedia: "Bullying is the use of force, threat, or coercion to
abuse, intimidate, or aggressively to impose domination over others.
... One essential prerequisite is the perception, by the bully or by
others, of an imbalance of social or physical power."

None of the behaviors that you cite are examples of bullying.



What would you classify insulting my late mother as?




I apologize for that and of course by that time i didn't knew this info 
about your mother.


But please recall how many times and in what degree you insulted me (let 
alone others insulting me simultaneously) prior of me loosing my temper 
and spoke the way i did.


When the pressure is too high and i'm having difficulties on solving 
something and all i get back are collective insults instead of actual 
help i let some steam off.


But my insults should have been explicitly directed at you, not at your 
mother.



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


Re: Please help with this

2013-11-13 Thread Peter Otten
mkharper wrote:

> Hi Saad,
> 
> I've had a play and the following "does something".
> (I'm running Python 2.7 so replaced input with raw_input.)
> (User can use upper or lower case, just lower it before test.)
> (I simplified the questions/answers so I could answer them.)
> 
> I'm out of time but hope the following helps.
> 
> Kind regards,
> 
> 
> Michael
> 
> 
> #!/usr/bin/env python
> """
> This is a game where you have to escape a dragon.
> By Saad Imran
> 
> """
> 
> import random
> import pygame
> 
> # Define questions and answers.
> 
> QUE = {1: "4 x 2",
>2: "3 x 6",
>3: "2 x 5",
>4: "6 / 2",
>5: "7 + 7",
>6: "8 - 3",
>7: "5 x 5",
>8: "4 / 1",
>9: "0 x 6", }
> 
> ANS = {1: "8;75;75",
>2: "18;75;75",
>3: "10;75;75",
>4: "3;75;75",
>5: "14;75;75",
>6: "5;75;75",
>7: "25;75;75",
>8: "4;75;75",
>9: "0;75;75", }
> 

> # Code to generate random number
> QUESEL = random.randrange(1, 10)

You can simplify that some more by putting question/answer pairs into a list

qa_pairs = [
("What is 4 x 2? ", "8"),
("What is 3 x 6? ", "18"),
#...
]

and then use random.choice() and tuple unpacking

question, answer = random.choice(qa_pairs)

if input(question) == answer: # python 2: replace input with raw_input
print("correct")
else:
print("UH-OH!")

You can nest the tuples if you really need other data

qa_pairs = [
("What is 4 x 2? ", ("8", 75, 75)),
("What is 3 x 6? ", ("18", 75, 75)),
#...
]

question, answer_and_offset = random.choice(qa_pairs)
answer, userx, dragonx = answer_and_offset
#...

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


Suggest an open-source issue tracker, with github integration and kanban boards?

2013-11-13 Thread Alec Taylor
Started to build this on my own; then was like, hang on! - This is
probably something very commonly requested…

Can you recommend an open source project (or two) written in Python;
which covers multi project + sub project issue tracking linked across
github repositories?

[on the github side, want to be able to reference "commit 
solved by patch from issue #"; fine to have that extra annotation only
present on my server]

Also would be perfect if it has kanban board support, issue
prioritisation and distribution/assignment amongst team members; as
well as related analytics.

Thanks for all suggestions! =)

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


Re: To whoever hacked into my Database

2013-11-13 Thread Antoon Pardon
Op 13-11-13 12:14, Ferrous Cranus schreef:
> Στις 13/11/2013 1:38 πμ, ο/η Mark Lawrence έγραψε:
>> On 12/11/2013 23:27, Ian Kelly wrote:
>>>
>>
>> What would you classify insulting my late mother as?
>>
> 
> 
> I apologize for that and of course by that time i didn't knew this info
> about your mother.
> 
> But please recall how many times and in what degree you insulted me (let
> alone others insulting me simultaneously) prior of me loosing my temper
> and spoke the way i did.
> 
> When the pressure is too high and i'm having difficulties on solving
> something and all i get back are collective insults instead of actual
> help i let some steam off.

You are again trying to spin this as if you are just the victim of
bullies.

But the fact is that you did get actual help. What you didn't get was
a solution completely to your satisfaction. You also displayed no
interest in actual learning but expected others to do your work.

This is a pattern that is repeated numerous times and people are
getting utterly fed up with it. So when you come around for yet
another round of the same, frustration levels rise and people
let off some steam.

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


Re: To whoever hacked into my Database

2013-11-13 Thread Ian Kelly
On Tue, Nov 12, 2013 at 6:19 PM, Ethan Furman  wrote:
> On 11/12/2013 03:27 PM, Ian Kelly wrote:
>>
>> On Tue, Nov 12, 2013 at 2:59 PM, Ethan Furman  wrote:
>>>
>>> Every time he uses foul language against somebody he's acting like a
>>> bully.
>>>
>>> Every time he reposts questions and ignores answers he's acting like a
>>> bully.
>>>
>>> Every time he declares that what he wants is the most important and so he
>>> is
>>> going to ignore our culture and the topic of this forum/ml/ng he is
>>> acting
>>> like a bully.
>>>
>>> If you haven't seen those posts, I have.  Now you know.
>>
>>
>> Per Wikipedia: "Bullying is the use of force, threat, or coercion to
>> abuse, intimidate, or aggressively to impose domination over others.
>> ... One essential prerequisite is the perception, by the bully or by
>> others, of an imbalance of social or physical power."
>
>
> So even though he is being verbally abusive, the fact that he's not standing
> over me with a stick makes him not a bully?  We'll have to agree to disagree
> on this point.

No, that's not my point.  Who has more power in this social forum, you
or Nikos?  I don't condone Nikos' behavior in any way, but if anybody
is acting like a bully here, it is the people attempting to intimidate
and coerce him into leaving.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-13 Thread Ian Kelly
On Wed, Nov 13, 2013 at 2:08 AM, Antoon Pardon
 wrote:
>> That doesn't mean that when somebody
>> misbehaves, you can do whatever you want in retaliation without regard
>> for others who might be involved.
>
> But I didn't do whatever. What I did was similar in what others
> had been doing before. And while those others were doing it
> they received very little reaction. So why the reaction now?

I've already answered that, so as far as I can see you're only asking
to be argumentative.

 "But he started it" wasn't an
 excuse in kindergarten, and it still isn't one now.
>>>
>>> Then that kindergarten teacher was lousy at her job and would
>>> probably let the bullies maninupulate her in punishing their
>>> victems. That is what you get if you unconditionally tell
>>> people that "he started it" can't be an excuse.
>>
>> Yes, when one kid is yelling at another kid because the second kid
>> pulled the first kid's hair, the teacher should just ignore the
>> yelling because, after all, "he started it."  I'm sure that won't
>> cause any disruption in the classroom at all, and having one kid
>> yelling probably isn't going to set any of the others off, is it?
>
> Thank you for making my point. You are concentrating completely
> on the yelling and ignoring that somebody pulled the yellers hair.
> So you have no problem with the teacher telling the yeller to stop
> it, while ignoring that the hair puller is largely ignored in this.

No, they both get detention.  But I'm not going to bother addressing
the hair puller about it in this case, because he is incorrigible.  It
would serve no purpose and only fan the flames.

> Well you can expect all you want. It is not going to happen. Your
> expectations are completely unrealistic and the way you react will
> be perceived by a number of people as just an attempt to getting those
> that are frustrated silenced without much care about what caused those
> frustrations.

There is absolutely nothing that I can do about what caused those
frustrations, so what practical difference does it make whether I care
or not?

> It looks like in your world you have a very limited idea of how adults
> behave. Expecting the others to behave like adults has often enough
> been the strategy of the priveledged to ignore justified frustration.

Nobody is being disenfranchised here.  If you want to make this about
privilege, then I will just say that I think it is the height of
privilege to be fussing over the fact that there are people who annoy
you on the internet, and moreover doing so to the detriment of the
community.

> It is a win either way. If the frustration is uttered in an adult,
> mature way it doesn't cause much discomfort and is easily ignored. So
> when those who are frustrated see that being adult and mature doesn't
> get them much and start reacting a bit less adultly and maturely the
> frustration can now be dismissed as not being done in an adult and
> mature way.
>
> That is your goal here too. You are not interested in the frustrations
> of a number of people. You just want to be able to ignore there are
> frustrated people on the news group.

It's not about me at all.  If it were, I would be more likely to just
unsubscribe than to raise a fuss about it.  It's also not about you,
and it's not even about Nikos.  What it is about is that this crap
about Nikos is often the first thing that newcomers will see when they
join this group.  You seem very concerned in your posts about what
kind of message I'm sending by what I choose to respond to.  Well,
think about what kind of message it sends to a new user when their
introduction to the group -- which is supposedly about Python -- is a
lot of flaming directed at some poster whom they know nothing about.
You keep trying to cast certain people who are frustrated by Nikos as
victims in all this, but they're not.  I think that all who have
posted in this thread, and many who haven't, are probably all
frustrated in one way or another by all this -- I know that I
certainly am.  The victims are the community as a whole, and anybody
who decides not to join because they see this fracas and decide to
seek out a more inviting forum.

Here's my plea to everybody, in a nutshell.  Remember that the name of
this group is comp.lang.python.  It's *not*
alt.misc.flame.trolls.nikos.sucks.  The topic here is Python, and if
you want to talk about that, then welcome and please do.  If on the
other hand you just want to vent your frustration, then find somewhere
else to do it.  Please.

I said I would be bowing out soon, and now I will.  This argument is
tiresome and seems only to be counter-productive.  If these threads
are still going on in another six months then I will probably speak up
again, and we can rejoin this circus then.
-- 
https://mail.python.org/mailman/listinfo/python-list


Trying tcompile an use the Python 3.4a

2013-11-13 Thread Ferrous Cranus

$ mkdir temp
$ cd temp
$ wget http://www.python.org/ftp/python/3.4/Python-3.4.tar.bz2
$ tar -xjvf Python-3.4.tar.bz2
$ cd Python-3.3.2
$ ./configure
$ make && make test
$ su
# make install
# exit
$ $ cd ../ && rm -rf Python-3.4


root@secure [/home/nikos/www/cgi-bin]# python3 -V
Python 3.4.0a4


can yu please tell me where python 3.4a was placed in the system?

i tried

#!/usr/bin/python3
#!/usr/local/bin/python3

and also is there a way to call it like #!/usr/bin/python

i know it can be done via ln 0s but i have to know where the newest 
python got installed.


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


Re: Bullying [was Re: To whoever hacked into my Database]

2013-11-13 Thread Ian Kelly
On Tue, Nov 12, 2013 at 8:40 PM, Steven D'Aprano  wrote:
> Is "bullying" the new "terrorism", which in turn is the new "socialism"?
> That is, a meaningless term of opprobrium used on anything you don't
> like? That's what it sounds like to me.
>
> Nikos has practically no power in this community. He's one person,
> friendless in this community, with no social standing. His position is
> way down the bottom of what little pecking order a bunch of geeks has.
> Nobody looks up at him for guidance or for hints as to what sort of
> behaviour is acceptable. He has no Python know-how to withhold from those
> he doesn't approve of (or inclination to help others). He can't even
> force anyone to read his comments. I say this not to make him out to be
> the victim here, he is at least equally responsible for the position he
> is in, but to highlight the absurdity of claiming he is "bullying"
> anywhere here.
>
> Just because (generic) you are annoyed by Nikos, or even if your feelings
> are hurt because he called you a bad name or insulted your dead mother,
> doesn't mean you are the victim of bullying. Claiming the badge of
> victimhood for mild annoyances and hurt feelings is one of the least
> admirable parts of the politically-correct crowd, please don't emulate
> them.

Well put.  If I had seen your response earlier, I would not have
written my own, because yours was much better written and more to the
point..
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Trying tcompile an use the Python 3.4a

2013-11-13 Thread Chris “Kwpolska” Warrick
On Wed, Nov 13, 2013 at 3:17 PM, Ferrous Cranus  wrote:
> $ mkdir temp
> $ cd temp
> $ wget http://www.python.org/ftp/python/3.4/Python-3.4.tar.bz2
> $ tar -xjvf Python-3.4.tar.bz2
> $ cd Python-3.3.2
> $ ./configure
> $ make && make test
> $ su
> # make install
> # exit
> $ $ cd ../ && rm -rf Python-3.4
>
>
> root@secure [/home/nikos/www/cgi-bin]# python3 -V
> Python 3.4.0a4
>
>
> can yu please tell me where python 3.4a was placed in the system?
>
> i tried
>
> #!/usr/bin/python3
> #!/usr/local/bin/python3
>
> and also is there a way to call it like #!/usr/bin/python
>
> i know it can be done via ln 0s but i have to know where the newest python
> got installed.
>
> Thank you.
> --
> https://mail.python.org/mailman/listinfo/python-list

The command you are looking for is: which python3
Alternatively, you could run `where python3` to see how big the mess
on your system is (i.e. how many interpreters you have).

-- 
Chris “Kwpolska” Warrick 
PGP: 5EAAEA16
stop html mail | always bottom-post | only UTF-8 makes sense
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Trying tcompile an use the Python 3.4a

2013-11-13 Thread Ferrous Cranus

Στις 13/11/2013 4:17 μμ, ο/η Ferrous Cranus έγραψε:

$ mkdir temp
$ cd temp
$ wget http://www.python.org/ftp/python/3.4/Python-3.4.tar.bz2
$ tar -xjvf Python-3.4.tar.bz2
$ cd Python-3.3.2
$ ./configure
$ make && make test
$ su
# make install
# exit
$ $ cd ../ && rm -rf Python-3.4


root@secure [/home/nikos/www/cgi-bin]# python3 -V
Python 3.4.0a4


can yu please tell me where python 3.4a was placed in the system?

i tried

#!/usr/bin/python3
#!/usr/local/bin/python3

and also is there a way to call it like #!/usr/bin/python

i know it can be done via ln 0s but i have to know where the newest
python got installed.

Thank you.



I also tried to install pip and easy_install on my CentOS but could not 
find them.


How can I install them?

Also, I have two versions of Python, 2.6.6 and 3.4a. How will pip make 
sure to link newly installed components with Python 3.4a ?

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


Re: Trying tcompile an use the Python 3.4a

2013-11-13 Thread Ferrous Cranus

Στις 13/11/2013 4:23 μμ, ο/η Chris “Kwpolska” Warrick έγραψε:

On Wed, Nov 13, 2013 at 3:17 PM, Ferrous Cranus  wrote:

$ mkdir temp
$ cd temp
$ wget http://www.python.org/ftp/python/3.4/Python-3.4.tar.bz2
$ tar -xjvf Python-3.4.tar.bz2
$ cd Python-3.3.2
$ ./configure
$ make && make test
$ su
# make install
# exit
$ $ cd ../ && rm -rf Python-3.4


root@secure [/home/nikos/www/cgi-bin]# python3 -V
Python 3.4.0a4


can yu please tell me where python 3.4a was placed in the system?

i tried

#!/usr/bin/python3
#!/usr/local/bin/python3

and also is there a way to call it like #!/usr/bin/python

i know it can be done via ln 0s but i have to know where the newest python
got installed.

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


The command you are looking for is: which python3
Alternatively, you could run `where python3` to see how big the mess
on your system is (i.e. how many interpreters you have).




root@secure [~]# which python
/usr/bin/python

root@secure [~]# which python3
/usr/local/bin/python3

root@secure [~]# python -V
Python 2.6.6

root@secure [~]# python3 -V
Python 3.4.0a4
root@secure [~]#
--
https://mail.python.org/mailman/listinfo/python-list


Re: Trying tcompile an use the Python 3.4a

2013-11-13 Thread Ferrous Cranus

Στις 13/11/2013 4:23 μμ, ο/η Chris “Kwpolska” Warrick έγραψε:

On Wed, Nov 13, 2013 at 3:17 PM, Ferrous Cranus  wrote:

$ mkdir temp
$ cd temp
$ wget http://www.python.org/ftp/python/3.4/Python-3.4.tar.bz2
$ tar -xjvf Python-3.4.tar.bz2
$ cd Python-3.3.2
$ ./configure
$ make && make test
$ su
# make install
# exit
$ $ cd ../ && rm -rf Python-3.4


root@secure [/home/nikos/www/cgi-bin]# python3 -V
Python 3.4.0a4


can yu please tell me where python 3.4a was placed in the system?

i tried

#!/usr/bin/python3
#!/usr/local/bin/python3

and also is there a way to call it like #!/usr/bin/python

i know it can be done via ln 0s but i have to know where the newest python
got installed.

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


The command you are looking for is: which python3
Alternatively, you could run `where python3` to see how big the mess
on your system is (i.e. how many interpreters you have).




root@secure [~]# which python3
/usr/local/bin/python3
root@secure [~]# where pyhton3
-bash: where: command not found

also how can a link the newset python to just /usr/bin/python.
here is what i tried

root@secure [~]# ln -s /usr/local/bin/python3 /usr/bin/python
ln: creating symbolic link `/usr/bin/python': File exists
root@secure [~]#
--
https://mail.python.org/mailman/listinfo/python-list


chroot to install packages

2013-11-13 Thread Himanshu Garg
I am writing a python script to run chroot command to chroot to a linux distro 
and then run commands.  How can I do this, as after chrooting, the script runs 
the commands relative to the outside not inside the chrooted env?
-- 
https://mail.python.org/mailman/listinfo/python-list


change volume of single audio device

2013-11-13 Thread moldevort87
hi,

i'd like to change the volume of my av-receiver (HDMI) and speakers (analogue) 
simultaneously. in order to use both outputs i'm using virtual audio cable but 
if i set it as default device and change volume, hdmi and analogue remains 
unchanged. 
i intend to script a command line tool in python providing to change the volume 
of a single device (eg "setvolume {deviceID} {volume}")

i've been looking for a similar tool, but none of them worked (eg nircmd); i'm 
using Win7. 

while looking for a solution i found that snippet of code

[CODE]
#!/usr/bin/env python
#Boa:PyApp:main
modules = {}
 
import ctypes
 
mixerSetControlDetails = (
ctypes.windll.winmm.mixerSetControlDetails)
 
mixerGetControlDetails = (
ctypes.windll.winmm.mixerGetControlDetailsA)
 
# Some constants
MIXER_OBJECTF_MIXER = 0 # mmsystem.h
VOLUME_CONTROL_ID = 0 # Same on all machines?
SPEAKER_LINE_FADER_ID = 0 # "Identifier  in OID value does not 
resolve to a positive integer"
MINIMUM_VOLUME = 0 # fader control (MSDN Library)
MAXIMUM_VOLUME = 65535 # fader control (MSDN Library)
 
class MIXERCONTROLDETAILS(ctypes.Structure):
_pack_ = 1
_fields_ = [('cbStruct', ctypes.c_ulong),
('dwControlID', ctypes.c_ulong),
('cChannels', ctypes.c_ulong),
('cMultipleItems', ctypes.c_ulong),
('cbDetails', ctypes.c_ulong),
('paDetails', ctypes.POINTER(ctypes.c_ulong))]
 
def setVolume(volume):
"""Set the speaker volume on the 'Volume Control' mixer"""
if not (MINIMUM_VOLUME <= volume <= MAXIMUM_VOLUME):
raise ValueError, "Volume out of range"
cd = MIXERCONTROLDETAILS(ctypes.sizeof(MIXERCONTROLDETAILS),
 SPEAKER_LINE_FADER_ID,
 1, 0,
 ctypes.sizeof(ctypes.c_ulong),
 ctypes.pointer(ctypes.c_ulong(volume)))
   
ret = mixerSetControlDetails(VOLUME_CONTROL_ID,
 ctypes.byref(cd),
 MIXER_OBJECTF_MIXER)
   
if ret != 0:
print WindowsError, "Error %d while setting volume" % ret
 
ret = mixerGetControlDetails(VOLUME_CONTROL_ID,
 ctypes.byref(cd),
 MIXER_OBJECTF_MIXER)
if ret != 0:
print WindowsError, "Error %d while setting volume" % ret
else:
print 'cbStruct', cd.cbStruct
print 'dwControlID', cd.dwControlID
print 'cChannels', cd.cChannels
print 'cMultipleItems', cd.cMultipleItems
print 'cbDetails', cd.cbDetails
print 'paDetails', cd.paDetails.contents
return
 
setVolume((2**16-1)/2)
 
from ctypes import *
from struct import *
 
winmm= windll.winmm
print
print 'waveOutGetNumDevs=',winmm.waveOutGetNumDevs()
print 'mixerGetNumDevs', winmm.mixerGetNumDevs()
 
wvcps= ' '*52
print 'res:', winmm.waveOutGetDevCapsA(0,wvcps,len(wvcps))
 
res = unpack('IIL32cLI', wvcps)
wMid=res[0]
wPid=res[1]
vDriverVersion=res[2]
szPname=''.join(res[3:35])
dwFormats=res[35]
wChannels=res[36]
print 'wMid=',wMid
print 'wPid=',wPid
print 'vDriverVersion=',vDriverVersion
print 'szPname=',szPname
print 'dwFormats=',dwFormats
print 'wChannels=',wChannels
 
vol=c_ulong()
print 'res', winmm.waveOutGetVolume(0, byref(vol))
 
print 'l:', vol.value & 0x, 'r:',vol.value >> 16 # left, right
[/CODE]


on executing i get
[CODE]
< Error 11 while setting volume
 Error 11 while setting volume
 
waveOutGetNumDevs= 3
mixerGetNumDevs 4
res: 0
wMid= 6553601
wPid= 1537
vDriverVersion= 2037083727
szPname= o (AMD High Definition Audi
dwFormats= 2
wChannels= 36
res 0
l: 65535 r: 0
[/CODE]

Could anyone tell me why this error occurs?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: change volume of single audio device

2013-11-13 Thread Jean-Michel Pichavant
- Original Message -
> hi,
> 
> i'd like to change the volume of my av-receiver (HDMI) and speakers
> (analogue) simultaneously. in order to use both outputs i'm using
> virtual audio cable but if i set it as default device and change
> volume, hdmi and analogue remains unchanged.
> i intend to script a command line tool in python providing to change
> the volume of a single device (eg "setvolume {deviceID} {volume}")
> 
> i've been looking for a similar tool, but none of them worked (eg
> nircmd); i'm using Win7.
> 
> while looking for a solution i found that snippet of code
> 
> [CODE]
> #!/usr/bin/env python
> #Boa:PyApp:main
> modules = {}
>  
> import ctypes
>  
> mixerSetControlDetails = (
> ctypes.windll.winmm.mixerSetControlDetails)
>  
> mixerGetControlDetails = (
> ctypes.windll.winmm.mixerGetControlDetailsA)
>  
> # Some constants
> MIXER_OBJECTF_MIXER = 0 # mmsystem.h
> VOLUME_CONTROL_ID = 0 # Same on all machines?
> SPEAKER_LINE_FADER_ID = 0 # "Identifier  in OID value
> does not resolve to a positive integer"
> MINIMUM_VOLUME = 0 # fader control (MSDN Library)
> MAXIMUM_VOLUME = 65535 # fader control (MSDN Library)
>  
> class MIXERCONTROLDETAILS(ctypes.Structure):
> _pack_ = 1
> _fields_ = [('cbStruct', ctypes.c_ulong),
> ('dwControlID', ctypes.c_ulong),
> ('cChannels', ctypes.c_ulong),
> ('cMultipleItems', ctypes.c_ulong),
> ('cbDetails', ctypes.c_ulong),
> ('paDetails', ctypes.POINTER(ctypes.c_ulong))]
>  
> def setVolume(volume):
> """Set the speaker volume on the 'Volume Control' mixer"""
> if not (MINIMUM_VOLUME <= volume <= MAXIMUM_VOLUME):
> raise ValueError, "Volume out of range"
> cd = MIXERCONTROLDETAILS(ctypes.sizeof(MIXERCONTROLDETAILS),
>  SPEAKER_LINE_FADER_ID,
>  1, 0,
>  ctypes.sizeof(ctypes.c_ulong),
>  ctypes.pointer(ctypes.c_ulong(volume)))
>
> ret = mixerSetControlDetails(VOLUME_CONTROL_ID,
>  ctypes.byref(cd),
>  MIXER_OBJECTF_MIXER)
>
> if ret != 0:
> print WindowsError, "Error %d while setting volume" % ret
>  
> ret = mixerGetControlDetails(VOLUME_CONTROL_ID,
>  ctypes.byref(cd),
>  MIXER_OBJECTF_MIXER)
> if ret != 0:
> print WindowsError, "Error %d while setting volume" % ret
> else:
> print 'cbStruct', cd.cbStruct
> print 'dwControlID', cd.dwControlID
> print 'cChannels', cd.cChannels
> print 'cMultipleItems', cd.cMultipleItems
> print 'cbDetails', cd.cbDetails
> print 'paDetails', cd.paDetails.contents
> return
>  
> setVolume((2**16-1)/2)
>  
> from ctypes import *
> from struct import *
>  
> winmm= windll.winmm
> print
> print 'waveOutGetNumDevs=',winmm.waveOutGetNumDevs()
> print 'mixerGetNumDevs', winmm.mixerGetNumDevs()
>  
> wvcps= ' '*52
> print 'res:', winmm.waveOutGetDevCapsA(0,wvcps,len(wvcps))
>  
> res = unpack('IIL32cLI', wvcps)
> wMid=res[0]
> wPid=res[1]
> vDriverVersion=res[2]
> szPname=''.join(res[3:35])
> dwFormats=res[35]
> wChannels=res[36]
> print 'wMid=',wMid
> print 'wPid=',wPid
> print 'vDriverVersion=',vDriverVersion
> print 'szPname=',szPname
> print 'dwFormats=',dwFormats
> print 'wChannels=',wChannels
>  
> vol=c_ulong()
> print 'res', winmm.waveOutGetVolume(0, byref(vol))
>  
> print 'l:', vol.value & 0x, 'r:',vol.value >> 16 # left,
> right
> [/CODE]
> 
> 
> on executing i get
> [CODE]
> < Error 11 while setting volume
>  Error 11 while setting volume
>  
> waveOutGetNumDevs= 3
> mixerGetNumDevs 4
> res: 0
> wMid= 6553601
> wPid= 1537
> vDriverVersion= 2037083727
> szPname= o (AMD High Definition Audi
> dwFormats= 2
> wChannels= 36
> res 0
> l: 65535 r: 0
> [/CODE]
> 

I'm afraid there's nothing related to python here.
It looks like the win function mixerSetControlDetails returned the error 
MMSYSERR_INVALPARAM.
You've set your devices IDs to 0. Are you sure this is correct ? 


Cheers,


JM


-- IMPORTANT NOTICE: 

The contents of this email and any attachments are confidential and may also be 
privileged. If you are not the intended recipient, please notify the sender 
immediately and do not disclose the contents to any other person, use it for 
any purpose, or store or copy the information in any medium. Thank you.
-- 
https://mail.python.org/mailman/li

Re: Trying tcompile an use the Python 3.4a

2013-11-13 Thread Steven D'Aprano
On Wed, 13 Nov 2013 16:26:37 +0200, Ferrous Cranus wrote:

> root@secure [~]# which python3
> /usr/local/bin/python3
> root@secure [~]# where pyhton3
> -bash: where: command not found

That just means that you don't have the "where" command installed. Oh 
well, if it's not installed you can't use it. (I don't have it installed 
on any of my systems either.)


> also how can a link the newset python to just /usr/bin/python.

Don't do that, you will break your system. The OS expects the python 
command to be Python 2, not Python 3, and ESPECIALLY not an alpha-quality 
version 3.4.

If you decide to ignore this advice, and break your system, don't bother 
ask for help here. You won't get any from me.


> here is what i tried
> 
> root@secure [~]# ln -s /usr/local/bin/python3 /usr/bin/python ln:
> creating symbolic link `/usr/bin/python': File exists root@secure [~]#

That's not a Python issue, that's a basic Linux sys admin issue. Go buy 
yourself a book on Linux and study that. Or do some googling. Read the 
man page for ln. Or just spend three seconds thinking about what an error 
message like "File exists" could possibly mean.

Really Nikos, you're not a beginner at this. Your English is excellent. 
Between simple logic and Google, you ought to be able to work out what 
"File exists" means faster than writing a post and sending it here.


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


Re: change volume of single audio device

2013-11-13 Thread Steven D'Aprano
On Wed, 13 Nov 2013 06:40:02 -0800, moldevort87 wrote:

> on executing i get
> [CODE]
> < Error 11 while setting volume
>  Error 11 while setting volume
>  
> waveOutGetNumDevs= 3
> mixerGetNumDevs 4
> res: 0
> wMid= 6553601
> wPid= 1537
> vDriverVersion= 2037083727
> szPname= o (AMD High Definition Audi
> dwFormats= 2
> wChannels= 36
> res 0
> l: 65535 r: 0
> [/CODE]
> 
> Could anyone tell me why this error occurs?

It's a Windows error, not a Python error. You'll need to look up the 
documentation for the Windows API used (I think it is 
mixerSetControlDetails) and see what return code 11 means. I don't even 
know if it's documented.

Start by googling for "mixerSetControlDetails return value 11" and go on 
from there.



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


Re: change volume of single audio device

2013-11-13 Thread Tim Chase
On 2013-11-13 16:05, Steven D'Aprano wrote:
> Start by googling for "mixerSetControlDetails return value 11" and
> go on from there.

Sounds like Nigel at work.[1]

-tkc


http://en.wikipedia.org/wiki/Up_to_eleven
-- 
https://mail.python.org/mailman/listinfo/python-list


Jabberbot

2013-11-13 Thread Matt Graves
I'm using the jabberbot library and there is not a whole lot of documentation 
on it. Does anyone have experience with this library?

This is basically the only example given:


-
from jabberbot import JabberBot, botcmd
import datetime

class SystemInfoJabberBot(JabberBot):
@botcmd
def serverinfo( self, mess, args):
"""Displays information about the server"""
version = open('/proc/version').read().strip()
loadavg = open('/proc/loadavg').read().strip()

return '%s\n\n%s' % ( version, loadavg, )

@botcmd
def time( self, mess, args):
"""Displays current server time"""
return str(datetime.datetime.now())

@botcmd
def rot13( self, mess, args):
"""Returns passed arguments rot13'ed"""
return args.encode('rot13')

@botcmd
def whoami(self, mess, args):
"""Tells you your username"""
return mess.getFrom().getStripped()


username = 'xxx...@..com'
password = 'x'
bot = SystemInfoJabberBot(username,password)
bot.serve_forever()

-
I cannot figure out how I would have it simulate a conversation. For example, 
if I added 

@botcmd
def Hello(self, mess, args):
return "Hi, how are you?"

how would I get it to carry on from here? To look for different answers to the 
response that was returned. Any bit of information would be appreciated. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Trying tcompile an use the Python 3.4a

2013-11-13 Thread Steven D'Aprano
On Wed, 13 Nov 2013 16:17:22 +0200, Ferrous Cranus wrote:

> $ mkdir temp
> $ cd temp
> $ wget http://www.python.org/ftp/python/3.4/Python-3.4.tar.bz2 $ tar
> -xjvf Python-3.4.tar.bz2
> $ cd Python-3.3.2
> $ ./configure
> $ make && make test
> $ su
> # make install
> # exit
> $ $ cd ../ && rm -rf Python-3.4
> 
> 
> root@secure [/home/nikos/www/cgi-bin]# python3 -V Python 3.4.0a4
> 
> 
> can yu please tell me where python 3.4a was placed in the system?
> 
> i tried
> 
> #!/usr/bin/python3
> #!/usr/local/bin/python3

And did they work? What result did you get? You've been here long enough 
that you ought to know better than to post a question like this without 
showing the actual error that you received.


> and also is there a way to call it like #!/usr/bin/python

Of course there is, but only if you wish to break your system. The OS 
will be expecting /usr/bin/python to be Python 2. Leave it be.


> i know it can be done via ln 0s but i have to know where the newest
> python got installed.

Here's one way (although not the best):

sudo updatedb
locate python | grep bin

Or, you can start up the Python version of your choice, then do:


py> import sys
py> sys.executable
'/usr/local/bin/python2.5'


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


Re: Jabberbot

2013-11-13 Thread Mark Lawrence

On 13/11/2013 16:12, Matt Graves wrote:

I'm using the jabberbot library and there is not a whole lot of documentation 
on it. Does anyone have experience with this library?



[snip code from http://thp.io/2007/python-jabberbot/]


I cannot figure out how I would have it simulate a conversation. For example, 
if I added

 @botcmd
 def Hello(self, mess, args):
 return "Hi, how are you?"

how would I get it to carry on from here? To look for different answers to the 
response that was returned. Any bit of information would be appreciated.



From the link above "More examples

Starting with version 0.7, more examples can be found in the examples/ 
subdirectory of the source distribution."


Have you looked at these?

--
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: Trying tcompile an use the Python 3.4a

2013-11-13 Thread Ferrous Cranus

Στις 13/11/2013 6:13 μμ, ο/η Steven D'Aprano έγραψε:


and also is there a way to call it like #!/usr/bin/python


Of course there is, but only if you wish to break your system. The OS
will be expecting /usr/bin/python to be Python 2. Leave it be.


Okey i will leave it be although i dislike the idea of using the shebang 
constructor as #~/usr/local/bin/python3


Is there any way that i can use it as it was #!/usr/bin/python but 
firing python3 instead of python 2.6.6 ?


Also i'm tryong 'yum install python-pip' because some modules like 
'pymysql' and 'pygeoip' are missing but CentOS doesn't seem able to 
detect it.


Please help me install 'pip' so i can install the modules.
--
https://mail.python.org/mailman/listinfo/python-list


Re: Jabberbot

2013-11-13 Thread Matt Graves
On Wednesday, November 13, 2013 11:32:24 AM UTC-5, Mark Lawrence wrote:
> On 13/11/2013 16:12, Matt Graves wrote:
> 
> > I'm using the jabberbot library and there is not a whole lot of 
> > documentation on it. Does anyone have experience with this library?
> 
> >
> 
> 
> 
> [snip code from http://thp.io/2007/python-jabberbot/]
> 
> 
> 
> > I cannot figure out how I would have it simulate a conversation. For 
> > example, if I added
> 
> >
> 
> >  @botcmd
> 
> >  def Hello(self, mess, args):
> 
> >  return "Hi, how are you?"
> 
> > 
> 
> > how would I get it to carry on from here? To look for different answers to 
> > the response that was returned. Any bit of information would be appreciated.
> 
> >
> 
> 
> 
>  From the link above "More examples
> 
> 
> 
> Starting with version 0.7, more examples can be found in the examples/ 
> 
> subdirectory of the source distribution."
> 
> 
> 
> Have you looked at these?
> 
> 
> 
> -- 
> 
> Python is the second best programming language in the world.
> 
> But the best has yet to be invented.  Christian Tismer
> 
> 
> 
> Mark Lawrence

I have, but unfortunately they are about just as clear as the example I posted. 
The examples they posted are relevant for certain things, but not what I'm 
looking to do. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Jabberbot

2013-11-13 Thread Mark Lawrence

On 13/11/2013 16:42, Matt Graves wrote:

On Wednesday, November 13, 2013 11:32:24 AM UTC-5, Mark Lawrence wrote:

On 13/11/2013 16:12, Matt Graves wrote:


I'm using the jabberbot library and there is not a whole lot of documentation 
on it. Does anyone have experience with this library?








[snip code from http://thp.io/2007/python-jabberbot/]




I cannot figure out how I would have it simulate a conversation. For example, 
if I added







  @botcmd



  def Hello(self, mess, args):



  return "Hi, how are you?"







how would I get it to carry on from here? To look for different answers to the 
response that was returned. Any bit of information would be appreciated.








  From the link above "More examples



Starting with version 0.7, more examples can be found in the examples/

subdirectory of the source distribution."



Have you looked at these?



--

Python is the second best programming language in the world.

But the best has yet to be invented.  Christian Tismer



Mark Lawrence


I have, but unfortunately they are about just as clear as the example I posted. 
The examples they posted are relevant for certain things, but not what I'm 
looking to do.



Bah humbug, back to the drawing board :(

Slight aside, would you please read and action this 
https://wiki.python.org/moin/GoogleGroupsPython, a quick glance above 
will tell you why, thanks.


--
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: Trying tcompile an use the Python 3.4a

2013-11-13 Thread Ned Batchelder
On Wednesday, November 13, 2013 11:38:53 AM UTC-5, Ferrous Cranus wrote:
> Στις 13/11/2013 6:13 μμ, ο/η Steven D'Aprano έγραψε:
> 
> >> and also is there a way to call it like #!/usr/bin/python
> >
> > Of course there is, but only if you wish to break your system. The OS
> > will be expecting /usr/bin/python to be Python 2. Leave it be.
> 
> Okey i will leave it be although i dislike the idea of using the shebang 
> constructor as #~/usr/local/bin/python3
> 
> Is there any way that i can use it as it was #!/usr/bin/python but 
> firing python3 instead of python 2.6.6 ?

No, you can't.  "python" should mean Python 2.x.  If you want to use Python 3, 
invoke it as "python3".

BUT: you should have a good reason to switch to Python 3.  Your existing Python 
programs WILL NOT WORK with Python 3.  They will require porting from Python 2 
to Python 3, and that is not always a simple task, especially when you are 
dealing with text, such as on a web site.

I strongly recommend that you stay on Python 2, and focus on other concerns.  
"I want the latest Python" is probably not a good enough reason to switch.

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


Re: Trying tcompile an use the Python 3.4a

2013-11-13 Thread Chris “Kwpolska” Warrick
On Wed, Nov 13, 2013 at 5:38 PM, Ferrous Cranus  wrote:
> Στις 13/11/2013 6:13 μμ, ο/η Steven D'Aprano έγραψε:
>
>
>>> and also is there a way to call it like #!/usr/bin/python
>>
>>
>> Of course there is, but only if you wish to break your system. The OS
>> will be expecting /usr/bin/python to be Python 2. Leave it be.
>
>
> Okey i will leave it be although i dislike the idea of using the shebang
> constructor as #~/usr/local/bin/python3
> Is there any way that i can use it as it was #!/usr/bin/python but firing
> python3 instead of python 2.6.6 ?

You can link it to /usr/bin/python3.  There should be no problem when
you do this.

> Also i'm tryong 'yum install python-pip' because some modules like 'pymysql'
> and 'pygeoip' are missing but CentOS doesn't seem able to detect it.

That should install it for the Python 2.6.6 you have, and possibly
under the name `python-pip` because of various shenanigans in the
redhatesque repos.

> Please help me install 'pip' so i can install the modules.

http://www.pip-installer.org/en/latest/installing.html#install-or-upgrade-setuptools

Get ez_setup.py and get-pip.py, and run them with the desired Python.

-- 
Chris “Kwpolska” Warrick 
PGP: 5EAAEA16
stop html mail | always bottom-post | only UTF-8 makes sense
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Reading c struct via python

2013-11-13 Thread Lakshmipathi.G
> Looks like your "e"... Is that the key field?

Yes, you are right 'e' is the key. And rest of them are data.

>AND the order of the items is "o" before "i"
>-- that doesn't seem to match your C struct definition.

Sorry, I was testing the bdb and while doing that I noticed,
c-struct order is not same as inserted bdb record . But forgot to
fix the struct order before posting it here.

(And also I didn't expect someone will dig this deeper on the binary
string output :p . Thanks for your effort! )


>"s" format in which you precode the length of the string in the
>format ("10s" is a 10 character string), and "p" format in which the first
>byte of the string is the length (0..255) of the rest of the string. The
>struct module doesn't handle C-type null terminated strings directly.

I think we can use 'p' format. (Thus storing the string-length before
actual
string content). That should help us unpack easily.

Thanks  Dennis Lee Bieber, for the detailed info and step by step parsing
of the output. It really helped.



--
> Wulfraed Dennis Lee Bieber AF6VN
> wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.com/
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>



-- 

Cheers,
Lakshmipathi.G
FOSS Programmer.
www.giis.co.in
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-13 Thread Antoon Pardon
Op 13-11-13 15:10, Ian Kelly schreef:

>> Well you can expect all you want. It is not going to happen. Your
>> expectations are completely unrealistic and the way you react will
>> be perceived by a number of people as just an attempt to getting those
>> that are frustrated silenced without much care about what caused those
>> frustrations.
> 
> There is absolutely nothing that I can do about what caused those
> frustrations, so what practical difference does it make whether I care
> or not?

If you want to persuade people to change their behaviour, it matters
very much if you can show them you care.

>> It looks like in your world you have a very limited idea of how adults
>> behave. Expecting the others to behave like adults has often enough
>> been the strategy of the priveledged to ignore justified frustration.
> 
> Nobody is being disenfranchised here.  If you want to make this about
> privilege, then I will just say that I think it is the height of
> privilege to be fussing over the fact that there are people who annoy
> you on the internet, and moreover doing so to the detriment of the
> community.

Is it? Then why are you fussing here? Why don't you address the spoon
feeders who frustrate other group members to the detriment of the community.

>> It is a win either way. If the frustration is uttered in an adult,
>> mature way it doesn't cause much discomfort and is easily ignored. So
>> when those who are frustrated see that being adult and mature doesn't
>> get them much and start reacting a bit less adultly and maturely the
>> frustration can now be dismissed as not being done in an adult and
>> mature way.
>>
>> That is your goal here too. You are not interested in the frustrations
>> of a number of people. You just want to be able to ignore there are
>> frustrated people on the news group.
> 
> It's not about me at all.  If it were, I would be more likely to just
> unsubscribe than to raise a fuss about it.  It's also not about you,
> and it's not even about Nikos.  What it is about is that this crap
> about Nikos is often the first thing that newcomers will see when they
> join this group.

So? If this wasn't about you, this just wouldn't make a difference to
you.

> You seem very concerned in your posts about what
> kind of message I'm sending by what I choose to respond to.

Just making sure you were aware of that aspect as the rest of your contribution
strongly suggested you were not.

> Well,
> think about what kind of message it sends to a new user when their
> introduction to the group -- which is supposedly about Python -- is a
> lot of flaming directed at some poster whom they know nothing about.

Well one message obviously is that it is possible to annoy the regulars to
the point that they start flaming you. I don't think that is bad.

> You keep trying to cast certain people who are frustrated by Nikos as
> victims in all this, but they're not.  I think that all who have
> posted in this thread, and many who haven't, are probably all
> frustrated in one way or another by all this -- I know that I
> certainly am.  The victims are the community as a whole, 

The community as a whole suffers when its members get frustrated and
one part of the community telling the other part to just deal with
it is no way to turn the community into something welcoming again and
is IMO more detrimental to the community than a number of people
venting their frustration.

You expect those that get frustrated to tolerate Nikos and to tolerate
the spoon feeding, but you are unable to tolerate the venting of
frustrations.

> and anybody
> who decides not to join because they see this fracas and decide to
> seek out a more inviting forum.

Why would they be a victim? What is there to be victim about seeking
out a more inviting forum? I also think you are confusing a welcome
community with a community without conflict.

> Here's my plea to everybody, in a nutshell.  Remember that the name of
> this group is comp.lang.python.  It's *not*
> alt.misc.flame.trolls.nikos.sucks.

It is also not alt.misc.keep.spoon.feeding.nikos.

> The topic here is Python, and if
> you want to talk about that, then welcome and please do.  If on the
> other hand you just want to vent your frustration, then find somewhere
> else to do it.  Please.

But if you want to spoon feed a help vampire to the detriment of the
group you can go right ahead?

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


Re: To whoever hacked into my Database

2013-11-13 Thread superchromix


hi all,

I've been thinking about learning Python for scientific programming.. but all 
of these flame war type posts make the user community look pretty lame.  How 
did all of these nice packages get written when most of the user interaction is 
 this??

Can anyone tell me, is there another newsgroup where the discussion is more on 
python programming?

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


Packing byte fields and an array object into struct

2013-11-13 Thread krishna2prasad
Hello,

I am trying to build a structure to be passed down to an I2C device driver. The 
driver expects a struct that has a data array of size 512 bytes among other 
things. This is my code -

rd_wr   = 0x0   # Read operation
i2c_addr= addr
mux = mux_sel
multi_len   = count
cmd = 0x0 
i2c_inst_type = CHEL_I2C_AUTO_RD_TYPE_5
flag= CHEL_I2C_AUTO_VALID
status  = 0x0 
data= array.array('B', (0 for x in range(0,512)))

os_inst_bytes = (struct.pack('B', rd_wr)  +
 struct.pack('B', i2c_addr)   +
 struct.pack('B', mux)+
 struct.pack('B', multi_len)  +   
 struct.pack('B', cmd)+
 struct.pack('B', i2c_inst_type)  +
 struct.pack('B', flag)   +
 struct.pack('I', status) +   
 struct.pack('512B', data))

#Convert to byte array
os_inst = bytearray(os_inst_bytes)

ret = fcntl.ioctl(self._dev_fd,
  self.__IOWR(FXCB_FPGAIO_I2C_AUTO_OS_INST),
  os_inst, 1)

I get an error like this -

591  struct.pack('B', flag)   +
592  struct.pack('I', status) +

--> 593 struct.pack('512B', data))

error: pack requires exactly 512 arguments

In [1]:

Even though data is a 512 element array, it is not treat as such in this 
struct.pack. The data field is used to return data from the driver. I should be 
able to unpack the struct os_inst and read the data buffer after the IOCTL 
call. How can I achieve this ?

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


Re: To whoever hacked into my Database

2013-11-13 Thread Ned Batchelder
On Wednesday, November 13, 2013 1:27:39 PM UTC-5, superchromix wrote:
> hi all,
> 
> I've been thinking about learning Python for scientific programming.. but all 
> of these flame war type posts make the user community look pretty lame.  How 
> did all of these nice packages get written when most of the user interaction 
> is  this??
> 
> Can anyone tell me, is there another newsgroup where the discussion is more 
> on python programming?
> 
> thanks

I apologize for all of the flame wars.  All online communities have to deal 
with negative forces in their midst, and we are no exception. It doesn't always 
go smoothly.

Please start a new thread with your question about scientific programming.  I 
promise it won't go badly.

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


Re: Packing byte fields and an array object into struct

2013-11-13 Thread Ned Batchelder
On Wednesday, November 13, 2013 1:31:49 PM UTC-5, krishna...@gmail.com wrote:
> Hello,
> 
> I am trying to build a structure to be passed down to an I2C device driver. 
> The driver expects a struct that has a data array of size 512 bytes among 
> other things. This is my code -
> 
> rd_wr   = 0x0   # Read operation
> i2c_addr= addr
> mux = mux_sel
> multi_len   = count
> cmd = 0x0 
> i2c_inst_type = CHEL_I2C_AUTO_RD_TYPE_5
> flag= CHEL_I2C_AUTO_VALID
> status  = 0x0 
> data= array.array('B', (0 for x in range(0,512)))
> 
> os_inst_bytes = (struct.pack('B', rd_wr)  +
>  struct.pack('B', i2c_addr)   +
>  struct.pack('B', mux)+
>  struct.pack('B', multi_len)  +   
>  struct.pack('B', cmd)+
>  struct.pack('B', i2c_inst_type)  +
>  struct.pack('B', flag)   +
>  struct.pack('I', status) +   
>  struct.pack('512B', data))
> 
> #Convert to byte array
> os_inst = bytearray(os_inst_bytes)
> 
> ret = fcntl.ioctl(self._dev_fd,
>   self.__IOWR(FXCB_FPGAIO_I2C_AUTO_OS_INST),
>   os_inst, 1)
> 
> I get an error like this -
> 
> 591  struct.pack('B', flag)   +
> 592  struct.pack('I', status) +
> 
> --> 593 struct.pack('512B', data))
> 
> error: pack requires exactly 512 arguments
> 
> In [1]:
> 
> Even though data is a 512 element array, it is not treat as such in this 
> struct.pack. The data field is used to return data from the driver. I should 
> be able to unpack the struct os_inst and read the data buffer after the IOCTL 
> call. How can I achieve this ?
> 
> Thanks in advance!

To make a 512-byte field in struct, use '512s' with a data value of ''.  It 
will zero-pad the result and give you 512 zero bytes.  Also, you can use 
multiple format specifiers in one struct.pack call:

os_inst_bytes = struct.pack('7BI512s', rd_wr, i2c_addr, muc, multi_len, cmd, 
i2c_inst_type, flag, status, '')

Lastly, I suspect the value returned from struct.pack is byte-string enough for 
the ioctl call, no need to use bytearray.

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


Re: To whoever hacked into my Database

2013-11-13 Thread lconrad





On Wednesday 13/11/2013 at 12:31 pm, superchromix  wrote:



hi all,

I've been thinking about learning Python for scientific programming.. 
but all of these flame war type posts make the user community look 
pretty lame.  How did all of these nice packages get written when most 
of the user interaction is  this??


Can anyone tell me, is there another newsgroup where the discussion is 
more on python programming?


"most of the user interaction is  this??"

LOL

hope your problem and code analysis is better than your social 
analysis


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


Re: To whoever hacked into my Database

2013-11-13 Thread Steve Simmons


On 13/11/2013 19:27, superchromix wrote:


hi all,

I've been thinking about learning Python for scientific programming.. but all 
of these flame war type posts make the user community look pretty lame.  How 
did all of these nice packages get written when most of the user interaction is 
 this??

Can anyone tell me, is there another newsgroup where the discussion is more on 
python programming?

thanks
Sadly, I'm inclined to agree with you but this is a relatively recent 
development.


I joined this group about a year ago and, while it wasn't all 'sweetness 
and light', it was a lot better than '. . . . this' - in fact I'd say it 
was pretty good, I certainly got treated well and got quality answers to 
my (few) questions.  Right now, we have a 'help vampire' who has 
demanded an inordinate amount of time from the list members - and not in 
a polite or well structured way.  The members of this list have 
responded in various ways, ranging from continuing to help through to 
kill-file on the offending person. The discourse around how to deal with 
this issue has degenerated into some unfortunate and vitriolic debate.


As far as I can see, it remains possible to post sensible, well 
constructed questions and get sensible well-considered answers - just 
let the intense arguments pass you by and focus on your own issues and 
their resolutions and you'll be fine on this list.  There are plenty of 
very capable Pythonistas ready to help.


Some basic advice (not wanting to teach you to suck eggs):
- Include relevant info on your environment (OS; version of Python; any 
specialist libraries in use; etc)

- Come to the list with a clear description of what you are trying to do
- Preferably include a code sample that displays the problem
- Include the trace-back if you are getting one
- Try to avoid using Google Groups as your 'reader'

Welcome!  Ignore the BS and Enjoy  :-)

Steve S

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


Re: To whoever hacked into my Database

2013-11-13 Thread Zachary Ware
On Wed, Nov 13, 2013 at 12:27 PM, superchromix  wrote:
>
>
> hi all,
>
> I've been thinking about learning Python for scientific programming.. but all 
> of these flame war type posts make the user community look pretty lame.  How 
> did all of these nice packages get written when most of the user interaction 
> is  this??
>
> Can anyone tell me, is there another newsgroup where the discussion is more 
> on python programming?

Please don't judge the whole community by this thread, I promise we're
not all bad!  The majority of the traffic on this list is of a useful
sort, and you can learn fairly quickly the addresses that are best
ignored, blocked, or otherwise passed over.  For myself using Gmail, I
have a filter set up to mark particular threads that I don't want to
be notified about and mute them after the first few mails come in.  I
didn't see your message initially because it was part of a muted
thread, I only saw it at all because the thread spilled over the 100
message mark into a "new" thread in Gmail with one of the replies to
your message.

Also, if you have a specific question about how to do something in
Python you can try the tutor list (tu...@python.org) which is much
more focused, much lower traffic, and has several very knowledgeable
Pythonistas listening in.

Give us a chance, and I don't think we'll let you down :)

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


Oh look, another language (ceylon)

2013-11-13 Thread Neal Becker
http://ceylon-lang.org/documentation/1.0/introduction/

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


Re: To whoever hacked into my Database

2013-11-13 Thread Oscar Benjamin
On Nov 13, 2013 6:31 PM, "superchromix"  wrote:
>
> I've been thinking about learning Python for scientific programming.. but
all of these flame war type posts make the user community look pretty lame.
 How did all of these nice packages get written when most of the user
interaction is  this??

This isn't usually what happens on this list. Most people on this list
(myself included) are ignoring or at least not contributing to these
particular threads.

>
> Can anyone tell me, is there another newsgroup where the discussion is
more on python programming?

For a beginner I would certainly recommend the python-tutor list. I've
never seen a flame war there. Threads tend to stay on-topic and are usually
helpful to the OP. The tutor list is for generic python problems but you
can usually get help for simple scientific programming problems.

https://mail.python.org/mailman/listinfo/tutor

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


Re: To whoever hacked into my Database

2013-11-13 Thread William Ray Wing
On Nov 13, 2013, at 1:27 PM, superchromix  wrote:

> 
> 
> hi all,
> 
> I've been thinking about learning Python for scientific programming.. but all 
> of these flame war type posts make the user community look pretty lame.  How 
> did all of these nice packages get written when most of the user interaction 
> is  this??
> 
> Can anyone tell me, is there another newsgroup where the discussion is more 
> on python programming?
> 
> thanks
> -- 
> https://mail.python.org/mailman/listinfo/python-list

I'd like to add one final thought to the note about joining the python-tutor 
list.
For scientific programming you are almost certainly going to want to learn 
about scipy, numpy and matplotlib.

These specialized libraries have dedicated discussion groups, which can be 
found at: , and 


I'd recommend looking over the material at

http://www.scipy.org

Welcome to the community.

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


Re: Packing byte fields and an array object into struct

2013-11-13 Thread krishna2prasad

Correction in the last input line...

In [16]: result = struct.unpack('5p', os_inst[11:16])
---
error Traceback (most recent call last)
 in ()
> 1 result = struct.unpack('5p', os_inst[11:16])

error: unpack requires a bytes object of length 5

In [17]: 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Packing byte fields and an array object into struct

2013-11-13 Thread krishna2prasad
Thanks for your reply Ned!

I tried this your suggestion and this is what it complains...

os_inst_bytes = struct.pack('7BI512s', 0, 0x51, 0x10, 5, 0, 0xD, 0x80, 0, '')

---
error 
Traceback (most recent call last)
 in ()
> 1 os_inst_bytes = struct.pack('7BI512s', 0, 0x51, 0x10, 5, 0, 0xD, 0x80, 
0, "")

error: argument for 's' must be a bytes object

In [7]: 


And about the bytearray() call, I want to pass a mutable object to the IOCTL to 
be able to get the data back from the driver. Without bytearray(), the ioctl 
with mutable flag set to 1 would complain.

I tried to use the p format specifier with pack after converting the array 
object to byte stream. Packing seems fine. However, I cant seem to unpack.

In [1]: import array

In [2]: import struct

In [3]: data= array.array('B', (1 for x in range(5)))

In [4]: data_bytes  = data.tobytes()

In [5]: os_inst_bytes = struct.pack('7BIp', 0, 0x51, 0x10, 5, 0, 0xD, 0x80, 0, 
data_bytes) 

In [6]: 

In [6]: os_inst = bytearray(os_inst_bytes)

In [7]: result = struct.unpack('7B', os_inst[0:7])

In [8]: print(result)
(0, 81, 16, 5, 0, 13, 128)

In [9]: result = struct.unpack('I', os_inst[7:11])

In [10]: print(result)
(0,)

In [11]: result = struct.unpack('5s', os_inst[11:16])
---
error Traceback (most recent call last)
 in ()
> 1 result = struct.unpack('5s', os_inst[11:16])

error: unpack requires a bytes object of length 5

In [12]: 


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


Re: Packing byte fields and an array object into struct

2013-11-13 Thread Ned Batchelder
On Wednesday, November 13, 2013 3:41:03 PM UTC-5, krishna...@gmail.com wrote:
> Thanks for your reply Ned!
> 
> I tried this your suggestion and this is what it complains...
> 
> os_inst_bytes = struct.pack('7BI512s', 0, 0x51, 0x10, 5, 0, 0xD, 0x80, 0, '')
> 
> ---
> error 
> Traceback (most recent call last)
>  in ()
> > 1 os_inst_bytes = struct.pack('7BI512s', 0, 0x51, 0x10, 5, 0, 0xD, 
> 0x80, 0, "")
> 
> error: argument for 's' must be a bytes object
> 

OK, looks like you are using Python 3 (it helps to specify these things 
up-front).  Use b"" to get an empty byte-string.


> In [7]: 
> 
> 
> And about the bytearray() call, I want to pass a mutable object to the IOCTL 
> to be able to get the data back from the driver. Without bytearray(), the 
> ioctl with mutable flag set to 1 would complain.

OK, keep the bytearray call if it helps.

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


Re: Trying tcompile an use the Python 3.4a

2013-11-13 Thread Ferrous Cranus

Στις 13/11/2013 7:45 μμ, ο/η Chris “Kwpolska” Warrick έγραψε:

On Wed, Nov 13, 2013 at 5:38 PM, Ferrous Cranus  wrote:

Στις 13/11/2013 6:13 μμ, ο/η Steven D'Aprano έγραψε:



and also is there a way to call it like #!/usr/bin/python



Of course there is, but only if you wish to break your system. The OS
will be expecting /usr/bin/python to be Python 2. Leave it be.



Okey i will leave it be although i dislike the idea of using the shebang
constructor as #~/usr/local/bin/python3
Is there any way that i can use it as it was #!/usr/bin/python but firing
python3 instead of python 2.6.6 ?


You can link it to /usr/bin/python3.  There should be no problem when
you do this.


Also i'm tryong 'yum install python-pip' because some modules like 'pymysql'
and 'pygeoip' are missing but CentOS doesn't seem able to detect it.


That should install it for the Python 2.6.6 you have, and possibly
under the name `python-pip` because of various shenanigans in the
redhatesque repos.


Please help me install 'pip' so i can install the modules.


http://www.pip-installer.org/en/latest/installing.html#install-or-upgrade-setuptools

Get ez_setup.py and get-pip.py, and run them with the desired Python.




Why can't i just use that?

root@secure [~]# sudo yum install python-pip
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.plusline.de
 * extras: mirror.skylink-datacenter.de
 * updates: ftp.plusline.de
base 



| 3.7 kB 00:00
extras 



| 3.4 kB 00:00
updates 



| 3.4 kB 00:00
Setting up Install Process
No package python-pip available.
Error: Nothing to do
root@secure [~]#

'python-pip' is something that all repos should have, why it cannot be 
found?

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


Re: Trying tcompile an use the Python 3.4a

2013-11-13 Thread Johannes Findeisen
On Wed, 13 Nov 2013 23:19:53 +0200
Ferrous Cranus wrote:

> Στις 13/11/2013 7:45 μμ, ο/η Chris “Kwpolska” Warrick έγραψε:>
> > Get ez_setup.py and get-pip.py, and run them with the desired Python.
> >
> 
> 
> Why can't i just use that?
> 
> root@secure [~]# sudo yum install python-pip
> Loaded plugins: fastestmirror
> Loading mirror speeds from cached hostfile
>   * base: ftp.plusline.de
>   * extras: mirror.skylink-datacenter.de
>   * updates: ftp.plusline.de
> base 
>  
>  
> | 3.7 kB 00:00
> extras 
>  
>  
> | 3.4 kB 00:00
> updates 
>  
>  
> | 3.4 kB 00:00
> Setting up Install Process
> No package python-pip available.
> Error: Nothing to do
> root@secure [~]#
> 
> 'python-pip' is something that all repos should have, why it cannot be 
> found?

Please try to figure out your distribution specific stuff by
using a search engine! This was what I found as first result by
searching for "centos pip" at Google:

http://superuser.com/questions/292378/how-to-install-pip-and-easy-install-on-centos

This really is not a Python question but a CentOS issue!

Regards,
Johannes

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


Re: Trying tcompile an use the Python 3.4a

2013-11-13 Thread Ned Batchelder
On Wednesday, November 13, 2013 4:39:59 PM UTC-5, Ferrous Cranus wrote:
> Στις 13/11/2013 11:30 μμ, ο/η Johannes Findeisen έγραψε:
> > On Wed, 13 Nov 2013 23:19:53 +0200
> > Ferrous Cranus wrote:
> >
> >> Στις 13/11/2013 7:45 μμ, ο/η Chris “Kwpolska” Warrick έγραψε:>
> >>> Get ez_setup.py and get-pip.py, and run them with the desired Python.
> >>>
> >>
> >>
> >> Why can't i just use that?
> >>
> >> root@secure [~]# sudo yum install python-pip
> >> Loaded plugins: fastestmirror
> >> Loading mirror speeds from cached hostfile
> >>* base: ftp.plusline.de
> >>* extras: mirror.skylink-datacenter.de
> >>* updates: ftp.plusline.de
> >> base
> >>
> >>
> >> | 3.7 kB 00:00
> >> extras
> >>
> >>
> >> | 3.4 kB 00:00
> >> updates
> >>
> >>
> >> | 3.4 kB 00:00
> >> Setting up Install Process
> >> No package python-pip available.
> >> Error: Nothing to do
> >> root@secure [~]#
> >>
> >> 'python-pip' is something that all repos should have, why it cannot be
> >> found?
> >
> > Please try to figure out your distribution specific stuff by
> > using a search engine! This was what I found as first result by
> > searching for "centos pip" at Google:
> >
> > http://superuser.com/questions/292378/how-to-install-pip-and-easy-install-on-centos
> >
> > This really is not a Python question but a CentOS issue!
> >
> > Regards,
> > Johannes
> >
> 
> 
> I have foung this link myself in the morning but it wasnt successfull:
> 
> Look:
> 
> root@secure [~]# /usr/local/bin/easy_install pip
> -bash: /usr/local/bin/easy_install: No such file or directory
> 
> root@secure [~]# /usr/bin/easy_install pip
> -bash: /usr/bin/easy_install: No such file or directory
> 
> If i cannot use 'yum' or even 'easy_setup' how will i install 'pip' and 
> hence the modules?

Nikos, we've talked about this before.  These aren't Python questions.  You 
need to fix your OS.  We can't help you with that.  I know you are frustrated 
and want answers, but you can't just post the same question here again and 
expect a response.  You need to solve this some other way.

Asking over and over again will simply cause another fight on this list, and no 
one wants that.  Find another way to solve your problem.

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


Re: Trying tcompile an use the Python 3.4a

2013-11-13 Thread Ferrous Cranus

Στις 13/11/2013 11:30 μμ, ο/η Johannes Findeisen έγραψε:

On Wed, 13 Nov 2013 23:19:53 +0200
Ferrous Cranus wrote:


Στις 13/11/2013 7:45 μμ, ο/η Chris “Kwpolska” Warrick έγραψε:>

Get ez_setup.py and get-pip.py, and run them with the desired Python.




Why can't i just use that?

root@secure [~]# sudo yum install python-pip
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
   * base: ftp.plusline.de
   * extras: mirror.skylink-datacenter.de
   * updates: ftp.plusline.de
base


| 3.7 kB 00:00
extras


| 3.4 kB 00:00
updates


| 3.4 kB 00:00
Setting up Install Process
No package python-pip available.
Error: Nothing to do
root@secure [~]#

'python-pip' is something that all repos should have, why it cannot be
found?


Please try to figure out your distribution specific stuff by
using a search engine! This was what I found as first result by
searching for "centos pip" at Google:

http://superuser.com/questions/292378/how-to-install-pip-and-easy-install-on-centos

This really is not a Python question but a CentOS issue!

Regards,
Johannes




I have foung this link myself in the morning but it wasnt successfull:

Look:

root@secure [~]# /usr/local/bin/easy_install pip
-bash: /usr/local/bin/easy_install: No such file or directory

root@secure [~]# /usr/bin/easy_install pip
-bash: /usr/bin/easy_install: No such file or directory

If i cannot use 'yum' or even 'easy_setup' how will i install 'pip' and 
hence the modules?


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


Re: To whoever hacked into my Database

2013-11-13 Thread Ferrous Cranus

root@secure:~/lib64# ls -al | grep libkey

lrwxrwxrwx 1 root root 20 Jun 22 2012 libkeyutils.so.1 -> 
libkeyutils.so.1.3.0*

-rwxr-xr-x 1 root root 10192 Jun 22 2012 libkeyutils.so.1.3*
-rwxr-xr-x 1 root root 32920 Jun 22 2012 libkeyutils.so.1.3.0*

root@secure:~/lib64# rpm -qf libkeyutils.so.1.3.0
file /lib64/libkeyutils.so.1.3.0 is not owned by any package



It appears that my server has been compromised with a malicious payload 
designed to sniff for and steal server passwords.


This must have happened when i was handling my root passwords out in the 
open.


Served me well.
--
https://mail.python.org/mailman/listinfo/python-list


Most discussion on comp.lang.python is about developing with Python

2013-11-13 Thread bob gailer

I joined a week or so ago.

The subject line was copied from the description of comp.lang.python aka 
python-list@python.org.


I am very disappointed to see so much energy and bandwidth going to 
conversations that bash individuals.


Is there a moderator for this list?

Is there some other place for discussions that are completely OT and 
also full of flames?


Or would you be willing to stop the bashing? I don't see that it helps 
anyone, and could be very offputting to other newbies.


I hope and pray that there will be a few simple answers. The last thing 
I want is to start another flame war.


Thanks for hearing me.

--
Bob Gailer
919-636-4239
Chapel Hill NC

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


python 2.7.x on MacOSX: failed dlopen() on .so's

2013-11-13 Thread Paul Smith
Hi all.  I need to build my own version of Python on a MacOSX system,
and I can't seem to do it successfully.  I need to build it with a
particular location, etc. and so I can't use Homebrew or whatever: I
need to compile it myself from the source tarball.  I did look through
the Homebrew recipe and I don't see anything that seems like it would
help with my problem.

I'm using MacOSX 10.7.5 with xcode 4.1, containing gcc 4.2.1 / clang 2.1
(configure seems to choose gcc).

I've tried this with both Python 2.7.5 and 2.7.6.  I get the tarball,
unpack it, then:

  $ configure --prefix=/Users/build/python
  $ make
  $ make install
  $ export PATH=/Users/build/python/bin:$PATH
  $ export PYTHONHOME=/Users/build/python
  $ python2.7 --version
  Python 2.7.6

Simple scripts seem to work fine.  But then I need to install various
packages; for example pycrypto.  When I try to build that it fails to
build:

  $ cd src/pycrypto-2.6 && python2.7 setup.py build
  Traceback (most recent call last):
File "setup.py", line 45, in 
  import struct
File "/Users/build/python/lib/python2.7/struct.py", line 1, in 
  from _struct import *
  ImportError: dlopen(/Users/build/python/lib/python2.7/lib-dynload/_struct.so, 
2): Symbol not found: _PyObject_Free
Referenced from: /Users/build/python/lib/python2.7/lib-dynload/_struct.so
Expected in: dynamic lookup

This happens with every module that is not pure-Python: boto, paramiko,
etc.

Looking at the various python2.7/lib-dynload/*.so files with nm I see
that actually a number of them refer to an unresolved ("U") symbol
_PyObject_Free (and other _PyObject_* symbols).  I can't find any shared
library being built by the python build (.dylib or .so or whatever);
there's just a libpython2.7.a file (I tried forcing --enable-shared on
the configure line and it didn't change anything).


I should say that I've used this same configuration and set of steps,
etc. on my GNU/Linux system and it worked perfectly.

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


Re: Trying tcompile an use the Python 3.4a

2013-11-13 Thread Ferrous Cranus

Στις 13/11/2013 11:44 μμ, ο/η Ned Batchelder έγραψε:

On Wednesday, November 13, 2013 4:39:59 PM UTC-5, Ferrous Cranus wrote:

Στις 13/11/2013 11:30 μμ, ο/η Johannes Findeisen έγραψε:

On Wed, 13 Nov 2013 23:19:53 +0200
Ferrous Cranus wrote:


Στις 13/11/2013 7:45 μμ, ο/η Chris “Kwpolska” Warrick έγραψε:>

Get ez_setup.py and get-pip.py, and run them with the desired Python.




Why can't i just use that?

root@secure [~]# sudo yum install python-pip
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp.plusline.de
* extras: mirror.skylink-datacenter.de
* updates: ftp.plusline.de
base


| 3.7 kB 00:00
extras


| 3.4 kB 00:00
updates


| 3.4 kB 00:00
Setting up Install Process
No package python-pip available.
Error: Nothing to do
root@secure [~]#

'python-pip' is something that all repos should have, why it cannot be
found?


Please try to figure out your distribution specific stuff by
using a search engine! This was what I found as first result by
searching for "centos pip" at Google:

http://superuser.com/questions/292378/how-to-install-pip-and-easy-install-on-centos

This really is not a Python question but a CentOS issue!

Regards,
Johannes




I have foung this link myself in the morning but it wasnt successfull:

Look:

root@secure [~]# /usr/local/bin/easy_install pip
-bash: /usr/local/bin/easy_install: No such file or directory

root@secure [~]# /usr/bin/easy_install pip
-bash: /usr/bin/easy_install: No such file or directory

If i cannot use 'yum' or even 'easy_setup' how will i install 'pip' and
hence the modules?


Nikos, we've talked about this before.  These aren't Python questions.  You 
need to fix your OS.  We can't help you with that.  I know you are frustrated 
and want answers, but you can't just post the same question here again and 
expect a response.  You need to solve this some other way.

Asking over and over again will simply cause another fight on this list, and no 
one wants that.  Find another way to solve your problem.

--Ned.




If i knew how to solve this Ned i wouldn't be asking you. My provider 
haven't replied back to me.


Actually it is a python question regarding a python installation issue.
Is it so much trouble to help me with this?


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


Re: To whoever hacked into my Database

2013-11-13 Thread Ned Batchelder
On Wednesday, November 13, 2013 4:46:59 PM UTC-5, Ferrous Cranus wrote:
> root@secure:~/lib64# ls -al | grep libkey
> 
> lrwxrwxrwx 1 root root 20 Jun 22 2012 libkeyutils.so.1 -> 
> libkeyutils.so.1.3.0*
> -rwxr-xr-x 1 root root 10192 Jun 22 2012 libkeyutils.so.1.3*
> -rwxr-xr-x 1 root root 32920 Jun 22 2012 libkeyutils.so.1.3.0*
> 
> root@secure:~/lib64# rpm -qf libkeyutils.so.1.3.0
> file /lib64/libkeyutils.so.1.3.0 is not owned by any package
> 
> 
> 
> It appears that my server has been compromised with a malicious payload 
> designed to sniff for and steal server passwords.
> 
> This must have happened when i was handling my root passwords out in the 
> open.
> 
> Served me well.

This has nothing to do with the topic of this mailing list.  Please don't post 
it here.

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


Re: Trying tcompile an use the Python 3.4a

2013-11-13 Thread Mark Lawrence

On 13/11/2013 21:39, Ferrous Cranus wrote:

Στις 13/11/2013 11:30 μμ, ο/η Johannes Findeisen έγραψε:

On Wed, 13 Nov 2013 23:19:53 +0200
Ferrous Cranus wrote:


Στις 13/11/2013 7:45 μμ, ο/η Chris “Kwpolska” Warrick έγραψε:>

Get ez_setup.py and get-pip.py, and run them with the desired Python.




Why can't i just use that?

root@secure [~]# sudo yum install python-pip
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
   * base: ftp.plusline.de
   * extras: mirror.skylink-datacenter.de
   * updates: ftp.plusline.de
base


| 3.7 kB 00:00
extras


| 3.4 kB 00:00
updates


| 3.4 kB 00:00
Setting up Install Process
No package python-pip available.
Error: Nothing to do
root@secure [~]#

'python-pip' is something that all repos should have, why it cannot be
found?


Please try to figure out your distribution specific stuff by
using a search engine! This was what I found as first result by
searching for "centos pip" at Google:

http://superuser.com/questions/292378/how-to-install-pip-and-easy-install-on-centos


This really is not a Python question but a CentOS issue!

Regards,
Johannes




I have foung this link myself in the morning but it wasnt successfull:

Look:

root@secure [~]# /usr/local/bin/easy_install pip
-bash: /usr/local/bin/easy_install: No such file or directory

root@secure [~]# /usr/bin/easy_install pip
-bash: /usr/bin/easy_install: No such file or directory

If i cannot use 'yum' or even 'easy_setup' how will i install 'pip' and
hence the modules?



I really don't believe this, 24 lines above this one is the link to a 
page telling you how to do it, but you're *STILL* asking!!!  What do you 
want, jam on it???


--
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: PyMyth: Global variables are evil... WRONG!

2013-11-13 Thread Andrew Cooper
On 13/11/2013 02:45, Rick Johnson wrote:
> 
> "math.pi" should be "math.PI". and PI should be a CONSTANT. 
> And not just a pseudo constant, but a REAL constant that 
> cannot be changed.
> 

And what do you do when the wizards bend space-time to make PI exactly
3, for the ease of other calculations when building a sorting machine?

Does usenet start delivering these posts in the past/future?

I suspect real python programmers will be able to feel quite smug when
they can change the value of math.pi to suit the situation.

~Andrew

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


Re: Trying tcompile an use the Python 3.4a

2013-11-13 Thread Ferrous Cranus

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

On 13/11/2013 21:39, Ferrous Cranus wrote:

Στις 13/11/2013 11:30 μμ, ο/η Johannes Findeisen έγραψε:

On Wed, 13 Nov 2013 23:19:53 +0200
Ferrous Cranus wrote:


Στις 13/11/2013 7:45 μμ, ο/η Chris “Kwpolska” Warrick έγραψε:>

Get ez_setup.py and get-pip.py, and run them with the desired Python.




Why can't i just use that?

root@secure [~]# sudo yum install python-pip
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
   * base: ftp.plusline.de
   * extras: mirror.skylink-datacenter.de
   * updates: ftp.plusline.de
base


| 3.7 kB 00:00
extras


| 3.4 kB 00:00
updates


| 3.4 kB 00:00
Setting up Install Process
No package python-pip available.
Error: Nothing to do
root@secure [~]#

'python-pip' is something that all repos should have, why it cannot be
found?


Please try to figure out your distribution specific stuff by
using a search engine! This was what I found as first result by
searching for "centos pip" at Google:

http://superuser.com/questions/292378/how-to-install-pip-and-easy-install-on-centos



This really is not a Python question but a CentOS issue!

Regards,
Johannes




I have foung this link myself in the morning but it wasnt successfull:

Look:

root@secure [~]# /usr/local/bin/easy_install pip
-bash: /usr/local/bin/easy_install: No such file or directory

root@secure [~]# /usr/bin/easy_install pip
-bash: /usr/bin/easy_install: No such file or directory

If i cannot use 'yum' or even 'easy_setup' how will i install 'pip' and
hence the modules?



I really don't believe this, 24 lines above this one is the link to a
page telling you how to do it, but you're *STILL* asking!!!  What do you
want, jam on it???




But i have gone to the link and did what it said and it didn't proved 
usefull thats why i re-ask.

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


Re: Trying tcompile an use the Python 3.4a

2013-11-13 Thread Mark Lawrence

On 13/11/2013 22:00, Ferrous Cranus wrote:

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

On 13/11/2013 21:39, Ferrous Cranus wrote:

Στις 13/11/2013 11:30 μμ, ο/η Johannes Findeisen έγραψε:

On Wed, 13 Nov 2013 23:19:53 +0200
Ferrous Cranus wrote:


Στις 13/11/2013 7:45 μμ, ο/η Chris “Kwpolska” Warrick έγραψε:>

Get ez_setup.py and get-pip.py, and run them with the desired Python.




Why can't i just use that?

root@secure [~]# sudo yum install python-pip
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
   * base: ftp.plusline.de
   * extras: mirror.skylink-datacenter.de
   * updates: ftp.plusline.de
base


| 3.7 kB 00:00
extras


| 3.4 kB 00:00
updates


| 3.4 kB 00:00
Setting up Install Process
No package python-pip available.
Error: Nothing to do
root@secure [~]#

'python-pip' is something that all repos should have, why it cannot be
found?


Please try to figure out your distribution specific stuff by
using a search engine! This was what I found as first result by
searching for "centos pip" at Google:

http://superuser.com/questions/292378/how-to-install-pip-and-easy-install-on-centos




This really is not a Python question but a CentOS issue!

Regards,
Johannes




I have foung this link myself in the morning but it wasnt successfull:

Look:

root@secure [~]# /usr/local/bin/easy_install pip
-bash: /usr/local/bin/easy_install: No such file or directory

root@secure [~]# /usr/bin/easy_install pip
-bash: /usr/bin/easy_install: No such file or directory

If i cannot use 'yum' or even 'easy_setup' how will i install 'pip' and
hence the modules?



I really don't believe this, 24 lines above this one is the link to a
page telling you how to do it, but you're *STILL* asking!!!  What do you
want, jam on it???




But i have gone to the link and did what it said and it didn't proved
usefull thats why i re-ask.


Wrong.  You've once again not bothered to read the information that's 
been handed to you on a plate.  If you'd followed the instructions you 
would not get the "No such file or directory" error shown above.  I'm 
not going to spoon feed you, so please go away and sort this out for 
yourself, we're sick to death of seeing you here.


--
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 2.7.x on MacOSX: failed dlopen() on .so's

2013-11-13 Thread Ned Deily
In article <1384370183.3496.472.camel@pdsdesk>,
 Paul Smith  wrote:
> I'm using MacOSX 10.7.5 with xcode 4.1, containing gcc 4.2.1 / clang 2.1
> (configure seems to choose gcc).
> 
> I've tried this with both Python 2.7.5 and 2.7.6.  I get the tarball,
> unpack it, then:
> 
>   $ configure --prefix=/Users/build/python
>   $ make
>   $ make install
>   $ export PATH=/Users/build/python/bin:$PATH
>   $ export PYTHONHOME=/Users/build/python
>   $ python2.7 --version
>   Python 2.7.6
> 
> Simple scripts seem to work fine.  But then I need to install various
> packages; for example pycrypto.  When I try to build that it fails to
> build:
> 
>   $ cd src/pycrypto-2.6 && python2.7 setup.py build
>   Traceback (most recent call last):
> File "setup.py", line 45, in 
>   import struct
> File "/Users/build/python/lib/python2.7/struct.py", line 1, in 
>   from _struct import *
>   ImportError: 
>   dlopen(/Users/build/python/lib/python2.7/lib-dynload/_struct.so, 2): Symbol 
>   not found: _PyObject_Free
> Referenced from: /Users/build/python/lib/python2.7/lib-dynload/_struct.so
> Expected in: dynamic lookup
> 
> This happens with every module that is not pure-Python: boto, paramiko,
> etc.
> 
> Looking at the various python2.7/lib-dynload/*.so files with nm I see
> that actually a number of them refer to an unresolved ("U") symbol
> _PyObject_Free (and other _PyObject_* symbols).  I can't find any shared
> library being built by the python build (.dylib or .so or whatever);
> there's just a libpython2.7.a file (I tried forcing --enable-shared on
> the configure line and it didn't change anything).

There shouldn't be any problems with what you are trying to do.  It works for 
me with Python 2.7.6 and pycrypto-2.6.1.  Some suggestions:
- Avoid --enable-shared on OS X at least initially.  There are too many ways 
things can go wrong.  If you've built with it, suggest starting with a fresh 
Python source directory just to be sure.
- Check the dynamic library dependencies of _struct.  On OS X:

  otool -L /Users/build/python/lib/python2.7/lib-dynload/_struct.so

For a non-shared build, the only library dependency should be 
/usr/lib/libSystem.B.dylib.
- Make sure you are *really* building pycrypto and friends with your Python 
and not with some other one.
- On OS X with an installed Python, you shouldn't need to set PYTHONHOME.

-- 
 Ned Deily,
 n...@acm.org

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


Re: python 2.7.x on MacOSX: failed dlopen() on .so's

2013-11-13 Thread Ned Deily
In article ,
 Ned Deily  wrote:
> There shouldn't be any problems with what you are trying to do.  It works for 
> me with Python 2.7.6 and pycrypto-2.6.1.  Some suggestions:
> - Avoid --enable-shared on OS X at least initially.  There are too many ways 
> things can go wrong.  If you've built with it, suggest starting with a fresh 
> Python source directory just to be sure.
> - Check the dynamic library dependencies of _struct.  On OS X:
> 
>   otool -L /Users/build/python/lib/python2.7/lib-dynload/_struct.so
> 
> For a non-shared build, the only library dependency should be 
> /usr/lib/libSystem.B.dylib.
> - Make sure you are *really* building pycrypto and friends with your Python 
> and not with some other one.
> - On OS X with an installed Python, you shouldn't need to set PYTHONHOME.

- Check your other environment variables and make sure you are not setting any 
DYLD_ or LD_ env variables.

-- 
 Ned Deily,
 n...@acm.org

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


Re: Most discussion on comp.lang.python is about developing with Python

2013-11-13 Thread Terry Reedy

On 11/13/2013 3:35 PM, bob gailer wrote:


I am very disappointed to see so much energy and bandwidth going to
conversations that bash individuals.


Me too.


Is there a moderator for this list?


Posts from new addresses go to moderators for spam deletion. There are a 
couple a day that are discarded. Posts with 'suspicious headers' also 
get checked. Non-suspicious posts from known people (perhaps 90%) do not 
get checked. We have not yet gotten into 'censorship' of trolling and 
flaming. I would prefer not being forced into considering it.



Or would you be willing to stop the bashing? I don't see that it helps
anyone, and could be very offputting to other newbies.


I wish a few more old-timers would consider the effect of their posts on 
newcomers.


--
Terry Jan Reedy

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


Re: Most discussion on comp.lang.python is about developing with Python

2013-11-13 Thread Chris Angelico
On Thu, Nov 14, 2013 at 7:35 AM, bob gailer  wrote:
> I am very disappointed to see so much energy and bandwidth going to
> conversations that bash individuals.
>

I agree, and there've been times when I've been part of the problem
(usually in the form of trying to help Nikos, which results in
stupidity, which leads to anger,. which leads to hate, to suffering,
and to the dark side). Fortunately, it's periodic - like a pendulum,
the mass of posts swings around now and then. Some days it's all about
Nikos, other days we're a lot more productive... sometimes we spend a
day rambling on some off-topic but interesting point, but it always
comes back to Python.

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


Re: Most discussion on comp.lang.python is about developing with Python

2013-11-13 Thread Rhodri James

On Wed, 13 Nov 2013 22:53:46 -, Terry Reedy  wrote:


On 11/13/2013 3:35 PM, bob gailer wrote:


Is there a moderator for this list?


Posts from new addresses go to moderators for spam deletion. There are a  
couple a day that are discarded. Posts with 'suspicious headers' also  
get checked. Non-suspicious posts from known people (perhaps 90%) do not  
get checked. We have not yet gotten into 'censorship' of trolling and  
flaming. I would prefer not being forced into considering it.


This is true of python-list.  comp.lang.python the Usenet newsgroup is not  
moderated.  God alone knows what Googlegroups thinks it's doing.


--
Rhodri James *-* Wildebeest Herder to the Masses
--
https://mail.python.org/mailman/listinfo/python-list


Re: Setting up for python django development with Debian Linux

2013-11-13 Thread D.M. Procida
Gary Roach  wrote:

> I have been trying to set up a python, django, mysql, virtualenvwrapper
> and git development project and am really confused. All of the 
> documentation seems to ignore the apt-get installation methods used by
> Debian Linux and its derivatives. 

I assume you've either worked this out or given up by now, but in any
case...

> Does pip install the same as apt-get; I don't think so. If I use
> virtualenvwrapper, how does this fit with the normal debian (wheezy)
> installation.

Firstly, pip doesn't install in the same way apt-get does. 

The general rule is: if it's a Python package (such as Django) use pip;
if it's not (such as MySQL) use apt-get.

Secondly, there is little if any need to install Python packages outside
a virtualenv. It's almost always more convenient to have them in a
virtualenv, rather than system-wide.

> I also need git which just confuses 
> the situation even more. Must I give up the automatic updating system
> that Debian provides when setting up the development environment? 

I just use apt-get to install Git and update it every now and then.

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


Re: chroot to install packages

2013-11-13 Thread Chris Angelico
On Thu, Nov 14, 2013 at 1:31 AM, Himanshu Garg  wrote:
> I am writing a python script to run chroot command to chroot to a linux 
> distro and then run commands.  How can I do this, as after chrooting, the 
> script runs the commands relative to the outside not inside the chrooted env?

Probably the easiest way to do this is to divide your script into two
pieces: one piece runs inside the chroot, the other doesn't. Then you
have the "outer" script invoke the "inner" script as a separate
process. When the inner process terminates, the outer continues, and
since the outer wasn't chrooted, it's now running commands relative to
the outside.

One convenient way to manage this is to have one script that invokes
itself with arguments. Another way is to have two actually separate
script files. It really depends how much work you're doing in each
half.

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


Re: PyMyth: Global variables are evil... WRONG!

2013-11-13 Thread Rhodri James
On Tue, 12 Nov 2013 02:06:09 -, Rick Johnson  
 wrote:



PyMyth: Global variables are evil... WRONG!


That's not a PyMyth.  It's a CompSciMyth, or to be more accurate a good  
general Software Engineering guideline regardless of language.  Like all  
guidelines it can be broken, but people who break it should do so  
knowingly, aware that they have created potential problems for themselves.




 The denial of the 99%:

Python has globals, but we just can't admit it!


A different subject entirely, but no more accurately stated.

[snip]

But even the "module level" globals can be accessed
"globally" if the module they are contained in is imported
everywhere.


Remember when I said that guidelines can be broken?


Globals are justified when they are used to communicate
information between scopes that otherwise were meant to be
mutually exclusive. One good example would be package sub-
modules.


Sometimes, yes.  As long as you don't mind not being thread-safe, etc,  
etc.  If you've designed your interface, you're probably fine.  If you've  
throw it together with globals because it's the easy way, you're about to  
find out why the guideline you're breaking is a good one.



 "But Rick, even when we use globals, we don't need that many"

Only if you consider the single package that represents your
program, but what about the thousands of support libraries
with millions of lines of code that work in the background
to make your measly few thousand lines of code work?  What
about all the globals that they have injected?


Didn't you just say that Python globals are really module-level globals?   
Isn't this a strawman you've already disallowed?  It sounds to me like  
you're complaining that Python is ahead of the curve here :-)


--
Rhodri James *-* Wildebeest Herder to the Masses
--
https://mail.python.org/mailman/listinfo/python-list


Re: Most discussion on comp.lang.python is about developing with Python

2013-11-13 Thread Steven D'Aprano
On Wed, 13 Nov 2013 15:35:56 -0500, bob gailer wrote:

> Is there a moderator for this list?

Sadly no.

 
> Is there some other place for discussions that are completely OT and
> also full of flames?

Yes, there is private email. Unfortunately private email doesn't give the 
culprits the audience that they desire.

> Or would you be willing to stop the bashing? I don't see that it helps
> anyone, and could be very offputting to other newbies.

That's what I have been saying for a long time. I believe that whatever 
negative effect Nikos the help-vampire is having, it is long ago 
overwhelmed by the negative of the anti-Nikos vigilantes.

Fortunately, Nikos appears to pay absolutely no attention to any thread 
which isn't about him. So if you avoid threads started by him, you'll 
miss the worst of it.

As a community, it is difficult to balance the conflicting needs here. If 
we ignore Nikos completely, we appear unfriendly and indifferent to those 
asking for help. If we answer his questions, we encourage him to post. It 
is hard to find the right balance, if there even is a right balance, and 
people can have differing ideas of what that right balance is.

But it is clear from the last few months that abusive, aggressive posts 
don't help anyone -- they don't set a good tone for the group, they put 
off newcomers, and they do absolutely nothing to discourage Nikos. Please 
consider this a request to the community, ignore Nikos if you like, 
answer his questions if you must, but please keep the abusive posts off-
list. They aren't helping.



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


Re: Most discussion on comp.lang.python is about developing with Python

2013-11-13 Thread Steven D'Aprano
On Wed, 13 Nov 2013 17:53:46 -0500, Terry Reedy wrote:

>> Is there a moderator for this list?
> 
> Posts from new addresses go to moderators for spam deletion. There are a
> couple a day that are discarded. Posts with 'suspicious headers' also
> get checked. Non-suspicious posts from known people (perhaps 90%) do not
> get checked. We have not yet gotten into 'censorship' of trolling and
> flaming. I would prefer not being forced into considering it.

Terry, perhaps you are referring to the pyt...@python.org mailing list. 
But this is also a newsgroup, and I believe that there is no moderator on 
that.


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


Re: PyMyth: Global variables are evil... WRONG!

2013-11-13 Thread Mark Lawrence

On 13/11/2013 23:42, Rhodri James wrote:

On Tue, 12 Nov 2013 02:06:09 -, Rick Johnson
 wrote:


PyMyth: Global variables are evil... WRONG!


That's not a PyMyth.  It's a CompSciMyth, or to be more accurate a good
general Software Engineering guideline regardless of language.  Like all
guidelines it can be broken, but people who break it should do so
knowingly, aware that they have created potential problems for themselves.



A quote from a colleage of mine circa 1991 "Real time programming is 
easy, just make all the data global".  There you are everybody, problem 
solved :)


--
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: Most discussion on comp.lang.python is about developing with Python

2013-11-13 Thread Ben Finney
bob gailer  writes:

> I joined a week or so ago.

Welcome! Please feel free to start a new thread of dicussion about the
Python programming language.

> I am very disappointed to see so much energy and bandwidth going to
> conversations that bash individuals.

As am I. Let's talk about Python more. Go for it! Start a new thread
with an idea or question related to Python programming.

-- 
 \  “I hope if dogs ever take over the world, and they chose a |
  `\king, they don't just go by size, because I bet there are some |
_o__)   Chihuahuas with some good ideas.” —Jack Handey |
Ben Finney

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


Re: python 2.7.x on MacOSX: failed dlopen() on .so's

2013-11-13 Thread Ned Deily

On Nov 13, 2013, at 14:59 , Paul Smith  wrote:

> Thanks for the response Ned!
> 
> On Wed, 2013-11-13 at 14:40 -0800, Ned Deily wrote:
>> There shouldn't be any problems with what you are trying to do.  It
>> works for me with Python 2.7.6 and pycrypto-2.6.1.  Some suggestions:
>> - Avoid --enable-shared on OS X at least initially.  There are too
>> many ways things can go wrong.  If you've built with it, suggest
>> starting with a fresh Python source directory just to be sure.
> 
> I've tried it with all three options: no flag, --disable-shared, and
> --enable-shared, and don't notice any difference in the results; even
> with --enable-shared I don't seem to get any shared libs created.
> 
>> - Check the dynamic library dependencies of _struct.  On OS X:
>> 
>>  otool -L /Users/build/python/lib/python2.7/lib-dynload/_struct.so
> 
> I get a libgcc_s reference as well, since I'm building with GCC:
> 
> /Users/build/python/lib/python2.7/lib-dynload/_struct.so:
>/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current
> version 159.1.0)
>/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current
> version 1105.0.0)
> 
> I wonder if using the GCC linker etc. is part of the problem?

That shouldn't be an issue.  What you do don't want to see is references to 
python libraries.  BTW, Xcode 4.1 is quite old and outdated for OS X 10.7.  
Suggest you update to the current Xcode 4.6.3 or Command Line Tools for 10.7.

> The reason I've set PYTHONHOME is ultimately I need this installation to
> be relocatable.  It's going to be shared across lots of different
> systems and they'll have the ability to copy it wherever they want.

That could be problematic. You need to be *really* careful about how you do 
that.  You stand a chance with a non-shared installation.  You still should not 
need to set PYTHONHOME.  Also, be aware that executables and libraries built on 
one version of OS X are not guaranteed to work on other versions, particularly 
older versions unless you take certain precautions.  Even non-shared Pythons on 
OS X dynamically link with system-supplied libraries which can vary across os 
releases.  And not all libraries are supplied, so, depending on your needs, you 
may need to supply some additional third-party libraries.

If you need to support various OS X releases, the safest approach is to build 
on the oldest release to be supported, say, 10.6.  The resultant executables 
and libraries should then work on 10.7 through 10.9 - except every once in a 
while there will be a gotcha like the incompatible change in libedit for 10.9.  
(Python 2.7.6 can deal with that problem.)  There is also the question if all 
the systems you will need to support are of the same architecture.  10.6 
supports both 32-bit-only and 64-bit Intel machines.  10.5 supports in addition 
PPC machines.  The solution to that is to build OS X universal binaries.  If 
you really are careful and lucky, it is in theory possible to build on a newer 
system and use an OS X SDK and set MACOSX_DEPLOYMENT_TARGET for an older 
version and it will be downward compatible. But thorough testing is called for 
in that case since it is easy to have a hidden dependency.  For the python.org 
OS X binary installers, we go to a fair amount of trouble to build P
 ythons that will work across a range of OS X releases.  You might want to 
consider using one of them as a base.  It's usually a lot less work than trying 
to make it work yourself.

> 
>> - Check your other environment variables and make sure you are not
>> setting any DYLD_ or LD_ env variables.
> Hm; I am setting LD_LIBRARY_PATH to find the Python .so files.  Does
> python figure out where to look for them by itself?

Yes

--
  Ned Deily
  n...@acm.org -- []


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


Re: python 2.7.x on MacOSX: failed dlopen() on .so's

2013-11-13 Thread Paul Smith
Thanks for the response Ned!

On Wed, 2013-11-13 at 14:40 -0800, Ned Deily wrote:
> There shouldn't be any problems with what you are trying to do.  It
> works for me with Python 2.7.6 and pycrypto-2.6.1.  Some suggestions:
> - Avoid --enable-shared on OS X at least initially.  There are too
> many ways things can go wrong.  If you've built with it, suggest
> starting with a fresh Python source directory just to be sure.

I've tried it with all three options: no flag, --disable-shared, and
--enable-shared, and don't notice any difference in the results; even
with --enable-shared I don't seem to get any shared libs created.

> - Check the dynamic library dependencies of _struct.  On OS X:
> 
>   otool -L /Users/build/python/lib/python2.7/lib-dynload/_struct.so

I get a libgcc_s reference as well, since I'm building with GCC:

/Users/build/python/lib/python2.7/lib-dynload/_struct.so:
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current
version 159.1.0)
/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current
version 1105.0.0)

I wonder if using the GCC linker etc. is part of the problem?

> - Make sure you are *really* building pycrypto and friends with your
> Python and not with some other one.

I'm pretty sure but I'll triple-check.

The reason I've set PYTHONHOME is ultimately I need this installation to
be relocatable.  It's going to be shared across lots of different
systems and they'll have the ability to copy it wherever they want.

> - Check your other environment variables and make sure you are not
> setting any DYLD_ or LD_ env variables.

Hm; I am setting LD_LIBRARY_PATH to find the Python .so files.  Does
python figure out where to look for them by itself?

Thanks for this info; I'll get back to you.


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


Re: Most discussion on comp.lang.python is about developing with Python

2013-11-13 Thread Chuck Quast
On Thursday, November 14, 2013 3:35:56 AM UTC+7, bob gailer wrote:
> I joined a week or so ago.
> 
> 
> 
> The subject line was copied from the description of comp.lang.python aka 
> 
> python-list@python.org.
> 
> 
> 
> I am very disappointed to see so much energy and bandwidth going to 
> 
> conversations that bash individuals.
> 
> 
> 
> Is there a moderator for this list?
> 
> 
> 
> Is there some other place for discussions that are completely OT and 
> 
> also full of flames?
> 
> 
> 
> Or would you be willing to stop the bashing? I don't see that it helps 
> 
> anyone, and could be very offputting to other newbies.
> 
> 
> 
> I hope and pray that there will be a few simple answers. The last thing 
> 
> I want is to start another flame war.
> 
> 
> 
> Thanks for hearing me.
> 
> 
> 
> -- 
> 
> Bob Gailer
> 
> 919-636-4239
> 
> Chapel Hill NC

I just changed my profile to turn off email updates from this list. Too many 
posts were in response to the blatant troll postings. If I never get another 
comp.lang.python post in my mailbox it will be too soon.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PyMyth: Global variables are evil... WRONG!

2013-11-13 Thread Tim Daneliuk

On 11/11/2013 10:46 PM, Rick Johnson wrote:

On Monday, November 11, 2013 8:47:09 PM UTC-6, Tim Daneliuk wrote:

I think this is certainly the use case most people would
suggest. But I think you may have missed the real reason
most modern designers object to inter-module globals:  The
presence of such entities almost always means the code has
been designed badly.  Whether we're writing pristine OO
code (cough, cough) or more traditional procedural stuff,
information hiding is a good thing.


Yes, and i agree. But you cannot "hide" everything. There
will always be a need to share information.


When and where there is a need for modules (or programs,
or machines, or "clouds", or interstellar space ...) to
share information, my view is this is better done via some
sort of interface/message passing mechanism.


But python modules can't be interfaces because interfaces
should protect internal data, prevent external forces from
meddling with internal state (EXCEPT via the rules of a
predefined "contract"), hide dirty details from the caller,
and have clearly defined access points.

   BUT PYTHON MODULES DON'T FOLLOW THIS DESIGN PATTERN!



I think this is an unfair criticism.   You can do this in
ANY language if you know how.  For example, if I understand
stack frames, I can write code that fiddles with local
variables in compiled code.  For that matter, if I understand
pointers at the assembler level, I can probably do the same
with globals.

Global access/visibility is a matter of convenience - it's harder
to do in a static compiled language and easier to do in a
late bound, dynamic language.   The fact that this is
*possible* in Python doesn't speak to Python's fitness for
any particular purpose nor does it speak to whether globals
are a good- or bad idea.  Anyone that knows enough to fiddle
with the internal implementation of a module and or subvert
global constants like math.pi, also know what they're doing
is "perverse" and have to be willing to live with the side
effects and consequences of such acts.

I cut my teeth in this business writing realtime machine control
software in assembly language (and PL/M!) where there was NO
memory protection and everything - code, data, stack - was
"global" in some sense, or at least could be made to be.
We managed to routinely write highly reliable, blazingly
fast code that didn't break, didn't bork, and did what it
was supposed to.   There's no reason to believe that Python
programs cannot do the exact same thing (well, not the realtime
part) with just as much robustness and correctness as those
old asm programs.

Programming well has far less to do with the language and has
far more to do with the designer and coder...



Tim Daneliuk tun...@tundraware.com
PGP Key: http://www.tundraware.com/PGP/

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


Re: Most discussion on comp.lang.python is about developing with Python

2013-11-13 Thread Rick Johnson

Hello Bob,

I understand your concern but you need to realize there is
not much that can (or should) be done *IF* we want to live in
societies that are free from oppression.

The minute we start drawing lines in the sand and punishing
people for exercising their freedom of speech, is when we
start living under Fascism -- and trust me friend;  trolls,
spammers and flamers are nothing compared to overzealous
nanny police forcing other people to live by rules they
refuse to live by themselves. Is Bloomberg ringing a bell[*]

  WHERE DO WE DRAW THE LINE? 

You cannot create social rules in ANY society that do not
infringe upon the personal freedom of others. We ALL have a
right to express ourselves. 

  HOWEVER,

when we live in a free society we must accept that
some people will be annoying; some will be rude; some will
be friendly; some will be hostile; or any number of 
unpleasing emotional states.

Learning to "tune out" what we find offensive and "tune in"
what we find pleasing (or interesting) is part of being a
member of any free society.

 SOMETIMES, YOU JUST GOTTA PUT YOUR "BIG BOY" PANTS ON.

One aspect about online forums (unlike real life) is that
you can avoid people (or opinions) you find offensive simply
by choosing not to read their words.

But, at the end of the day, ask yourself: "What can a troll,
a flamer, or a spammer do to me anyway?" Answer is: only
that which you allow them to do. Then ask yourself: "What
could the gestapo[**] do to me?"

 "POWER CORRUPTS: ABSOLUTE POWER CORRUPTS ABSOLUTELY."

PS: Funny thing about threads requesting "group
moderation"... they have a tendency to digress into flame
wars -- ain't life a beach?

[*] That sanctimonious prick!
[**] Does "gestapo" qualify as evoking Godwins Law?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Chinese Zodiac - python project

2013-11-13 Thread edmundicon
Den tisdagen den 12:e november 2013 kl. 23:50:03 UTC+1 skrev Denis McMahon:
> On Tue, 12 Nov 2013 14:04:08 -0800, edmundicon wrote:
> 
> 
> 
> > Greetings everyone! This is my first post on this forum :)
> 
> > 
> 
> > TL;DR: I want to convert the gregorian years into Chinese years, and
> 
> > deal with the fact that the Chinese new years are different each
> 
> > gregorian year. If I manage to do that, I'll know which year the user is
> 
> > born in Chinese years and can then give him a personal description based
> 
> > upon that year!
> 
> > 
> 
> > I started to learn Python programming language 2 months ago (noob), but
> 
> > I like it and I feel like if I keep learning I might become a great
> 
> > programmer one day!
> 
> > 
> 
> > I recently started a small Python project in which my mission is to give
> 
> > a personal description to a user based upon the year he / she is born in
> 
> > the Chinese Zodiac and I have run into some trouble. For instance, if
> 
> > someone is born on the 15'th January 1990, he is actually born 1989
> 
> > because the Chinese new year occurred on the 27:th January that year.
> 
> > 
> 
> > I have a text file which shows when the Chinese new years in gregorian
> 
> > years (normal years), starting from 1900-01-31 to 2007-02-18. It goes
> 
> > like this:
> 
> > 1900-1-31 1901-2-19 1902-2-08 1903-1-29 1904-2-16 1905-2-04 1906-1-25
> 
> > ...(and so on)
> 
> > 2007-02-18 ( I can't see the logic behind this really)
> 
> > 
> 
> > The Chinese calendar is divided into cycles of 60 years each, and each
> 
> > year has a combination of an animal and an element. There are 12 animals
> 
> > and 5 elements, the animals changes each year, and the elements every
> 
> > other year. The current cycle was initiated in the year of 1984 which
> 
> > was the year of the Wood Rat. The personal descriptions for each
> 
> > combination has conveniently also been provided in text files.
> 
> > 
> 
> > The animals are in this order:
> 
> > 
> 
> > Rat Ox Tiger Rabbit Dragon Snake Horse Sheep Monkey Rooster Dog Boar
> 
> > 
> 
> > And the elements are:
> 
> > 
> 
> > Wood Fire Earth Metal Water
> 
> > 
> 
> > I have already created a modulus method which takes the input year (the
> 
> > gregorian year you were born) and gives you an element and an animal,
> 
> > for example if you type "1990" you are given Metal Horse. The problem I
> 
> > now have is to convert the gregorian years into Chinese years, and deal
> 
> > with the fact that the Chinese new years are different each gregorian
> 
> > year. If I manage to do that, I'll know which year the user is born in
> 
> > Chinese years and can then give him a personal description based upon
> 
> > that year!
> 
> > 
> 
> > Any advice will be greatly appreciated! Have a nice day :)
> 
> 
> 
> Here is one suggestion
> 
> 
> 
> Write a function to convert a gregorian date into the number of days 
> 
> since 1st January 1900 (we'll call 1st january 1900 your epoch). You will 
> 
> need to take leap years into account.
> 
> 
> 
> Convert the users date of birth using this function.
> 
> 
> 
> Convert your chinese new year dates using this function.
> 
> 
> 
> You now have the simple task of comparing the users date of birth as 
> 
> daynumber_since_epoch with the start date of each chinese year as 
> 
> daynumber_since_epoch.
> 
> 
> 
> You may wish to create a list of tuples where each tuple has start_day, 
> 
> end_day, year_name:
> 
> 
> 
> years = [(0,30,"stone pig"),(31,414,"stone weasel") ... ]
> 
> 
> 
> You should be able to automate creating this list.
> 
> 
> 
> You could then search through the list of tuples with a function such as:
> 
> 
> 
> yearname( birthdate ):
> 
> foreach thing in years
> 
> if birthdate is in the range specified by the thing
> 
> return the yearname from the thing
> 
> return "constipated program"
> 
> 
> 
> (this is obviously not written as python code, you have to do that bit 
> 
> yourself)
> 
> 
> 
> -- 
> 
> Denis McMahon, denismfmcma...@gmail.com

Sir, I am really happy that you answered, but could you *please* elaborate / 
give more great advice on how to write the function which converts your 
gregorian date into a Chinese year? 

Should I do it like this? For example, if I pretend I'm born 1902-2-02, the 
difference in days between this date and 1900-1-01 is 366(because 1900 is a 
leap year) + 365(for 1901) + 31 (for january 1902) + 2(2 days into february 
1902) = 764 days.

How will this integer value help me convert my gregorian date into Chinese 
years? I know, by knowing that 1984 (gregorian year) is the year of the Wood 
Rat, that 1900 (still gregorian year) should be Metal Rat, which means it is 
the 1st value in the animals list and the 4th value in the elements list, but I 
am still confused how to proceed.

If this is any help, I have written some code that makes you type in a 
gregorian year (not a date), compares it with 1984 (gregorian year) and gives 
you an anima

Re: Most discussion on comp.lang.python is about developing with Python

2013-11-13 Thread alex23

On 14/11/2013 9:48 AM, Steven D'Aprano wrote:

I believe that whatever
negative effect Nikos the help-vampire is having, it is long ago
overwhelmed by the negative of the anti-Nikos vigilantes.


I don't know, the anti-Nikos-vigilante vigilantes are beginning to give 
them a run for their money, especially when their criticisms are just as 
applicable to their own behaviour.

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


Re: Most discussion on comp.lang.python is about developing with Python

2013-11-13 Thread Chris Angelico
On Thu, Nov 14, 2013 at 11:41 AM, Rick Johnson
 wrote:
>  "POWER CORRUPTS: ABSOLUTE POWER CORRUPTS ABSOLUTELY."

http://xkcd.com/643/

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


writing fortran equivalent binary file using python

2013-11-13 Thread Sudheer Joseph
Hi,
 I need to write a binary file exactly as written by fortran code below 
to be read by another code which is part of a model which is not advisable to 
edit.I would like to use python for this purpose as python has mode flexibility 
and easy coding methods.
  
  character(40) :: TITLE="122322242"
  integer :: IWI,JWI
  real :: XFIN,YFIN,DXIN=0.5,DYIN=0.5,WDAY(6000)
  XFIN=0.0,YFIN=-90.0,NREC=1461,DXIN=0.5;DYIN=0.5;IWI=720;JWI=361 
  real,allocatable,dimension(:,:,:) :: VAR1_VAL
  real,allocatable,dimension(:,:,:) :: VAR2_VAL

  open(11,file=outf,form='UNFORMATTED')
  WRITE(11) TITLE
  WRITE(11) NX,NY,XFIN,YFIN,DXIN,DYIN,NREC,WDAY
  write(*,'(A10,2f10.3)') "START=",VAR1_VAL(1,1,1),VAR2_VAL(1,1,1)
  write(*,'(A10,2f10.3)') "END=",VAR1_VAL(nx,ny,nrec),VAR2_VAL(nx,ny,nrec)
  do i=1,NREC
  WRITE(11) VAR1_VAL(:,:,i),VAR2_VAL(:,:,i)
  WRITE(*,'(2I10,f10.3)') NX,NY,WDAY(i)
  enddo

My trial code with Python (data is read from file here)

from netCDF4 import Dataset as nc
import numpy as np
XFIN=0.0,YFIN=-90.0,NREC=1461,DXIN=0.5;DYIN=0.5
TITLE="NCMRWF 6HOURLY FORCING MKS"
nf=nc('ncmrwf_uv.nc')
ncv=nf.variables.keys()
IWI=len(nf.variables[ncv[0]])
JWI=len(nf.variables[ncv[1]])
WDAY=nf.varlables[ncv[2]][0:NREC]
U=nf.variables[ncv[3]][0:NREC,:,:]
V=nf.variables[ncv[4]][0:NREC,:,:]
bf=open('ncmrwf_uv.bin',"wb")
f.write(TITLE)
f.write(IWI,JWI,XFIN,YFIN,DXIN,DYIN,NREC,WDAY)
for i in np.arange(0,NREC):
f.write(U[i,:,:],V[i,:,:])
f.close()

But the issue is that f.write do not allow multiple values( it allows one by 
one so throws an error with above code ) on same write statement like in the 
fortran code. experts may please advice if there a solution for this?

with best regards,
Sudheer
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Most discussion on comp.lang.python is about developing with Python

2013-11-13 Thread Terry Reedy

On 11/13/2013 6:27 PM, Rhodri James wrote:

On Wed, 13 Nov 2013 22:53:46 -, Terry Reedy  wrote:


On 11/13/2013 3:35 PM, bob gailer wrote:


Is there a moderator for this list?


Posts from new addresses go to moderators for spam deletion. There are
a couple a day that are discarded. Posts with 'suspicious headers'
also get checked. Non-suspicious posts from known people (perhaps 90%)
do not get checked. We have not yet gotten into 'censorship' of
trolling and flaming. I would prefer not being forced into considering
it.


This is true of python-list.  comp.lang.python the Usenet newsgroup is
not moderated.  God alone knows what Googlegroups thinks it's doing.


On 11/13/2013 6:50 PM, Steven D'Aprano wrote:> On Wed, 13 Nov 2013 1
> Terry, perhaps you are referring to the pyt...@python.org mailing list.

Yes, I took 'list' to mean 'mailing list', not 'newsgroup'.

> But this is also a newsgroup,

Two newsgroups, comp.lang.python and gmane.comp.python.general, and 
(indirectly, I believe) a googlegroup.


> and I believe that there is no moderator on that.

No, not on any of them. However, as near as I can tell, gmane sends 
posts to python-list first and only displays and archives posts that go 
out to the list (and back to gmane, if they originate there, like this 
one). Gmane also has a spam filter and after-the-fact spam reporting. 
People on c.l.p and py g.g. benefit from filtering of spam originally 
sent to the list or gmane. About half of it originates from gmail 
acounts but I do not know (and have not checked) whether gmail posts 
come directly or via gg.


--
Terry Jan Reedy

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


Re: Trying tcompile an use the Python 3.4a

2013-11-13 Thread Johannes Findeisen
On Thu, 14 Nov 2013 00:00:04 +0200
Ferrous Cranus wrote:

> Στις 13/11/2013 11:56 μμ, ο/η Mark Lawrence έγραψε:



> 
> But i have gone to the link and did what it said and it didn't proved 
> usefull thats why i re-ask.

Try looking for a package named "setuptools". I think that is the
package you are missing for installing pip. I don't know anything about
the current CentOS release so may it will not be available via yum.

Good luck!

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


Re: Trying tcompile an use the Python 3.4a

2013-11-13 Thread Ned Batchelder
On Wednesday, November 13, 2013 5:32:49 PM UTC-5, Mark Lawrence wrote:
> Wrong.  You've once again not bothered to read the information that's 
> been handed to you on a plate.  If you'd followed the instructions you 
> would not get the "No such file or directory" error shown above.  I'm 
> not going to spoon feed you, so please go away and sort this out for 
> yourself, we're sick to death of seeing you here.
> 
> Mark Lawrence

Mark, language like that has no place on this list.  Whatever problems are 
happening here, you are not helping to solve them.  Please stop.  Think about 
what you want this list to be like, and write when you can make a positive 
contribution to that effect.

http://www.python.org/psf/codeofconduct/

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


pypy and ctypes

2013-11-13 Thread Peter Chant
I'm looking to speed up some python code.  Replacing the python 
interpreter with pypy was impressive.  I noted that use of ctypes (in 
cython?), specifically declaring variables as below, was reported as 
giving a useful result:


cdef float myvar
cdef int i

under cython can provide a useful speed increase even if sections of 
code are not re-written in C.  Does this also work in PyPy?  From 
googling I keep getting pointed at ffi - but that seems to relate more 
to calling c-libraries rather than what I'm trying to do - seeing if 
there are any simple speed ups by declaring variables.


Or is it that - if I keep the code as simple as possible, PyPy is about 
as fast as you can get?


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


Re: Most discussion on comp.lang.python is about developing with Python

2013-11-13 Thread Steven D'Aprano
On Thu, 14 Nov 2013 10:47:35 +1000, alex23 wrote:

> On 14/11/2013 9:48 AM, Steven D'Aprano wrote:
>> I believe that whatever
>> negative effect Nikos the help-vampire is having, it is long ago
>> overwhelmed by the negative of the anti-Nikos vigilantes.
> 
> I don't know, the anti-Nikos-vigilante vigilantes are beginning to give
> them a run for their money, especially when their criticisms are just as
> applicable to their own behaviour.

Right, because shouting abuse at somebody is completely morally 
equivalent to not shouting abuse at somebody. I'll try to keep that in 
mind for the future.


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


Re: PyMyth: Global variables are evil... WRONG!

2013-11-13 Thread Steven D'Aprano
On Wed, 13 Nov 2013 23:42:24 +, Rhodri James wrote:

> On Tue, 12 Nov 2013 02:06:09 -, Rick Johnson
>  wrote:
> 
>> PyMyth: Global variables are evil... WRONG!
> 
> That's not a PyMyth.  It's a CompSciMyth, or to be more accurate a good
> general Software Engineering guideline regardless of language.

To be precise, it's not a myth at all.

Just because there are occasional medical uses for digitalis doesn't make 
it a myth that it is deadly poison. Just because there are occasional 
programming uses for global variables doesn't make it a myth that they 
are poor practice and lead to hard-to-maintain, unsafe, buggy code.


> Like all
> guidelines it can be broken, but people who break it should do so
> knowingly, aware that they have created potential problems for
> themselves.

Absolutely correct.


>> 
>>  The denial of the 99%:
>>  Python has
>> globals, but we just can't admit it!
> 
> A different subject entirely, but no more accurately stated.

Completely inaccurately stated. It certainly isn't true that "99%" of 
people (who exactly? Rick doesn't say) claim that Python has no globals. 
That would be a stupid thing to say for a language with a "global" 
keyword, a "globals" function, and a built-in module that is shared 
across the entire process.


> [snip]
>> But even the "module level" globals can be accessed "globally" if the
>> module they are contained in is imported everywhere.
> 
> Remember when I said that guidelines can be broken?

I think you know the following, but for anyone else reading...

Just because a module global alpha.spam is accessible to anything that 
imports the module doesn't make it a process-wide global. The ability to 
do this:

import alpha
alpha.spam = 23

does not make "spam" a process-wide global. It just means that attribute 
access on the module object is the supported interface for manipulating 
names in namespaces which are modules.

There is very little practical difference apart from convenience between 
directly manipulating attributes as above, and using a setter function 
like "setattr(alpha, 'spam', 23)". Python tries to avoid boilerplate. 
Since manipulating attributes is useful, a philosophy of consenting 
adults applies and we have direct access to those attributes, with an 
understanding that we should use this power with care. With great power 
comes great responsibility -- if you're going to reach inside another 
module and manipulate things, you ought to know what you're doing.

One of the numerous problems with process-wide globals is that there's no 
encapsulation and consequently one package's use of "spam" clobbers 
another package's use of "spam" for a different purpose. But that's not 
the case here: alpha's "spam" is separate from module omega's "spam" 
variable.

To give an analogy: just because I can walk through the door of number 23 
Alpha Street and rummage through their fridge, and walk through the door 
of number 42 Omega Road and do the same, doesn't mean that the two 
fridges are actually the same fridge.



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


Re: Chinese Zodiac - python project

2013-11-13 Thread Denis McMahon
On Wed, 13 Nov 2013 16:44:03 -0800, edmundicon wrote:

> Den tisdagen den 12:e november 2013 kl. 23:50:03 UTC+1 skrev Denis
> McMahon:
>> On Tue, 12 Nov 2013 14:04:08 -0800, edmundicon wrote:
>> 
>> 
>> 
>> > Greetings everyone! This is my first post on this forum :)
>> 
>> 
>> > 
>> > TL;DR: I want to convert the gregorian years into Chinese years, and
>> 
>> > deal with the fact that the Chinese new years are different each
>> 
>> > gregorian year. If I manage to do that, I'll know which year the user
>> > is
>> 
>> > born in Chinese years and can then give him a personal description
>> > based
>> 
>> > upon that year!
>> 
>> 
>> > 
>> > I started to learn Python programming language 2 months ago (noob),
>> > but
>> 
>> > I like it and I feel like if I keep learning I might become a great
>> 
>> > programmer one day!
>> 
>> 
>> > 
>> > I recently started a small Python project in which my mission is to
>> > give
>> 
>> > a personal description to a user based upon the year he / she is born
>> > in
>> 
>> > the Chinese Zodiac and I have run into some trouble. For instance, if
>> 
>> > someone is born on the 15'th January 1990, he is actually born 1989
>> 
>> > because the Chinese new year occurred on the 27:th January that year.
>> 
>> 
>> > 
>> > I have a text file which shows when the Chinese new years in
>> > gregorian
>> 
>> > years (normal years), starting from 1900-01-31 to 2007-02-18. It goes
>> 
>> > like this:
>> 
>> > 1900-1-31 1901-2-19 1902-2-08 1903-1-29 1904-2-16 1905-2-04 1906-1-25
>> 
>> > ...(and so on)
>> 
>> > 2007-02-18 ( I can't see the logic behind this really)
>> 
>> 
>> > 
>> > The Chinese calendar is divided into cycles of 60 years each, and
>> > each
>> 
>> > year has a combination of an animal and an element. There are 12
>> > animals
>> 
>> > and 5 elements, the animals changes each year, and the elements every
>> 
>> > other year. The current cycle was initiated in the year of 1984 which
>> 
>> > was the year of the Wood Rat. The personal descriptions for each
>> 
>> > combination has conveniently also been provided in text files.
>> 
>> 
>> > 
>> > The animals are in this order:
>> 
>> 
>> > 
>> > Rat Ox Tiger Rabbit Dragon Snake Horse Sheep Monkey Rooster Dog Boar
>> 
>> 
>> > 
>> > And the elements are:
>> 
>> 
>> > 
>> > Wood Fire Earth Metal Water
>> 
>> 
>> > 
>> > I have already created a modulus method which takes the input year
>> > (the
>> 
>> > gregorian year you were born) and gives you an element and an animal,
>> 
>> > for example if you type "1990" you are given Metal Horse. The problem
>> > I
>> 
>> > now have is to convert the gregorian years into Chinese years, and
>> > deal
>> 
>> > with the fact that the Chinese new years are different each gregorian
>> 
>> > year. If I manage to do that, I'll know which year the user is born
>> > in
>> 
>> > Chinese years and can then give him a personal description based upon
>> 
>> > that year!
>> 
>> 
>> > 
>> > Any advice will be greatly appreciated! Have a nice day :)
>> 
>> 
>> 
>> Here is one suggestion
>> 
>> 
>> 
>> Write a function to convert a gregorian date into the number of days
>> 
>> since 1st January 1900 (we'll call 1st january 1900 your epoch). You
>> will
>> 
>> need to take leap years into account.
>> 
>> 
>> 
>> Convert the users date of birth using this function.
>> 
>> 
>> 
>> Convert your chinese new year dates using this function.
>> 
>> 
>> 
>> You now have the simple task of comparing the users date of birth as
>> 
>> daynumber_since_epoch with the start date of each chinese year as
>> 
>> daynumber_since_epoch.
>> 
>> 
>> 
>> You may wish to create a list of tuples where each tuple has start_day,
>> 
>> end_day, year_name:
>> 
>> 
>> 
>> years = [(0,30,"stone pig"),(31,414,"stone weasel") ... ]
>> 
>> 
>> 
>> You should be able to automate creating this list.
>> 
>> 
>> 
>> You could then search through the list of tuples with a function such
>> as:
>> 
>> 
>> 
>> yearname( birthdate ):
>> 
>> foreach thing in years
>> 
>> if birthdate is in the range specified by the thing
>> 
>> return the yearname from the thing
>> 
>> return "constipated program"
>> 
>> 
>> 
>> (this is obviously not written as python code, you have to do that bit
>> 
>> yourself)
>> 
>> 
>> 
>> --
>> 
>> Denis McMahon, denismfmcma...@gmail.com
> 
> Sir, I am really happy that you answered, but could you *please*
> elaborate / give more great advice on how to write the function which
> converts your gregorian date into a Chinese year?
> 
> Should I do it like this? For example, if I pretend I'm born 1902-2-02,
> the difference in days between this date and 1900-1-01 is 366(because
> 1900 is a leap year) + 365(for 1901) + 31 (for january 1902) + 2(2 days
> into february 1902) = 764 days.
> 
> How will this integer value help me convert my gregorian date into
> Chinese years? I know, by knowing that 1984 (gregorian year) is the year
> of the Wood Rat, that 1900 (still gregorian year) should be 

How to disable RTLD_NOW for Python 2.7.x dlopen() in Mac OS X Mavericks?

2013-11-13 Thread tcwan99
Hi,

I've tried searching for topics related to dlopen() of dynamic libraries in the 
list but there's nothing relevant or recent.

I'm facing a problem with a 3rd party C/C++ Framework (dynamic library) on Mac 
OS X which I'm trying to import into Python using ctypes. Unfortunately OS X 
has deprecated a function which is called from the Framework and is no longer 
available as of 10.8+ (Mtn. Lion, now updated to Mavericks). In addition, there 
is no recent version of the 3rd party framework available and it does not look 
like it's actively updated. (The 3rd party framework in question is the Fantom 
framework/driver for the LEGO Mindstorms NXT/EV3).

Existing tools using the 3rd party framework runs ok, but attempting to access 
it using ctypes fails with a Symbol not Found error when Python 2.7.x attempts 
to dlopen() the library. I suspect it is due to the setting of RTLD_NOW when 
opening the framework. I'd like to try to specify RTLD_LAZY instead.

Unfortunately sys.setdlopenflags(0) does not appear to do anything. RTLD_NOW is 
still set, which I presume overrides RTLD_LAZY if both flags were set. I've 
tried this with both the Apple supplied python and the version from MacPorts.

Enclosed is a snippet of the code and the Traceback. Is there a way to force 
RTLD_NOW off?

[code]

# Load library.
#dll = ctypes.cdll.LoadLibrary(libpath)
RTLD_LAZY = 1
sys.setdlopenflags(0)
print "dlopen() flags = %d" % sys.getdlopenflags()
dll = ctypes.CDLL(libpath, RTLD_LAZY)

[/code]

[traceback]

$ arch -i386 python --version
Python 2.7.5

$ arch -i386 python pyfantom.py
Running on Darwin Platform (Rel. 13.0.0)
  Bluetooth Stack not supported (Rel >= 12.0.0)
Found Fantom Library ( /Library/Frameworks/fantom.framework/fantom )
dlopen() flags = 0
Traceback (most recent call last):
  File "pyfantom.py", line 83, in 
dll = ctypes.CDLL(libpath, RTLD_LAZY)
  File 
"/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py",
 line 365, in __init__
self._handle = _dlopen(self._name, mode)
OSError: dlopen(/Library/Frameworks/fantom.framework/fantom, 3): Symbol not 
found: _IOBluetoothSDPServiceRecordGetRFCOMMChannelID
  Referenced from: /Library/Frameworks/fantom.framework/fantom
  Expected in: 
/System/Library/Frameworks/IOBluetooth.framework/Versions/A/IOBluetooth

[/traceback]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Trying tcompile an use the Python 3.4a

2013-11-13 Thread Denis McMahon
On Wed, 13 Nov 2013 16:17:22 +0200, Ferrous Cranus wrote:

> root@secure [/home/nikos/www/cgi-bin]# python3 -V Python 3.4.0a4

Let me just check.

Nobody is so stupid as to run alpha software on a production server[1] 
are they?

[1] In this context, "production server" means any system facing the 
public internet upon which python code is executed in response to inputs 
from the public internet.

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


Re: Trying tcompile an use the Python 3.4a

2013-11-13 Thread Mark Lawrence

On 14/11/2013 00:57, Ned Batchelder wrote:

On Wednesday, November 13, 2013 5:32:49 PM UTC-5, Mark Lawrence wrote:

Wrong.  You've once again not bothered to read the information that's
been handed to you on a plate.  If you'd followed the instructions you
would not get the "No such file or directory" error shown above.  I'm
not going to spoon feed you, so please go away and sort this out for
yourself, we're sick to death of seeing you here.

Mark Lawrence


Mark, language like that has no place on this list.  Whatever problems are 
happening here, you are not helping to solve them.  Please stop.  Think about 
what you want this list to be like, and write when you can make a positive 
contribution to that effect.

http://www.python.org/psf/codeofconduct/

--Ned.



Stop him and stop the spoon feeders and I stop.  Simples.  And we are 
sick to death of seeing him here, don't you have the guts to say it like 
it is?


--
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: Most discussion on comp.lang.python is about developing with Python

2013-11-13 Thread Terry Reedy

On 11/13/2013 6:48 PM, Steven D'Aprano wrote:

On Wed, 13 Nov 2013 15:35:56 -0500, bob gailer wrote:



Or would you be willing to stop the bashing? I don't see that it helps
anyone, and could be very offputting to other newbies.


That's what I have been saying for a long time. I believe that whatever
negative effect Nikos the help-vampire is having, it is long ago
overwhelmed by the negative of the anti-Nikos vigilantes.


I agree and privately asked one such vigilante to desist.


Fortunately, Nikos appears to pay absolutely no attention to any thread
which isn't about him. So if you avoid threads started by him, you'll
miss the worst of it.


Thunderbird now make this easy with R click, Ignore thread. I do this 
with non-Python threads and eventually with all that continue too long. 
So I have no idea how many Nikos threads are currently active other than 
the one I have not ignored yet. Sometimes ignorance *is* bliss ;-).


The last straw for me was a day when half the posts were for various 
Nikos threads. And perhaps 2/3rds of those were *not* from Nikos. To me, 
this is way unbalanced.



As a community, it is difficult to balance the conflicting needs here. If
we ignore Nikos completely, we appear unfriendly and indifferent to those
asking for help.


I think at this point that off-topic posts should get one and only one 
answer:

"This question is not about Python. Please take it somewhere else."
If you see that already posted, move on.


If we answer his questions, we encourage him to post. It
is hard to find the right balance, if there even is a right balance, and
people can have differing ideas of what that right balance is.


I think that Python questions, like "How do I complile 3.4a4 on Centos", 
that might interest others, should get answer or two or three for the 
benefit of everyone. And then answers should stop unless one has more 
information to give. No more 'I already answered that'. Sensible people 
can see that the question was answered, so repeating the obvious adds 
nothing.



But it is clear from the last few months that abusive, aggressive posts
don't help anyone -- they don't set a good tone for the group, they put
off newcomers, and they do absolutely nothing to discourage Nikos. Please
consider this a request to the community, ignore Nikos if you like,
answer his questions if you must, but please keep the abusive posts off-
list. They aren't helping.


I agree and second the request. Thanks for posting this.

--
Terry Jan Reedy

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


Re: Trying tcompile an use the Python 3.4a

2013-11-13 Thread Chris Angelico
On Thu, Nov 14, 2013 at 12:14 PM, Denis McMahon
 wrote:
> On Wed, 13 Nov 2013 16:17:22 +0200, Ferrous Cranus wrote:
>
>> root@secure [/home/nikos/www/cgi-bin]# python3 -V Python 3.4.0a4
>
> Let me just check.
>
> Nobody is so stupid as to run alpha software on a production server[1]
> are they?
>
> [1] In this context, "production server" means any system facing the
> public internet upon which python code is executed in response to inputs
> from the public internet.

I don't know that that's necessarily stupid. For a lot of my work,
I've been using a trunk version of Pike (7.9.11 currently), and if I
were working more heavily with Python on my servers, I would consider
using alpha versions if there were features that I wanted (or fixes
that I needed). It's not stupid, but it does require a "hand on the
tiller" so to speak; running alpha code - or, for that matter, any
code you compiled yourself - in production means taking responsibility
for it. I'm confident of my own ability to keep up with changes, but
for most people, I would strongly recommend taking, in order: (1) the
Python that your distro provides; (2) a python.org published stable
version; (3) a preproduction (eg RC) version; and finally (4) anything
else, including straight from Mercurial. The further down that list
you go, the more work you have to do yourself to ensure compatibility,
dependency management, etcetera.

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


Re: chroot to install packages

2013-11-13 Thread Himanshu Garg
On Thursday, November 14, 2013 5:10:20 AM UTC+5:30, Chris Angelico wrote:
> On Thu, Nov 14, 2013 at 1:31 AM, Himanshu Garg  wrote:
> 
> > I am writing a python script to run chroot command to chroot to a linux 
> > distro and then run commands.  How can I do this, as after chrooting, the 
> > script runs the commands relative to the outside not inside the chrooted 
> > env?
> 
> 
> 
> Probably the easiest way to do this is to divide your script into two
> 
> pieces: one piece runs inside the chroot, the other doesn't. Then you
> 
> have the "outer" script invoke the "inner" script as a separate
> 
> process. When the inner process terminates, the outer continues, and
> 
> since the outer wasn't chrooted, it's now running commands relative to
> 
> the outside.
> 
> 
> 
> One convenient way to manage this is to have one script that invokes
> 
> itself with arguments. Another way is to have two actually separate
> 
> script files. It really depends how much work you're doing in each
> 
> half.
> 
> 
> 
> ChrisA

How can I do that?  Can you guide me?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: chroot to install packages

2013-11-13 Thread Chris Angelico
On Thu, Nov 14, 2013 at 12:52 PM, Himanshu Garg  wrote:
> How can I do that?  Can you guide me?

First off: Google Groups is making your posts very ugly. Please either
fix them before posting, or use a better client.

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

As to chrooting: It'd look something like this, in pseudocode:

if sys.argv[1] == "chroot":
chroot("/some/path/to/new/root")
do_stuff_in_chroot()
do_more_stuff_in_chroot()
exit(0)

do_stuff_not_in_chroot()
os.system("python my_script_name.py chroot")
do_more_stuff_not_in_chroot()


There are many ways to do things, but that's one of the simplest. You
have two completely separate processes.

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


ogg2mp3 utility?

2013-11-13 Thread Tim Johnson
I've written an application that does some audio file conversions.

I use mutagen for some of the mp3 file manipulation, but to convert
ogg files to mp3 format I've been using subprocess to run the
ogg2mp3 perl utility.  (available from http://marginalhacks.com/) by
David Madison.

It's a "spot on" great app, but I would like to be able to "keep it
all one codebase".

Are there any python utility that anyone could recommend?

thanks
-- 
Tim 
tim at tee jay forty nine dot com or akwebsoft dot com
http://www.akwebsoft.com, http://www.tj49.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Using alpha software in production [was Re: Trying tcompile an use the Python 3.4a]

2013-11-13 Thread Steven D'Aprano
On Thu, 14 Nov 2013 12:27:58 +1100, Chris Angelico wrote:

> On Thu, Nov 14, 2013 at 12:14 PM, Denis McMahon
>  wrote:

>> Nobody is so stupid as to run alpha software on a production server[1]
>> are they?
>>
>> [1] In this context, "production server" means any system facing the
>> public internet upon which python code is executed in response to
>> inputs from the public internet.

Surely the answer to that is, "define stupid"?

What are the consequences of breakage? If the consequences are minor, why 
wouldn't I use alpha software? Hypothetically speaking, even if the 
machine were totally compromised, I might just shrug and rebuild it 
(hopefully having reported the security vulnerability that allowed the 
compromise, and having it fixed).

But specifically in this case, I agree with your implication, and 
question the wisdom of the OP upgrading from a stable version of 3.3 to 
an alpha version of 3.4.


> I don't know that that's necessarily stupid. For a lot of my work, I've
> been using a trunk version of Pike (7.9.11 currently), and if I were
> working more heavily with Python on my servers, I would consider using
> alpha versions if there were features that I wanted (or fixes that I
> needed). It's not stupid, but it does require a "hand on the tiller" so
> to speak; running alpha code - or, for that matter, any code you
> compiled yourself - in production means taking responsibility for it.

Yes, this! A master craftsman knows when to break the rules. I personally 
would not run a public web app using alpha software because I know my 
limitations, but I'm sure there are those who have both the skill to 
manage it and the wisdom to know whether or not to risk it.


> I'm confident of my own ability to keep up with changes, but for most
> people, I would strongly recommend taking, in order: (1) the Python that
> your distro provides; (2) a python.org published stable version; (3) a
> preproduction (eg RC) version; and finally (4) anything else, including
> straight from Mercurial. The further down that list you go, the more
> work you have to do yourself to ensure compatibility, dependency
> management, etcetera.

+1


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


Re: PyMyth: Global variables are evil... WRONG!

2013-11-13 Thread Rick Johnson
On Wednesday, November 13, 2013 5:42:24 PM UTC-6, Rhodri James wrote:
> On Tue, 12 Nov 2013 02:06:09 -, Rick Johnson wrote:
> > PyMyth: Global variables are evil... WRONG!
> That's not a PyMyth.  It's a CompSciMyth, or to be more
> accurate a good general Software Engineering guideline
> regardless of language.  Like all guidelines it can be
> broken, but people who break it should do so knowingly,
> aware that they have created potential problems for
> themselves.

You speak as if using globals are inhabited by gremlins
just wanting to get out and run a muck. There are no
"inherent" problems in the global interface design except
those that programmer inserts himself.

Real global variable interfacing is no different than
python object member interfacing, or module interfacing,
except that the latter two are encapsulated by inside a
namespace, and the former (historically) are unprotected and
available everywhere; hence the name "global" :-)

With Python, i can still reassign a value to class attribute
and break code that depends on that attribute, of course,
doing so is not a good idea; but it's allowed nonetheless!

The programmer can break ANY interface in Python, be it
accessing a module attribute he shouldn't touch or via a
"real global" variable (if Python had that functionality).

So that renders this whole argument of "global gremlins" as
FUD. The gremlins don't exist until the programmer creates
them. Just because one programmer is unable to create a
logical global implementation, does not mean another cannot.

All you need to do is adopt the principles of consistency.

But i'm not here to convince you that globals are correct
for you, nor do i want you to use them if you feel
uncomfortable (lord knows there's enough bad code
circulating already!) i just want people to stop propagating
this myth that globals are evil.

And i also want to point out the hypocrisy of Python's
design. Python DOES have globals


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


Re: chroot to install packages

2013-11-13 Thread Steven D'Aprano
On Wed, 13 Nov 2013 17:52:42 -0800, Himanshu Garg wrote:

> On Thursday, November 14, 2013 5:10:20 AM UTC+5:30, Chris Angelico
> wrote:
>> On Thu, Nov 14, 2013 at 1:31 AM, Himanshu Garg 
>> wrote:
>> 
>> > I am writing a python script to run chroot command to chroot to a
>> > linux distro and then run commands.  How can I do this, as after
>> > chrooting, the script runs the commands relative to the outside not
>> > inside the chrooted env?
>> 
>> Probably the easiest way to do this is to divide your script into two
>> pieces: one piece runs inside the chroot, the other doesn't. Then you
>> have the "outer" script invoke the "inner" script as a separate
>> process. When the inner process terminates, the outer continues, and
>> since the outer wasn't chrooted, it's now running commands relative to
>> the outside.
>> 
>> One convenient way to manage this is to have one script that invokes
>> itself with arguments. Another way is to have two actually separate
>> script files. It really depends how much work you're doing in each
>> half.

> 
> How can I do that?  Can you guide me?

That's an extremely open-ended question that basically means "please 
write my code for me", but I'll give it a go. Note that I haven't done 
this before, so take what I say with a grain of salt, and I look forward 
to corrections from others.

Suppose you have a function that you want to run on the inside of the 
chroot. So you build a module like this:

# module inside.py
def function(a, b, c):
...

if __name__ == '__main__':
args = sys.argv[1:]
function(*args)


Make sure this module is executable: on Linux systems, you would use 
chmod u+x inside.py


The next bit is the part I have no idea about... use your operating 
system tools to set up a chroot jail for "inside.py". Google is your 
friend there, I'm sure there will be many, many websites that discuss 
chroot jails.

Finally, you have your outside script that calls the inner one:


# module outside.py
from subprocess import call
return_code = call(["path/to_jail/inside.py", 
"first arg", "second arg", "third arg"])


For more complicated usage, you should read the docs for the subprocess 
module. For quick and dirty uses, you can use:

import sys
sys.system('path/to_jail/inside.py "first arg" "second arg" "third arg"')

but I recommend against that except for throw-away scripts.


Corrections welcome!


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


Re: PyMyth: Global variables are evil... WRONG!

2013-11-13 Thread Rick Johnson
On Wednesday, November 13, 2013 4:00:15 PM UTC-6, Andrew Cooper wrote:
> And what do you do when the wizards bend space-time to
> make PI exactly 3, for the ease of other calculations when
> building a sorting machine?

Are you telling me that these wizards can't be bothered to
write the integer "3"? They have to reassign math.pi instead?

Look if you need some other granularity of PI besides
what's offered in math.PI, then do your own calculation.

The last thing you want to do is create a variable when a
constant is what you need.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Using alpha software in production [was Re: Trying tcompile an use the Python 3.4a]

2013-11-13 Thread Chris Angelico
On Thu, Nov 14, 2013 at 1:00 PM, Steven D'Aprano
 wrote:
> Yes, this! A master craftsman knows when to break the rules. I personally
> would not run a public web app using alpha software because I know my
> limitations...

+1. Plenty of people know that a master knows when to break the
rules... the flip side is that a master also knows when NOT to break
the rules. I'll run a trunk build of Pike, and I might of Python, but
I wouldn't run a pre-alpha version of Apache, nor of the Linux kernel,
nor pretty much anything else on my system. That is, not in
production. There are all sorts of things that I'll happily do in a
VM, where the consequences of totally hosing the system are "Oh dear,
now I have to restore from a snapshot". :)

For what it's worth, I've been running 3.4 builds for a while - not in
production, but only because my production box is actually a rather
ancient and very stable machine and I have no reason yet to change
anything. It's looking fairly good, but I'd say the change from 3.3 to
3.4 is a lot less exciting for me than the change from 3.2 to 3.3.
(Though asyncio may invert that valuation, once I dig into it enough
to find out how fun it is.)

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


  1   2   >