RE: help how to sort a list in order of 'n' in python without using inbuilt functions??

2013-05-25 Thread Carlos Nepomuceno

> Date: Fri, 24 May 2013 23:05:17 -0700
> Subject: Re: help how to sort a list in order of 'n' in python without using 
> inbuilt functions??
> From: lokeshkopp...@gmail.com
> To: python-list@python.org
[...]
> ya steven i had done the similar logic but thats not satisfying my professor
> he had given the following constrains
> 1. No in-built functions should be used
> 2. we are expecting a O(n) solution
> 3. Don't use count method

That's trivial!

# l is a list of numbers: 0,1,2
def order_n(l):
    r = []
    count = [0]*3
    count[2] = len(l)
    for i in range(len(l)):
    count[1] += abs((l[i]>0)-1)
    r.insert(count[l[i]], l[i])
    return r

'count' is a list I've defined to count the quantity of the elements in the 
argument, not the method.

I don't think it needs any explanations, but if you have any doubts just ask. ;)

Good luck!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: help how to sort a list in order of 'n' in python without using inbuilt functions??

2013-05-25 Thread Chris Angelico
On Sat, May 25, 2013 at 5:53 PM, Carlos Nepomuceno
 wrote:
> 
>> Date: Fri, 24 May 2013 23:05:17 -0700
>> 1. No in-built functions should be used
> count[2] = len(l)

Fail! :)

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


RE: help how to sort a list in order of 'n' in python without using inbuilt functions??

2013-05-25 Thread Carlos Nepomuceno

> Date: Sat, 25 May 2013 18:28:32 +1000
> Subject: Re: help how to sort a list in order of 'n' in python without using 
> inbuilt functions??
> From: ros...@gmail.com
> To: python-list@python.org
>
> On Sat, May 25, 2013 at 5:53 PM, Carlos Nepomuceno
>  wrote:
>> 
>>> Date: Fri, 24 May 2013 23:05:17 -0700
>>> 1. No in-built functions should be used
>> count[2] = len(l)
>
> Fail! :)
>
> ChrisA
> --
> http://mail.python.org/mailman/listinfo/python-list

lol I forgot to include this monkey patch! ;)

def length(l):
    x=0
    y=l[:]
    while y:
    x+=1
    y.pop()
    return x  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: help how to sort a list in order of 'n' in python without using inbuilt functions??

2013-05-25 Thread Chris Angelico
On Sat, May 25, 2013 at 6:43 PM, Carlos Nepomuceno
 wrote:
> 
> lol I forgot to include this monkey patch! ;)
>
> def length(l):
> x=0
> y=l[:]
> while y:
> x+=1
> y.pop()
> return x

Nice. Now eliminate abs (easy) and range. :)

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


RE: help how to sort a list in order of 'n' in python without using inbuilt functions??

2013-05-25 Thread Carlos Nepomuceno
lol

def absolute(x):
    return x if x>0 else -x

def reach(x):
    y=[]
    z=0
    while z Date: Sat, 25 May 2013 18:47:24 +1000
> Subject: Re: help how to sort a list in order of 'n' in python without using 
> inbuilt functions??
> From: ros...@gmail.com
> To: python-list@python.org
>
> On Sat, May 25, 2013 at 6:43 PM, Carlos Nepomuceno
>  wrote:
>> 
>> lol I forgot to include this monkey patch! ;)
>>
>> def length(l):
>> x=0
>> y=l[:]
>> while y:
>> x+=1
>> y.pop()
>> return x
>
> Nice. Now eliminate abs (easy) and range. :)
>
> ChrisA
> --
> http://mail.python.org/mailman/listinfo/python-list   
>   
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: help how to sort a list in order of 'n' in python without using inbuilt functions??

2013-05-25 Thread Chris Angelico
On Sat, May 25, 2013 at 6:54 PM, Carlos Nepomuceno
 wrote:
> lol
>
> def absolute(x):
> return x if x>0 else -x
>
> def reach(x):
> y=[]
> z=0
> while z y.append(z)
> z+=1
> return y

Very good. You are now in a position to get past the limitations of a
restricted-environment eval/exec. Avoiding builtins is actually a fun
skill to hone.

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


RE: help how to sort a list in order of 'n' in python without using inbuilt functions??

2013-05-25 Thread Carlos Nepomuceno

> Date: Sat, 25 May 2013 19:01:09 +1000
> Subject: Re: help how to sort a list in order of 'n' in python without using 
> inbuilt functions??
> From: ros...@gmail.com
> To: python-list@python.org
[...]
> Very good. You are now in a position to get past the limitations of a
> restricted-environment eval/exec. Avoiding builtins is actually a fun
> skill to hone.
>
> ChrisA


I'm glad he didn't ask for a Pseudo-RNG without built-ins! ;)   
  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: help how to sort a list in order of 'n' in python without using inbuilt functions??

2013-05-25 Thread Chris Angelico
On Sat, May 25, 2013 at 7:10 PM, Carlos Nepomuceno
 wrote:
> 
>> Date: Sat, 25 May 2013 19:01:09 +1000
>> Subject: Re: help how to sort a list in order of 'n' in python without using 
>> inbuilt functions??
>> From: ros...@gmail.com
>> To: python-list@python.org
> [...]
>> Very good. You are now in a position to get past the limitations of a
>> restricted-environment eval/exec. Avoiding builtins is actually a fun
>> skill to hone.
>>
>> ChrisA
>
>
> I'm glad he didn't ask for a Pseudo-RNG without built-ins! ;)

def random_number():
return 7

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


RE: help how to sort a list in order of 'n' in python without using inbuilt functions??

2013-05-25 Thread Carlos Nepomuceno
lol http://search.dilbert.com/comic/Random%20Nine


> Date: Sat, 25 May 2013 19:14:57 +1000
> Subject: Re: help how to sort a list in order of 'n' in python without using 
> inbuilt functions??
> From: ros...@gmail.com
> To: python-list@python.org
>
> On Sat, May 25, 2013 at 7:10 PM, Carlos Nepomuceno
>  wrote:
>> 
>>> Date: Sat, 25 May 2013 19:01:09 +1000
>>> Subject: Re: help how to sort a list in order of 'n' in python without 
>>> using inbuilt functions??
>>> From: ros...@gmail.com
>>> To: python-list@python.org
>> [...]
>>> Very good. You are now in a position to get past the limitations of a
>>> restricted-environment eval/exec. Avoiding builtins is actually a fun
>>> skill to hone.
>>>
>>> ChrisA
>>
>>
>> I'm glad he didn't ask for a Pseudo-RNG without built-ins! ;)
>
> def random_number():
> return 7
>
> ChrisA
> --
> http://mail.python.org/mailman/listinfo/python-list   
>   
-- 
http://mail.python.org/mailman/listinfo/python-list


Py_Initialize and Py_Finalize and MatPlotlib

2013-05-25 Thread Rene Grothmann
This is a known problem, but I want to ask the experts for the best way to 
solve it for me.

I have a project (Euler Math Toolbox), which runs Python as a script language. 
For this, a library module "python.dll" is loaded at run time, which is linked 
against "python27.lib". Then Py_Initialize is called. This all works well.

But Euler can be restarted by the user with a new session and notebook. Then I 
want Python to clear all variables and imports. For this, I call Py_Finalize 
and unload "python.dll". When Python is needed, loading and initializing starts 
Python again.

This works. But Python crashes at the first call, if MatPlotlib is imported in 
the previous session. It seems that Py_Finalize does not completely clear 
Python, nor does unloading my "python.dll". I tried unloading "python27.dll" 
(the Python DLL), but this does not help. Most likey, another DLL remains 
active, but corrupts during Py_Finalize.

To solve this, it would suffice to clear all variables and imports. I could 
live with not calling Py_Finalize. But how?

PS: You may wonder, why I do not directly link euler.exe to Python. The reason 
is that this prevents Euler form starting, if Python is not installed, even if 
it is never needed.

Thanks for any answers! You duplicate your answer to renegrothmann at gmail, if 
you like. That would help me.
-- 
http://mail.python.org/mailman/listinfo/python-list


Total Beginner - Extracting Data from a Database Online (Screenshot)

2013-05-25 Thread neil.suffi...@gmail.com
If you are talking about accessing a web page, rather than an image, then you 
want to do what is known as screen scraping. 

One of the best tools for this is called BeautifulSoup.

http://www.crummy.com/software/BeautifulSoup/
-- 
http://mail.python.org/mailman/listinfo/python-list


Total Beginner - Extracting Data from a Database Online (Screenshot)

2013-05-25 Thread neil.suffi...@gmail.com
If you are talking about accessing a web page, rather than an image, then what 
you want to do is known as 'screen scraping'. 

One of the best tools for this is called BeautifulSoup. 

http://www.crummy.com/software/BeautifulSoup/ 
-- 
http://mail.python.org/mailman/listinfo/python-list


Text-to-Sound or Vice Versa (Method NOT the source code)

2013-05-25 Thread Rakshith Nayak
Always wondered how sound is generated from text. Googling couldn't help. Devs 
having knowledge about this could provide, the information, Links, URLs or 
anything that could help. 


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


Re: help how to sort a list in order of 'n' in python without using inbuilt functions??

2013-05-25 Thread Mark Lawrence

On 25/05/2013 09:54, Carlos Nepomuceno wrote:

lol

def absolute(x):
 return x if x>0 else -x

def reach(x):
 y=[]
 z=0
 while z

In my book this is another fail as lists are inbuilt (yuck!) and so is 
the add function that'll be called for z+=1.


--
If you're using GoogleCrap™ please read this 
http://wiki.python.org/moin/GoogleGroupsPython.


Mark Lawrence

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


Re: Text-to-Sound or Vice Versa (Method NOT the source code)

2013-05-25 Thread Günther Dietrich
Rakshith Nayak  wrote:

>Always wondered how sound is generated from text. Googling couldn't help. Devs 
>having knowledge about this could provide, the information, Links, URLs or 
>anything that could help. 

Perhaps try 'text to speech' instead of 'text to sound'?



Best regards,

Günther
-- 
http://mail.python.org/mailman/listinfo/python-list


Learning Python

2013-05-25 Thread Asad Hasan
Hi All ,

 I have started leaning Python through web . Would like to know if
I should follow any book so that basics become clear with examples also
want to know like in perl i use to invoke perl -d to get a debugged output
is there any option in python.

THanks,
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: help how to sort a list in order of 'n' in python without using inbuilt functions??

2013-05-25 Thread Roy Smith
In article <78192328-b31b-49d9-9cd6-ec742c092...@googlegroups.com>,
 lokeshkopp...@gmail.com wrote:

> On Friday, May 24, 2013 1:34:51 PM UTC+5:30, lokesh...@gmail.com wrote:
> > i need to write a code which can sort the list in order of 'n' without use 
> > builtin functions 
> > 
> > can anyone help me how to do?
> 
>  Note:
> the list only contains 0's,1's,2's
> need to sort them in order of 'n'

What do you mean by "need to sort them in order of 'n'".  Are you saying 
that you need to sort them into numerical order?  Or that you need to 
running time of the algorithm to be O(n)?

I'm assuming the later, in which case this is starting to sound like a 
classic interview question.

Assuming you can accept an unstable sort, there's an easy solution.  I'm 
not aware of any solution if you require a stable sort.  Perhaps that's 
enough of a hint?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: help how to sort a list in order of 'n' in python without using inbuilt functions??

2013-05-25 Thread Roy Smith
In article <74e33270-a79a-4878-a400-8a6cda663...@googlegroups.com>,
 lokeshkopp...@gmail.com wrote:

> ya steven i had done the similar logic but thats not satisfying my professor 
> he had given the following constrains
>  1. No in-built functions should be used
>  2. we are expecting a O(n) solution
>  3. Don't use count method

A couple of points here:

1) In general, people on mailing lists are not into doing homework 
problems for other people.

2) If you're going to bring us a homework problem, at least describe the 
whole problem up front.  It really doesn't help to dribble out new 
requirements one at a time.

3) rustompm...@gmail.com already posted a pointer to the wikipedia 
article describing the required algorithm in detail.

4) I don't know what "no built-in functions should be used" means.  I 
assume it means, "don't call sort()"?  If you can't even call 
int.__lt__(), it's going to be really hard to do this.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: help how to sort a list in order of 'n' in python without using inbuilt functions??

2013-05-25 Thread Dave Angel

On 05/25/2013 10:03 AM, Roy Smith wrote:

In article <74e33270-a79a-4878-a400-8a6cda663...@googlegroups.com>,
  lokeshkopp...@gmail.com wrote:


ya steven i had done the similar logic but thats not satisfying my professor
he had given the following constrains
  1. No in-built functions should be used
  2. we are expecting a O(n) solution
  3. Don't use count method


A couple of points here:

1) In general, people on mailing lists are not into doing homework
problems for other people.

2) If you're going to bring us a homework problem, at least describe the
whole problem up front.  It really doesn't help to dribble out new
requirements one at a time.

3) rustompm...@gmail.com already posted a pointer to the wikipedia
article describing the required algorithm in detail.

4) I don't know what "no built-in functions should be used" means.  I
assume it means, "don't call sort()"?  If you can't even call
int.__lt__(), it's going to be really hard to do this.



The OP has already admitted that he didn't want a sort at all.  He wants 
to COUNT the items, not sort them.  So nothing in his orginal post 
relates to the real homework assignment.


--
DaveA
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python Magazine

2013-05-25 Thread Steven D'Aprano
On Sat, 25 May 2013 16:41:58 +1000, Chris Angelico wrote:

> On Sat, May 25, 2013 at 4:38 PM, zoom  wrote:
>> But why would anyone want to use IPv6?
> 
> I hope you're not serious :)

He's planning to drop off the Internet once the IP address run out.


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


Re: help how to sort a list in order of 'n' in python without using inbuilt functions??

2013-05-25 Thread Steven D'Aprano
On Sat, 25 May 2013 19:14:57 +1000, Chris Angelico wrote:

> def random_number():
> return 7

I call shenanigans! That value isn't generated randomly, you just made it 
up! I rolled a die *hundreds* of times and not once did it come up seven!



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


Re: help how to sort a list in order of 'n' in python without using inbuilt functions??

2013-05-25 Thread Steven D'Aprano
On Fri, 24 May 2013 23:05:17 -0700, lokeshkoppaka wrote:

> On Saturday, May 25, 2013 11:27:38 AM UTC+5:30, Steven D'Aprano wrote:

>> tally = 0
>> for item in list_of_items:
>> if item == 0:
>> tally = tally + 1
>> 
>> print "The number of zeroes equals", tally
> 
>
> ya steven i had done the similar logic but thats not satisfying my
> professor he had given the following constrains
>  1. No in-built functions should be used 

The above does not use any built-in functions.

> 2. we are expecting a O(n) solution

The above is O(n).

>  3. Don't use count method

The above does not use the count method.



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


Re: Learning Python

2013-05-25 Thread Steven D'Aprano
On Sat, 25 May 2013 18:11:11 +0530, Asad Hasan wrote:

> I have started leaning Python through web . Would like to know
> if I should follow any book so that basics become clear with examples 

Reading books is a good thing to do.


> also
> want to know like in perl i use to invoke perl -d to get a debugged
> output is there any option in python.

Yes. Instead of calling your script like this:

python myscript.py

call it like this:

python -m pdb myscript.py



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


Re: help how to sort a list in order of 'n' in python without using inbuilt functions??

2013-05-25 Thread Fábio Santos
On 25 May 2013 15:35, "Steven D'Aprano" <
steve+comp.lang.pyt...@pearwood.info> wrote:
>
> On Sat, 25 May 2013 19:14:57 +1000, Chris Angelico wrote:
>
> > def random_number():
> > return 7
>
> I call shenanigans! That value isn't generated randomly, you just made it
> up! I rolled a die *hundreds* of times and not once did it come up seven!
>
>
>
> --
> Steven
> --
> http://mail.python.org/mailman/listinfo/python-list

Try flipping a coin. I flipped one a couple of times and got the seventh
face once.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: help how to sort a list in order of 'n' in python without using inbuilt functions??

2013-05-25 Thread Jussi Piitulainen
Roy Smith writes:

> In article <78192328-b31b-49d9-9cd6-ec742c092...@googlegroups.com>,
>  lokeshkopp...@gmail.com wrote:
> 
> > On Friday, May 24, 2013 1:34:51 PM UTC+5:30, lokesh...@gmail.com wrote:
> > > i need to write a code which can sort the list in order of 'n'
> > > without use builtin functions
> > > 
> > > can anyone help me how to do?
> > 
> >  Note:
> > the list only contains 0's,1's,2's
> > need to sort them in order of 'n'
> 
> What do you mean by "need to sort them in order of 'n'".  Are you
> saying that you need to sort them into numerical order?  Or that you
> need to running time of the algorithm to be O(n)?
> 
> I'm assuming the later, in which case this is starting to sound like
> a classic interview question.
> 
> Assuming you can accept an unstable sort, there's an easy solution.
> I'm not aware of any solution if you require a stable sort.  Perhaps
> that's enough of a hint?

Surely it's assumed that each element of the input list can be
classified as 0, 1, or 2 in O(1) time. If O(n) auxiliary space can be
allocated in O(n) time, just put the 0's in their own list in the
order they are encountered, 1's in their own list in the order they
are encountered, 2's in their own list in the order they are
encountered, then put the 0's back into the input list in the order
they are encountered in their auxiliary list, followed by the 1's,
followed by the 2's. Stable and O(n), no?

Even ( [ x for x in input if x.key == 0 ] +
   [ x for x in input if x.key == 1 ] +
   [ x for x in input if x.key == 2 ] ).
I suppose a list comprehension is not technically a function any more
than a loop is.

(Neither stability nor O(1) space has been required yet, I think.)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Magazine

2013-05-25 Thread Daniel
All of the above, plus:

- Best Pythonic tools for GUI

- notorious projects (in science, education, NGOs, etc) using python

Please keep us informed, and best wishes

Daniel

El 25/05/2013, a las 07:29, Michael Poeltl  
escribió:

> * DRJ Reddy  [2013-05-25 05:26]:
>> Planning to start a python online chronicle.What you want to see in it. :)
> - idiomatic python (common mistakes; do it 'pythonically')
> - interviews
> - challenge of the week (how would you solve that?)
> - python for kids
> - scientific python news
> - new python-books
> 
> - 
> 
> 
>> -- 
>> http://mail.python.org/mailman/listinfo/python-list
> 
> -- 
>  Michael Poeltl 
>  Computational Materials Physics at University
>  Wien, Sensengasse 8/12, A-1090 Wien, AUSTRIA
>  http://cmp.univie.ac.at/
>  http://homepage.univie.ac.at/michael.poeltl/
>  using elinks-0.12, mutt-1.5.21, and vim-7.3,
>  with python-3.2.3, on slackware-13.37   :-)
>  fon: +43-1-4277-51409
> -- 
> http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: help how to sort a list in order of 'n' in python without using inbuilt functions??

2013-05-25 Thread Mark Lawrence

On 25/05/2013 15:28, Steven D'Aprano wrote:

On Sat, 25 May 2013 19:14:57 +1000, Chris Angelico wrote:


def random_number():
 return 7


I call shenanigans! That value isn't generated randomly, you just made it
up! I rolled a die *hundreds* of times and not once did it come up seven!





Lies, damn lies and statistics? :)

--
If you're using GoogleCrap™ please read this 
http://wiki.python.org/moin/GoogleGroupsPython.


Mark Lawrence

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


Re: Python Magazine

2013-05-25 Thread Roy Smith
In article ,
 Chris Angelico  wrote:

> > Also, comparison of Python flavors (CPython, PyPy, Cython, Stackles, etc.) 

Stackles?  That sounds like breakfast cereal.

"New all-natural stackles, with 12 essential vitamins, plus fiber!"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Magazine

2013-05-25 Thread Chris Angelico
On Sun, May 26, 2013 at 1:24 AM, Roy Smith  wrote:
> In article ,
>  Chris Angelico  wrote:
>
>> > Also, comparison of Python flavors (CPython, PyPy, Cython, Stackles, etc.)
>
> Stackles?  That sounds like breakfast cereal.
>
> "New all-natural stackles, with 12 essential vitamins, plus fiber!"

Heh!! But watch the citations please, I didn't say that - my email was
quoting Carlos.

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


Re: Python Magazine

2013-05-25 Thread Roy Smith
In article <51a0caac$0$30002$c3e8da3$54964...@news.astraweb.com>,
 Steven D'Aprano  wrote:

> On Sat, 25 May 2013 16:41:58 +1000, Chris Angelico wrote:
> 
> > On Sat, May 25, 2013 at 4:38 PM, zoom  wrote:
> >> But why would anyone want to use IPv6?
> > 
> > I hope you're not serious :)
> 
> He's planning to drop off the Internet once the IP address run out.

We already have run out.  People have gotten so used to being behind NAT 
gateways they don't even understand how evil it is.  From my phone, I 
can call any other phone anywhere in the world.  But I can't talk 
directly to the file server in my neighbor's house across the street?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: help how to sort a list in order of 'n' in python without using inbuilt functions??

2013-05-25 Thread Chris Angelico
On Sun, May 26, 2013 at 12:28 AM, Steven D'Aprano
 wrote:
> On Sat, 25 May 2013 19:14:57 +1000, Chris Angelico wrote:
>
>> def random_number():
>> return 7
>
> I call shenanigans! That value isn't generated randomly, you just made it
> up! I rolled a die *hundreds* of times and not once did it come up seven!

You've obviously never used a REAL set of dice. Now, I have here with
me a set used for maths drill (to be entirely accurate, what I have
here is the company's stock of them, so there are multiples of each of
these - anyone need to buy dice?) with everything except the classic 1
through 6 that everyone knows:

* Six sides, faces marked 7 through 12
* Six sides, faces marked "+x-\xf7+" and a "wild" marker (yes, two of +)
* Ten sides, numbered 0 through 9
* Eight sides, numbered 1 through 8
* Twelve sides, as above
* Twenty sides, as above

Now, tabletop roleplayers will recognize the latter four as the ones
notated as d10, d8, d12, and d20, but these are NOT for gameplay, they
are for serious educational purposes! Honest!

Anyway, all of those can roll a 7... well, one of them has to roll a
\xf7, but close enough right? Plus, if you roll 2d6 (that is, two
regular six-sided dice and add them up), 7 is statistically the most
likely number to come up with. Therefore it IS random.

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


RE: Ldap module and base64 oncoding

2013-05-25 Thread Joseph L. Casale
> Can you give an example of the code you have?

I actually just overrode the regex used by the method in the LDIFWriter class 
to be far more broad
about what it interprets as a safe string. I really need to properly handle 
reading, manipulating and
writing non ascii data to solve this...

Shame there is no ldap module (with the ldifwriter) in Python 3.
jlc
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Text-to-Sound or Vice Versa (Method NOT the source code)

2013-05-25 Thread rusi
On May 25, 3:52 pm, Rakshith Nayak  wrote:
> Always wondered how sound is generated from text. Googling couldn't help. 
> Devs having knowledge about this could provide, the information, Links, URLs 
> or anything that could help.
>
> 

look for speech synthesis

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


RE: help how to sort a list in order of 'n' in python without using inbuilt functions??

2013-05-25 Thread Carlos Nepomuceno

> To: python-list@python.org
> From: breamore...@yahoo.co.uk
> Subject: Re: help how to sort a list in order of 'n' in python without using 
> inbuilt functions??
> Date: Sat, 25 May 2013 13:01:06 +0100
[...]
> In my book this is another fail as lists are inbuilt (yuck!) and so is
> the add function that'll be called for z+=1.

Indeed! It's a joke Mark! lol
;)
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: help how to sort a list in order of 'n' in python without using inbuilt functions??

2013-05-25 Thread Carlos Nepomuceno

> From: steve+comp.lang.pyt...@pearwood.info
> Subject: Re: help how to sort a list in order of 'n' in python without using 
> inbuilt functions??
> Date: Sat, 25 May 2013 14:28:33 +
> To: python-list@python.org
>
> On Sat, 25 May 2013 19:14:57 +1000, Chris Angelico wrote:
>
>> def random_number():
>> return 7
>
> I call shenanigans! That value isn't generated randomly, you just made it
> up! I rolled a die *hundreds* of times and not once did it come up seven!


lol It worked fine on my d8! lol  
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: help how to sort a list in order of 'n' in python without using inbuilt functions??

2013-05-25 Thread Carlos Nepomuceno

> Date: Sun, 26 May 2013 01:41:58 +1000
> Subject: Re: help how to sort a list in order of 'n' in python without using 
> inbuilt functions??
> From: ros...@gmail.com
> To: python-list@python.org
>
> On Sun, May 26, 2013 at 12:28 AM, Steven D'Aprano
>  wrote:
>> On Sat, 25 May 2013 19:14:57 +1000, Chris Angelico wrote:
>>
>>> def random_number():
>>> return 7
>>
>> I call shenanigans! That value isn't generated randomly, you just made it
>> up! I rolled a die *hundreds* of times and not once did it come up seven!
>
> You've obviously never used a REAL set of dice. Now, I have here with
> me a set used for maths drill (to be entirely accurate, what I have
> here is the company's stock of them, so there are multiples of each of
> these - anyone need to buy dice?) with everything except the classic 1
> through 6 that everyone knows:
>
> * Six sides, faces marked 7 through 12
> * Six sides, faces marked "+x-\xf7+" and a "wild" marker (yes, two of +)
> * Ten sides, numbered 0 through 9
> * Eight sides, numbered 1 through 8
> * Twelve sides, as above
> * Twenty sides, as above
>
> Now, tabletop roleplayers will recognize the latter four as the ones
> notated as d10, d8, d12, and d20, but these are NOT for gameplay, they
> are for serious educational purposes! Honest!
>
> Anyway, all of those can roll a 7... well, one of them has to roll a
> \xf7, but close enough right? Plus, if you roll 2d6 (that is, two
> regular six-sided dice and add them up), 7 is statistically the most
> likely number to come up with. Therefore it IS random.
>
> ChrisA
> --
> http://mail.python.org/mailman/listinfo/python-list


def f(x):
    return x+1

or you can just go:

f(roll_d6())

;)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: help how to sort a list in order of 'n' in python without using inbuilt functions??

2013-05-25 Thread Chris Angelico
On Sun, May 26, 2013 at 3:17 AM, Carlos Nepomuceno
 wrote:
> def f(x):
> return x+1
>
> or you can just go:
>
> f(roll_d6())

Hmm. Interesting. So now we have a question: Does adding 1 to a random
number make it less random? It adds determinism to the number; can a
number be more deterministic while still no less random?

Ah! I know. The answer comes from common sense:

a = random()   # a is definitely a random number
a -= random()  # a is no longer random, we subtracted all the randomness from it

Of course, since number-number => number, a is still a number. And so
we can conclude that adding 1 to a random dice roll does indeed leave
all the randomness still in it. But wait! That means we can do
better!!

a = random()   # a is a random number
a *= 5   # a is clearly five times as random now!

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


RE: Learning Python

2013-05-25 Thread Carlos Nepomuceno

> Date: Sat, 25 May 2013 18:11:11 +0530 
> Subject: Learning Python 
> From: pythona...@gmail.com 
> To: Python-list@python.org 
>  
> Hi All , 
>  
>   I have started leaning Python through web . Would like to know  
> if I should follow any book so that basics become clear with examples  
> also want to know like in perl i use to invoke perl -d to get a  
> debugged output is there any option in python. 
>  
> THanks, 
>  
> -- http://mail.python.org/mailman/listinfo/python-list


I have used those:

"Dive into Python" (2004)[1]
"Python Programming" (2012)[2]
"Programming Python, 3rd Ed" (2006) [print]
  
[1] http://www.diveintopython.net/
[1] http://en.wikibooks.org/wiki/Python_Programming 
  
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Python Magazine

2013-05-25 Thread Carlos Nepomuceno

> From: r...@panix.com
> Subject: Re: Python Magazine
> Date: Sat, 25 May 2013 11:24:03 -0400
> To: python-list@python.org
>
> In article ,
> Chris Angelico  wrote:
>
>>> Also, comparison of Python flavors (CPython, PyPy, Cython, Stackles, etc.)
>
> Stackles? That sounds like breakfast cereal.
>
> "New all-natural stackles, with 12 essential vitamins, plus fiber!"
> --
> http://mail.python.org/mailman/listinfo/python-list

lol pardon my typo! I'm really considering that cereal! lol 
  
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: help how to sort a list in order of 'n' in python without using inbuilt functions??

2013-05-25 Thread Carlos Nepomuceno

> Date: Sun, 26 May 2013 03:23:44 +1000
> Subject: Re: help how to sort a list in order of 'n' in python without using 
> inbuilt functions??
> From: ros...@gmail.com
> To: python-list@python.org
>
> On Sun, May 26, 2013 at 3:17 AM, Carlos Nepomuceno
>  wrote:
>> def f(x):
>> return x+1
>>
>> or you can just go:
>>
>> f(roll_d6())
>
> Hmm. Interesting. So now we have a question: Does adding 1 to a random
> number make it less random? It adds determinism to the number; can a
> number be more deterministic while still no less random?
>
> Ah! I know. The answer comes from common sense:
>
> a = random() # a is definitely a random number
> a -= random() # a is no longer random, we subtracted all the randomness from 
> it
>
> Of course, since number-number => number, a is still a number. And so
> we can conclude that adding 1 to a random dice roll does indeed leave
> all the randomness still in it. But wait! That means we can do
> better!!
>
> a = random() # a is a random number
> a *= 5 # a is clearly five times as random now!
>
> ChrisA
> --
> http://mail.python.org/mailman/listinfo/python-list

It depends if the result (any operation) is in the required range.

For example: "int(random.random()+1)" it's not random at all!

But "int(random.random()*1000)" my look random if it fits your needs.

;)
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: help how to sort a list in order of 'n' in python without using inbuilt functions??

2013-05-25 Thread Carlos Nepomuceno

> Date: Fri, 24 May 2013 23:05:17 -0700
> Subject: Re: help how to sort a list in order of 'n' in python without using 
> inbuilt functions??
> From: lokeshkopp...@gmail.com
[...]

> ya steven i had done the similar logic but thats not satisfying my professor
> he had given the following constrains
> 1. No in-built functions should be used
> 2. we are expecting a O(n) solution
> 3. Don't use count method


PS: If you find something faster please let me know!
  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: authentication with python-ldap

2013-05-25 Thread Jorge Alberto Diaz Orozco
I have been doing the same thing and I tried to use java for testing the 
credentials and they are correct. It works perfectly with java.
I really don´t know what we´re doing wrong.


You are accessing a protected operation of the LDAP server
and it (the server) rejects it due to invalid credentials.
You may have forgotten to pass on credentials (e.g. a password)
or the credentials do not fit to the specified user
(maybe the user does not exist at all).
http://www.uci.cu
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: authentication with python-ldap

2013-05-25 Thread Joseph L. Casale
> I have been doing the same thing and I tried to use java for testing the 
> credentials and they are correct. It works perfectly with java.
> I really don´t know what we´re doing wrong.
>
>
> You are accessing a protected operation of the LDAP server
> and it (the server) rejects it due to invalid credentials.
> You may have forgotten to pass on credentials (e.g. a password)
> or the credentials do not fit to the specified user
> (maybe the user does not exist at all).

Depending on the directory (which we don't know) and the code as well, the way 
you auth
might be the problem. Possibly Java met the directory requirements with the 
methods you
used whereas they did not with Python given your code.

For example, certain operations in AD require specific transports to be used...

jlc
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie question about evaluating raw_input() responses

2013-05-25 Thread Nobody
On Thu, 23 May 2013 17:20:19 +1000, Chris Angelico wrote:

> Aside: Why was PHP's /e regexp option ever implemented?

Because it's a stupid idea, and that's the only requirement for a feature
to be implemented in PHP.

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


Re: Newbie question about evaluating raw_input() responses

2013-05-25 Thread Chris Angelico
On Sun, May 26, 2013 at 4:27 AM, Nobody  wrote:
> On Thu, 23 May 2013 17:20:19 +1000, Chris Angelico wrote:
>
>> Aside: Why was PHP's /e regexp option ever implemented?
>
> Because it's a stupid idea, and that's the only requirement for a feature
> to be implemented in PHP.

Hey, don't be rude. I mean, not that it isn't true, but it's still
rude to say it.

Ah, who am I kidding. Be as rude as you like. I have to work with PHP all week.

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


Re: Newbie question about evaluating raw_input() responses

2013-05-25 Thread Fábio Santos
On 25 May 2013 19:37, "Chris Angelico"  wrote:
> Ah, who am I kidding. Be as rude as you like. I have to work with PHP all
week.
>
> ChrisA
> --
> http://mail.python.org/mailman/listinfo/python-list

I have cried.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Total Beginner - Extracting Data from a Database Online (Screenshot)

2013-05-25 Thread logan . c . graham
Sorry to be unclear -- it's a screenshot of the webpage, which is publicly 
accessible, but it contains sensitive information. A bad combination, 
admittedly, and something that'll be soon fixed.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Magazine

2013-05-25 Thread John Ladasky
On Saturday, May 25, 2013 8:30:19 AM UTC-7, Roy Smith wrote:
> From my phone, I 
> can call any other phone anywhere in the world.  But I can't talk  
> directly to the file server in my neighbor's house across the street?

Hmmm... I've been an advocate of IPv6, but... now you've got me thinking of 
what Iran's new cadre of hackers might do with it!  :^)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple algorithm question - how to reorder a sequence economically

2013-05-25 Thread John Ladasky
On Friday, May 24, 2013 10:33:47 AM UTC-7, Yours Truly wrote:
> If you don't reshuffle p, it guarantees the maximum interval between reusing
> the same permutation.

Of course, that comes at a certain price.  Given two permutations p[x] and 
p[x+1], they will ALWAYS be adjacent, in every repetition of the list, unless 
you reshuffle.  So the "spurious correlation" problem that Peter is worrying 
about would still exist, albeit at a meta-level.

You could play clever games, such as splitting p in half once you get to the 
end of it, shuffling each half independently, and then concatenating the 
halves.  This algorithm scrambles the p[x]'s and p[x+1]'s pretty well, at the 
cost of cutting the average interval between repeats of a given p[x] from 
len(p) to something closer to len(p)/2.

Because someone's got to say it... "The generation of random numbers is too 
important to be left to chance." — Robert R. Coveyou
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Total Beginner - Extracting Data from a Database Online (Screenshot)

2013-05-25 Thread John Ladasky
On Friday, May 24, 2013 4:36:35 PM UTC-7, Carlos Nepomuceno wrote:
> #to create the tables list
> tables=[[re.findall('(.*?)',r,re.S) for r in 
> re.findall('(.*?)',t,re.S)] for t in 
> re.findall('(.*?)',page,re.S)]
> 
> 
> Pretty simple. 

Two nested list comprehensions, with regex pattern matching?

Logan did say he was a "total beginner."  :^)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple algorithm question - how to reorder a sequence economically

2013-05-25 Thread Roy Smith
In article <15a1bb3a-514c-454e-a966-243c84123...@googlegroups.com>,
 John Ladasky  wrote:

> Because someone's got to say it... "The generation of random numbers is too 
> important to be left to chance." ‹ Robert R. Coveyou

Absolutely.  I know just enough about random number generation to 
understand that I don't really know anything about it :-)

That being said, people who really care about random numbers, tend to 
rely on some sort of physical process instead of computer algorithms.  A 
classic example would be /dev/random.  A somewhat more fun example is 
http://www.youtube.com/watch?v=7n8LNxGbZbs.  Something radioactive and a 
geiger counter are a good source of randomness (time intervals between 
decay events).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Magazine

2013-05-25 Thread Roy Smith
In article <7cd17be8-d455-4db8-b8d0-ccc757db5...@googlegroups.com>,
 John Ladasky  wrote:

> On Saturday, May 25, 2013 8:30:19 AM UTC-7, Roy Smith wrote:
> > From my phone, I 
> > can call any other phone anywhere in the world.  But I can't talk  
> > directly to the file server in my neighbor's house across the street?
> 
> Hmmm... I've been an advocate of IPv6, but... now you've got me thinking of 
> what Iran's new cadre of hackers might do with it!  :^)

You (like many people) are confusing universal addressability with 
universal connectivity.  The converse of that is people confusing NAT 
with security.

Of course not every IPv6 endpoint will be able to talk to every other 
IPv6 endpoint, even if the both have globally unique addresses.  But, 
the access controls will be implemented in firewalls with appropriately 
coded security policies.  Not as an accident of being behind a NAT box.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Magazine

2013-05-25 Thread Chris Angelico
On Sun, May 26, 2013 at 11:54 AM, Roy Smith  wrote:
> In article <7cd17be8-d455-4db8-b8d0-ccc757db5...@googlegroups.com>,
>  John Ladasky  wrote:
>
>> On Saturday, May 25, 2013 8:30:19 AM UTC-7, Roy Smith wrote:
>> > From my phone, I
>> > can call any other phone anywhere in the world.  But I can't talk
>> > directly to the file server in my neighbor's house across the street?
>>
>> Hmmm... I've been an advocate of IPv6, but... now you've got me thinking of
>> what Iran's new cadre of hackers might do with it!  :^)
>
> You (like many people) are confusing universal addressability with
> universal connectivity.  The converse of that is people confusing NAT
> with security.
>
> Of course not every IPv6 endpoint will be able to talk to every other
> IPv6 endpoint, even if the both have globally unique addresses.  But,
> the access controls will be implemented in firewalls with appropriately
> coded security policies.  Not as an accident of being behind a NAT box.

To be more specific: The control of who can talk to whom is in the
hands of the admins of the two endpoints and the nodes in between,
rather than being arbitrarily in the hands of the technology. So I
would be able to talk to the file server across the street, but only
IF its admin lets me.

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


Re: Python Magazine

2013-05-25 Thread John Ladasky
A perfectly fair point, Roy.  It's just when you started suggesting connecting 
to your neighbor's file server -- well, that's not something that many people 
would ordinarily do.  So, my mind leaped to the possibility of uninvited 
connections.

Related question: would denial-of-service attacks be more pernicious without a 
NAT?
-- 
http://mail.python.org/mailman/listinfo/python-list


Automate Grabbing Email From Outlook On Shared Folder

2013-05-25 Thread darin . hensley
I am trying to automate Outlook mail client by retrieving a message with an 
attachment, using win32com. The message box is a shared folder that is not 
really underneath root folder inbox, so I had no success with inbox = 
mapi.GetDefaultFolder(6). However, I did have some success with:

import win32com.client
outlook = win32com.client.Dispatch("Outlook.Application")
mapi = outlook.GetNamespace("MAPI").Folders
print mapi[7]

In which the output is "Mailbox - Foo Operations"--- the folder I want.

However, if I tried:
import win32com.client
outlook = win32com.client.Dispatch("Outlook.Application")
mapi = outlook.GetNamespace("MAPI").Folders
messages = mapi[7].Items
message = messages.getLast()
body_content = message.body
print body_content

I get no success. So I am pretty much stuck. I googled many things but no 
success. I prefer to win32com since I don't have to use a login in the script. 
But if this is possible with another Python module with no login requirement 
that would be great also.

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


Re: help how to sort a list in order of 'n' in python without using inbuilt functions??

2013-05-25 Thread Steven D'Aprano
On Sun, 26 May 2013 01:41:58 +1000, Chris Angelico wrote:

> On Sun, May 26, 2013 at 12:28 AM, Steven D'Aprano
>  wrote:
>> On Sat, 25 May 2013 19:14:57 +1000, Chris Angelico wrote:
>>
>>> def random_number():
>>> return 7
>>
>> I call shenanigans! That value isn't generated randomly, you just made
>> it up! I rolled a die *hundreds* of times and not once did it come up
>> seven!
> 
> You've obviously never used a REAL set of dice.

You're right, all my dice are eight-sided and complex:

1+0i
1+1i
1-1i
-1+0i
-1+1i
-1-1i


:-)


But seriously, I have various D&D style gaming dice, d4, d6, d8, d12, d20 
and d30. But I thought the opportunity for a joke was more important than 
pedantic correctness :-)


> Now, I have here with me
> a set used for maths drill (to be entirely accurate, what I have here is
> the company's stock of them, so there are multiples of each of these -
> anyone need to buy dice?) 

Are you serious? What's the cost, posted to Melbourne?


> with everything except the classic 1 through 6 that everyone knows:
> 
> * Six sides, faces marked 7 through 12 
> * Six sides, faces marked "+x-\xf7+" and a "wild" marker 
>   (yes, two of +)

Oh, you mean ÷ (division sign)! Why didn't you say so? :-P

And another thing, shame on you, you mean × not x. It's easy to find too:

py> from unicodedata import lookup
py> print(lookup("MULTIPLICATION SIGN"))
×


> * Ten sides, numbered 0 through 9
> * Eight sides, numbered 1 through 8
> * Twelve sides, as above
> * Twenty sides, as above
> 
> Now, tabletop roleplayers will recognize the latter four as the ones
> notated as d10, d8, d12, and d20, but these are NOT for gameplay, they
> are for serious educational purposes! Honest!
> 
> Anyway, all of those can roll a 7... well, one of them has to roll a
> \xf7, but close enough right? 

I don't think so...

> Plus, if you roll 2d6 (that is, two
> regular six-sided dice and add them up), 7 is statistically the most
> likely number to come up with. Therefore it IS random.

Yes, but if you subtract them the most common is 0, if you multiply the 
most common are 6 or 12, and if you divide the most common is 1. If you 
decide on the operation randomly, using the +-×÷+ die above (ignoring 
wildcards), the most common result is 6. The probability of getting a 7 
is just 1/15.

from collections import Counter
from operator import add, sub, mul, truediv as div
ops = (add, sub, mul, div, add)
Counter(op(i, j) for op in ops for i in range(1, 7) for j in range(1, 7))


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


Re: Python Magazine

2013-05-25 Thread Roy Smith
In article <8f19e20c-4f77-43dc-a732-4169e482d...@googlegroups.com>,
 John Ladasky  wrote:

> A perfectly fair point, Roy.  It's just when you started suggesting 
> connecting to your neighbor's file server -- well, that's not something that 
> many people would ordinarily do.  So, my mind leaped to the possibility of 
> uninvited connections.
> 
> Related question: would denial-of-service attacks be more pernicious without 
> a NAT?

Not really.  If I know the external IP address of your NAT box, I can 
throw as much traffic at it as your internet connection will deliver.  
Assuming you have sufficient bandwidth, eventually I'll melt down your 
router.  This is equally true with NAT or without it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Magazine

2013-05-25 Thread Mark Lawrence

On 26/05/2013 02:58, Chris Angelico wrote:

On Sun, May 26, 2013 at 11:54 AM, Roy Smith  wrote:

In article <7cd17be8-d455-4db8-b8d0-ccc757db5...@googlegroups.com>,
  John Ladasky  wrote:


On Saturday, May 25, 2013 8:30:19 AM UTC-7, Roy Smith wrote:

 From my phone, I
can call any other phone anywhere in the world.  But I can't talk
directly to the file server in my neighbor's house across the street?


Hmmm... I've been an advocate of IPv6, but... now you've got me thinking of
what Iran's new cadre of hackers might do with it!  :^)


You (like many people) are confusing universal addressability with
universal connectivity.  The converse of that is people confusing NAT
with security.

Of course not every IPv6 endpoint will be able to talk to every other
IPv6 endpoint, even if the both have globally unique addresses.  But,
the access controls will be implemented in firewalls with appropriately
coded security policies.  Not as an accident of being behind a NAT box.


To be more specific: The control of who can talk to whom is in the
hands of the admins of the two endpoints and the nodes in between,
rather than being arbitrarily in the hands of the technology. So I
would be able to talk to the file server across the street, but only
IF its admin lets me.

ChrisA



By such means as leaving the top level admin password set to the factory 
default? :)


--
If you're using GoogleCrap™ please read this 
http://wiki.python.org/moin/GoogleGroupsPython.


Mark Lawrence

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


Re: help how to sort a list in order of 'n' in python without using inbuilt functions??

2013-05-25 Thread Steven D'Aprano
On Sun, 26 May 2013 03:23:44 +1000, Chris Angelico wrote:

> Does adding 1 to a random
> number make it less random? It adds determinism to the number; can a
> number be more deterministic while still no less random?
> 
> Ah! I know. The answer comes from common sense:
[snip spurious answer]

I know you're being funny, but in fact adding a constant to a random 
variable still leaves it equally random. Adding, multiplying, dividing or 
subtracting a constant from a random variable X just shifts the possible 
values X can take, it doesn't change the shape of the distribution. 
However, adding two random variables X and Y does change the 
distribution. In fact, a very cheap way of simulating an almost normally 
distributed random variable is to add up a whole lot of uniformly 
distributed random variables. Adding up 12 calls to random.random(), and 
subtracting 6, gives you a close approximation to a Gaussian random 
variable with mean 0 and standard deviation 1.



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


Re: Python Magazine

2013-05-25 Thread Chris Angelico
On Sun, May 26, 2013 at 1:04 PM, John Ladasky
 wrote:
> A perfectly fair point, Roy.  It's just when you started suggesting 
> connecting to your neighbor's file server -- well, that's not something that 
> many people would ordinarily do.  So, my mind leaped to the possibility of 
> uninvited connections.
>
> Related question: would denial-of-service attacks be more pernicious without 
> a NAT?

Not sure what you mean. If we assume that network topology doesn't
change, then what we have is a single uplink (say, an ADSL connection,
given that most home users don't have luxuries) going to a router
(let's be generous here and say that's a Linux box with two NICs, and
you have a smart admin in charge of it), behind which is a set of
switches and computers making up a LAN of peers. On IPv4, the LAN
would operate on one of the RFC 1918 address blocks - say, 192.168.0.x
- and all external communication would be through one single IP
address - 203.0.113.47 will do for the purposes of discussion.

As far as other hosts on the internet are concerned, that entire
network is one single host, with address 203.0.113.47. It's unaware of
the three computers 192.168.0.4, .0.87, and .0.92; they merge into
one. This means they share the 65536 ports, they share entries on
blacklists, etc, etc.

With IPv6, that ADSL connection would come with a /64 block - say,
2001:db8:142:857::/64. Within that block, each computer would be
assigned a single address - perhaps 2001:db8:142:857::4,
2001:db8:142:857::87, and 2001:db8:142:857::92, or perhaps they'd be
assigned them by their MAC addresses eg
2001:db8:142:857:200:5eff:fe00:531a, which can be done automatically.
Now all your computers (including the router) are individually
addressable; they can be identified separately, or treated as a group
(the /64 representing the whole group). Their ports, blacklist
entries, etc, are all unique. This means you can run three servers on
port 80, etc.

The question now is: What sort of DOS attack are you fearing? If it's
a simple matter of saturating the connection, it makes absolutely no
difference. As Roy said, that's just a question of overloading. If I
command more bandwidth than you do, I can saturate you. Easy. (Very
easy if I have a botnet, for instance.) Harder to judge are the
amplifying attacks; a half-open-connection attack, for instance,
attacks a TCP server's RAM allocation. It's possible that some attacks
will be easier or harder with NAT than without, but you'd have to
evaluate a specific attack technique.

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


Re: Python Magazine

2013-05-25 Thread Steven D'Aprano
On Sat, 25 May 2013 21:54:43 -0400, Roy Smith wrote:

> Of course not every IPv6 endpoint will be able to talk to every other
> IPv6 endpoint, even if the both have globally unique addresses.  But,
> the access controls will be implemented in firewalls with appropriately
> coded security policies.

Or, more likely, *not* implemented in firewalls with *inappropriately* 
coded security policies.



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


CrazyHTTPd - HTTP Daemon in Python

2013-05-25 Thread cdorm245
This is a small little Project that I have started. Its a light little Web 
Server (HTTPd) coded in python. Requirements: Python 2.7 =< And Linux / BSD. I 
believe this could work in a CLI Emulator in windows too.
Welcome to check out the website powered by CrazyHTTPd: 
http://web.crazycoder.me:14081/index.html

Please Email me with any bugs, errors, and/or comments about my little project: 
cdorm...@gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: help how to sort a list in order of 'n' in python without using inbuilt functions??

2013-05-25 Thread Chris Angelico
On Sun, May 26, 2013 at 1:09 PM, Steven D'Aprano
 wrote:
> You're right, all my dice are eight-sided and complex:
>
> 1+0i
> 1+1i
> 1-1i
> -1+0i
> -1+1i
> -1-1i
>
>
> :-)

Now THAT is a dice of win!

>> Now, I have here with me
>> a set used for maths drill (to be entirely accurate, what I have here is
>> the company's stock of them, so there are multiples of each of these -
>> anyone need to buy dice?)
>
> Are you serious? What's the cost, posted to Melbourne?

$1 each, postage probably $5 for any number. Or there may even be
option to pick up / hand deliver, depending on where in Melb you are.

http://www.kepl.com.au/ - company's winding down, but we still have stock.

> Oh, you mean ÷ (division sign)! Why didn't you say so? :-P

I tend to stick to ASCII in these posts. :)

> And another thing, shame on you, you mean × not x. It's easy to find too:
>
> py> from unicodedata import lookup
> py> print(lookup("MULTIPLICATION SIGN"))
> ×

I'm aware of that, but see above, I stick to ASCII where possible. The
faces would be better represented with some of the other digits (the
bolded ones, perhaps), but I used the ASCII digits. :)

>> Plus, if you roll 2d6 (that is, two
>> regular six-sided dice and add them up), 7 is statistically the most
>> likely number to come up with. Therefore it IS random.
>
> Yes, but if you subtract them the most common is 0, if you multiply the
> most common are 6 or 12, and if you divide the most common is 1. If you
> decide on the operation randomly, using the +-×÷+ die above (ignoring
> wildcards), the most common result is 6. The probability of getting a 7
> is just 1/15.
>
> from collections import Counter
> from operator import add, sub, mul, truediv as div
> ops = (add, sub, mul, div, add)
> Counter(op(i, j) for op in ops for i in range(1, 7) for j in range(1, 7))

LOL! I never thought to go THAT far into the analysis. Nice one!

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


RE: Python Magazine

2013-05-25 Thread Carlos Nepomuceno

> Date: Sat, 25 May 2013 20:04:28 -0700
> Subject: Re: Python Magazine
> From: john_lada...@sbcglobal.net
> To: python-list@python.org
>
> A perfectly fair point, Roy. It's just when you started suggesting connecting 
> to your neighbor's file server -- well, that's not something that many people 
> would ordinarily do. So, my mind leaped to the possibility of uninvited 
> connections.
>
> Related question: would denial-of-service attacks be more pernicious without 
> a NAT?
> --
> http://mail.python.org/mailman/listinfo/python-list

I don't think so.

IP blocking still a very common mitigation approach to DDoS, but it may cause 
denial of service to legitimate clients who share the same blocked public IP 
address used by the malicious clients. So, NAPT will still benefit DDoS 
attackers, at least temporarily (until the IP is unblocked).
   
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Magazine

2013-05-25 Thread Steven D'Aprano
On Sun, 26 May 2013 11:58:09 +1000, Chris Angelico wrote:

> On Sun, May 26, 2013 at 11:54 AM, Roy Smith  wrote:

>> Of course not every IPv6 endpoint will be able to talk to every other
>> IPv6 endpoint, even if the both have globally unique addresses.  But,
>> the access controls will be implemented in firewalls with appropriately
>> coded security policies.  Not as an accident of being behind a NAT box.
> 
> To be more specific: The control of who can talk to whom is in the hands
> of the admins of the two endpoints and the nodes in between, rather than
> being arbitrarily in the hands of the technology. So I would be able to
> talk to the file server across the street, but only IF its admin lets
> me.

Or when (not if) you find a vulnerability in the particular firewall. 
Make no mistake: the most secure entry point is the one that isn't there.



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


Re: CrazyHTTPd - HTTP Daemon in Python

2013-05-25 Thread Mark Lawrence

On 26/05/2013 04:55, cdorm...@gmail.com wrote:

This is a small little Project that I have started. Its a light little Web Server 
(HTTPd) coded in python. Requirements: Python 2.7 =< And Linux / BSD. I believe 
this could work in a CLI Emulator in windows too.
Welcome to check out the website powered by CrazyHTTPd: 
http://web.crazycoder.me:14081/index.html

Please Email me with any bugs, errors, and/or comments about my little project: 
cdorm...@gmail.com



IMHO writing a project right now that is limited to Python 2 is about as 
much use as a chocolate teapot.


--
If you're using GoogleCrap™ please read this 
http://wiki.python.org/moin/GoogleGroupsPython.


Mark Lawrence

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


Re: help how to sort a list in order of 'n' in python without using inbuilt functions??

2013-05-25 Thread Dan Sommers
On Sun, 26 May 2013 03:38:12 +, Steven D'Aprano wrote:

> ... adding a constant to a random variable still leaves it equally
> random. Adding, multiplying, dividing or subtracting a constant from a
> random variable X just shifts the possible values X can take ...

That's mathematically true, but this is the Python mailing list.

Adding, subtracting, or dividing by a sufficiently large constant loses
all the randomness.

Python 3.2.4 (default, May  8 2013, 20:55:18) 
[GCC 4.7.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import random
>>> random.random() + 1e200
1e+200
>>> random.random() - 1e200
-1e+200
>>> random.random() / 1e309
0.0

But you knew that.  ;-)

Dan
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: CrazyHTTPd - HTTP Daemon in Python

2013-05-25 Thread Carlos Nepomuceno
Your code isn't threaded. I suggest you consider[1] and take that road! ;) Good 
luck!

[1] http://bulk.fefe.de/scalable-networking.pdf


> To: python-list@python.org
> From: breamore...@yahoo.co.uk
> Subject: Re: CrazyHTTPd - HTTP Daemon in Python
> Date: Sun, 26 May 2013 05:06:50 +0100
>
> On 26/05/2013 04:55, cdorm...@gmail.com wrote:
>> This is a small little Project that I have started. Its a light little Web 
>> Server (HTTPd) coded in python. Requirements: Python 2.7 =< And Linux / BSD. 
>> I believe this could work in a CLI Emulator in windows too.
>> Welcome to check out the website powered by CrazyHTTPd: 
>> http://web.crazycoder.me:14081/index.html
>>
>> Please Email me with any bugs, errors, and/or comments about my little 
>> project: cdorm...@gmail.com
>>
>
> IMHO writing a project right now that is limited to Python 2 is about as
> much use as a chocolate teapot.
>
> --
> If you're using GoogleCrap™ please read this
> http://wiki.python.org/moin/GoogleGroupsPython.
>
> Mark Lawrence
>
> --
> http://mail.python.org/mailman/listinfo/python-list   
>   
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: help how to sort a list in order of 'n' in python without using inbuilt functions??

2013-05-25 Thread Chris Angelico
On Sun, May 26, 2013 at 1:38 PM, Steven D'Aprano
 wrote:
> On Sun, 26 May 2013 03:23:44 +1000, Chris Angelico wrote:
>
>> Does adding 1 to a random
>> number make it less random? It adds determinism to the number; can a
>> number be more deterministic while still no less random?
>>
>> Ah! I know. The answer comes from common sense:
> [snip spurious answer]
>
> I know you're being funny, but in fact adding a constant to a random
> variable still leaves it equally random. Adding, multiplying, dividing or
> subtracting a constant from a random variable X just shifts the possible
> values X can take, it doesn't change the shape of the distribution.

In real numbers, that's correct. However, computers don't work with
real numbers, so there's the very, uhh, REAL possibility that some of
the entropy will be lost. For instance, multiplying and dividing when
working with integers results in truncation, and adding huge numbers
to small floats results in precision loss.

I was deliberately playing around, but unfortunately there have been
many people who've genuinely thought things similar to what I was
saying - and then implemented into code.

> However, adding two random variables X and Y does change the
> distribution. In fact, a very cheap way of simulating an almost normally
> distributed random variable is to add up a whole lot of uniformly
> distributed random variables. Adding up 12 calls to random.random(), and
> subtracting 6, gives you a close approximation to a Gaussian random
> variable with mean 0 and standard deviation 1.

Yep. The more dice you roll, the more normal the distribution. Which
means that d100 is extremely swingy, but 11d10-10 is much less so, and
99d2-98 quite stable. The more randomness you add, the more
predictable the result.

Does that seem right to you?

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


Re: Python Magazine

2013-05-25 Thread Chris Angelico
On Sun, May 26, 2013 at 2:01 PM, Carlos Nepomuceno
 wrote:
> 
>> Date: Sat, 25 May 2013 20:04:28 -0700
>> Subject: Re: Python Magazine
>> From: john_lada...@sbcglobal.net
>> To: python-list@python.org
>>
>> A perfectly fair point, Roy. It's just when you started suggesting 
>> connecting to your neighbor's file server -- well, that's not something that 
>> many people would ordinarily do. So, my mind leaped to the possibility of 
>> uninvited connections.
>>
>> Related question: would denial-of-service attacks be more pernicious without 
>> a NAT?
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>
> I don't think so.
>
> IP blocking still a very common mitigation approach to DDoS, but it may cause 
> denial of service to legitimate clients who share the same blocked public IP 
> address used by the malicious clients. So, NAPT will still benefit DDoS 
> attackers, at least temporarily (until the IP is unblocked).

I expect that IP blocks will be upgraded to /64 block blocks, if that
starts being a problem. But it often won't, and specific IP address
blocks will still be the norm.

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


Re: Python Magazine

2013-05-25 Thread Chris Angelico
On Sun, May 26, 2013 at 2:03 PM, Steven D'Aprano
 wrote:
> On Sun, 26 May 2013 11:58:09 +1000, Chris Angelico wrote:
>
>> On Sun, May 26, 2013 at 11:54 AM, Roy Smith  wrote:
>
>>> Of course not every IPv6 endpoint will be able to talk to every other
>>> IPv6 endpoint, even if the both have globally unique addresses.  But,
>>> the access controls will be implemented in firewalls with appropriately
>>> coded security policies.  Not as an accident of being behind a NAT box.
>>
>> To be more specific: The control of who can talk to whom is in the hands
>> of the admins of the two endpoints and the nodes in between, rather than
>> being arbitrarily in the hands of the technology. So I would be able to
>> talk to the file server across the street, but only IF its admin lets
>> me.
>
> Or when (not if) you find a vulnerability in the particular firewall.
> Make no mistake: the most secure entry point is the one that isn't there.

Packets have to get somewhere. If they come into this computer, it has
to deliberately forward them to that computer or they won't get there.
Same thing. All it takes is

# ip6tables -p FORWARD DROP

and you have a "secure unless I specifically permit it" router.
Obviously an attacker can target the router itself (which is exactly
the same as current situation), but can't attack anything beyond it
without an explicit forwarding rule (which is also exactly the same).

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


Re: CrazyHTTPd - HTTP Daemon in Python

2013-05-25 Thread cdorm245
On Sunday, May 26, 2013 12:21:46 PM UTC+8, Carlos Nepomuceno wrote:
> Your code isn't threaded. I suggest you consider[1] and take that road! ;) 
> Good luck!
> 
> [1] http://bulk.fefe.de/scalable-networking.pdf
> 
> 
> > To: python-list@python.org
> > From: breamore...@yahoo.co.uk
> > Subject: Re: CrazyHTTPd - HTTP Daemon in Python
> > Date: Sun, 26 May 2013 05:06:50 +0100
> >
> > On 26/05/2013 04:55, cdorm...@gmail.com wrote:
> >> This is a small little Project that I have started. Its a light little Web 
> >> Server (HTTPd) coded in python. Requirements: Python 2.7 =< And Linux / 
> >> BSD. I believe this could work in a CLI Emulator in windows too.
> >> Welcome to check out the website powered by CrazyHTTPd: 
> >> http://web.crazycoder.me:14081/index.html
> >>
> >> Please Email me with any bugs, errors, and/or comments about my little 
> >> project: cdorm...@gmail.com
> >>
> >
> > IMHO writing a project right now that is limited to Python 2 is about as
> > much use as a chocolate teapot.
> >
> > --
> > If you're using GoogleCrap™ please read this
> > http://wiki.python.org/moin/GoogleGroupsPython.
> >
> > Mark Lawrence
> >
> > --
> > http://mail.python.org/mailman/listinfo/python-list

Thanks, I plan on doing this. Then CrazyHTTPd will support bigger file 
downloading and multiple network connections at once. Thanks Again!
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Python Magazine

2013-05-25 Thread Carlos Nepomuceno

> Date: Sun, 26 May 2013 14:31:57 +1000
> Subject: Re: Python Magazine
> From: ros...@gmail.com
> To: python-list@python.org
[...]
> I expect that IP blocks will be upgraded to /64 block blocks, if that
> starts being a problem. But it often won't, and specific IP address
> blocks will still be the norm.
>
> ChrisA


Blocking a whole network (/65) is totally undesirable and may even become 
illegal.

Currently it may not only happen at the target of the DDoS attack, but be 
spread all over the internet where block lists are enforced.

I don't expect that to happen and if it happens I'm surely in favor of 
protection against this type of 'solution' because it will block not only 
malicious clients but potentially many other legitimate clients.
 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Magazine

2013-05-25 Thread Chris Angelico
On Sun, May 26, 2013 at 3:00 PM, Carlos Nepomuceno
 wrote:
> 
>> Date: Sun, 26 May 2013 14:31:57 +1000
>> Subject: Re: Python Magazine
>> From: ros...@gmail.com
>> To: python-list@python.org
> [...]
>> I expect that IP blocks will be upgraded to /64 block blocks, if that
>> starts being a problem. But it often won't, and specific IP address
>> blocks will still be the norm.
>>
>> ChrisA
>
>
> Blocking a whole network (/65) is totally undesirable and may even become 
> illegal.

Blocking a /64 is exactly the same as blocking a /32 with NAT behind
it. And how could it be illegal? I provide service to those I choose
to provide to.

> Currently it may not only happen at the target of the DDoS attack, but be 
> spread all over the internet where block lists are enforced.
>
> I don't expect that to happen and if it happens I'm surely in favor of 
> protection against this type of 'solution' because it will block not only 
> malicious clients but potentially many other legitimate clients.

Banning a wide netblock is of course going to lock out legit clients.
But IP rotation means that can happen anyway. You block a single IPv4
address that right now represents an abusive user; that user
disconnects and reconnects, gets a new IP, and someone else gets the
other one. Can happen all too easily. That's why IP-banning is at best
a temporary solution anyway.

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


Re: authentication with python-ldap

2013-05-25 Thread Dieter Maurer
Jorge Alberto Diaz Orozco wrote at 2013-5-25 14:00 -0400:
>I have been doing the same thing and I tried to use java for testing the 
>credentials and they are correct. It works perfectly with java.
>I really don´t know what we´re doing wrong.

Neither do I.

But the error message definitely originates from the LDAP server.
This means that the server sees different things for the
(successful) Java connection and the (unsuccessful) Python connection.
Maybe, you can convince your LDAP server administrator to configure
a form of logging that allows you to compare the two requests
(this may not be easy - because sensitive information is involved).
Comparing the requests may provide valuable clues towards the cause
of the problem.

One may also try some guesswork: There is an important difference
between Java and Python 2. Java uses unicode as the typical type
for text variables while in Python 2, you use normally the type "str"
for text. "str" means no unicode but encoded text.
When the Java-LDAP bridge passes text to the LDAP server, it must
encode the text - and maybe, it uses the correct encoding
(the one the LDAP server expects). The Python-LDAP bridge, on the other
hand, does not get unicode but "str" and likely passes the "str"
values directly. Thus, if your "str" values do not use the correct
encoding (the one expected by the LDAP server), things will not
work out correctly.

I expect the LDAP server to expect the "utf-8" encoding.
In this case, problems could be expected when the data
passed on to the LDAP server contains non ascii characters
while all ascii data should not see problems.



--
Dieter
-- 
http://mail.python.org/mailman/listinfo/python-list